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 2015/03/28 16:31:47 UTC

[1/2] libcloud git commit: Improvements to HostVirtual driver

Repository: libcloud
Updated Branches:
  refs/heads/trunk 928b64f06 -> c218088ab


Improvements to HostVirtual driver

* methods to handle 'Packages' concept [basically, it is a reserved compute
  instance with pre-allocated resources (RAM,Disk,IPs etc) in any specified
  location]
* changed create_node to use the extra packages method
* fix website url in docs
* fix method ordering
* fix kwargs abuse in create_node
* fix docstrings
* add test cases for extra methods
* fix the fixtures
* fix default location

Closes #472

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/84a3457f
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/84a3457f
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/84a3457f

Branch: refs/heads/trunk
Commit: 84a3457f6c0dfa2373e18d9b9cd92bbf87b9e164
Parents: 928b64f
Author: Dinesh Bhoopathy <db...@vr.org>
Authored: Mon Mar 2 15:25:21 2015 -0800
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sat Mar 28 16:24:13 2015 +0100

----------------------------------------------------------------------
 CHANGES.rst                                     |   5 +
 .../_supported_methods_block_storage.rst        |   2 +-
 .../_supported_methods_image_management.rst     |   2 +-
 .../_supported_methods_key_pair_management.rst  |   2 +-
 docs/compute/_supported_methods_main.rst        |   2 +-
 docs/compute/_supported_providers.rst           |   2 +-
 docs/dns/_supported_methods.rst                 |   2 +-
 docs/dns/_supported_providers.rst               |   2 +-
 libcloud/compute/drivers/hostvirtual.py         | 245 +++++++++++++------
 libcloud/dns/drivers/hostvirtual.py             |   2 +-
 .../fixtures/hostvirtual/cancel_package.json    |   3 +
 .../fixtures/hostvirtual/create_node.json       |   3 -
 .../fixtures/hostvirtual/list_packages.json     |  61 +++++
 .../fixtures/hostvirtual/node_destroy.json      |   3 -
 .../fixtures/hostvirtual/order_package.json     |   3 +
 .../fixtures/hostvirtual/unlink_package.json    |   3 +
 libcloud/test/compute/test_hostvirtual.py       |  44 +++-
 17 files changed, 295 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 32a2c6b..a4185bf 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -124,6 +124,11 @@ Compute
   (LIBCLOUD-676, GITHUB-482)
   [John Kinsella]
 
+- Various improvements in the HostVirual driver (code refactoring, support for
+  managing "packages").
+  (LIBCLOUD-670, GITHUB-472)
+  [Dinesh Bhoopathy]
+
 DNS
 ~~~
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/docs/compute/_supported_methods_block_storage.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_methods_block_storage.rst b/docs/compute/_supported_methods_block_storage.rst
index 56ba834..96b0f78 100644
--- a/docs/compute/_supported_methods_block_storage.rst
+++ b/docs/compute/_supported_methods_block_storage.rst
@@ -102,7 +102,7 @@ Provider                              list volumes create volume destroy volume
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: http://www.vr.org
+.. _`HostVirtual`: https://www.hostvirtual.com/
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/docs/compute/_supported_methods_image_management.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_methods_image_management.rst b/docs/compute/_supported_methods_image_management.rst
index 75fd6ac..611197c 100644
--- a/docs/compute/_supported_methods_image_management.rst
+++ b/docs/compute/_supported_methods_image_management.rst
@@ -102,7 +102,7 @@ Provider                              list images get image create image delete
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: http://www.vr.org
+.. _`HostVirtual`: https://www.hostvirtual.com/
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/docs/compute/_supported_methods_key_pair_management.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_methods_key_pair_management.rst b/docs/compute/_supported_methods_key_pair_management.rst
index 1475075..efcbb73 100644
--- a/docs/compute/_supported_methods_key_pair_management.rst
+++ b/docs/compute/_supported_methods_key_pair_management.rst
@@ -102,7 +102,7 @@ Provider                              list key pairs get key pair create key pai
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: http://www.vr.org
+.. _`HostVirtual`: https://www.hostvirtual.com/
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/docs/compute/_supported_methods_main.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_methods_main.rst b/docs/compute/_supported_methods_main.rst
index a4b7f93..d384436 100644
--- a/docs/compute/_supported_methods_main.rst
+++ b/docs/compute/_supported_methods_main.rst
@@ -102,7 +102,7 @@ Provider                              list nodes create node reboot node destroy
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: http://www.vr.org
+.. _`HostVirtual`: https://www.hostvirtual.com
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/docs/compute/_supported_providers.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_providers.rst b/docs/compute/_supported_providers.rst
index b5de045..0b39d4b 100644
--- a/docs/compute/_supported_providers.rst
+++ b/docs/compute/_supported_providers.rst
@@ -102,7 +102,7 @@ Provider                              Documentation
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: http://www.vr.org
+.. _`HostVirtual`: https://www.hostvirtual.com
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/docs/dns/_supported_methods.rst
----------------------------------------------------------------------
diff --git a/docs/dns/_supported_methods.rst b/docs/dns/_supported_methods.rst
index 33be25c..507999a 100644
--- a/docs/dns/_supported_methods.rst
+++ b/docs/dns/_supported_methods.rst
@@ -15,7 +15,7 @@ Provider              list zones list records create zone update zone create rec
 
 .. _`Gandi DNS`: http://www.gandi.net/domain
 .. _`Google DNS`: https://cloud.google.com/
