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 2014/01/31 19:32:51 UTC

[1/7] git commit: docs: Update commiter guide.

Updated Branches:
  refs/heads/trunk bfee04e8d -> 9e24600b8


docs: Update commiter guide.


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

Branch: refs/heads/trunk
Commit: 3f84e6b4ffb9984beef4787ca4113f85ba22515e
Parents: bfee04e
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Jan 31 13:15:21 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Jan 31 13:15:21 2014 +0100

----------------------------------------------------------------------
 docs/committer_guide.rst | 6 ------
 1 file changed, 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/3f84e6b4/docs/committer_guide.rst
----------------------------------------------------------------------
diff --git a/docs/committer_guide.rst b/docs/committer_guide.rst
index b90e7ee..ebb1aba 100644
--- a/docs/committer_guide.rst
+++ b/docs/committer_guide.rst
@@ -288,9 +288,6 @@ Body::
 
     pip install apache-libcloud
 
-    It is possible that the file hasn't been synced to all the mirrors yet. If this
-    is the case, please use the main Apache mirror - http://www.apache.org/dist/libcloud.
-
     Upgrading
 
     If you have installed Libcloud using pip you can also use it to upgrade it:
@@ -349,9 +346,6 @@ Body::
 
     pip install apache-libcloud
 
-    It is possible that the file hasn't been synced to all the mirrors yet. If this
-    is the case, please use the main Apache mirror - http://www.apache.org/dist/libcloud.
-
     Upgrading
 
     If you have installed Libcloud using pip you can also use it to upgrade it:


[4/7] git commit: Include subscribed_object attribute on the Subscription class.

Posted by to...@apache.org.
Include subscribed_object attribute on the Subscription class.


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

Branch: refs/heads/trunk
Commit: 1c6caeb60e389b267a900f2051ade2b28c21e349
Parents: 7003847
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Jan 31 18:24:15 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Jan 31 18:24:15 2014 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/cloudsigma.py        | 16 ++++++++++++----
 libcloud/test/compute/test_cloudsigma_v2_0.py |  1 +
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1c6caeb6/libcloud/compute/drivers/cloudsigma.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudsigma.py b/libcloud/compute/drivers/cloudsigma.py
index 990f906..034f55a 100644
--- a/libcloud/compute/drivers/cloudsigma.py
+++ b/libcloud/compute/drivers/cloudsigma.py
@@ -689,7 +689,7 @@ class CloudSigmaSubscription(object):
     """
 
     def __init__(self, id, resource, amount, period, status, price, start_time,
-                 end_time, auto_renew):
+                 end_time, auto_renew, subscribed_object=None):
         """
         :param id: Subscription ID.
         :type id: ``str``
@@ -714,6 +714,9 @@ class CloudSigmaSubscription(object):
 
         :param auto_renew: True if the subscription is auto renewed.
         :type auto_renew: ``bool``
