ministryofjustice / salt-cloud-provider-vcloud

Salt Cloud Provider for VMWare vCloud
MIT License
13 stars 7 forks source link

ValueError: Invalid attribute name u'xml:lang' #7

Open shellhacks opened 9 years ago

shellhacks commented 9 years ago

The following error appears while trying to create a new VM:

ValueError: Invalid attribute name u'xml:lang'

Debug:

[root@dplt-tc3-1 ~]# salt-cloud -m /etc/salt/cloud.maps.d/vcloud.conf -l debug
[DEBUG   ] Reading configuration from /etc/salt/cloud
[DEBUG   ] Reading configuration from /etc/salt/master
[DEBUG   ] Missing configuration file: /etc/salt/cloud.providers
[DEBUG   ] Including configuration from '/etc/salt/cloud.providers.d/vcloud.conf'
[DEBUG   ] Reading configuration from /etc/salt/cloud.providers.d/vcloud.conf
[DEBUG   ] Missing configuration file: /etc/salt/cloud.profiles
[DEBUG   ] Including configuration from '/etc/salt/cloud.profiles.d/vcloud.conf'
[DEBUG   ] Reading configuration from /etc/salt/cloud.profiles.d/vcloud.conf
[DEBUG   ] Configuration file path: /etc/salt/cloud
[INFO    ] salt-cloud starting
[DEBUG   ] Loading vCloud cloud module
[DEBUG   ] Failed to import clouds joyent:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/loader.py", line 951, in _load_module
    ), fn_, fpath, desc)
  File "/usr/lib/python2.6/site-packages/salt/cloud/clouds/joyent.py", line 68, in <module>
    from Crypto.Signature import PKCS1_v1_5
ImportError: No module named Signature
[DEBUG   ] Could not LazyLoad parallels.avail_sizes
[DEBUG   ] LazyLoaded parallels.avail_locations
[DEBUG   ] LazyLoaded proxmox.avail_sizes
[DEBUG   ] Could not LazyLoad saltify.destroy
[DEBUG   ] Could not LazyLoad saltify.avail_sizes
[DEBUG   ] Could not LazyLoad saltify.avail_images
[DEBUG   ] Could not LazyLoad saltify.avail_locations
[DEBUG   ] LazyLoaded rackspace.reboot
[DEBUG   ] LazyLoaded openstack.list_locations
[DEBUG   ] LazyLoaded rackspace.list_locations
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] Jinja search path: ['/var/cache/salt/master/files/base']
[DEBUG   ] Rendered data from file: /etc/salt/cloud.maps.d/vcloud.conf:
vcd_tiny_vdc_a:
  - test:
      network: Internet

[DEBUG   ] Results of YAML rendering: 
OrderedDict([('vcd_tiny_vdc_a', [OrderedDict([('test', OrderedDict([('network', 'Internet')]))])])])
[INFO    ] Applying map from '/etc/salt/cloud.maps.d/vcloud.conf'.
[DEBUG   ] Could not LazyLoad vcloud.optimize_providers
[DEBUG   ] The 'vcloud' cloud driver is unable to be optimized.
[DEBUG   ] Loading vCloud cloud module
[DEBUG   ] Failed to import clouds joyent:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/loader.py", line 951, in _load_module
    ), fn_, fpath, desc)
  File "/usr/lib/python2.6/site-packages/salt/cloud/clouds/joyent.py", line 68, in <module>
    from Crypto.Signature import PKCS1_v1_5
ImportError: No module named Signature
[DEBUG   ] Could not LazyLoad parallels.avail_sizes
[DEBUG   ] LazyLoaded parallels.avail_locations
[DEBUG   ] LazyLoaded proxmox.avail_sizes
[DEBUG   ] Could not LazyLoad saltify.destroy
[DEBUG   ] Could not LazyLoad saltify.avail_sizes
[DEBUG   ] Could not LazyLoad saltify.avail_images
[DEBUG   ] Could not LazyLoad saltify.avail_locations
[DEBUG   ] LazyLoaded rackspace.reboot
[DEBUG   ] LazyLoaded openstack.list_locations
[DEBUG   ] LazyLoaded rackspace.list_locations
The following virtual machines are set to be created:
  test

