salt.cloud.clouds.vsphere

vSphere Cloud Module

注解

Carbon 版后已移除: The vsphere cloud driver has been deprecated in favor of the vmware cloud driver and will be removed in Salt Carbon. Please refer to Getting started with VMware to get started and convert your vsphere provider configurations to use the vmware driver.

The vSphere cloud module is used to control access to VMware vSphere.

depends:PySphere Python module >= 0.1.8

Note: Ensure python pysphere module is installed by running following one-liner check. The output should be 0.

python -c "import pysphere" ; echo $?
# if this fails install using
pip install https://pysphere.googlecode.com/files/pysphere-0.1.8.zip

Use of this module only requires a URL, username and password. Set up the cloud configuration at:

/etc/salt/cloud.providers or /etc/salt/cloud.providers.d/vsphere.conf:

my-vsphere-config:
  driver: vsphere
  user: myuser
  password: verybadpass
  template_user: root
  template_password: mybadVMpassword
  url: 'https://10.1.1.1:443'

Note: Your URL may or may not look like any of the following, depending on how your VMware installation is configured:

10.1.1.1
10.1.1.1:443
https://10.1.1.1:443
https://10.1.1.1:443/sdk
10.1.1.1:443/sdk
folder
Name of the folder that will contain the new VM. If not set, the VM will be added to the folder the original VM belongs to.
resourcepool
MOR of the resourcepool to be used for the new vm. If not set, it uses the same resourcepool than the original vm.
datastore
MOR of the datastore where the virtual machine should be located. If not specified, the current datastore is used.
host

MOR of the host where the virtual machine should be registered.

Id not specified:
  • if resourcepool is not specified, current host is used.
  • if resourcepool is specified, and the target pool represents a stand-alone host, the host is used.
  • if resourcepool is specified, and the target pool represents a DRS-enabled cluster, a host selected by DRS is used.
  • if resourcepool is specified and the target pool represents a cluster without DRS enabled, an InvalidArgument exception will be thrown.
template
Specifies whether or not the new virtual machine should be marked as a template. Default is False.
template_user
Specifies the user to access the VM. Should be
template_password
The password with which to access the VM.
sudo

The user to access the VM with sudo privileges.

2015.5.2 新版功能.

sudo_password

The password corresponding to the sudo user to access the VM with sudo privileges.

2015.5.2 新版功能.

salt.cloud.clouds.vsphere.avail_images()

Return a dict of all available VM images on the cloud provider.

salt.cloud.clouds.vsphere.avail_locations()

返回一个字典,包含所有在云服务商可用的VM路径和相关数据

salt.cloud.clouds.vsphere.create(vm_)

从一个字典数据中创建单一的VM

salt.cloud.clouds.vsphere.create_snapshot(kwargs=None, call=None)

Create a snapshot

@name: Name of the virtual machine to snapshot @snapshot: Name of the snapshot @description: Description of the snapshot (optional) @memory: Dump of the internal state of the virtual machine (optional)

2015.8.0 新版功能.

命令行接口CLI 范例:

salt-cloud -f create_snapshot [PROVIDER] name=myvm.example.com snapshot=mysnapshot
salt-cloud -f create_snapshot [PROVIDER] name=myvm.example.com snapshot=mysnapshot description='My Snapshot' memory=True
salt.cloud.clouds.vsphere.delete_snapshot(kwargs=None, call=None)

Delete snapshot

2015.8.0 新版功能.

命令行接口CLI 范例:

salt-cloud -f delete_snapshot [PROVIDER] name=myvm.example.com snapshot=mysnapshot
salt.cloud.clouds.vsphere.destroy(name, call=None)

Destroy a node.

命令行接口CLI 范例:

salt-cloud --destroy mymachine
salt.cloud.clouds.vsphere.get_configured_provider()

Return the first configured instance.

salt.cloud.clouds.vsphere.get_conn()

Return a conn object for the passed VM data

salt.cloud.clouds.vsphere.get_dependencies()

Warn if dependencies aren't met.

salt.cloud.clouds.vsphere.list_clusters(kwargs=None, call=None)

List the clusters for this VMware environment

salt.cloud.clouds.vsphere.list_datacenters(kwargs=None, call=None)

List the data centers for this VMware environment

salt.cloud.clouds.vsphere.list_datastores(kwargs=None, call=None)

List the datastores for this VMware environment

salt.cloud.clouds.vsphere.list_folders(kwargs=None, call=None)

List the folders for this VMware environment

salt.cloud.clouds.vsphere.list_hosts(kwargs=None, call=None)

List the hosts for this VMware environment

salt.cloud.clouds.vsphere.list_nodes(kwargs=None, call=None)

Return a list of the VMs that are on the provider, with basic fields

salt.cloud.clouds.vsphere.list_nodes_full(kwargs=None, call=None)

Return a list of the VMs that are on the provider with full details

salt.cloud.clouds.vsphere.list_nodes_min(kwargs=None, call=None)

Return a list of the nodes in the provider, with no details

salt.cloud.clouds.vsphere.list_nodes_select()

Return a list of the VMs that are on the provider, with select fields

salt.cloud.clouds.vsphere.list_resourcepools(kwargs=None, call=None)

List the hosts for this VMware environment

salt.cloud.clouds.vsphere.reset(name, call=None)

To reset a VM using its name

命令行接口CLI 范例:

salt-cloud -a reset vmname
salt.cloud.clouds.vsphere.script(vm_)

Return the script deployment object

salt.cloud.clouds.vsphere.show_instance(name, call=None)

Show the details from vSphere concerning a guest

salt.cloud.clouds.vsphere.snapshot_list(kwargs=None, call=None)

List virtual machines with snapshots

2015.8.0 新版功能.

命令行接口CLI 范例:

salt-cloud -f snapshot_list
salt.cloud.clouds.vsphere.start(name, call=None)

To start/power on a VM using its name

命令行接口CLI 范例:

salt-cloud -a start vmname
salt.cloud.clouds.vsphere.status(name, call=None)

To check the status of a VM using its name

命令行接口CLI 范例:

salt-cloud -a status vmname
salt.cloud.clouds.vsphere.stop(name, call=None)

To stop/power off a VM using its name

命令行接口CLI 范例:

salt-cloud -a stop vmname
salt.cloud.clouds.vsphere.suspend(name, call=None)

To suspend a VM using its name

命令行接口CLI 范例:

salt-cloud -a suspend vmname
salt.cloud.clouds.vsphere.wait_for_ip(vm_)