libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1400989 - in /libcloud/trunk/libcloud/compute: deployment.py drivers/ec2.py drivers/ibm_sce.py drivers/openstack.py drivers/rackspace.py drivers/vcloud.py
Date Mon, 22 Oct 2012 18:33:01 GMT
Author: tomaz
Date: Mon Oct 22 18:33:01 2012
New Revision: 1400989

URL: http://svn.apache.org/viewvc?rev=1400989&view=rev
Log:
Update docstrings and fix pep8 issues. Contributed by Ilgiz Islamgulov.

Modified:
    libcloud/trunk/libcloud/compute/deployment.py
    libcloud/trunk/libcloud/compute/drivers/ec2.py
    libcloud/trunk/libcloud/compute/drivers/ibm_sce.py
    libcloud/trunk/libcloud/compute/drivers/openstack.py
    libcloud/trunk/libcloud/compute/drivers/rackspace.py
    libcloud/trunk/libcloud/compute/drivers/vcloud.py

Modified: libcloud/trunk/libcloud/compute/deployment.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/deployment.py?rev=1400989&r1=1400988&r2=1400989&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/deployment.py (original)
+++ libcloud/trunk/libcloud/compute/deployment.py Mon Oct 22 18:33:01 2012
@@ -91,7 +91,7 @@ class FileDeployment(Deployment):
         @keyword source: Local path of file to be installed
 
         @type target: C{str}
