Ver código fonte

Suppressed invalid warnings for pylint and pyflakes

nuwan_ag 10 anos atrás
pai
commit
8b7c773014

+ 2 - 2
cloudbridge/cloud/__init__.py

@@ -1,2 +1,2 @@
-from .factory import CloudProviderFactory
-from .factory import ProviderList
+from .factory import CloudProviderFactory  # noqa
+from .factory import ProviderList  # noqa

+ 14 - 3
cloudbridge/cloud/base.py

@@ -212,6 +212,7 @@ class BaseInstanceType(InstanceType):
 
     def __eq__(self, other):
         return (isinstance(other, InstanceType) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id)
 
@@ -231,6 +232,7 @@ class BaseInstance(BaseObjectLifeCycleMixin, Instance):
 
     def __eq__(self, other):
         return (isinstance(other, Instance) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id and
                 # check from most to least likely mutables
@@ -331,6 +333,7 @@ class BaseMachineImage(BaseObjectLifeCycleMixin, MachineImage):
 
     def __eq__(self, other):
         return (isinstance(other, MachineImage) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id and
                 # check from most to least likely mutables
@@ -357,6 +360,7 @@ class BaseVolume(BaseObjectLifeCycleMixin, Volume):
 
     def __eq__(self, other):
         return (isinstance(other, Volume) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id and
                 # check from most to least likely mutables
@@ -382,6 +386,7 @@ class BaseSnapshot(BaseObjectLifeCycleMixin, Snapshot):
 
     def __eq__(self, other):
         return (isinstance(other, Snapshot) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id and
                 # check from most to least likely mutables
@@ -407,9 +412,10 @@ class BaseKeyPair(KeyPair):
         self._key_pair = key_pair
 
     def __eq__(self, other):
-        return isinstance(other, KeyPair) and \
-            self._provider == other._provider and \
-            self.name == other.name
+        return (isinstance(other, KeyPair) and
+                # pylint:disable=protected-access
+                self._provider == other._provider and
+                self.name == other.name)
 
     @property
     def id(self):
@@ -451,6 +457,7 @@ class BaseSecurityGroup(SecurityGroup):
         Check if all the defined rules match across both security groups.
         """
         return (isinstance(other, SecurityGroup) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 len(self.rules) == len(other.rules) and  # Shortcut
                 set(self.rules) == set(other.rules))
@@ -535,6 +542,7 @@ class BasePlacementZone(PlacementZone):
 
     def __eq__(self, other):
         return (isinstance(other, PlacementZone) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id)
 
@@ -550,6 +558,7 @@ class BaseRegion(Region):
 
     def __eq__(self, other):
         return (isinstance(other, Region) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id)
 
@@ -561,6 +570,7 @@ class BaseContainerObject(ContainerObject):
 
     def __eq__(self, other):
         return (isinstance(other, ContainerObject) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id and
                 # check from most to least likely mutables
@@ -578,6 +588,7 @@ class BaseContainer(BasePageableObjectMixin, Container):
 
     def __eq__(self, other):
         return (isinstance(other, Container) and
+                # pylint:disable=protected-access
                 self._provider == other._provider and
                 self.id == other.id and
                 # check from most to least likely mutables

+ 9 - 9
cloudbridge/cloud/interfaces/__init__.py

@@ -1,12 +1,12 @@
 """
 Public interface exports
 """
-from .impl import CloudProvider
-from .resources import CloudProviderServiceType
-from .resources import InstanceState
-from .resources import InvalidConfigurationException
-from .resources import LaunchConfig
-from .resources import MachineImageState
-from .resources import Region
-from .resources import SnapshotState
-from .resources import VolumeState
+from .impl import CloudProvider  # noqa
+from .resources import CloudProviderServiceType  # noqa
+from .resources import InstanceState  # noqa
+from .resources import InvalidConfigurationException  # noqa
+from .resources import LaunchConfig  # noqa
+from .resources import MachineImageState  # noqa
+from .resources import Region  # noqa
+from .resources import SnapshotState  # noqa
+from .resources import VolumeState  # noqa

+ 2 - 2
cloudbridge/cloud/providers/aws/__init__.py

@@ -2,5 +2,5 @@
 Exports from this provider
 """
 
-from .impl import AWSCloudProvider
-from .impl import MockAWSCloudProvider
+from .impl import AWSCloudProvider  # noqa
+from .impl import MockAWSCloudProvider  # noqa

+ 9 - 2
cloudbridge/cloud/providers/aws/resources.py

@@ -37,6 +37,7 @@ class AWSMachineImage(BaseMachineImage):
     def __init__(self, provider, image):
         super(AWSMachineImage, self).__init__(provider)
         if isinstance(image, AWSMachineImage):
+            # pylint:disable=protected-access
             self._ec2_image = image._ec2_image
         else:
             self._ec2_image = image
@@ -89,6 +90,7 @@ class AWSMachineImage(BaseMachineImage):
         """
         image = self._provider.compute.images.get(self.id)
         if image:
+            # pylint:disable=protected-access
             self._ec2_image = image._ec2_image
         else:
             # image no longer exists
@@ -100,6 +102,7 @@ class AWSPlacementZone(BasePlacementZone):
     def __init__(self, provider, zone):
         super(AWSPlacementZone, self).__init__(provider)
         if isinstance(zone, AWSPlacementZone):
+            # pylint:disable=protected-access
             self._aws_zone = zone._aws_zone
         else:
             self._aws_zone = zone
@@ -221,6 +224,7 @@ class AWSInstance(BaseInstance):
         return self._ec2_instance.tags.get('Name')
 
     @name.setter
+    # pylint:disable=arguments-differ
     def name(self, value):
         """
         Set the instance name.
@@ -378,6 +382,7 @@ class AWSVolume(BaseVolume):
         return self._volume.tags.get('Name')
 
     @name.setter
+    # pylint:disable=arguments-differ
     def name(self, value):
         """
         Set the volume name.
@@ -462,6 +467,7 @@ class AWSSnapshot(BaseSnapshot):
         return self._snapshot.tags.get('Name')
 
     @name.setter
+    # pylint:disable=arguments-differ
     def name(self, value):
         """
         Set the snapshot name.
@@ -562,6 +568,7 @@ class AWSSecurityGroup(BaseSecurityGroup):
             from_port=from_port,
             to_port=to_port,
             cidr_ip=cidr_ip,
+            # pylint:disable=protected-access
             src_group=src_group._security_group if src_group else None)
 
 
@@ -592,9 +599,9 @@ class AWSSecurityGroupRule(BaseSecurityGroupRule):
     def group(self):
         if len(self._rule.grants) > 0:
             if self._rule.grants[0].name:
-                cg = self.parent._provider.ec2_conn.get_all_security_groups(
+                cg = self._provider.ec2_conn.get_all_security_groups(
                     groupnames=[self._rule.grants[0].name])[0]
-                return AWSSecurityGroup(self.parent._provider, cg)
+                return AWSSecurityGroup(self._provider, cg)
         return None
 
 

+ 1 - 1
cloudbridge/cloud/providers/aws/services.py

@@ -254,7 +254,7 @@ class AWSVolumeService(BaseVolumeService):
             results.append(AWSVolume(self.provider, vol))
         return results
 
-    def create(self, name, size, zone, snapshot=None):
+    def create(self, name, size, zone, snapshot=None, description=None):
         """
         Creates a new volume.
         """

+ 1 - 1
cloudbridge/cloud/providers/openstack/__init__.py

@@ -2,4 +2,4 @@
 Exports from this provider
 """
 
-from .impl import OpenStackCloudProvider
+from .impl import OpenStackCloudProvider  # noqa

+ 11 - 8
cloudbridge/cloud/providers/openstack/resources.py

@@ -40,6 +40,7 @@ class OpenStackMachineImage(BaseMachineImage):
     def __init__(self, provider, os_image):
         super(OpenStackMachineImage, self).__init__(provider)
         if isinstance(os_image, OpenStackMachineImage):
+            # pylint:disable=protected-access
             self._os_image = os_image._os_image
         else:
             self._os_image = os_image
@@ -83,7 +84,7 @@ class OpenStackMachineImage(BaseMachineImage):
         """
         image = self._provider.compute.images.get(self.id)
         if image:
-            self._os_image = image._os_image
+            self._os_image = image._os_image  # pylint:disable=protected-access
         else:
             # The image no longer exists and cannot be refreshed.
             # set the status to unknown
@@ -95,7 +96,7 @@ class OpenStackPlacementZone(BasePlacementZone):
     def __init__(self, provider, zone):
         super(OpenStackPlacementZone, self).__init__(provider)
         if isinstance(zone, OpenStackPlacementZone):
-            self._os_zone = zone._os_zone
+            self._os_zone = zone._os_zone  # pylint:disable=protected-access
         else:
             self._os_zone = zone
 
@@ -226,6 +227,7 @@ class OpenStackInstance(BaseInstance):
         return self._os_instance.name
 
     @name.setter
+    # pylint:disable=arguments-differ
     def name(self, value):
         """
         Set the instance name.
@@ -352,6 +354,7 @@ class OpenStackInstance(BaseInstance):
         instance = self._provider.compute.instances.get(
             self.id)
         if instance:
+            # pylint:disable=protected-access
             self._os_instance = instance._os_instance
         else:
             # The instance no longer exists and cannot be refreshed.
@@ -413,7 +416,7 @@ class OpenStackVolume(BaseVolume):
         return self._volume.name
 
     @name.setter
-    def name(self, value):
+    def name(self, value):  # pylint:disable=arguments-differ
         """
         Set the volume name.
         """
@@ -461,7 +464,7 @@ class OpenStackVolume(BaseVolume):
         vol = self._provider.block_store.volumes.get(
             self.id)
         if vol:
-            self._volume = vol._volume
+            self._volume = vol._volume  # pylint:disable=protected-access
         else:
             # The volume no longer exists and cannot be refreshed.
             # set the status to unknown
@@ -495,7 +498,7 @@ class OpenStackSnapshot(BaseSnapshot):
         return self._snapshot.name
 
     @name.setter
-    def name(self, value):
+    def name(self, value):  # pylint:disable=arguments-differ
         """
         Set the snapshot name.
         """
@@ -515,7 +518,7 @@ class OpenStackSnapshot(BaseSnapshot):
         snap = self._provider.block_store.snapshots.get(
             self.id)
         if snap:
-            self._snapshot = snap._snapshot
+            self._snapshot = snap._snapshot  # pylint:disable=protected-access
         else:
             # The snapshot no longer exists and cannot be refreshed.
             # set the status to unknown
@@ -642,10 +645,10 @@ class OpenStackSecurityGroupRule(BaseSecurityGroupRule):
     def group(self):
         cg = self._rule.get('group', {}).get('name')
         if cg:
-            security_groups = self.parent._provider.nova.security_groups.list()
+            security_groups = self._provider.nova.security_groups.list()
             for sg in security_groups:
                 if sg.name == cg:
-                    return OpenStackSecurityGroup(self.parent._provider, sg)
+                    return OpenStackSecurityGroup(self._provider, sg)
         return None
 
 

+ 7 - 3
cloudbridge/cloud/providers/openstack/services.py

@@ -81,6 +81,7 @@ class OpenStackKeyPairService(BaseKeyPairService):
         :return:  list of KeyPair objects
         """
 
+        # pylint:disable=unused-argument
         def _list_key_pairs(nlimit):
             keypairs = self.provider.nova.keypairs.list()
             if marker:
@@ -135,6 +136,7 @@ class OpenStackSecurityGroupService(BaseSecurityGroupService):
         :return:  list of SecurityGroup objects
         """
 
+        # pylint:disable=unused-argument
         def _list_security_groups(nlimit):
             sgs = self.provider.nova.security_groups.list()
             if marker:
@@ -325,7 +327,7 @@ class OpenStackVolumeService(BaseVolumeService):
                     limit=nlimit,
                     marker=marker)])
 
-    def create(self, name, size, zone, snapshot=None):
+    def create(self, name, size, zone, snapshot=None, description=None):
         """
         Creates a new volume.
         """
@@ -334,8 +336,8 @@ class OpenStackVolumeService(BaseVolumeService):
             zone, OpenStackSnapshot) and snapshot else snapshot
 
         os_vol = self.provider.cinder.volumes.create(
-            size, name=name, availability_zone=zone_id,
-            snapshot_id=snapshot_id)
+            size, name=name, description=description,
+            availability_zone=zone_id, snapshot_id=snapshot_id)
         return OpenStackVolume(self.provider, os_vol)
 
 
@@ -417,6 +419,7 @@ class OpenStackObjectStoreService(BaseObjectStoreService):
         """
         List all containers.
         """
+        # pylint:disable=unused-argument
         def _list_containers(nlimit):
             _, container_list = self.provider.swift.get_account(
                 limit=nlimit, marker=marker)
@@ -447,6 +450,7 @@ class OpenStackRegionService(BaseRegionService):
 
     def list(self, limit=None, marker=None):
 
+        # pylint:disable=unused-argument
         def _list_regions(nlimit):
             regions = (
                 endpoint.get('region') or endpoint.get('region_id')