-.. _`Host Virtual DNS`: http://www.vr.org/
+.. _`Host Virtual DNS`: https://www.hostvirtual.com/
 .. _`Linode DNS`: http://www.linode.com/
 .. _`Rackspace DNS`: http://www.rackspace.com/
 .. _`Rackspace DNS (UK)`: http://www.rackspace.com/

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/docs/dns/_supported_providers.rst
----------------------------------------------------------------------
diff --git a/docs/dns/_supported_providers.rst b/docs/dns/_supported_providers.rst
index 1330a54..0665a33 100644
--- a/docs/dns/_supported_providers.rst
+++ b/docs/dns/_supported_providers.rst
@@ -15,7 +15,7 @@ Provider              Documentation                           Provider constant
 
 .. _`Gandi DNS`: http://www.gandi.net/domain
 .. _`Google DNS`: https://cloud.google.com/
-.. _`Host Virtual DNS`: http://www.vr.org/
+.. _`Host Virtual DNS`: https://www.hostvirtual.com/
 .. _`Linode DNS`: http://www.linode.com/
 .. _`Rackspace DNS`: http://www.rackspace.com/
 .. _`Rackspace DNS (UK)`: http://www.rackspace.com/

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/libcloud/compute/drivers/hostvirtual.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/hostvirtual.py b/libcloud/compute/drivers/hostvirtual.py
index e9fa6c8..116a211 100644
--- a/libcloud/compute/drivers/hostvirtual.py
+++ b/libcloud/compute/drivers/hostvirtual.py
@@ -14,10 +14,11 @@
 
 """
 libcloud driver for the Host Virtual Inc. (VR) API
-Home page http://www.vr.org/
+Home page https://www.hostvirtual.com/
 """
 
 import time
+import re
 
 try:
     import simplejson as json
@@ -46,7 +47,7 @@ NODE_STATE_MAP = {
     'STOPPED': NodeState.STOPPED
 }
 
-DEFAULT_NODE_LOCATION_ID = 4
+DEFAULT_NODE_LOCATION_ID = 21
 
 
 class HostVirtualComputeResponse(HostVirtualResponse):
@@ -60,7 +61,7 @@ class HostVirtualComputeConnection(HostVirtualConnection):
 class HostVirtualNodeDriver(NodeDriver):
     type = Provider.HOSTVIRTUAL
     name = 'HostVirtual'
-    website = 'http://www.vr.org'
+    website = 'http://www.hostvirtual.com'
     connectionCls = HostVirtualComputeConnection
     features = {'create_node': ['ssh_key', 'password']}
 
@@ -69,25 +70,17 @@ class HostVirtualNodeDriver(NodeDriver):
         super(HostVirtualNodeDriver, self).__init__(key=key, secure=secure,
                                                     host=host, port=port)
 