+
+        :param subscribed_object: Optional UUID of the subscribed object.
+        :type subscribed_object: ``str``
         """
         self.id = id
         self.resource = resource
@@ -724,13 +727,16 @@ class CloudSigmaSubscription(object):
         self.start_time = start_time
         self.end_time = end_time
         self.auto_renew = auto_renew
+        self.subscribed_object = subscribed_object
 
     def __str__(self):
         return self.__repr__()
 
     def __repr__(self):
-        return ('<CloudSigmaSubscription id=%s, resource=%s, amount=%s>' %
-                (self.id, self.resource, self.amount))
+        return ('<CloudSigmaSubscription id=%s, resource=%s, amount=%s, '
+                'period=%s, object_uuid=%s>' %
+                (self.id, self.resource, self.amount, self.period,
+                 self.subscribed_object))
 
 
 class CloudSigmaTag(object):
@@ -1904,6 +1910,7 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver):
     def _to_subscription(self, data):
         start_time = parse_date(data['start_time'])
         end_time = parse_date(data['end_time'])
+        obj_uuid = data['subscribed_object']
 
         subscription = CloudSigmaSubscription(id=data['id'],
                                               resource=data['resource'],
@@ -1913,7 +1920,8 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver):
                                               price=data['price'],
                                               start_time=start_time,
                                               end_time=end_time,
-                                              auto_renew=data['auto_renew'])
+                                              auto_renew=data['auto_renew'],
+                                              subscribed_object=obj_uuid)
         return subscription
 
     def _to_firewall_policy(self, data):

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1c6caeb6/libcloud/test/compute/test_cloudsigma_v2_0.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudsigma_v2_0.py b/libcloud/test/compute/test_cloudsigma_v2_0.py
index aa5035e..358c1e7 100644
--- a/libcloud/test/compute/test_cloudsigma_v2_0.py
+++ b/libcloud/test/compute/test_cloudsigma_v2_0.py
@@ -347,6 +347,7 @@ class CloudSigmaAPI20BaseTestCase(object):
         self.assertEqual(subscription.resource, 'vlan')
         self.assertEqual(subscription.price, '10.26666666666666666666666667')
         self.assertEqual(subscription.auto_renew, False)
+        self.assertEqual(subscription.subscribed_object, '2494079f-8376-40bf-9b37-34d633b8a7b7')
 
     def test_ex_list_subscriptions_status_filterting(self):
         CloudSigmaMockHttp.type = 'STATUS_FILTER'


[6/7] git commit: docs: Add an example of how to create a server with a vlan.

Posted by to...@apache.org.
docs: Add an example of how to create a server with a vlan.


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

Branch: refs/heads/trunk
Commit: f086c44e0038033682ab1876174ce2e7358e86a7
Parents: 24350fd
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Jan 31 19:04:15 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Jan 31 19:04:15 2014 +0100

----------------------------------------------------------------------
 docs/compute/drivers/cloudsigma.rst             | 50 +++++++++++++-------
 .../cloudsigma/create_server_with_vlan.py       | 19 ++++++++
 2 files changed, 53 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/f086c44e/docs/compute/drivers/cloudsigma.rst
----------------------------------------------------------------------
diff --git a/docs/compute/drivers/cloudsigma.rst b/docs/compute/drivers/cloudsigma.rst
index e6d3581..831ac15 100644
--- a/docs/compute/drivers/cloudsigma.rst
+++ b/docs/compute/drivers/cloudsigma.rst
@@ -26,14 +26,14 @@ Available arguments:
 Examples
 --------
 
-1. Connect to zrh region using new API v2.0
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Connect to zrh region using new API v2.0
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 .. literalinclude:: /examples/compute/cloudsigma/connect_to_api_2_0.py
    :language: python
 
-2. Connect to zrh region using deprecated API v1.0
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Connect to zrh region using deprecated API v1.0
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 As noted above, API 1.0 has been deprecated and you are strongly encouraged to
 migrate any code which uses API 1.0 to API 2.0. This example is only included
@@ -42,8 +42,8 @@ here for completeness.
 .. literalinclude:: /examples/compute/cloudsigma/connect_to_api_1_0.py
    :language: python
 
-3. Listing available sizes, images and drives
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Listing available sizes, images and drives
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 In Libcloud, a :class:`libcloud.compute.base.NodeSize` represents a physical
 configuration of a server and a :class:`libcloud.compute.base.NodeImage`
@@ -66,8 +66,8 @@ drives.
 .. literalinclude:: /examples/compute/cloudsigma/list_sizes_images_drives.py
    :language: python
 
-4. Create a server using a custom node size
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Create a server using a custom node size
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Unlike most of the other cloud providers out there, CloudSigma is not limited
 to pre-defined instance sizes and allows you to specify your own custom size
@@ -96,8 +96,26 @@ You can find exact limits and free capacity for your account's location using
 :meth:`libcloud.compute.drivers.cloudsigma.CloudSigma_2_0_NodeDriver.ex_list_capabilities`
 method.
 
-5. Associate metadata with a server upon creation
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Create a server with a VLAN
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+By default, each server created with Libcloud has one network interface with a
+public IP assigned.
+
+Besides networks with a public IP, CloudSigma also allows you to create and use
+VLANs.
+
+This example shows how to do that. It first creates a VLAN by purchasing a
+subscription and then assigns the create VLAN to a node upon creation.
+
+Created node will have two network interfaces assigned - one with a public IP
+and one with the provided VLAN.
+
+.. literalinclude:: /examples/compute/cloudsigma/create_server_with_vlan.py
+   :language: python
+
+Associate metadata with a server upon creation
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 CloudSigma allows you to associate arbitrary key / value pairs with each
 server. This examples shows how to do that upon server creation.
@@ -105,8 +123,8 @@ server. This examples shows how to do that upon server creation.
 .. literalinclude:: /examples/compute/cloudsigma/create_server_with_metadata.py
    :language: python
 
-6. Add a tag to the server
-~~~~~~~~~~~~~~~~~~~~~~~~~~
+Add a tag to the server
+~~~~~~~~~~~~~~~~~~~~~~~
 
 CloudSigma allows you to ogranize resources such as servers and drivers by
 tagging them. This example shows how to do that.
@@ -114,8 +132,8 @@ tagging them. This example shows how to do that.
 .. literalinclude:: /examples/compute/cloudsigma/tag_server.py
    :language: python
 
-7. Open a VNC tunnel to the server
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Open a VNC tunnel to the server
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 CloudSigma allows you to connect and manage your server using `VNC`_. To
 connect to the server using VNC, you can use clients such as ``vinagre`` or
@@ -183,8 +201,8 @@ method as displayed bellow.
 Both of those methods return a ``list``. Servers and drives which share the same
 physical host will be stored under the same index in the returned list.
 
-10. Retrieving the account balance
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Retrieving the account balance
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 This example shows how to retrieve the account balance. The method returns a
 dictionary with two keys - ``balance`` and ``currency``.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/f086c44e/docs/examples/compute/cloudsigma/create_server_with_vlan.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/cloudsigma/create_server_with_vlan.py b/docs/examples/compute/cloudsigma/create_server_with_vlan.py
new file mode 100644
index 0000000..c48d8b3
--- /dev/null
+++ b/docs/examples/compute/cloudsigma/create_server_with_vlan.py
@@ -0,0 +1,19 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+
+cls = get_driver(Provider.CLOUDSIGMA)
+driver = cls('username', 'password', region='zrh', api_version='2.0')
+
+name = 'test node with vlan'
+size = driver.list_sizes()[0]
+image = driver.list_images()[0]
+
+# 1. Create a VLAN. VLANs are created by purchasing a subscription.
+subscription = driver.ex_create_subscription(amount=1, period='1 month',
+                                             resource='vlan', auto_renew=True)
+vlan_uuid = subscription.subscribed_object
+
+# 2. Create a node with a VLAN
+node = driver.create_node(name=name, size=size, image=image,
+                          ex_vlan=vlan_uuid)
+print(node)


[2/7] git commit: Add ex_create_subscription method to CloudSigma driver. Also modify subscription class so the amount attribute is an int.

Posted by to...@apache.org.
Add ex_create_subscription method to CloudSigma driver. Also modify
subscription class so the amount attribute is an int.


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

Branch: refs/heads/trunk
Commit: 0d7b5a5787400eda65c4418fd49fc0e17e4ba244
Parents: 3f84e6b
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Jan 31 18:11:47 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Jan 31 18:11:47 2014 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/cloudsigma.py          | 36 +++++++++++++++++++-
 .../cloudsigma_2_0/create_subscription.json     | 23 +++++++++++++
 libcloud/test/compute/test_cloudsigma_v2_0.py   | 16 ++++++++-
 3 files changed, 73 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/0d7b5a57/libcloud/compute/drivers/cloudsigma.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudsigma.py b/libcloud/compute/drivers/cloudsigma.py
index 266708e..5000a33 100644
--- a/libcloud/compute/drivers/cloudsigma.py
+++ b/libcloud/compute/drivers/cloudsigma.py
@@ -1736,6 +1736,40 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver):
                                         method='POST')
         return response.status == httplib.OK
 
+    def ex_create_subscription(self, amount, period, resource,
+                               auto_renew=False):
+        """
+        Create a new subscription.
+
+        :param amount: Subscription amount. For example, in dssd case this
+                       would be disk size in gigabytes.
+        :type amount: ``int``
+
+        :param period: Subscription period. For example: 30 days, 1 week, 1
+                                            month, ...
+        :type period: ``str``
+
+        :param resource: Resource the purchase the subscription for.
+        :type resource: ``str``
+
+        :param auto_renew: True to automatically renew the subscription.
+        :type auto_renew: ``bool``
+        """
+        data = [
+            {
+                'amount': amount,
+                'period': period,
+                'auto_renew': auto_renew,
+                'resource': resource
+            }
+        ]
+
+        response = self.connection.request(action='/subscriptions/',
+                                           data=data, method='POST')
+        data = response.object['objects'][0]
+        subscription = self._to_subscription(data=data)
+        return subscription
+
     # Misc extension methods
 
     def ex_list_capabilities(self):
@@ -1869,7 +1903,7 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver):
 
         subscription = CloudSigmaSubscription(id=data['id'],
                                               resource=data['resource'],
-                                              amount=data['amount'],
+                                              amount=int(data['amount']),
                                               period=data['period'],
                                               status=data['status'],
                                               price=data['price'],

http://git-wip-us.apache.org/repos/asf/libcloud/blob/0d7b5a57/libcloud/test/compute/fixtures/cloudsigma_2_0/create_subscription.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudsigma_2_0/create_subscription.json b/libcloud/test/compute/fixtures/cloudsigma_2_0/create_subscription.json
new file mode 100644
index 0000000..7699d40
--- /dev/null
+++ b/libcloud/test/compute/fixtures/cloudsigma_2_0/create_subscription.json
@@ -0,0 +1,23 @@
+{
+    "objects": [
+        {
+            "amount": "1",
+            "auto_renew": false,
+            "descendants": [],
+            "discount_amount": "0",
+            "discount_percent": "0",
+            "end_time": "2014-03-01T12:00:00+00:00",
+            "id": "228816",
+            "period": "1 month",
+            "price": "10.26666666666666666666666667",
+            "remaining": "1",
+            "resource": "vlan",
+            "resource_uri": "/api/2.0/subscriptions/228816/",
+            "start_time": "2014-01-31T17:06:19.388295+00:00",
+            "status": "active",
+            "subscribed_object": "2494079f-8376-40bf-9b37-34d633b8a7b7",
+            "uuid": "0dd25c5c-6c01-498f-b009-e07d76552a1a"
+        }
+    ],
+    "price": "10.26666666666666666666666667"
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/0d7b5a57/libcloud/test/compute/test_cloudsigma_v2_0.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudsigma_v2_0.py b/libcloud/test/compute/test_cloudsigma_v2_0.py
index 966a072..7d04682 100644
--- a/libcloud/test/compute/test_cloudsigma_v2_0.py
+++ b/libcloud/test/compute/test_cloudsigma_v2_0.py
@@ -332,11 +332,21 @@ class CloudSigmaAPI20BaseTestCase(object):
         self.assertEqual(len(subscriptions), 5)
         self.assertEqual(subscription.id, '7272')
         self.assertEqual(subscription.resource, 'vlan')
-        self.assertEqual(subscription.amount, '1')
+        self.assertEqual(subscription.amount, 1)
         self.assertEqual(subscription.period, '345 days, 0:00:00')
         self.assertEqual(subscription.status, 'active')
         self.assertEqual(subscription.price, '0E-20')
 
+    def test_ex_create_subscription(self):
+        CloudSigmaMockHttp.type = 'CREATE_SUBSCRIPTION'
+        subscription = self.driver.ex_create_subscription(amount=1,
+                                                          period='1 month',
+                                                          resource='vlan')
+        self.assertEqual(subscription.amount, 1)
+        self.assertEqual(subscription.period, '1 month')
+        self.assertEqual(subscription.resource, 'vlan')
+        self.assertEqual(subscription.price, '10.26666666666666666666666667')
+
     def test_ex_list_subscriptions_status_filterting(self):
         CloudSigmaMockHttp.type = 'STATUS_FILTER'
         self.driver.ex_list_subscriptions(status='active')
@@ -577,6 +587,10 @@ class CloudSigmaMockHttp(MockHttpTestCase):
         body = ''
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _api_2_0_subscriptions_CREATE_SUBSCRIPTION(self, method, url, body, headers):
+        body = self.fixtures.load('create_subscription.json')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
     def _api_2_0_capabilities(self, method, url, body, headers):
         body = self.fixtures.load('capabilities.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])


[5/7] git commit: Allow user to create server with VLAN.

Posted by to...@apache.org.
Allow user to create server with VLAN.


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

Branch: refs/heads/trunk
Commit: 24350fd75eb37911c5cfff606c71979e91c05da0
Parents: 1c6caeb
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Jan 31 18:55:56 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Jan 31 18:55:56 2014 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/cloudsigma.py | 50 ++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/24350fd7/libcloud/compute/drivers/cloudsigma.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudsigma.py b/libcloud/compute/drivers/cloudsigma.py
index 034f55a..5d38537 100644
--- a/libcloud/compute/drivers/cloudsigma.py
+++ b/libcloud/compute/drivers/cloudsigma.py
@@ -1060,7 +1060,7 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver):
         return images
 
     def create_node(self, name, size, image, ex_metadata=None,
-                    ex_vnc_password=None, ex_avoid=None):
+                    ex_vnc_password=None, ex_avoid=None, ex_vlan=None):
         """
         Create a new server.
 
