Hi, 

I could not reproduce the error in my dev environment with python-2.7.10 and ovirt-4.1.

Could you please share the oVirt version in your case? I saw in another mail that you are using oVirt 3.5. If so, please pick sdk v3 instead of current v4. AFAIK, sdk v4 is not compatible with oVirt 3.x.

Regards,
Joey

On Tue, Sep 25, 2018 at 12:37 PM Budur Nagaraju <nbudoor@gmail.com> wrote:
HI

Done the modification now am getting the below error.

[root@cephc ovirt-scripts]# python get_vm_names
Traceback (most recent call last):
  File "get_vm_names", line 22, in <module>
    vms = vms_service.list()
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 34154, in list
    return self._internal_get(headers, query, wait)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 202, in _internal_get
    context = self._connection.send(request)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 370, in send
    return self.__send(request)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 388, in __send
    self.authenticate()
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 381, in authenticate
    self._sso_token = self._get_access_token()
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 617, in _get_access_token
    sso_response = self._get_sso_response(self._sso_url, post_data)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 702, in _get_sso_response
    self._check_content_type(self.__JSON_CONTENT_TYPE_RE, 'JSON', header_lines)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 889, in _check_content_type
    raise Error(msg)
ovirtsdk4.Error: The response content type 'text/html;charset=UTF-8' isn't the expected JSON
[root@cephc ovirt-scripts]#



On Tue, Sep 25, 2018 at 9:35 AM Joey Ma <majunjiev@gmail.com> wrote:


On Tue, Sep 25, 2018 at 11:40 AM Budur Nagaraju <nbudoor@gmail.com> wrote:
Hi ,

Have done the below modification in the script and getting the error,can you please help to fix the issue?


Script :

[root@cephc ovirt-scripts]# vi get_vm_names
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import logging
import ovirtsdk4 as sdk
import ovirtsdk4.types as types

logging.basicConfig(level=logging.DEBUG, filename='example.log')

connection = sdk.Connection(
        url='https://pscloud.bnglab.psecure.net/ovirt-engine/api ',

hi, 

Simply remove the trailing space in url parameter may solve your problem.

Regards,
Joey

 
        username='admin@internal',
        password='password',
        insecure=True,
#       ca_file='/etc/pki/ovirt-engine/ca.pem',
        debug=True,
        log=logging.getLogger(),
)

vms_service = connection.system_service().vms_service()

vms = vms_service.list()

for vm in vms:
        print("%s: %s" % (vm.name, vm.id))
connection.close()
~
=======================================================================================

Error:

[root@cephc ovirt-scripts]# python get_vm_names
Traceback (most recent call last):
  File "get_vm_names", line 22, in <module>
    vms = vms_service.list()
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 34154, in list
    return self._internal_get(headers, query, wait)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 202, in _internal_get
    context = self._connection.send(request)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 370, in send
    return self.__send(request)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 388, in __send
    self.authenticate()
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 381, in authenticate
    self._sso_token = self._get_access_token()
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 617, in _get_access_token
    sso_response = self._get_sso_response(self._sso_url, post_data)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 702, in _get_sso_response
    self._check_content_type(self.__JSON_CONTENT_TYPE_RE, 'JSON', header_lines)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 889, in _check_content_type
    raise Error(msg)
ovirtsdk4.Error: The response content type 'text/html;charset=UTF-8' isn't the expected JSON. Is the path '/ovirt-engine/api ' included in the 'url' parameter correct? The typical one is '/ovirt-engine/api'
[root@cephc ovirt-scripts]#

Thanks,
Nagaraju





On Mon, Sep 24, 2018 at 11:49 PM Valentin Bajrami <valentin.bajrami@target-holding.nl> wrote:

Hi Budur,

You can add  insecure=True  for unsigned certificates. See example

connection = sdk.Connection(
        url='https://pscloud.bnglab.psecure.net/ovirt-engine/api ',
        username='admin@internal',
        password='password',
        insecure=True,
        ca_file= '/etc/pki/ovirt-engine/ca.pem',
        debug=True,
        log=logging.getLogger()
)


On 9/24/18 5:08 PM, Budur Nagaraju wrote:
Below is the script and getting error while executing.


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import logging
import ovirtsdk4 as sdk
import ovirtsdk4.types as types

logging.basicConfig(level=logging.DEBUG, filename='example.log')

connection = sdk.Connection(
        url='https://pscloud.bnglab.psecure.net/ovirt-engine/api ',
        username='admin@internal',
        password='password',
        ca_file= '/etc/pki/ovirt-engine/ca.pem',
        debug=True,
        log=logging.getLogger(),
)

