libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [1/2] git commit: [LIBCLOUD-435] Fix a bug in ktucloud driver when diskoffering doesn't exist
Date Wed, 13 Nov 2013 09:58:26 GMT
Updated Branches:
  refs/heads/trunk f14a53d19 -> 5d44ce14b


[LIBCLOUD-435] Fix a bug in ktucloud driver when diskoffering doesn't exist

Signed-off-by: Tomaz Muraus <tomaz@apache.org>


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

Branch: refs/heads/trunk
Commit: e6e623e627ea6842a6d6dc6369bc969854accc4c
Parents: f14a53d
Author: charsyam <charsyam@gmail.com>
Authored: Sun Nov 10 03:53:28 2013 +0900
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Wed Nov 13 10:51:20 2013 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/ktucloud.py            |  9 +++++++--
 .../listAvailableProductTypes_nodisk.json       |  1 +
 libcloud/test/compute/test_ktucloud.py          | 21 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/e6e623e6/libcloud/compute/drivers/ktucloud.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ktucloud.py b/libcloud/compute/drivers/ktucloud.py
index 4f647c8..c635ed7 100644
--- a/libcloud/compute/drivers/ktucloud.py
+++ b/libcloud/compute/drivers/ktucloud.py
@@ -21,6 +21,7 @@ from libcloud.compute.drivers.cloudstack import CloudStackNodeDriver
 class KTUCloudNodeDriver(CloudStackNodeDriver):
     "Driver for KTUCloud Compute platform."
 
+    EMPTY_DISKOFFERINGID = '0'
     type = Provider.KTUCLOUD
     name = 'KTUCloud'
     website = 'https://ucloudbiz.olleh.com/'
@@ -55,8 +56,10 @@ class KTUCloudNodeDriver(CloudStackNodeDriver):
         szs = self._sync_request('listAvailableProductTypes')
         sizes = []
         for sz in szs['producttypes']:
+            diskofferingid = sz.get('diskofferingid',
+                                    self.EMPTY_DISKOFFERINGID)
             sizes.append(NodeSize(
-                sz['diskofferingid'],
+                diskofferingid,
                 sz['diskofferingdesc'],
                 0, 0, 0, 0, self)
             )
@@ -70,11 +73,13 @@ class KTUCloudNodeDriver(CloudStackNodeDriver):
         else:
             extra_args['usageplantype'] = usageplantype
 
+        if size.id != self.EMPTY_DISKOFFERINGID:
+            extra_args['diskofferingid'] = size.id
+
         result = self._async_request(
             'deployVirtualMachine',
             displayname=name,
             serviceofferingid=image.id,
-            diskofferingid=size.id,
             templateid=str(image.extra['templateid']),
             zoneid=str(image.extra['zoneid']),
             **extra_args

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e6e623e6/libcloud/test/compute/fixtures/ktucloud/listAvailableProductTypes_nodisk.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ktucloud/listAvailableProductTypes_nodisk.json
b/libcloud/test/compute/fixtures/ktucloud/listAvailableProductTypes_nodisk.json
new file mode 100644
index 0000000..e799b12
--- /dev/null
+++ b/libcloud/test/compute/fixtures/ktucloud/listAvailableProductTypes_nodisk.json
@@ -0,0 +1 @@
+{"listavailableproducttypesresponse": {"count": 2, "producttypes": [{"diskofferingdesc":
"100GB", "templatedesc": "Centos 5.4 32bit", "serviceofferingdesc": "premium 2vCore 2GB RAM",
"productstate": "available", "product": "Standard", "zoneid": "eceb5d65-6571-4696-875f-5a17949f3317",
"zonedesc": "KOR-Central A", "templateid": "d2241244-0b6c-444d-b075-72cfcd562826", "diskofferingid":
"cc85e4dd-bfd9-4cec-aa22-cf226c1da92f", "serviceofferingid": "94341d94-ccd4-4dc4-9ccb-05c0c632d0b4",
"productid": "eceb5d65-6571-4696-875f-5a17949f3317-d2241244-0b6c-444d-b075-72cfcd562826-94341d94-ccd4-4dc4-9ccb-05c0c632d0b4-cc85e4dd-bfd9-4cec-aa22-cf226c1da92f"},
{"diskofferingdesc": "20GB", "templatedesc": "Centos 5.4 32bit", "serviceofferingdesc": "premium
2vCore 2GB RAM", "productstate": "available", "product": "Standard", "zoneid": "eceb5d65-6571-4696-875f-5a17949f3317",
"zonedesc": "KOR-Central A", "templateid": "d2241244-0b6c-444d-b075-72cfcd562826", "serviceofferingid":
"94341d94-ccd4-4dc4-9ccb-
 05c0c632d0b4", "productid": "eceb5d65-6571-4696-875f-5a17949f3317-d2241244-0b6c-444d-b075-72cfcd562826-94341d94-ccd4-4dc4-9ccb-05c0c632d0b4-0"}]}}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e6e623e6/libcloud/test/compute/test_ktucloud.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ktucloud.py b/libcloud/test/compute/test_ktucloud.py
index 64c1aba..83a0838 100644
--- a/libcloud/test/compute/test_ktucloud.py
+++ b/libcloud/test/compute/test_ktucloud.py
@@ -71,6 +71,27 @@ class KTUCloudNodeDriverTest(unittest.TestCase, TestCaseMixin):
         images = self.driver.list_images()
         self.assertEqual(0, len(images))
 
+    def test_list_images_available(self):
+        images = self.driver.list_images()
+        self.assertEqual(112, len(images))
+
+    def test_list_sizes_available(self):
+        sizes = self.driver.list_sizes()
+        self.assertEqual(112, len(sizes))
+
+    def test_list_sizes_nodisk(self):
+        KTUCloudStackMockHttp.fixture_tag = 'nodisk'
+
+        sizes = self.driver.list_sizes()
+        self.assertEqual(2, len(sizes))
+
+        check = False
+        size = sizes[1]
+        if size.id == KTUCloudNodeDriver.EMPTY_DISKOFFERINGID:
+            check = True
+
+        self.assertTrue(check)
+
 
 class KTUCloudStackMockHttp(MockHttpTestCase):
     fixtures = ComputeFileFixtures('ktucloud')


Mime
View raw message