Proceed? [N/y] y
... proceeding
[INFO    ] Calculating dependencies for test
[DEBUG   ] Got execution order 0 for test
[DEBUG   ] No make_master found in map
[DEBUG   ] Generating minion keys for 'test'
[]
[ERROR   ] There was a query error: Invalid attribute name u'xml:lang'
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/cloud/cli.py", line 316, in run
    ret = mapper.run_map(dmap)
  File "/usr/lib/python2.6/site-packages/salt/cloud/__init__.py", line 2091, in run_map
    profile, local_master=local_master
  File "/usr/lib/python2.6/site-packages/salt/cloud/__init__.py", line 1241, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.6/site-packages/salt/cloud/clouds/vcloud.py", line 92, in create
    dnat_list=dnat_list
  File "/usr/lib/python2.6/site-packages/salt/cloud/clouds/vcloud_support/libcloud_vcloud.py", line 513, in create_vm
    ex_vm_ipmode=('POOL', network_name),
  File "/usr/lib/python2.6/site-packages/libcloud/compute/drivers/vcloud.py", line 1450, in create_node
    ex_clone_timeout)
  File "/usr/lib/python2.6/site-packages/libcloud/compute/drivers/vcloud.py", line 1487, in _instantiate_node
    vm_fence=vm_fence
  File "/usr/lib/python2.6/site-packages/libcloud/compute/drivers/vcloud.py", line 878, in __init__
    self._build_xmltree()
  File "/usr/lib/python2.6/site-packages/libcloud/compute/drivers/vcloud.py", line 884, in _build_xmltree
    self.root = self._make_instantiation_root()
  File "/usr/lib/python2.6/site-packages/libcloud/compute/drivers/vcloud.py", line 910, in _make_instantiation_root
    'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance'}
  File "lxml.etree.pyx", line 2912, in lxml.etree.Element (src/lxml/lxml.etree.c:68681)
  File "apihelpers.pxi", line 140, in lxml.etree._makeElement (src/lxml/lxml.etree.c:15242)
  File "apihelpers.pxi", line 128, in lxml.etree._makeElement (src/lxml/lxml.etree.c:15125)
  File "apihelpers.pxi", line 287, in lxml.etree._initNodeAttributes (src/lxml/lxml.etree.c:17012)
  File "apihelpers.pxi", line 296, in lxml.etree._addAttributeToNode (src/lxml/lxml.etree.c:17180)
  File "apihelpers.pxi", line 1583, in lxml.etree._attributeValidOrRaise (src/lxml/lxml.etree.c:29377)
ValueError: Invalid attribute name u'xml:lang'

Current settings:

# cat /etc/salt/cloud.maps.d/vcloud.conf
vcd_tiny_vdc_a:
  - test:
      network: Internet

# cat /etc/salt/cloud.profiles.d/vcloud.conf 
vcd_tiny_vdc_a:
  provider: my_vcloud
  image: my_1st_vApp
  size: tiny
  vdc: vDC-CLIENT-*****

# cat /etc/salt/cloud.providers.d/vcloud.conf 
my_vcloud:
  provider: vcloud
  user: *****
  org: *****
  secret: *****
  host: vcloud.***.tld

I think that the code that cause the issue is located in "/usr/lib/python2.6/site-packages/libcloud/compute/drivers/vcloud.py". Here it is:

    def _make_instantiation_root(self):
        return ET.Element(
            'InstantiateVAppTemplateParams',
            {'name': self.name,
             'deploy': 'false',
             'powerOn': 'false',
             'xml:lang': 'en',
             'xmlns': 'http://www.vmware.com/vcloud/v1.5',
             'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance'}
        )

Thanks in advance for help.

ashb commented 9 years ago

