libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seb...@apache.org
Subject git commit: CLOUDSTACK: option to start VM in a STOPPED state
Date Fri, 03 Oct 2014 13:10:40 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 76c6fd91e -> 2d58fa9ed


CLOUDSTACK: option to start VM in a STOPPED state

Signed-off-by: Sebastien Goasguen <runseb@gmail.com>

This closes #368


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

Branch: refs/heads/trunk
Commit: 2d58fa9ed4defec7f44ce0b83aede701dbc806e1
Parents: 76c6fd9
Author: Roeland Kuipers <rkuipers@schubergphilis.com>
Authored: Fri Oct 3 13:29:10 2014 +0200
Committer: Sebastien Goasguen <runseb@gmail.com>
Committed: Fri Oct 3 09:10:02 2014 -0400

----------------------------------------------------------------------
 CHANGES.rst                                     |  4 ++++
 libcloud/compute/drivers/cloudstack.py          |  8 +++++++
 .../deployVirtualMachine_stoppedvm.json         |  1 +
 .../cloudstack/listNetworks_stoppedvm.json      |  1 +
 .../listServiceOfferings_stoppedvm.json         |  1 +
 .../cloudstack/listTemplates_stoppedvm.json     |  1 +
 .../cloudstack/listZones_stoppedvm.json         |  1 +
 .../queryAsyncJobResult_deployvmstopped.json    |  1 +
 libcloud/test/compute/test_cloudstack.py        | 23 ++++++++++++++++++++
 9 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d58fa9e/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 2d0aa6d..70dff2f 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -141,6 +141,10 @@ Compute
   (GITHUB-367, LIBCLOUD-615)
   [Rene Moser]
 
+- CLOUDSTACK: option to start VM in a STOPPED state
+  (GITHUB-368)
+  [Roeland Kuipers]
+
 Storage
 ~~~~~~~
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d58fa9e/libcloud/compute/drivers/cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudstack.py b/libcloud/compute/drivers/cloudstack.py
index 6ff91f2..a9d7169 100644
--- a/libcloud/compute/drivers/cloudstack.py
+++ b/libcloud/compute/drivers/cloudstack.py
@@ -952,6 +952,10 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver):
         :keyword    ex_ip_address: String with ipaddress for the default nic
         :type       ex_ip_address: ``str``
 