@@ -1082,6 +1082,11 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver):
         :param ex_avoid: A list of server UUIDs to avoid when starting this
                          node. (optional)
         :type ex_avoid: ``list``
+
+        :param ex_vlan: Optional UUID of a VLAN network to use. If specified,
+        server will have two nics assigned - 1 with a public ip and 1 with the
+        provided VLAN.
+        :type ex_vlan: ``str``
         """
         # Only pre-installed images can be used with create_node
 
@@ -1123,24 +1128,37 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver):
             data['meta'] = ex_metadata
 
         # Assign 1 public interface (DHCP) to the node
-        data['nics'] = [
-            {
+        nic = {
+            'boot_order': None,
+            'ip_v4_conf': {
+                'conf': 'dhcp',
+            },
+            'ip_v6_conf': None
+        }
+
+        nics = [nic]
+
+        if ex_vlan:
+            # Assign another interface for VLAN
+            nic = {
                 'boot_order': None,
-                'ip_v4_conf': {
-                    'conf': 'dhcp',
-                },
-                'ip_v6_conf': None
+                'ip_v4_conf': None,
+                'ip_v6_conf': None,
+                'vlan': ex_vlan
             }
-        ]
+            nics.append(nic)
 
-        data['drives'] = [
-            {
-                'boot_order': 1,
-                'dev_channel': '0:0',
-                'device': 'ide',
-                'drive': drive.id
-            }
-        ]
+        drive = {
+            'boot_order': 1,
+            'dev_channel': '0:0',
+            'device': 'ide',
+            'drive': drive.id
+        }
+
+        drives = [drive]
+
+        data['nics'] = nics
+        data['drives'] = drives
 
         action = '/servers/'
         response = self.connection.request(action=action, method='POST',


[3/7] git commit: Add auto_renew attribute to subscription class.

Posted by to...@apache.org.
Add auto_renew attribute to subscription class.


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

Branch: refs/heads/trunk
Commit: 700384716e584385ffe78d62e5d97fc6fc263863
Parents: 0d7b5a5
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Jan 31 18:13:38 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Jan 31 18:13:38 2014 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/cloudsigma.py        | 9 +++++++--
 libcloud/test/compute/test_cloudsigma_v2_0.py | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/70038471/libcloud/compute/drivers/cloudsigma.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudsigma.py b/libcloud/compute/drivers/cloudsigma.py
index 5000a33..990f906 100644
--- a/libcloud/compute/drivers/cloudsigma.py
+++ b/libcloud/compute/drivers/cloudsigma.py
@@ -689,7 +689,7 @@ class CloudSigmaSubscription(object):
     """
 
     def __init__(self, id, resource, amount, period, status, price, start_time,
-                 end_time):
+                 end_time, auto_renew):
         """
         :param id: Subscription ID.
         :type id: ``str``
@@ -711,6 +711,9 @@ class CloudSigmaSubscription(object):
 
         :param end_time: End time for this subscription.
         :type end_time: ``datetime.datetime``
+
+        :param auto_renew: True if the subscription is auto renewed.
+        :type auto_renew: ``bool``
         """
         self.id = id
         self.resource = resource
