salt icon indicating copy to clipboard operation
salt copied to clipboard

[Solved] Salt-Cloud with vsphere : Provisioning from a template throw an exeption

Open wolfyzvf opened this issue 12 years ago • 2 comments

I'm trying to get vsphere salt-cloud solution work, but I'm facing an issue with provisioning of a VM from a template :

sudo salt-cloud -p centos_vsphere web1 -l debug [DEBUG ] Missing configuration file: /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/vsphere.conf' [DEBUG ] Reading configuration from /etc/salt/cloud.providers.d/vsphere.conf [DEBUG ] Reading configuration from /etc/salt/cloud.profiles [DEBUG ] Configuration file path: /etc/salt/master [INFO ] salt-cloud starting [DEBUG ] 'parallels.avail_sizes' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'parallels.avail_locations' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'proxmox.avail_sizes' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'saltify.destroy' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'saltify.avail_sizes' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'saltify.avail_images' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'saltify.avail_locations' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'rackspace.reboot' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] The 'vsphere' cloud driver is unable to be optimized. [DEBUG ] 'parallels.avail_sizes' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'parallels.avail_locations' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'proxmox.avail_sizes' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'saltify.destroy' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'saltify.avail_sizes' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'saltify.avail_images' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'saltify.avail_locations' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] 'rackspace.reboot' has been marked as not supported. Removing from the list of supported cloud functions [DEBUG ] Generating minion keys for 'web1' web1: ---------- Provisioning: VM being provisioned in parallel. PID: 86462

[DEBUG ] MasterEvent PUB socket URI: ipc:///var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: ipc:///var/run/salt/master/master_event_pull.ipc [DEBUG ] Sending event - data = {'profile': 'centos_vsphere', 'event': 'starting create', '_stamp': '2014-08-12T21:08:32.075898', 'name': 'web1', 'provider': 'my_provider:vsphere'} [INFO ] Creating Cloud VM web1 [DEBUG ] MasterEvent PUB socket URI: ipc:///var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: ipc:///var/run/salt/master/master_event_pull.ipc [DEBUG ] Sending event - data = {'_stamp': '2014-08-12T21:08:32.905097', 'event': 'requesting instance', 'kwargs': {'profile': 'centos_vsphere', 'resourcepool': 'Resources', 'priv_key': '-----BEGIN RSA PRIVATE KEY-----\n ... -----END RSA PRIVATE KEY-----\n', 'image': 'Centosx64', 'host': 'cloud-02.domain.tld', 'datastore': 'Datastore-02', 'folder': 'Saltstack', 'name': 'web1', 'provider': 'my_provider:vsphere', 'pub_key': '-----BEGIN PUBLIC KEY-----\n... -----END PUBLIC KEY-----\n', 'os': 'bootstrap-salt'}} [DEBUG ] clone_kwargs are set to {'datastore': 'Datastore-02', 'folder': 'Saltstack', 'host': 'cloud-02.domain.tld', 'name': 'web1', 'resourcepool': 'Resources', 'template': False} [ERROR ] Error creating web1 on vSphere

The following exception was thrown by libcloud when trying to run the initial deployment: This object has already been deleted or has not been completely created Traceback (most recent call last): File "/Library/Python/2.7/site-packages/salt/cloud/clouds/vsphere.py", line 222, in create new_instance = template.clone(**clone_kwargs) File "/Library/Python/2.7/site-packages/pysphere/vi_virtual_machine.py", line 541, in clone raise VIApiException(e) VIApiException: [ManagedObjectNotFoundFault]: This object has already been deleted or has not been completely created

I can sucessfully connect to the vsphere :

sudo salt-cloud --list-images=all [INFO ] salt-cloud starting my_provider: ---------- vsphere: ---------- Centosx64: ---------- Name: Centosx64 Windows2k8r2: ---------- Name: Windows2k8r2

Environment :

Salt: 2014.7.0 Python: 2.7.5 (default, Mar 9 2014, 22:15:05) Jinja2: 2.7.3 M2Crypto: 0.22 msgpack-python: 0.4.2 msgpack-pure: 0.1.3 pycrypto: 2.6.1 libnacl: Not Installed PyYAML: 3.11 ioflo: 0.9.39 PyZMQ: 14.3.1 RAET: Not Installed ZMQ: 4.0.4 Mako: 1.0.0 Apache Libcloud: 0.15.1

Salt Master running on MacOSX

VSphere version 5.0

/etc/salt/cloud.providers.d/vsphere.conf my_provider: provider: vsphere user: admin password: mypassword url: 'https://vsphere.domain.tld:443/sdk'

/etc/salt/cloud.profiles centos_vsphere: provider: my_provider image: Centosx64 host: cloud-02.domain.tld resourcepool: Resources folder: Saltstack datastore: Datastore-02 windows_vsphere: provider: my_provider image: Windows2k8r2 host: cloud-02.domain.tld folder: Saltstack datastore: Datastore-02

I don't know where is coming from, because when using this script, I can successfully provision a VM from a template : http://dellaert.org/2013/03/04/pysphere-script-to-clone-a-template-into-multiple-vms-with-post-processing/

wolfyzvf avatar Aug 12 '14 19:08 wolfyzvf

Finally nailed it ! The /Library/Python/2.7/site-packages/salt/cloud/clouds/vsphere.py doesn't get the MOR of the vsphere, so you have to put it by hand. The MOR is requested by libcloud (/Library/Python/2.7/site-packages/pysphere/vi_virtual_machine.py Starting line 402 ).

I think there is a possibility to automatically get the value like the script I mention before. As I'm not a developer, I can't help on this part.

Here is a workaround :

  • To get the MOR of the resource Pool, which is the one mandatory, you have to go to your vsphere MOB webpage (ex. https://IP_OF_VSPHERE/mob/) then click on "RetriveServiceContent" and then on "Invoke Method".
  • Then search for the "rootFolder" on the left and click on the "group-xx" on the right.
  • Click on "childEntity" right value "datacenter-xx"
  • Click on "datastore" right value "datastore-xx"
  • Finally click on a vm, you will have the value on "resourcePool". Just copy-paste the value on the cloud.profiles file you have and it will be good. For exemple mine looks like : centos_vsphere: provider: my_provider image: Centosx64 folder: Saltstack resourcepool: resgroup-47 <= The MOR of my resource Pool.

Now test : sudo salt-cloud -p centos_vsphere web1 -l debug [DEBUG ] clone_kwargs are set to {'datastore': None, 'folder': 'Saltstack', 'host': None, 'name': 'web1', 'resourcepool': 'resgroup-47', 'template': False} [DEBUG ] VM web1 is created, waiting for it to boot [DEBUG ] Attempting function <function wait_for_ip at 0x10654b398>

Hope thats help !

wolfyzvf avatar Aug 12 '14 20:08 wolfyzvf

Hi wolfyzvf I notice that you dropped the folder and host params from your cloud.profile as well. The error persisted for me until I did the same. I'm guessing that those also need to be MOR values.

Curious, it doesn't look like you are using --no-deploy. Are you not getting SSH errors when it attempts to install the minion?

mike-ainsworth avatar Aug 21 '14 05:08 mike-ainsworth