+        :keyword    ex_start_vm: Boolean to specify to start VM after creation
+                                 Defaults to True
+        :type       ex_start_vm: ``bool``
+
         :rtype:     :class:`.CloudStackNode`
         """
 
@@ -979,6 +983,7 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver):
         ex_security_groups = kwargs.get('ex_security_groups', None)
         ex_displayname = kwargs.get('ex_displayname', None)
         ex_ip_address = kwargs.get('ex_ip_address', None)
+        ex_start_vm = kwargs.get('ex_start_vm', None)
 
         if name:
             server_params['name'] = name
@@ -1022,6 +1027,9 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver):
         if ex_ip_address:
             server_params['ipaddress'] = ex_ip_address
 
+        if ex_start_vm is False:
+            server_params['startvm'] = ex_start_vm
+
         return server_params
 
     def destroy_node(self, node):

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d58fa9e/libcloud/test/compute/fixtures/cloudstack/deployVirtualMachine_stoppedvm.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudstack/deployVirtualMachine_stoppedvm.json
b/libcloud/test/compute/fixtures/cloudstack/deployVirtualMachine_stoppedvm.json
new file mode 100644
index 0000000..5906c4d
--- /dev/null
+++ b/libcloud/test/compute/fixtures/cloudstack/deployVirtualMachine_stoppedvm.json
@@ -0,0 +1 @@
+{ "deployvirtualmachineresponse" : {"jobid":"deployvmstopped","id":65385} }

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d58fa9e/libcloud/test/compute/fixtures/cloudstack/listNetworks_stoppedvm.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudstack/listNetworks_stoppedvm.json b/libcloud/test/compute/fixtures/cloudstack/listNetworks_stoppedvm.json
new file mode 100644
index 0000000..ad0bb80
--- /dev/null
+++ b/libcloud/test/compute/fixtures/cloudstack/listNetworks_stoppedvm.json
@@ -0,0 +1 @@
+{"listnetworksresponse": { "count": 3, "network": [ { "broadcastdomaintype": "Vlan", "broadcasturi":
"vlan://1002", "displaytext": "network:192.168.2.0/24", "dns1": "8.8.8.8", "dns2": "8.8.8.8",
"domain": "ROOT", "domainid": 1623, "endip": "192.168.2.233", "gateway": "192.168.2.254",
"id": 1823, "isdefault": false, "isshared": true, "issystem": false, "name": "ROOT", "netmask":
"255.255.255.0", "networkdomain": "cs1cloud.internal", "networkofferingavailability": "Optional",
"networkofferingdisplaytext": "Direct", "networkofferingid": 7, "networkofferingname": "DefaultDirectNetworkOffering",
"related": 1823, "securitygroupenabled": false, "service": [ { "name": "UserData" }, { "capability":
[ { "name": "AllowDnsSuffixModification", "value": "true" } ], "name": "Dns" }, { "capability":
[ { "name": "SupportedProtocols", "value": "tcp, udp" }, { "name": "SupportedLbAlgorithms",
"value": "roundrobin,leastconn,source" } ], "name": "Lb" }, { "name": "Dhcp" } ], "startip":
"192.168.2.1", "s
 tate": "Setup", "traffictype": "Guest", "type": "Direct", "vlan": "1002", "zoneid": 1 },
{ "account": "testuser", "broadcastdomaintype": "Vlan", "broadcasturi": "vlan://2909", "displaytext":
"testuser-network", "dns1": "8.8.8.8", "dns2": "8.8.8.8", "domain": "ROOT", "domainid": 1623,
"id": 1547, "isdefault": true, "isshared": false, "issystem": false, "name": "testuser-network",
"networkdomain": "cs586cloud.internal", "networkofferingavailability": "Optional", "networkofferingdisplaytext":
"Virtual Vlan", "networkofferingid": 6, "networkofferingname": "DefaultVirtualizedNetworkOffering",
"related": 1547, "securitygroupenabled": false, "service": [ { "name": "UserData" }, { "capability":
[ { "name": "AllowDnsSuffixModification", "value": "true" } ], "name": "Dns" }, { "capability":
[ { "name": "SupportedProtocols", "value": "tcp, udp" }, { "name": "SupportedLbAlgorithms",
"value": "roundrobin,leastconn,source" } ], "name": "Lb" }, { "name": "Gateway" }, { "name":
"Dhcp" }, { "capabil
 ity": [ { "name": "SupportedVpnTypes", "value": "pptp,l2tp,ipsec" } ], "name": "Vpn" }, {
"capability": [ { "name": "MultipleIps", "value": "true" }, { "name": "SupportedSourceNatTypes",
"value": "per account" }, { "name": "SupportedProtocols", "value": "tcp,udp,icmp" }, { "name":
"TrafficStatistics", "value": "per public ip" }, { "name": "PortForwarding", "value": "true"
}, { "name": "StaticNat", "value": "true" } ], "name": "Firewall" } ], "state": "Implemented",
"traffictype": "Guest", "type": "Virtual", "zoneid": 2 }, { "account": "testuser", "broadcastdomaintype":
"Vlan", "broadcasturi": "vlan://3564", "displaytext": "testuser-network", "dns1": "8.8.8.8",
"dns2": "8.8.8.8", "domain": "ROOT", "domainid": 1623, "id": 1374, "isdefault": true, "isshared":
false, "issystem": false, "name": "testuser-network", "networkdomain": "cs586cloud.internal",
"networkofferingavailability": "Optional", "networkofferingdisplaytext": "Virtual Vlan", "networkofferingid":
6, "networkofferingname": 
 "DefaultVirtualizedNetworkOffering", "related": 1374, "securitygroupenabled": false, "service":
[ { "name": "UserData" }, { "capability": [ { "name": "AllowDnsSuffixModification", "value":
"true" } ], "name": "Dns" }, { "capability": [ { "name": "SupportedProtocols", "value": "tcp,
udp" }, { "name": "SupportedLbAlgorithms", "value": "roundrobin,leastconn,source" } ], "name":
"Lb" }, { "name": "Gateway" }, { "name": "Dhcp" }, { "capability": [ { "name": "SupportedVpnTypes",
"value": "pptp,l2tp,ipsec" } ], "name": "Vpn" }, { "capability": [ { "name": "MultipleIps",
"value": "true" }, { "name": "SupportedSourceNatTypes", "value": "per account" }, { "name":
"SupportedProtocols", "value": "tcp,udp,icmp" }, { "name": "TrafficStatistics", "value": "per
public ip" }, { "name": "PortForwarding", "value": "true" }, { "name": "StaticNat", "value":
"true" } ], "name": "Firewall" } ], "state": "Implemented", "traffictype": "Guest", "type":
"Virtual", "zoneid": 1 } ] } }

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d58fa9e/libcloud/test/compute/fixtures/cloudstack/listServiceOfferings_stoppedvm.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudstack/listServiceOfferings_stoppedvm.json
b/libcloud/test/compute/fixtures/cloudstack/listServiceOfferings_stoppedvm.json
new file mode 100644
index 0000000..944a6f2
--- /dev/null
+++ b/libcloud/test/compute/fixtures/cloudstack/listServiceOfferings_stoppedvm.json
@@ -0,0 +1 @@
+{ "listserviceofferingsresponse" : {"count": 3, "serviceoffering": [ {"cpunumber": 2, "cpuspeed":
1600, "created": "2011-09-09T13:14:19+0900", "defaultuse": false, "displaytext": "M4", "id":
21, "issystem": false, "limitcpuuse": true, "memory": 4096, "name": "M4", "networkrate": 500,
"offerha": false, "storagetype": "shared", "tags": "Shared.auto"}, {"cpunumber": 1, "cpuspeed":
800, "created": "2011-09-09T13:17:52+0900", "defaultuse": false, "displaytext": "XS", "id":
24, "issystem": false, "limitcpuuse": true, "memory": 512, "name": "XS", "networkrate": 100,
"offerha": false, "storagetype": "shared", "tags": "Shared.auto"}, {"cpunumber": 1, "cpuspeed":
1600, "created": "2011-09-14T22:51:23+0900", "defaultuse": false, "displaytext": "S2", "id":
30, "issystem": false, "limitcpuuse": true, "memory": 2048, "name": "S2", "networkrate": 500,
"offerha": false, "storagetype": "shared", "tags": "Shared.auto"}]}}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d58fa9e/libcloud/test/compute/fixtures/cloudstack/listTemplates_stoppedvm.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudstack/listTemplates_stoppedvm.json b/libcloud/test/compute/fixtures/cloudstack/listTemplates_stoppedvm.json
new file mode 100644
index 0000000..a9c778c
--- /dev/null
+++ b/libcloud/test/compute/fixtures/cloudstack/listTemplates_stoppedvm.json
@@ -0,0 +1 @@
+{ "listtemplatesresponse" : {"count": 2, "template": [ {"account": "admin", "created": "2014-06-06T20:08:49+0900",
"crossZones": false, "displaytext": "CentOS 6.5", "domain": "ROOT", "domainid": 1, "format":
"OVA", "hypervisor": "VMware", "id": 8028, "isextractable": true, "isfeatured": true, "ispublic":
true, "isready": true, "name": "CentOS 6.5 64-bit", "ostypeid": 112, "ostypename": "CentOS
5.5 (64-bit)", "passwordenabled": true, "size": 16106127360, "status": "Download Complete",
"templatetype": "USER", "zoneid": 2, "zonename": "zone2"}, {"account": "admin", "created":
"2014-06-06T20:08:48+0900", "crossZones": false, "displaytext": "CentOS 6.5", "domain": "ROOT",
"domainid": 1, "format": "OVA", "hypervisor": "VMware", "id": 8028, "isextractable": true,
"isfeatured": true, "ispublic": true, "isready": true, "name": "CentOS 6.5 64-bit", "ostypeid":
112, "ostypename": "CentOS 5.5 (64-bit)", "passwordenabled": true, "size": 16106127360, "status":
"Download Complete", "templatetype":
  "USER", "zoneid": 1, "zonename": "zone1"} ]} }

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d58fa9e/libcloud/test/compute/fixtures/cloudstack/listZones_stoppedvm.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudstack/listZones_stoppedvm.json b/libcloud/test/compute/fixtures/cloudstack/listZones_stoppedvm.json
new file mode 100644
index 0000000..b072749
--- /dev/null
+++ b/libcloud/test/compute/fixtures/cloudstack/listZones_stoppedvm.json
@@ -0,0 +1 @@
+{ "listzonesresponse" : { "count":2 ,"zone" : [  {"id":1,"name":"zone1","networktype":"Advanced","securitygroupsenabled":false,"allocationstate":"Enabled","zonetoken":"6a3bfa26-67cd-3ff2-867e-20e86b211bb1","dhcpprovider":"VirtualRouter"},
{"id":2,"name":"zone2","networktype":"Advanced","securitygroupsenabled":false,"allocationstate":"Enabled","zonetoken":"8366e550-542d-373d-88e3-ca7c90bc8e6c","dhcpprovider":"VirtualRouter"}
] } }

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d58fa9e/libcloud/test/compute/fixtures/cloudstack/queryAsyncJobResult_deployvmstopped.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudstack/queryAsyncJobResult_deployvmstopped.json
b/libcloud/test/compute/fixtures/cloudstack/queryAsyncJobResult_deployvmstopped.json
new file mode 100644
index 0000000..9974248
--- /dev/null
+++ b/libcloud/test/compute/fixtures/cloudstack/queryAsyncJobResult_deployvmstopped.json
@@ -0,0 +1 @@
+{ "queryasyncjobresultresponse" : {"jobid":"deployvmstopped", "jobprocstatus": 0, "jobresult":
{"virtualmachine": {"account": "testuser", "cpunumber": 2, "cpuspeed": 1600, "created": "2014-07-06T16:40:39+0900",
"displayname": "deployip", "domain": "ROOT", "domainid": 1623, "guestosid": 112, "haenable":
false, "hypervisor": "VMware", "id": 65385, "memory": 4096, "name": "stopped_vm", "nic": [{"gateway":
"10.1.0.1", "id": 87320, "ipaddress": "10.1.0.128", "isdefault": true, "macaddress": "02:00:78:4a:01:9e",
"netmask": "255.255.252.0", "networkid": 1374, "traffictype": "Guest", "type": "Virtual"},
{"gateway": "192.168.2.254", "id": 87319, "ipaddress": "192.168.2.55", "isdefault": false,
"macaddress": "06:e6:50:00:70:0e", "netmask": "255.255.255.0", "networkid": 1823, "traffictype":
"Guest", "type": "Direct"}], "password": "password", "passwordenabled": true, "rootdeviceid":
0, "rootdevicetype": "VMFS", "securitygroup": [], "serviceofferingid": 21, "serviceofferingname":
"M4", "state":
  "Stopped" , "templatedisplaytext": "CentOS 6.5", "templateid": 8028, "templatename": "CentOS
6.5 64-bit", "zoneid": 1, "zonename": "zone1"}}, "jobresultcode": 0, "jobresulttype": "object",
"jobstatus": 1} }

http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d58fa9e/libcloud/test/compute/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py
index cd72b2b..387695f 100644
--- a/libcloud/test/compute/test_cloudstack.py
+++ b/libcloud/test/compute/test_cloudstack.py
@@ -29,6 +29,7 @@ from libcloud.common.types import ProviderError
 from libcloud.compute.drivers.cloudstack import CloudStackNodeDriver
 from libcloud.compute.types import LibcloudError, Provider, InvalidCredsError
 from libcloud.compute.types import KeyPairDoesNotExistError
+from libcloud.compute.types import NodeState
 from libcloud.compute.providers import get_driver
 
 from libcloud.test import unittest
@@ -149,6 +150,28 @@ class CloudStackCommonTestCase(TestCaseMixin):
         self.assertEqual(node.extra['image_id'], image.id)
         self.assertEqual(node.private_ips[0], ipaddress)
 
+    def test_create_node_ex_start_vm_false(self):
+        CloudStackMockHttp.fixture_tag = 'stoppedvm'
+        size = self.driver.list_sizes()[0]
+        image = self.driver.list_images()[0]
+        location = self.driver.list_locations()[0]
+
+        networks = [nw for nw in self.driver.ex_list_networks()
+                    if str(nw.zoneid) == str(location.id)]
+
+        node = self.driver.create_node(name='stopped_vm',
+                                       location=location,
+                                       image=image,
+                                       size=size,
+                                       networks=networks,
+                                       ex_start_vm=False)
+        self.assertEqual(node.name, 'stopped_vm')
+        self.assertEqual(node.extra['size_id'], size.id)
+        self.assertEqual(node.extra['zone_id'], location.id)
+        self.assertEqual(node.extra['image_id'], image.id)
+
+        self.assertEqual(node.state, NodeState.STOPPED)
+
     def test_create_node_ex_security_groups(self):
         size = self.driver.list_sizes()[0]
         image = self.driver.list_images()[0]


Mime
View raw message