@@ -720,6 +723,7 @@ class CloudSigmaSubscription(object):
         self.price = price
         self.start_time = start_time
         self.end_time = end_time
+        self.auto_renew = auto_renew
 
     def __str__(self):
         return self.__repr__()
@@ -1908,7 +1912,8 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver):
                                               status=data['status'],
                                               price=data['price'],
                                               start_time=start_time,
-                                              end_time=end_time)
+                                              end_time=end_time,
+                                              auto_renew=data['auto_renew'])
         return subscription
 
     def _to_firewall_policy(self, data):

http://git-wip-us.apache.org/repos/asf/libcloud/blob/70038471/libcloud/test/compute/test_cloudsigma_v2_0.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudsigma_v2_0.py b/libcloud/test/compute/test_cloudsigma_v2_0.py
index 7d04682..aa5035e 100644
--- a/libcloud/test/compute/test_cloudsigma_v2_0.py
+++ b/libcloud/test/compute/test_cloudsigma_v2_0.py
@@ -346,6 +346,7 @@ class CloudSigmaAPI20BaseTestCase(object):
         self.assertEqual(subscription.period, '1 month')
         self.assertEqual(subscription.resource, 'vlan')
         self.assertEqual(subscription.price, '10.26666666666666666666666667')
+        self.assertEqual(subscription.auto_renew, False)
 
     def test_ex_list_subscriptions_status_filterting(self):
         CloudSigmaMockHttp.type = 'STATUS_FILTER'


