diff --git a/doc/_static/snapshot_manager.png b/doc/_static/snapshot_manager.png new file mode 100644 index 000000000000..bd989f371179 Binary files /dev/null and b/doc/_static/snapshot_manager.png differ diff --git a/doc/topics/cloud/vmware.rst b/doc/topics/cloud/vmware.rst index 4fe3ca8475e1..1ec2b38e84f0 100644 --- a/doc/topics/cloud/vmware.rst +++ b/doc/topics/cloud/vmware.rst @@ -530,6 +530,32 @@ Example of a minimal profile: cluster: 'Prod' +Cloning from a Snapshot +======================= + +.. versionadded:: Carbon + +Cloning a template works similar to cloning a VM except for the fact that +a snapshot number must be provided. + +Example of a minimal profile: + +.. code-block:: yaml + + my-template-clone: + provider: vcenter01 + clonefrom: 'salt_vm' + snapshot: 3 + +.. image:: /_static/snapshot_manager.png + :align: center + :scale: 70% + +.. note:: + The previous diagram shows how to identify the snapshot number. Selected + (third snapshot) is number 3. + + Creating a VM ============= diff --git a/doc/topics/releases/2016.3.4.rst b/doc/topics/releases/2016.3.4.rst index e2c084829595..ced7dc2feb5e 100644 --- a/doc/topics/releases/2016.3.4.rst +++ b/doc/topics/releases/2016.3.4.rst @@ -7,3 +7,4 @@ Version 2016.3.4 is a bugfix release for :doc:`2016.3.0 - The `disk.wipe` execution module function has been modified so that it correctly wipes a disk. +- Add ability to clone from a snapshot to the VMWare salt-cloud driver. diff --git a/salt/cloud/clouds/vmware.py b/salt/cloud/clouds/vmware.py index d7de4ba482b3..164c474f99d5 100644 --- a/salt/cloud/clouds/vmware.py +++ b/salt/cloud/clouds/vmware.py @@ -2187,6 +2187,14 @@ def create(vm_): raise SaltCloudSystemExit( 'The VM/template that you have specified under clonefrom does not exist.' ) + + snapshot = None + if clone_type == 'vm' and 'snapshot' in vm_: + num = int(vm_['snapshot']) - 1 + snapshot = object_ref.rootSnapshot[0] + # Drill down to the correct snapshot number + for i in range(num): + snapshot = snapshot.childSnapshot[0] else: clone_type = None object_ref = None @@ -2325,12 +2333,20 @@ def create(vm_): config_spec.extraConfig.append(option) if 'clonefrom' in vm_: - # Create the clone specs - clone_spec = vim.vm.CloneSpec( - template=template, - location=reloc_spec, - config=config_spec - ) + if not snapshot: + # Create the clone specs + clone_spec = vim.vm.CloneSpec( + template=template, + location=reloc_spec, + config=config_spec + ) + else: + clone_spec = vim.vm.CloneSpec( + template=template, + location=reloc_spec, + config=config_spec, + snapshot=snapshot + ) if customization and (devices and 'network' in list(devices.keys())) and 'Windows' not in object_ref.config.guestFullName: global_ip = vim.vm.customization.GlobalIPSettings()