Intersting one. That's in libcloud not this module.

What versions of libcloud and lxml do you have?

ashb commented 9 years ago

I think I last tested this with libcloud 0.14.... 1? Might be worth trying to downgrade to that version to see if it at least gets you up and running.

shellhacks commented 9 years ago

Here are the current versions:

# rpm -qa | grep libcloud
python-libcloud-0.17.0-1.el6.noarch
# pip freeze | grep lxml
lxml==3.4.4

Will try to downgrade libcloud and come back after.

shellhacks commented 9 years ago

Removing current libcloud:

# rpm -e python-libcloud-0.17.0-1.el6.noarch
error: Failed dependencies:
    python-libcloud is needed by (installed) salt-cloud-2015.5.0-1.el6.noarch
# rpm -e --nodeps python-libcloud-0.17.0-1.el6.noarch

Installing the older libcloud:

# wget http://archive.apache.org/dist/libcloud/apache-libcloud-0.14.1.tar.gz -O - | tar -xz
# cd apache-libcloud-0.14.1
# python setup.py install

Checking version

# python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libcloud
>>> libcloud.__version__
'0.14.1'

And it works!!!

Is spite of new errors i see on vCloud that test VM has been created.

Here is the DEBUG:

# salt-cloud -m /etc/salt/cloud.maps.d/vcloud.conf -l debug
[DEBUG   ] Reading configuration from /etc/salt/cloud
[DEBUG   ] Reading configuration from /etc/salt/master
[DEBUG   ] Missing configuration file: /etc/salt/cloud.providers
[DEBUG   ] Including configuration from '/etc/salt/cloud.providers.d/vcloud.conf'
[DEBUG   ] Reading configuration from /etc/salt/cloud.providers.d/vcloud.conf
[DEBUG   ] Missing configuration file: /etc/salt/cloud.profiles
[DEBUG   ] Including configuration from '/etc/salt/cloud.profiles.d/vcloud.conf'
[DEBUG   ] Reading configuration from /etc/salt/cloud.profiles.d/vcloud.conf
[DEBUG   ] Configuration file path: /etc/salt/cloud
[INFO    ] salt-cloud starting
[DEBUG   ] Loading vCloud cloud module
[DEBUG   ] Failed to import clouds joyent:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/loader.py", line 951, in _load_module
    ), fn_, fpath, desc)
  File "/usr/lib/python2.6/site-packages/salt/cloud/clouds/joyent.py", line 68, in <module>
    from Crypto.Signature import PKCS1_v1_5
ImportError: No module named Signature
[DEBUG   ] Could not LazyLoad parallels.avail_sizes
[DEBUG   ] LazyLoaded parallels.avail_locations
[DEBUG   ] LazyLoaded proxmox.avail_sizes
[DEBUG   ] Could not LazyLoad saltify.destroy
[DEBUG   ] Could not LazyLoad saltify.avail_sizes
[DEBUG   ] Could not LazyLoad saltify.avail_images
[DEBUG   ] Could not LazyLoad saltify.avail_locations
[DEBUG   ] LazyLoaded rackspace.reboot
[DEBUG   ] LazyLoaded openstack.list_locations
[DEBUG   ] LazyLoaded rackspace.list_locations
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] Jinja search path: ['/var/cache/salt/master/files/base']
[DEBUG   ] Rendered data from file: /etc/salt/cloud.maps.d/vcloud.conf:
vcd_tiny_vdc_a:
  - test:
      network: Internet

[DEBUG   ] Results of YAML rendering: 
OrderedDict([('vcd_tiny_vdc_a', [OrderedDict([('test', OrderedDict([('network', 'Internet')]))])])])
[INFO    ] Applying map from '/etc/salt/cloud.maps.d/vcloud.conf'.
[DEBUG   ] Could not LazyLoad vcloud.optimize_providers
[DEBUG   ] The 'vcloud' cloud driver is unable to be optimized.
[DEBUG   ] Loading vCloud cloud module
[DEBUG   ] Failed to import clouds joyent:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/loader.py", line 951, in _load_module
    ), fn_, fpath, desc)
  File "/usr/lib/python2.6/site-packages/salt/cloud/clouds/joyent.py", line 68, in <module>
    from Crypto.Signature import PKCS1_v1_5
