Repository: libcloud
Updated Branches:
  refs/heads/trunk db4bc4244 -> dcb0cef8e


cloudstack: add tests for ipaddress-less nics

Signed-off-by: Quentin Pradet <[email protected]>


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

Branch: refs/heads/trunk
Commit: dcb0cef8eefae7e89dd79b76621f6cc53650a41b
Parents: 96d29f5
Author: Pierre-Yves Ritschard <[email protected]>
Authored: Fri Nov 10 14:52:08 2017 +0100
Committer: Quentin Pradet <[email protected]>
Committed: Sat Nov 11 06:46:41 2017 +0400

----------------------------------------------------------------------
 .../listVirtualMachines_noipaddress.json        | 98 ++++++++++++++++++++
 libcloud/test/compute/test_cloudstack.py        | 11 +++
 2 files changed, 109 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/dcb0cef8/libcloud/test/compute/fixtures/cloudstack/listVirtualMachines_noipaddress.json
----------------------------------------------------------------------
diff --git 
a/libcloud/test/compute/fixtures/cloudstack/listVirtualMachines_noipaddress.json
 
b/libcloud/test/compute/fixtures/cloudstack/listVirtualMachines_noipaddress.json
new file mode 100644
index 0000000..ede3a23
--- /dev/null
+++ 
b/libcloud/test/compute/fixtures/cloudstack/listVirtualMachines_noipaddress.json
@@ -0,0 +1,98 @@
+{
+    "listvirtualmachinesresponse" : {
+       "virtualmachine" : [
+           {
+               "id":2600,
+               "name":"test",
+               "displayname":"test",
+               "account":"fakeaccount",
+               "domainid":801,
+               "domain":"AA000062-libcloud-dev",
+               "created":"2011-06-23T05:06:42+0000",
+               "state":"Running",
+               "haenable":false,
+               "zoneid":1,
+               "zonename":"Sydney",
+               "templateid":421,
+               "templatename":"XEN Basic Ubuntu 10.04 Server x64 PV r2.0",
+               "templatedisplaytext":"XEN Basic Ubuntu 10.04 Server x64 PV 
r2.0",
+               "passwordenabled":false,
+               "serviceofferingid":105,
+               "serviceofferingname":"Compute Micro PRD",
+               "cpunumber":1,
+               "cpuspeed":1200,
+               "memory":384,
+               "cpuused":"1.78%",
+               "networkkbsread":2,
+               "networkkbswrite":2,
+               "guestosid":12,
+               "rootdeviceid":0,
+               "rootdevicetype":"IscsiLUN",
+               "securitygroup":[],
+               "nic":[
+                   {
+                       "id":3891,
+                       "networkid":860,
+                       "netmask":"255.255.240.0",
+                       "gateway":"1.1.2.1",
+                       "ipaddress":"1.1.1.116",
+                       "traffictype":"Guest",
+                       "type":"Virtual",
+                       "isdefault":true
+                   },
+                   {
+                       "id":3892,
+                       "networkid":861,
+                       "type":"Virtual",
+                       "isdefault":false
+                   }
+               ],
+               "hypervisor":"XenServer",
+               "tags": [
+                   {"key": "testkey", "value": "testvalue"},
+                   {"key": "foo", "value": "bar"}]
+           },
+           {
+               "id":2601,
+               "name":"test",
+               "displayname":"test",
+               "account":"fakeaccount",
+               "domainid":801,
+               "domain":"AA000062-libcloud-dev",
+               "created":"2011-06-23T05:09:44+0000",
+               "state":"Starting",
+               "haenable":false,
+               "zoneid":1,
+               "zonename":"Sydney",
+               "templateid":421,
+               "templatename":"XEN Basic Ubuntu 10.04 Server x64 PV r2.0",
+               "templatedisplaytext":"XEN Basic Ubuntu 10.04 Server x64 PV 
r2.0",
+               "passwordenabled":false,
+               "serviceofferingid":105,
+               "serviceofferingname": "Compute Micro PRD",
+               "cpunumber":1,
+               "cpuspeed":1200,
+               "memory":384,
+               "guestosid":12,
+               "rootdeviceid":0,
+               "rootdevicetype":"IscsiLUN",
+               "securitygroup":[],
+               "jobid":17147,
+               "jobstatus":0,
+               "nic":[
+                   {
+                       "id":3892,
+                       "networkid":860,
+                       "netmask":"255.255.240.0",
+                       "gateway":"1.1.2.1",
+                       "ipaddress":"1.1.1.203",
+                       "traffictype":"Guest",
+                       "type":"Virtual",
+                       "isdefault":true
+                   }
+               ],
+               "hypervisor":"XenServer"
+           }
+       ]
+    }
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/dcb0cef8/libcloud/test/compute/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudstack.py 
b/libcloud/test/compute/test_cloudstack.py
index 8e620bb..356cd94 100644
--- a/libcloud/test/compute/test_cloudstack.py
+++ b/libcloud/test/compute/test_cloudstack.py
@@ -649,6 +649,17 @@ class CloudStackCommonTestCase(TestCaseMixin):
         finally:
             del CloudStackMockHttp._cmd_listVirtualMachines
 
+    def test_list_nodes_noipaddress_filter(self):
+        def list_nodes_mock(self, **kwargs):
+            body, obj = 
self._load_fixture('listVirtualMachines_noipaddress.json')
+            return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+        CloudStackMockHttp._cmd_listVirtualMachines = list_nodes_mock
+        try:
+            self.driver.list_nodes()
+        finally:
+            del CloudStackMockHttp._cmd_listVirtualMachines
+
     def test_ex_get_node(self):
         node = self.driver.ex_get_node(2600)
         self.assertEqual('test', node.name)

Reply via email to