-    def _to_node(self, data):
-        state = NODE_STATE_MAP[data['status']]
-        public_ips = []
-        private_ips = []
-        extra = {}
-
-        if 'plan_id' in data:
-            extra['size'] = data['plan_id']
-        if 'os_id' in data:
-            extra['image'] = data['os_id']
-        if 'location_id' in data:
-            extra['location'] = data['location_id']
-        if 'ip' in data:
-            public_ips.append(data['ip'])
-
-        node = Node(id=data['mbpkgid'], name=data['fqdn'], state=state,
-                    public_ips=public_ips, private_ips=private_ips,
-                    driver=self.connection.driver, extra=extra)
-        return node
+    def list_nodes(self):
+        try:
+            result = self.connection.request(
+                API_ROOT + '/cloud/servers/').object
+        except HostVirtualException:
+            return []
+        nodes = []
+        for value in result:
+            node = self._to_node(value)
+            nodes.append(node)
+        return nodes
 
     def list_locations(self):
         result = self.connection.request(API_ROOT + '/cloud/locations/').object
@@ -102,11 +95,11 @@ class HostVirtualNodeDriver(NodeDriver):
 
     def list_sizes(self, location=None):
         params = {}
-        if location:
+        if location is not None:
             params = {'location': location.id}
         result = self.connection.request(
             API_ROOT + '/cloud/sizes/',
-            data=json.dumps(params)).object
+            params=params).object
         sizes = []
         for size in result:
             n = NodeSize(id=size['plan_id'],
@@ -132,59 +125,44 @@ class HostVirtualNodeDriver(NodeDriver):
             images.append(i)
         return images
 
-    def list_nodes(self):
-        result = self.connection.request(API_ROOT + '/cloud/servers/').object
-        nodes = []
-        for value in result:
-            node = self._to_node(value)
-            nodes.append(node)
-        return nodes
-
-    def _wait_for_node(self, node_id, timeout=30, interval=5.0):
+    def create_node(self, name, image, size, **kwargs):
+        """Creates a node
+        Example of node creation with ssh key deployed
+        >>> from libcloud.compute.base import NodeAuthSSHKey
+        >>> key = open('/home/user/.ssh/id_rsa.pub').read()
+        >>> auth = NodeAuthSSHKey(pubkey=key)
+        >>> from libcloud.compute.providers import get_driver;
+        >>> driver = get_driver('hostvirtual')
+        >>> conn = driver('API_KEY')
+        >>> image = conn.list_images()[1]
+        >>> size = conn.list_sizes()[0]
+        >>> location = conn.list_locations()[1]
+        >>> name = 'markos-dev'
+        >>> node = conn.create_node(name, image, size, auth=auth,
+                                    location=location)
         """
-        :param node_id: ID of the node to wait for.
-        :type node_id: ``int``
 
-        :param timeout: Timeout (in seconds).
-        :type timeout: ``int``
-
-        :param interval: How long to wait (in seconds) between each attempt.
-        :type interval: ``float``
-        """
-        # poll until we get a node
-        for i in range(0, timeout, int(interval)):
-            try:
-                node = self.ex_get_node(node_id)
-                return node
-            except HostVirtualException:
-                time.sleep(interval)
-
-        raise HostVirtualException(412, 'Timedout on getting node details')
-
-    def create_node(self, **kwargs):
         dc = None
 
-        size = kwargs['size']
-        image = kwargs['image']
-
         auth = self._get_and_check_auth(kwargs.get('auth'))
 
-        params = {'plan': size.name}
+        if not self._is_valid_fqdn(name):
+            raise HostVirtualException(
+                500, "Name should be a valid FQDN (e.g, hostname.example.com)")
+
+        # simply order a package first
+        pkg = self.ex_order_package(size)
 
-        dc = DEFAULT_NODE_LOCATION_ID
         if 'location' in kwargs:
             dc = kwargs['location'].id
-
-        # simply order a package first
-        result = self.connection.request(API_ROOT + '/cloud/buy/',
-                                         data=json.dumps(params),
-                                         method='POST').object
+        else:
+            dc = DEFAULT_NODE_LOCATION_ID
 
         # create a stub node
         stub_node = self._to_node({
-            'mbpkgid': result['id'],
+            'mbpkgid': pkg['id'],
             'status': 'PENDING',
-            'fqdn': kwargs['name'],
+            'fqdn': name,
             'plan_id': size.id,
             'os_id': image.id,
             'location_id': dc
@@ -193,7 +171,6 @@ class HostVirtualNodeDriver(NodeDriver):
         # provisioning a server using the stub node
         self.ex_provision_node(node=stub_node, auth=auth)
         node = self._wait_for_node(stub_node.id)
-
         if getattr(auth, 'generated', False):
             node.extra['password'] = auth.password
 
@@ -220,6 +197,73 @@ class HostVirtualNodeDriver(NodeDriver):
 
         return bool(result)
 
+    def ex_list_packages(self):
+        """
+        List the server packages.
+
+        """
+
+        try:
+            result = self.connection.request(
+                API_ROOT + '/cloud/packages/').object
+        except HostVirtualException:
+            return []
+        pkgs = []
+        for value in result:
+            pkgs.append(value)
+        return pkgs
+
+    def ex_order_package(self, size):
+        """
+        Order a server package.
+
+        :param      size:
+        :type       node: :class:`NodeSize`
+
+        :rtype: ``str``
+        """
+
+        params = {'plan': size.name}
+        pkg = self.connection.request(API_ROOT + '/cloud/buy/',
+                                      data=json.dumps(params),
+                                      method='POST').object
+
+        return pkg
+
+    def ex_cancel_package(self, node):
+        """
+        Cancel a server package.
+
+        :param      node: Node which should be used
+        :type       node: :class:`Node`
+
+        :rtype: ``str``
+        """
+
+        params = {'mbpkgid': node.id}
+        result = self.connection.request(API_ROOT + '/cloud/cancel/',
+                                         data=json.dumps(params),
+                                         method='POST').object
+
+        return result
+
+    def ex_unlink_package(self, node):
+        """
+        Unlink a server package from location.
+
+        :param      node: Node which should be used
+        :type       node: :class:`Node`
+
+        :rtype: ``str``
+        """
+
+        params = {'mbpkgid': node.id}
+        result = self.connection.request(API_ROOT + '/cloud/unlink/',
+                                         data=json.dumps(params),
+                                         method='POST').object
+
+        return result
+
     def ex_get_node(self, node_id):
         """
         Get a single node.
@@ -316,12 +360,16 @@ class HostVirtualNodeDriver(NodeDriver):
             params['password'] = password
 
         if not ssh_key and not password:
-            raise HostVirtualException(500, "Need SSH key or Root password")
+            raise HostVirtualException(
+                500, "SSH key or Root password is required")
 
-        result = self.connection.request(API_ROOT + '/cloud/server/build',
-                                         data=json.dumps(params),
-                                         method='POST').object
-        return bool(result)
+        try:
+            result = self.connection.request(API_ROOT + '/cloud/server/build',
+                                             data=json.dumps(params),
+                                             method='POST').object
+            return bool(result)
+        except HostVirtualException:
+            self.ex_cancel_package(node)
 
     def ex_delete_node(self, node):
         """
@@ -339,3 +387,60 @@ class HostVirtualNodeDriver(NodeDriver):
             method='POST').object
 
         return bool(result)
+
+    def _to_node(self, data):
+        state = NODE_STATE_MAP[data['status']]
+        public_ips = []
+        private_ips = []
+        extra = {}
+
+        if 'plan_id' in data:
+            extra['size'] = data['plan_id']
+        if 'os_id' in data:
+            extra['image'] = data['os_id']
+        if 'fqdn' in data:
+            extra['fqdn'] = data['fqdn']
+        if 'location_id' in data:
+            extra['location'] = data['location_id']
+        if 'ip' in data:
+            public_ips.append(data['ip'])
+
+        node = Node(id=data['mbpkgid'], name=data['fqdn'], state=state,
+                    public_ips=public_ips, private_ips=private_ips,
+                    driver=self.connection.driver, extra=extra)
+        return node
+
+    def _wait_for_node(self, node_id, timeout=30, interval=5.0):
+        """
+        :param node_id: ID of the node to wait for.
+        :type node_id: ``int``
+
+        :param timeout: Timeout (in seconds).
+        :type timeout: ``int``
+
+        :param interval: How long to wait (in seconds) between each attempt.
+        :type interval: ``float``
+
+        :return: Node representing the newly built server
+        :rtype: :class:`Node`
+        """
+        # poll until we get a node
+        for i in range(0, timeout, int(interval)):
+            try:
+                node = self.ex_get_node(node_id)
+                return node
+            except HostVirtualException:
+                time.sleep(interval)
+
+        raise HostVirtualException(412, 'Timeout on getting node details')
+
+    def _is_valid_fqdn(self, fqdn):
+        if len(fqdn) > 255:
+            return False
+        if fqdn[-1] == ".":
+            fqdn = fqdn[:-1]
+        valid = re.compile("(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
+        if len(fqdn.split(".")) > 1:
+            return all(valid.match(x) for x in fqdn.split("."))
+        else:
+            return False

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/libcloud/dns/drivers/hostvirtual.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/hostvirtual.py b/libcloud/dns/drivers/hostvirtual.py
index 71973c9..1775f06 100644
--- a/libcloud/dns/drivers/hostvirtual.py
+++ b/libcloud/dns/drivers/hostvirtual.py
@@ -61,7 +61,7 @@ class HostVirtualDNSConnection(HostVirtualConnection):
 class HostVirtualDNSDriver(DNSDriver):
     type = Provider.HOSTVIRTUAL
     name = 'Host Virtual DNS'
-    website = 'http://www.vr.org/'
+    website = 'https://www.hostvirtual.com/'
     connectionCls = HostVirtualDNSConnection
 
     RECORD_TYPE_MAP = {

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/libcloud/test/compute/fixtures/hostvirtual/cancel_package.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/hostvirtual/cancel_package.json b/libcloud/test/compute/fixtures/hostvirtual/cancel_package.json
new file mode 100644
index 0000000..9daa87d
--- /dev/null
+++ b/libcloud/test/compute/fixtures/hostvirtual/cancel_package.json
@@ -0,0 +1,3 @@
+{
+	"status" : "success"
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/libcloud/test/compute/fixtures/hostvirtual/create_node.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/hostvirtual/create_node.json b/libcloud/test/compute/fixtures/hostvirtual/create_node.json
deleted file mode 100644
index b9b3a09..0000000
--- a/libcloud/test/compute/fixtures/hostvirtual/create_node.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-  "id": "62291"
-}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/libcloud/test/compute/fixtures/hostvirtual/list_packages.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/hostvirtual/list_packages.json b/libcloud/test/compute/fixtures/hostvirtual/list_packages.json
new file mode 100644
index 0000000..d66aa1c
--- /dev/null
+++ b/libcloud/test/compute/fixtures/hostvirtual/list_packages.json
@@ -0,0 +1,61 @@
+[{
+	"mbpkgid": "4344",
+	"package_status": "Active",
+	"domU_package": "182",
+	"name": "VR1G",
+	"rescue": "0",
+	"locked": "0",
+	"state": "UP",
+	"installed": "1",
+	"locked_reason": null,
+	"package": "VR1G",
+	"ipv6": "2637:f740:b::33b",
+	"city": "IAD - Reston, VA",
+	"fqdn": "apibuild.vr.org",
+	"uptime": "19 hours",
+	"ip": "199.38.183.116",
+	"domu_dom0": "1019",
+	"os": "  Debian 7.6 x64",
+	"is_building": false
+},
+{
+	"mbpkgid": "176018",
+	"package_status": "Active",
+	"domU_package": "182",
+	"name": "VR1G",
+	"rescue": "0",
+	"locked": "0",
+	"state": "UP",
+	"installed": "1",
+	"locked_reason": null,
+	"package": "VR1G",
+	"ipv6": "2607:f740:c::b4d",
+	"city": "LAX - Los Angeles, CA",
+	"fqdn": "db.vr.org",
+	"uptime": "566 days, 15 hours",
+	"ip": "208.111.40.64",
+	"domu_dom0": "532",
+	"os": "  Debian 7.6 x64",
+	"is_building": false
+},
+{
+	"mbpkgid": "151472",
+	"package_status": "Suspended",
+	"domU_package": null,
+	"name": "VR1G",
+	"rescue": null,
+	"locked": null,
+	"state": null,
+	"installed": null,
+	"locked_reason": null,
+	"package": null,
+	"ipv6": "",
+	"city": null,
+	"fqdn": null,
+	"uptime": false,
+	"ip": null,
+	"domu_dom0": null,
+	"os": null,
+	"is_building": false
+
+}]

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/libcloud/test/compute/fixtures/hostvirtual/node_destroy.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/hostvirtual/node_destroy.json b/libcloud/test/compute/fixtures/hostvirtual/node_destroy.json
deleted file mode 100644
index 9daa87d..0000000
--- a/libcloud/test/compute/fixtures/hostvirtual/node_destroy.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-	"status" : "success"
-}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/libcloud/test/compute/fixtures/hostvirtual/order_package.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/hostvirtual/order_package.json b/libcloud/test/compute/fixtures/hostvirtual/order_package.json
new file mode 100644
index 0000000..b9b3a09
--- /dev/null
+++ b/libcloud/test/compute/fixtures/hostvirtual/order_package.json
@@ -0,0 +1,3 @@
+{
+  "id": "62291"
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/libcloud/test/compute/fixtures/hostvirtual/unlink_package.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/hostvirtual/unlink_package.json b/libcloud/test/compute/fixtures/hostvirtual/unlink_package.json
new file mode 100644
index 0000000..9daa87d
--- /dev/null
+++ b/libcloud/test/compute/fixtures/hostvirtual/unlink_package.json
@@ -0,0 +1,3 @@
+{
+	"status" : "success"
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/84a3457f/libcloud/test/compute/test_hostvirtual.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_hostvirtual.py b/libcloud/test/compute/test_hostvirtual.py
index 7098a63..42cedc9 100644
--- a/libcloud/test/compute/test_hostvirtual.py
+++ b/libcloud/test/compute/test_hostvirtual.py
@@ -78,6 +78,27 @@ class HostVirtualTest(unittest.TestCase):
         self.assertEqual(node.state, NodeState.TERMINATED)
         self.assertTrue('208.111.45.250' in node.public_ips)
 
+    def test_ex_list_packages(self):
+        pkgs = self.driver.ex_list_packages()
+        self.assertEqual(len(pkgs), 3)
+        self.assertEqual(pkgs[1]['mbpkgid'], '176018')
+        self.assertEqual(pkgs[2]['package_status'], 'Suspended')
+
+    def test_ex_order_package(self):
+        sizes = self.driver.list_sizes()
+        pkg = self.driver.ex_order_package(sizes[0])
+        self.assertEqual(pkg['id'], '62291')
+
+    def test_ex_cancel_package(self):
+        node = self.driver.list_nodes()[0]
+        result = self.driver.ex_cancel_package(node)
+        self.assertEqual(result['status'], 'success')
+
+    def test_ex_unlink_package(self):
+        node = self.driver.list_nodes()[0]
+        result = self.driver.ex_unlink_package(node)
+        self.assertEqual(result['status'], 'success')
+
     def test_ex_stop_node(self):
         node = self.driver.list_nodes()[0]
         self.assertTrue(self.driver.ex_stop_node(node))
@@ -142,6 +163,10 @@ class HostVirtualMockHttp(MockHttp):
         body = self.fixtures.load('get_node.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _cloud_packages(self, method, url, body, headers):
+        body = self.fixtures.load('list_packages.json')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
     def _cloud_sizes(self, method, url, body, headers):
         body = self.fixtures.load('list_sizes.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
@@ -154,8 +179,8 @@ class HostVirtualMockHttp(MockHttp):
         body = self.fixtures.load('list_locations.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
-    def _cloud_cancel(self, method, url, body, headers):
-        body = self.fixtures.load('node_destroy.json')
+    def _cloud_server_delete(self, method, url, body, headers):
+        body = self.fixtures.load('cancel_package.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _cloud_server_reboot(self, method, url, body, headers):
@@ -170,18 +195,23 @@ class HostVirtualMockHttp(MockHttp):
         body = self.fixtures.load('node_start.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _cloud_server_build(self, method, url, body, headers):
+        body = self.fixtures.load('order_package.json')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
     def _cloud_buy(self, method, url, body, headers):
-        body = self.fixtures.load('create_node.json')
+        body = self.fixtures.load('order_package.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
-    def _cloud_server_build(self, method, url, body, headers):
-        body = self.fixtures.load('create_node.json')
+    def _cloud_cancel(self, method, url, body, headers):
+        body = self.fixtures.load('cancel_package.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
-    def _cloud_server_delete(self, method, url, body, headers):
-        body = self.fixtures.load('node_destroy.json')
+    def _cloud_unlink(self, method, url, body, headers):
+        body = self.fixtures.load('unlink_package.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+
 if __name__ == '__main__':
     sys.exit(unittest.main())
 


[2/2] libcloud git commit: Re-generate supported providers and methods tables.

Posted by to...@apache.org.
Re-generate supported providers and methods tables.


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

Branch: refs/heads/trunk
Commit: c218088ab0a70338710991d0b225e2d85654aa5d
Parents: 84a3457
Author: Tomaz Muraus <to...@apache.org>
Authored: Sat Mar 28 16:24:52 2015 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sat Mar 28 16:24:52 2015 +0100

----------------------------------------------------------------------
 docs/compute/_supported_methods_block_storage.rst       | 2 +-
 docs/compute/_supported_methods_image_management.rst    | 2 +-
 docs/compute/_supported_methods_key_pair_management.rst | 2 +-
 docs/compute/_supported_methods_main.rst                | 2 +-
 docs/compute/_supported_providers.rst                   | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/c218088a/docs/compute/_supported_methods_block_storage.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_methods_block_storage.rst b/docs/compute/_supported_methods_block_storage.rst
index 96b0f78..e4eb87b 100644
--- a/docs/compute/_supported_methods_block_storage.rst
+++ b/docs/compute/_supported_methods_block_storage.rst
@@ -102,7 +102,7 @@ Provider                              list volumes create volume destroy volume
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: https://www.hostvirtual.com/
+.. _`HostVirtual`: http://www.hostvirtual.com
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack

http://git-wip-us.apache.org/repos/asf/libcloud/blob/c218088a/docs/compute/_supported_methods_image_management.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_methods_image_management.rst b/docs/compute/_supported_methods_image_management.rst
index 611197c..92f07c7 100644
--- a/docs/compute/_supported_methods_image_management.rst
+++ b/docs/compute/_supported_methods_image_management.rst
@@ -102,7 +102,7 @@ Provider                              list images get image create image delete
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: https://www.hostvirtual.com/
+.. _`HostVirtual`: http://www.hostvirtual.com
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack

http://git-wip-us.apache.org/repos/asf/libcloud/blob/c218088a/docs/compute/_supported_methods_key_pair_management.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_methods_key_pair_management.rst b/docs/compute/_supported_methods_key_pair_management.rst
index efcbb73..c3310c7 100644
--- a/docs/compute/_supported_methods_key_pair_management.rst
+++ b/docs/compute/_supported_methods_key_pair_management.rst
@@ -102,7 +102,7 @@ Provider                              list key pairs get key pair create key pai
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: https://www.hostvirtual.com/
+.. _`HostVirtual`: http://www.hostvirtual.com
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack

http://git-wip-us.apache.org/repos/asf/libcloud/blob/c218088a/docs/compute/_supported_methods_main.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_methods_main.rst b/docs/compute/_supported_methods_main.rst
index d384436..82f172e 100644
--- a/docs/compute/_supported_methods_main.rst
+++ b/docs/compute/_supported_methods_main.rst
@@ -102,7 +102,7 @@ Provider                              list nodes create node reboot node destroy
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: https://www.hostvirtual.com
+.. _`HostVirtual`: http://www.hostvirtual.com
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack

http://git-wip-us.apache.org/repos/asf/libcloud/blob/c218088a/docs/compute/_supported_providers.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_providers.rst b/docs/compute/_supported_providers.rst
index 0b39d4b..cf7385f 100644
--- a/docs/compute/_supported_providers.rst
+++ b/docs/compute/_supported_providers.rst
@@ -102,7 +102,7 @@ Provider                              Documentation
 .. _`Gandi`: http://www.gandi.net/
 .. _`Google Compute Engine`: https://cloud.google.com/
 .. _`GoGrid`: http://www.gogrid.com/
-.. _`HostVirtual`: https://www.hostvirtual.com
+.. _`HostVirtual`: http://www.hostvirtual.com
 .. _`HP Public Cloud (Helion)`: http://www.hpcloud.com/
 .. _`IBM SmartCloud Enterprise`: http://ibm.com/services/us/en/cloud-enterprise/
 .. _`Ikoula`: http://express.ikoula.co.uk/cloudstack