[7/7] git commit: Add a test case for creating a node with VLAN.

Posted by to...@apache.org.
Add a test case for creating a node with VLAN.


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

Branch: refs/heads/trunk
Commit: 9e24600b898fb753e09695a5d7961accb7ce77f5
Parents: f086c44
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Jan 31 19:26:24 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Jan 31 19:26:24 2014 +0100

----------------------------------------------------------------------
 .../servers_create_with_vlan.json               | 68 ++++++++++++++++++++
 libcloud/test/compute/test_cloudsigma_v2_0.py   | 29 ++++++++-
 2 files changed, 96 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/9e24600b/libcloud/test/compute/fixtures/cloudsigma_2_0/servers_create_with_vlan.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudsigma_2_0/servers_create_with_vlan.json b/libcloud/test/compute/fixtures/cloudsigma_2_0/servers_create_with_vlan.json
new file mode 100644
index 0000000..ee1b2d7
--- /dev/null
+++ b/libcloud/test/compute/fixtures/cloudsigma_2_0/servers_create_with_vlan.json
@@ -0,0 +1,68 @@
+{
+    "objects": [
+        {
+            "context": true,
+            "cpu": 1100,
+            "cpu_model": null,
+            "cpus_instead_of_cores": false,
+            "drives": [
+                {
+                    "boot_order": 1,
+                    "dev_channel": "0:0",
+                    "device": "ide",
+                    "drive": {
+                        "resource_uri": "/api/2.0/drives/7c0efbb2-b1e8-4e77-9d72-9f9f9d75ae7b/",
+                        "uuid": "7c0efbb2-b1e8-4e77-9d72-9f9f9d75ae7b"
+                    },
+                    "runtime": null
+                }
+            ],
+            "enable_numa": false,
+            "hv_relaxed": false,
+            "hv_tsc": false,
+            "mem": 671088640,
+            "meta": {},
+            "name": "test node vlan",
+            "nics": [
+                {
+                    "boot_order": null,
+                    "firewall_policy": null,
+                    "ip_v4_conf": {
+                        "conf": "dhcp",
+                        "ip": null
+                    },
+                    "ip_v6_conf": null,
+                    "mac": "22:94:75:3c:16:34",
+                    "model": "virtio",
+                    "runtime": null,
+                    "vlan": null
+                },
+                {
+                    "boot_order": null,
+                    "firewall_policy": null,
+                    "ip_v4_conf": null,
+                    "ip_v6_conf": null,
+                    "mac": "22:84:c4:af:f3:fc",
+                    "model": "virtio",
+                    "runtime": null,
+                    "vlan": {
+                        "resource_uri": "/api/2.0/vlans/39ae851d-433f-4ac2-a803-ffa24cb1fa3e/",
+                        "uuid": "39ae851d-433f-4ac2-a803-ffa24cb1fa3e"
+                    }
+                }
+            ],
+            "owner": {
+                "resource_uri": "/api/2.0/user/69fcfc03-d635-4f99-a8b3-e1b73637cb5d/",
+                "uuid": "69fcfc03-d635-4f99-a8b3-e1b73637cb5d"
+            },
+            "requirements": [],
+            "resource_uri": "/api/2.0/servers/c8b034fb-9e66-4892-be12-a36121d4b704/",
+            "runtime": null,
+            "smp": 1,
+            "status": "stopped",
+            "tags": [],
+            "uuid": "9de75ed6_fd33_45e2_963f_d405f31fd911",
+            "vnc_password": "testserver"
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/9e24600b/libcloud/test/compute/test_cloudsigma_v2_0.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudsigma_v2_0.py b/libcloud/test/compute/test_cloudsigma_v2_0.py
index 358c1e7..349858e 100644
--- a/libcloud/test/compute/test_cloudsigma_v2_0.py
+++ b/libcloud/test/compute/test_cloudsigma_v2_0.py
@@ -14,6 +14,12 @@
 # limitations under the License.
 
 import sys
+
+try:
+    import simplejson as json
+except:
+    import json
+
 from libcloud.utils.py3 import httplib
 
 from libcloud.common.types import InvalidCredsError
@@ -94,6 +100,19 @@ class CloudSigmaAPI20BaseTestCase(object):
         self.assertEqual(len(node.extra['nics']), 1)
         self.assertEqual(node.extra['nics'][0]['ip_v4_conf']['conf'], 'dhcp')
 
+    def test_create_node_with_vlan(self):
+        image = self.driver.list_images()[0]
+        size = self.driver.list_sizes()[0]
+
+        vlan_uuid = '39ae851d-433f-4ac2-a803-ffa24cb1fa3e'
+
+        node = self.driver.create_node(name='test node vlan', size=size,
+                                       image=image, ex_vlan=vlan_uuid)
+        self.assertEqual(node.name, 'test node vlan')
+        self.assertEqual(len(node.extra['nics']), 2)
+        self.assertEqual(node.extra['nics'][0]['ip_v4_conf']['conf'], 'dhcp')
+        self.assertEqual(node.extra['nics'][1]['vlan']['uuid'], vlan_uuid)
+
     def test_destroy_node(self):
         status = self.driver.destroy_node(node=self.node)
         self.assertTrue(status)
@@ -436,7 +455,15 @@ class CloudSigmaMockHttp(MockHttpTestCase):
     def _api_2_0_servers(self, method, url, body, headers):
         if method == 'POST':
             # create_node
-            body = self.fixtures.load('servers_create.json')
+
+            parsed = json.loads(body)
+
+            if 'vlan' in parsed['name']:
+                self.assertEqual(len(parsed['nics']), 2)
+                body = self.fixtures.load('servers_create_with_vlan.json')
+            else:
+                body = self.fixtures.load('servers_create.json')
+
             return (httplib.CREATED, body, {}, httplib.responses[httplib.CREATED])
 
     def _api_2_0_servers_9de75ed6_fd33_45e2_963f_d405f31fd911_action_start(self, method, url, body, headers):