You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/11/13 10:58:26 UTC

[1/2] git commit: [LIBCLOUD-435] Fix a bug in ktucloud driver when diskoffering doesn't exist

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 <to...@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 <ch...@gmail.com>
Authored: Sun Nov 10 03:53:28 2013 +0900
Committer: Tomaz Muraus <to...@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')


[2/2] git commit: Update CHANGES.

Posted by to...@apache.org.
Update CHANGES.


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

Branch: refs/heads/trunk
Commit: 5d44ce14bea073b4ad843a667509df045ccf65a0
Parents: e6e623e
Author: Tomaz Muraus <to...@apache.org>
Authored: Wed Nov 13 10:50:01 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Wed Nov 13 10:51:33 2013 +0100

----------------------------------------------------------------------
 CHANGES | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/5d44ce14/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 4d26d40..0ed78d4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -79,6 +79,10 @@ Changes with Apache Libcloud in development
     (LIBCLOUD-416)
     [Markos Gogoulos]
 
+  - Modify list_sizes method in the KT UCloud driver to work, even if the item
+    doesn't have 'diskofferingid' attribute. (LIBCLOUD-435)
+    [DaeMyung Kang]
+
  *) Storage
 
   - Add a new driver for KT UCloud based on the OpenStack Swift driver.