vms_service = connection.system_service().vms_service()

vms = vms_service.list()

for vm in vms:
        print("%s: %s" % (vm.name, vm.id))
connection.close()
=================================================


[root@cephc ovirt-scripts]# python get_vm_names
Traceback (most recent call last):
  File "get_vm_names", line 16, in <module>
    log=logging.getLogger(),
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 307, in __init__
    raise Error('The CA file \'%s\' doesn\'t exist' % ca_file)
ovirtsdk4.Error: The CA file '/etc/pki/ovirt-engine/ca.pem' doesn't exist
[root@cephc ovirt-scripts]#

On Mon, Sep 24, 2018 at 8:20 PM Staniforth, Paul <P.Staniforth@leedsbeckett.ac.uk> wrote:

Hi Nagaraju,

                     I meant not signed by a trusted CA, when you install oVirt it signs the certificates with it's own local CA, you can download it the CA certificate  for your engine from https://your.engine.address/ovirt-engine/  it you are running the program on your engine machine I think it's in /etc/pki/ovirt-engine/ca.pem


Regards,

               Paul S.


From: Budur Nagaraju <nbudoor@gmail.com>
Sent: 24 September 2018 12:20
To: Staniforth, Paul
Cc: users
Subject: Re: [ovirt-users] Re: vm names export
 
Am not using any self signed certificate, it was the default certificate installed at the time of ovirt-engine installation , do I need to comment for that also ?
Tried commenting the line but still facing issues.

On Mon, Sep 24, 2018 at 4:28 PM Staniforth, Paul <P.Staniforth@leedsbeckett.ac.uk> wrote:

Hi Nagaraju,

                     if you are using the self-signed certificate have you downloaded your CA certificate, if you are using a certificate from a trusted CA then you should comment  or remove the CA file line.


Regards,

               Paul S.


From: Budur Nagaraju <nbudoor@gmail.com>
Sent: 24 September 2018 11:16
To: Sandro Bonazzola
Cc: users
Subject: [ovirt-users] Re: vm names export
 

Have tried the below URL , getting the below error

Script:


Error:


Thanks,
Nagaraju

On Fri, Sep 21, 2018 at 8:50 PM Sandro Bonazzola <sbonazzo@redhat.com> wrote:


Il giorno ven 21 set 2018 alle ore 17:16 Budur Nagaraju <nbudoor@gmail.com> ha scritto:
Hi 

I didn't understand, could you please help me on that ?

I was asking Ondra to follow up on your question
 

Thanks,
Nagaraju



On Fri, Sep 21, 2018 at 8:28 PM Sandro Bonazzola <sbonazzo@redhat.com> wrote:


Il giorno gio 20 set 2018 alle ore 09:23 Budur Nagaraju <nbudoor@gmail.com> ha scritto:

HI

We have deployed vms in oVirt , is there a way to export the vm names along with owner names ? any script which would help ?

Ondra?
 

Thanks,
Nagaraju
_______________________________________________
Users mailing list -- users@ovirt.org
To unsubscribe send an email to users-leave@ovirt.org
Privacy Statement: https://www.ovirt.org/site/privacy-policy/
oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/4GC4RHEQBVGXST5UOLBUNMYOXKKYDSWN/


--

SANDRO BONAZZOLA

MANAGER, SOFTWARE ENGINEERING, EMEA R&D RHV

Red Hat EMEA

sbonazzo@redhat.com   



--

SANDRO BONAZZOLA

MANAGER, SOFTWARE ENGINEERING, EMEA R&D RHV

Red Hat EMEA

sbonazzo@redhat.com   

To view the terms under which this email is distributed, please go to:-
http://disclaimer.leedsbeckett.ac.uk/disclaimer/disclaimer.html
To view the terms under which this email is distributed, please go to:-
http://disclaimer.leedsbeckett.ac.uk/disclaimer/disclaimer.html

_______________________________________________
Users mailing list -- users@ovirt.org
To unsubscribe send an email to users-leave@ovirt.org
Privacy Statement: https://www.ovirt.org/site/privacy-policy/
oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/Z33J5NEDYWLVJPJTSF6R7HRTLXCH3VV7/
-- 
Met vriendelijke groeten,

Valentin Bajrami
Target Holding
_______________________________________________
Users mailing list -- users@ovirt.org
To unsubscribe send an email to users-leave@ovirt.org
Privacy Statement: https://www.ovirt.org/site/privacy-policy/
oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/ZLQJ2Y3HQBJWF5YDQFXTTRKWNYJHSZJ4/