-        @keyword target: Path to install file on node
+        @keyword target: Path to install file on node 
         """
         self.source = source
         self.target = target

Modified: libcloud/trunk/libcloud/compute/drivers/ec2.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/ec2.py?rev=1400989&r1=1400988&r2=1400989&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/ec2.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/ec2.py Mon Oct 22 18:33:01 2012
@@ -650,7 +650,7 @@ class EC2NodeDriver(NodeDriver):
 
         @note: This is a non-standard extension API, and only works for EC2.
 
-        @rtype: C{list}
+        @rtype: C{list} of C{str}
         """
 
         params = {
@@ -743,8 +743,8 @@ class EC2NodeDriver(NodeDriver):
         @param      from_port: The beginning of the port range to open
         @type       from_port: C{str}
 
-        @param      end_port: The end of the port range to open
-        @type       end_port: C{str}
+        @param      to_port: The end of the port range to open
+        @type       to_port: C{str}
 
         @param      cidr_ip: The ip to allow traffic for.
         @type       cidr_ip: C{str}
@@ -752,7 +752,7 @@ class EC2NodeDriver(NodeDriver):
         @param      protocol: tcp/udp/icmp
         @type       protocol: C{str}
 
-        @rtype: C{boolean}
+        @rtype: C{bool}
         """
 
         params = {'Action': 'AuthorizeSecurityGroupIngress',
@@ -762,7 +762,8 @@ class EC2NodeDriver(NodeDriver):
                   'ToPort': str(to_port),
                   'CidrIp': cidr_ip}
         try:
-            resp = self.connection.request(self.path, params=params.copy()).object
+            resp = self.connection.request(
+                self.path, params=params.copy()).object
             return bool(findtext(element=resp, xpath='return',
                                  namespace=NAMESPACE))
         except Exception:

Modified: libcloud/trunk/libcloud/compute/drivers/ibm_sce.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/ibm_sce.py?rev=1400989&r1=1400988&r2=1400989&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/ibm_sce.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/ibm_sce.py Mon Oct 22 18:33:01 2012
@@ -129,7 +129,8 @@ class VolumeOffering(object):
 class Address(object):
     """
     A reserved IP address that can be attached to an instance.
-    Properties: id, ip, state, options(location, type, created_time, state, hostname, instance_ids,
vlan, owner,
+    Properties: id, ip, state, options(location, type, created_time, state,
+     hostname, instance_ids, vlan, owner,
     mode, offering_id)
     """
     def __init__(self, id, ip, state, options):
@@ -264,6 +265,7 @@ class IBMNodeDriver(NodeDriver):
         @type       kwargs.target_location_id:  C{str}
 
         @return: The newly created L{StorageVolume}.
+        @rtype: L{StorageVolume}
         """
         data = {}
         data.update({'name': name})
@@ -273,14 +275,16 @@ class IBMNodeDriver(NodeDriver):
             data.update({'format': kwargs['format']})
         if (('offering_id' in kwargs) and (kwargs['offering_id'] is not None)):
             data.update({'offeringID': kwargs['offering_id']})
-        if (('storage_area_id' in kwargs) and (kwargs['storage_area_id'] is not None)):
+        if (('storage_area_id' in kwargs) and
+                (kwargs['storage_area_id'] is not None)):
             data.update({'storageAreaID': kwargs['storage_area_id']})
         if 'source_disk_id' in kwargs:
             data.update({'sourceDiskID': kwargs['source_disk_id']})
             data.update({'type': 'clone'})
         if 'target_location_id' in kwargs:
             data.update({'targetLocationID': kwargs['target_location_id']})
-        resp = self.connection.request(action=REST_BASE + '/storage',
+        resp = self.connection.request(
+            action=REST_BASE + '/storage',
             headers={'Content-Type': 'application/x-www-form-urlencoded'},
             method='POST',
             data=data).object
@@ -293,16 +297,18 @@ class IBMNodeDriver(NodeDriver):
         @param      name: Name of the image to be created (required)
         @type       name: C{str}
 
-        @param      description: Description of the image to be created (optional)
-        @type       description: L{str}
+        @param      description: Description of the image to be created
+        @type       description: C{str}
 
-        @keyword    kwarge.image_id:  The ID of the source image if cloning the image
-        @type       kwargs.image_id:  C{str}
+        @keyword    image_id:  The ID of the source image if cloning the image
+        @type       image_id:  C{str}
 
-        @keyword    kwargs.volume_id:  The ID of the storage volume if importing the image
-        @type       kwargs.volume_id:  C{str}
+        @keyword    volume_id:  The ID of the storage volume if
+                                importing the image
+        @type       volume_id:  C{str}
 
         @return: The newly created L{NodeImage}.
+        @rtype: L{NodeImage}
         """
         data = {}
         data.update({'name': name})
@@ -312,7 +318,8 @@ class IBMNodeDriver(NodeDriver):
             data.update({'imageId': kwargs['image_id']})
         if (('volume_id' in kwargs) and (kwargs['volume_id'] is not None)):
             data.update({'volumeId': kwargs['volume_id']})
-        resp = self.connection.request(action=REST_BASE + '/offerings/image',
+        resp = self.connection.request(
+            action=REST_BASE + '/offerings/image',
             headers={'Content-Type': 'application/x-www-form-urlencoded'},
             method='POST',
             data=data).object
@@ -331,7 +338,7 @@ class IBMNodeDriver(NodeDriver):
         @param      volume: Volume to be destroyed
         @type       volume: L{StorageVolume}
 
-        @return: C{bool}
+        @rtype: C{bool}
         """
         url = REST_BASE + '/storage/%s' % (volume.id)
         status = int(self.connection.request(action=url,
@@ -348,7 +355,7 @@ class IBMNodeDriver(NodeDriver):
         @param      volume: Volume to attach
         @type       volume: L{StorageVolume}
 
-        @return: C{bool}
+        @rtype: C{bool}
         """
         url = REST_BASE + '/instances/%s' % (node.id)
         headers = {'Content-Type': 'application/x-www-form-urlencoded'}
@@ -363,10 +370,13 @@ class IBMNodeDriver(NodeDriver):
         """
         Detaches a volume from a node.
 
+        @param      node: Node which should be used
+        @type       node: L{Node}
+
         @param      volume: Volume to be detached
         @type       volume: L{StorageVolume}
 
-        @returns C{bool}
+        @rtype: C{bool}
         """
         url = REST_BASE + '/instances/%s' % (node.id)
         headers = {'Content-Type': 'application/x-www-form-urlencoded'}
@@ -400,17 +410,17 @@ class IBMNodeDriver(NodeDriver):
         """
         List storage volumes.
 
-        @return: C{list} of L{StorageVolume} objects
+        @rtype: C{list} of L{StorageVolume}
         """
         return self._to_volumes(
             self.connection.request(REST_BASE + '/storage').object)
 
     def list_sizes(self, location=None):
         """
-        Returns a generic list of sizes.  See list_images() for a list of supported
-        sizes for specific images.  In particular, you need to have a size that
-        matches the architecture (32-bit vs 64-bit) of the virtual machine image
-        operating system.
+        Returns a generic list of sizes.  See list_images() for a list of
+        supported sizes for specific images.  In particular, you need to have
+        a size that matches the architecture (32-bit vs 64-bit) of the virtual
+        machine image operating system.
 
         @inherits: L{NodeDriver.list_sizes}
         """
@@ -435,15 +445,14 @@ class IBMNodeDriver(NodeDriver):
                      None, None, None, None, self.connection.driver)]
 
     def list_locations(self):
-        """
-        List the data center locations
-        """
         return self._to_locations(
             self.connection.request(REST_BASE + '/locations').object)
 
     def ex_list_storage_offerings(self):
         """
         List the storage center offerings
+
+        @rtype: C{list} of L{VolumeOffering}
         """
         return self._to_volume_offerings(
             self.connection.request(REST_BASE + '/offerings/storage').object)
@@ -453,12 +462,16 @@ class IBMNodeDriver(NodeDriver):
         Allocate a new reserved IP address
 
         @param      location_id: Target data center
-        @type       location_id: L{str}
+        @type       location_id: C{str}
+
         @param      offering_id: Offering ID for address to create
-        @type       offering_id: L{str}
+        @type       offering_id: C{str}
+
         @param      vlan_id: ID of target VLAN
-        @type       vlan_id: L{str}
-        @return:    L{Address} object
+        @type       vlan_id: C{str}
+
+        @return: L{Address} object
+        @rtype: L{Address}
         """
         url = REST_BASE + '/addresses'
         headers = {'Content-Type': 'application/x-www-form-urlencoded'}
@@ -475,8 +488,11 @@ class IBMNodeDriver(NodeDriver):
         """
         List the reserved IP addresses
 
-        @param      resource_id: If this is supplied only a single address will be returned
(optional)
-        @type       resource_id: L{str}
+        @param      resource_id: If this is supplied only a single address will
+         be returned (optional)
+        @type       resource_id: C{str}
+
+        @rtype: C{list} of L{Address}
         """
         url = REST_BASE + '/addresses'
         if resource_id:
@@ -494,6 +510,7 @@ class IBMNodeDriver(NodeDriver):
         @type       volume: L{StorageVolume}
 
         @return: C{bool} The success of the operation
+        @rtype: C{bool}
         """
         url = REST_BASE + '/storage/%s' % (volume.id)
         headers = {'Content-Type': 'application/x-www-form-urlencoded'}
@@ -509,7 +526,9 @@ class IBMNodeDriver(NodeDriver):
         Delete a reserved IP address
 
         @param      resource_id: The address to delete (required)
-        @type       resource_id: L{str}
+        @type       resource_id: C{str}
+
+        @rtype: C{bool}
         """
         url = REST_BASE + '/addresses/' + resource_id
         status = int(self.connection.request(action=url,
@@ -522,7 +541,7 @@ class IBMNodeDriver(NodeDriver):
         Block until storage volume state changes to the given value
 
         @param      volume: Storage volume.
-        @type       node: C{StorageVolume}
+        @type       volume: L{StorageVolume}
 
         @param      state: The target state to wait for
         @type       state: C{int}
@@ -535,7 +554,7 @@ class IBMNodeDriver(NodeDriver):
                              (default is 1200)
         @type       timeout: C{int}
 
-        @return: C{StorageVolume}
+        @rtype: L{StorageVolume}
         """
         start = time.time()
         end = start + timeout
@@ -565,16 +584,17 @@ class IBMNodeDriver(NodeDriver):
             public_ips.append(ip)
 
         return Node(
-                    id=instance.findtext('ID'),
-                    name=instance.findtext('Name'),
-                    state=self.NODE_STATE_MAP[int(instance.findtext('Status'))],
-                    public_ips=public_ips,
-                    private_ips=[],
-                    driver=self.connection.driver
+            id=instance.findtext('ID'),
+            name=instance.findtext('Name'),
+            state=self.NODE_STATE_MAP[int(instance.findtext('Status'))],
+            public_ips=public_ips,
+            private_ips=[],
+            driver=self.connection.driver
         )
 
     def _to_images(self, object):
-        # Converts data retrieved from SCE /offerings/image REST call to a NodeImage
+        # Converts data retrieved from SCE /offerings/image REST call to
+        # a NodeImage
         return [self._to_image(image) for image in object.findall('Image')]
 
     def _to_image(self, image):
@@ -663,12 +683,12 @@ class IBMNodeDriver(NodeDriver):
     def _to_volume(self, object):
         # Converts an SCE Volume to a Libcloud StorageVolume
         extra = {'state': object.findtext('State'),
-                'location': object.findtext('Location'),
-                'instanceID': object.findtext('instanceID'),
-                'owner': object.findtext('Owner'),
-                'format': object.findtext('Format'),
-                'createdTime': object.findtext('CreatedTime'),
-                'storageAreaID': object.findtext('StorageArea/ID')}
+                 'location': object.findtext('Location'),
+                 'instanceID': object.findtext('instanceID'),
+                 'owner': object.findtext('Owner'),
+                 'format': object.findtext('Format'),
+                 'createdTime': object.findtext('CreatedTime'),
+                 'storageAreaID': object.findtext('StorageArea/ID')}
         return StorageVolume(object.findtext('ID'),
                              object.findtext('Name'),
                              object.findtext('Size'),
@@ -683,9 +703,9 @@ class IBMNodeDriver(NodeDriver):
         # Converts an SCE DescribeVolumeOfferingsResponse/Offerings XML object
         # to an SCE VolumeOffering
         extra = {'label': object.findtext('Label'),
-                'supported_sizes': object.findtext('SupportedSizes'),
-                'formats': object.findall('SupportedFormats/Format/ID'),
-                'price': object.findall('Price')}
+                 'supported_sizes': object.findtext('SupportedSizes'),
+                 'formats': object.findall('SupportedFormats/Format/ID'),
+                 'price': object.findall('Price')}
         return VolumeOffering(object.findtext('ID'),
                               object.findtext('Name'),
                               object.findtext('Location'),
@@ -701,14 +721,14 @@ class IBMNodeDriver(NodeDriver):
         # Converts an SCE DescribeAddressesResponse/Address XML object to
         # an Address object
         extra = {'location': object.findtext('Location'),
-                'type': object.findtext('Label'),
-                'created_time': object.findtext('SupportedSizes'),
-                'hostname': object.findtext('Hostname'),
-                'instance_ids': object.findtext('InstanceID'),
-                'vlan': object.findtext('VLAN'),
-                'owner': object.findtext('owner'),
-                'mode': object.findtext('Mode'),
-                'offering_id': object.findtext('OfferingID')}
+                 'type': object.findtext('Label'),
+                 'created_time': object.findtext('SupportedSizes'),
+                 'hostname': object.findtext('Hostname'),
+                 'instance_ids': object.findtext('InstanceID'),
+                 'vlan': object.findtext('VLAN'),
+                 'owner': object.findtext('owner'),
+                 'mode': object.findtext('Mode'),
+                 'offering_id': object.findtext('OfferingID')}
         return Address(object.findtext('ID'),
                        object.findtext('IP'),
                        object.findtext('State'),

Modified: libcloud/trunk/libcloud/compute/drivers/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/openstack.py?rev=1400989&r1=1400988&r2=1400989&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/openstack.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/openstack.py Mon Oct 22 18:33:01 2012
@@ -953,7 +953,7 @@ class OpenStack_1_1_NodeDriver(OpenStack
         @type       ex_metadata: C{dict}
 
         @keyword    ex_files:   File Path => File contents to create on
-                                the node
+                                the no  de
         @type       ex_files:   C{dict}
 
         @keyword    ex_keyname:  Name of existing public key to inject into
@@ -966,7 +966,7 @@ class OpenStack_1_1_NodeDriver(OpenStack
         @type       ex_userdata: C{str}
 
         @keyword    networks: The server is launched into a set of Networks.
-        @type       networks: C{OpenStackNetwork}
+        @type       networks: L{OpenStackNetwork}
         """
 
         server_params = self._create_args_to_params(None, **kwargs)
@@ -1249,6 +1249,12 @@ class OpenStack_1_1_NodeDriver(OpenStack
         """
         Create a new Network
 
+        @param name: Name of network which should be used
+        @type name: C{str}
+
+        @param cidr: cidr of network which should be used
+        @type cidr: C{str}
+
         @rtype: L{OpenStackNetwork}
         """
         return self._to_network(self.connection.request(
@@ -1260,7 +1266,10 @@ class OpenStack_1_1_NodeDriver(OpenStack
         """
         Get a list of NodeNetorks that are available.
 
-        @rtype: L{bool}
+        @param network: Network which should be used
+        @type network: L{OpenStackNetwork}
+
+        @rtype: C{bool}
         """
         resp = self.connection.request('/os-networksv2/%s' % (network.id),
                                        method='DELETE')

Modified: libcloud/trunk/libcloud/compute/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/rackspace.py?rev=1400989&r1=1400988&r2=1400989&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/rackspace.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/rackspace.py Mon Oct 22 18:33:01 2012
@@ -17,9 +17,9 @@ Rackspace driver
 """
 from libcloud.compute.types import Provider, LibcloudError
 from libcloud.compute.base import NodeLocation
-from libcloud.compute.drivers.openstack import OpenStack_1_0_Connection, \
+from libcloud.compute.drivers.openstack import OpenStack_1_0_Connection,\
     OpenStack_1_0_NodeDriver, OpenStack_1_0_Response
-from libcloud.compute.drivers.openstack import OpenStack_1_1_Connection, \
+from libcloud.compute.drivers.openstack import OpenStack_1_1_Connection,\
     OpenStack_1_1_NodeDriver
 
 from libcloud.common.rackspace import (
@@ -27,15 +27,15 @@ from libcloud.common.rackspace import (
 
 
 ENDPOINT_ARGS_MAP = {
-    'dfw':  {'service_type': 'compute',
-              'name': 'cloudServersOpenStack',
-              'region': 'DFW'},
-    'ord':  {'service_type': 'compute',
-              'name': 'cloudServersOpenStack',
-              'region': 'ORD'},
-    'lon':  {'service_type': 'compute',
-             'name': 'cloudServersOpenStack',
-             'region': 'LON'}
+    'dfw': {'service_type': 'compute',
+            'name': 'cloudServersOpenStack',
+            'region': 'DFW'},
+    'ord': {'service_type': 'compute',
+            'name': 'cloudServersOpenStack',
+            'region': 'ORD'},
+    'lon': {'service_type': 'compute',
+            'name': 'cloudServersOpenStack',
+            'region': 'LON'}
 }
 
 
@@ -70,6 +70,12 @@ class RackspaceFirstGenNodeDriver(OpenSt
 
     def __init__(self, key, secret=None, secure=True, host=None, port=None,
                  region='us', **kwargs):
+        """
+        @inherits:  L{NodeDriver.__init__}
+
+        @param region: Region ID which should be used
+        @type region: C{str}
+        """
         if region not in ['us', 'uk']:
             raise ValueError('Invalid region: %s' % (region))
 
@@ -81,8 +87,10 @@ class RackspaceFirstGenNodeDriver(OpenSt
         self.region = region
 
         super(RackspaceFirstGenNodeDriver, self).__init__(key=key,
-                      secret=secret, secure=secure, host=host,
-                      port=port, **kwargs)
+                                                          secret=secret,
+                                                          secure=secure,
+                                                          host=host,
+                                                          port=port, **kwargs)
 
     def list_locations(self):
         """
@@ -136,6 +144,12 @@ class RackspaceNodeDriver(OpenStack_1_1_
 
     def __init__(self, key, secret=None, secure=True, host=None, port=None,
                  datacenter='dfw', **kwargs):
+        """
+        @inherits:  L{NodeDriver.__init__}
+
+        @param datacenter: Datacenter ID which should be used
+        @type datacenter: C{str}
+        """
 
         if datacenter not in ['dfw', 'ord', 'lon']:
             raise ValueError('Invalid datacenter: %s' % (datacenter))
@@ -149,9 +163,10 @@ class RackspaceNodeDriver(OpenStack_1_1_
 
         self.connectionCls._auth_version = '2.0'
         self.connectionCls.get_endpoint_args = \
-                ENDPOINT_ARGS_MAP[datacenter]
+            ENDPOINT_ARGS_MAP[datacenter]
 
         self.datacenter = datacenter
 
         super(RackspaceNodeDriver, self).__init__(key=key, secret=secret,
-                       secure=secure, host=host, port=port, **kwargs)
+                                                  secure=secure, host=host,
+                                                  port=port, **kwargs)

Modified: libcloud/trunk/libcloud/compute/drivers/vcloud.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/vcloud.py?rev=1400989&r1=1400988&r2=1400989&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/vcloud.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/vcloud.py Mon Oct 22 18:33:01 2012
@@ -74,7 +74,8 @@ def get_url_path(url):
 class Vdc:
     """Virtual datacenter (vDC) representation"""
 
-    def __init__(self, id, name, driver, allocation_model=None, cpu=None, memory=None, storage=None):
+    def __init__(self, id, name, driver, allocation_model=None, cpu=None,
+                 memory=None, storage=None):
         self.id = id
         self.name = name
         self.driver = driver
@@ -348,7 +349,7 @@ class VCloudNodeDriver(NodeDriver):
         vCloud virtual data centers (vDCs).
 
         @return: list of vDC objects
-        @rtype: C{list} of L{VCloudVDC}
+        @rtype: C{list} of L{Vdc}
         """
         if not self._vdcs:
             self.connection.check_org()  # make sure the org is set.  # pylint: disable-msg=E1101
@@ -514,7 +515,7 @@ class VCloudNodeDriver(NodeDriver):
                      will be queried.
         @type vdcs: L{Vdc}
 
-        @rtype: C{list} of L{Node} objects
+        @rtype: C{list} of L{Node}
         """
         if not vdcs:
             vdcs = self.vdcs
@@ -893,7 +894,7 @@ class VCloud_1_5_NodeDriver(VCloudNodeDr
         @type node_name: C{str}
 
         @param vdcs: None, vDC or a list of vDCs to search in. If None all vDCs will be searched.
-        @type node_name: L{VCloudVDC}
+        @type vdcs: L{Vdc}
 
         @return: node instance or None if not found
         @rtype: L{Node} or C{None}



Mime
View raw message