libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [07/14] libcloud git commit: Added forceCustomization param to ex_deploy.
Date Sat, 25 Jun 2016 23:37:43 GMT
Added forceCustomization param to ex_deploy.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/15b97834
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/15b97834
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/15b97834

Branch: refs/heads/trunk
Commit: 15b97834d51fc077996134a5a658c006701caee1
Parents: e06c974
Author: Juan Font Alonso <juanfontalonso@gmail.com>
Authored: Thu Jun 23 18:38:31 2016 +0200
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Sat Jun 25 20:00:11 2016 +1000

----------------------------------------------------------------------
 libcloud/compute/drivers/vcloud.py | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/15b97834/libcloud/compute/drivers/vcloud.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/vcloud.py b/libcloud/compute/drivers/vcloud.py
index 9789eaf..884adcf 100644
--- a/libcloud/compute/drivers/vcloud.py
+++ b/libcloud/compute/drivers/vcloud.py
@@ -1022,19 +1022,37 @@ class VCloud_1_5_NodeDriver(VCloudNodeDriver):
         else:
             return False
 
-    def ex_deploy_node(self, node):
+    def ex_deploy_node(self, node, force_customization=False):
         """
         Deploys existing node. Equal to vApp "start" operation.
 
         :param  node: The node to be deployed
         :type   node: :class:`Node`
 
+        :param  force_customization: Used to specify whether to force
+                                     customization on deployment,
+                                     if not set default value is False.
+        :type   force_customization: ``bool``
+
         :rtype: :class:`Node`
         """
+        if force_customization:
+            vms = self._get_vm_elements(node.id)
+            for vm in vms:
+                self._ex_deploy_node_or_vm(vm.get('href'),
+                                           force_customization=True)
+        else:
+            self._ex_deploy_node_or_vm(node.id)
+
+        res = self.connection.request(get_url_path(node.id))
+        return self._to_node(res.object)
+
+    def _ex_deploy_node_or_vm(self, vapp_or_vm_path, force_customization=False):
         data = {'powerOn': 'true',
+                'forceCustomization': str(force_customization).lower(),
                 'xmlns': 'http://www.vmware.com/vcloud/v1.5'}
         deploy_xml = ET.Element('DeployVAppParams', data)
-        path = get_url_path(node.id)
+        path = get_url_path(vapp_or_vm_path)
         headers = {
             'Content-Type':
             'application/vnd.vmware.vcloud.deployVAppParams+xml'
@@ -1044,8 +1062,6 @@ class VCloud_1_5_NodeDriver(VCloudNodeDriver):
                                       method='POST',
                                       headers=headers)
         self._wait_for_task_completion(res.object.get('href'))
-        res = self.connection.request(get_url_path(node.id))
-        return self._to_node(res.object)
 
     def ex_undeploy_node(self, node):
         """
@@ -1402,6 +1418,11 @@ class VCloud_1_5_NodeDriver(VCloudNodeDriver):
                                (started) after creation
         :type       ex_deploy: ``bool``
 
+        :keyword    ex_force_customization: Used to specify whether to force
+                                            customization on deployment,
+                                            if not set default value is False.
+        :type       ex_force_customization: ``bool``
+
         :keyword    ex_clone_timeout: timeout in seconds for clone/instantiate
                                       VM operation.
                                       Cloning might be a time consuming
@@ -1423,6 +1444,7 @@ class VCloud_1_5_NodeDriver(VCloudNodeDriver):
         ex_vm_network = kwargs.get('ex_vm_network', None)
         ex_vm_ipmode = kwargs.get('ex_vm_ipmode', None)
         ex_deploy = kwargs.get('ex_deploy', True)
+        ex_force_customization = kwargs.get('ex_force_customization', False)
         ex_vdc = kwargs.get('ex_vdc', None)
         ex_clone_timeout = kwargs.get('ex_clone_timeout',
                                       DEFAULT_TASK_COMPLETION_TIMEOUT)


Mime
View raw message