ImportError: No module named Signature
[DEBUG   ] Could not LazyLoad parallels.avail_sizes
[DEBUG   ] LazyLoaded parallels.avail_locations
[DEBUG   ] LazyLoaded proxmox.avail_sizes
[DEBUG   ] Could not LazyLoad saltify.destroy
[DEBUG   ] Could not LazyLoad saltify.avail_sizes
[DEBUG   ] Could not LazyLoad saltify.avail_images
[DEBUG   ] Could not LazyLoad saltify.avail_locations
[DEBUG   ] LazyLoaded rackspace.reboot
[DEBUG   ] LazyLoaded openstack.list_locations
[DEBUG   ] LazyLoaded rackspace.list_locations
The following virtual machines are set to be created:
  test

Proceed? [N/y] y
... proceeding
[INFO    ] Calculating dependencies for test
[DEBUG   ] Got execution order 0 for test
[DEBUG   ] No make_master found in map
[DEBUG   ] Generating minion keys for 'test'
[]
.....................[ERROR   ] There was a query error: <ns0:Error majorErrorCode="400" message="[ fe7cd11d-2c9e-49ce-b80e-fccc089fcbc3 ] Impossible de changer la carte r&#233;seau primaire lorsque la machine virtuelle n'est pas d&#233;sactiv&#233;e." minorErrorCode="BAD_REQUEST" ns1:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://192.168.0.100/api/v1.5/schema/master.xsd" xmlns:ns0="http://www.vmware.com/vcloud/v1.5" xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" />
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/cloud/cli.py", line 316, in run
    ret = mapper.run_map(dmap)
  File "/usr/lib/python2.6/site-packages/salt/cloud/__init__.py", line 2091, in run_map
    profile, local_master=local_master
  File "/usr/lib/python2.6/site-packages/salt/cloud/__init__.py", line 1241, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.6/site-packages/salt/cloud/clouds/vcloud.py", line 92, in create
    dnat_list=dnat_list
  File "/usr/lib/python2.6/site-packages/salt/cloud/clouds/vcloud_support/libcloud_vcloud.py", line 513, in create_vm
    ex_vm_ipmode=('POOL', network_name),
  File "/usr/lib/python2.6/site-packages/apache_libcloud-0.14.1-py2.6.egg/libcloud/compute/drivers/vcloud.py", line 1452, in create_node
    self._change_vm_ipmode(vapp_href, ex_vm_ipmode)
  File "/usr/lib/python2.6/site-packages/salt/cloud/clouds/vcloud_support/libcloud_vcloud.py", line 212, in _change_vm_ipmode
    headers=headers
  File "/usr/lib/python2.6/site-packages/apache_libcloud-0.14.1-py2.6.egg/libcloud/compute/drivers/vcloud.py", line 317, in request
    return super(VCloudConnection, self).request(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/apache_libcloud-0.14.1-py2.6.egg/libcloud/common/base.py", line 675, in request
    response = responseCls(**kwargs)
  File "/usr/lib/python2.6/site-packages/apache_libcloud-0.14.1-py2.6.egg/libcloud/common/base.py", line 112, in __init__
    raise Exception(self.parse_error())
Exception: <ns0:Error majorErrorCode="400" message="[ fe7cd11d-2c9e-49ce-b80e-fccc089fcbc3 ] Impossible de changer la carte r&#233;seau primaire lorsque la machine virtuelle n'est pas d&#233;sactiv&#233;e." minorErrorCode="BAD_REQUEST" ns1:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://192.168.0.100/api/v1.5/schema/master.xsd" xmlns:ns0="http://www.vmware.com/vcloud/v1.5" xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" />