瀏覽代碼

Tagging all protected access

almahmoud 7 年之前
父節點
當前提交
8f00d94caf

+ 4 - 0
cloudbridge/cloud/interfaces/services.py

@@ -988,6 +988,7 @@ class BucketObjectService(CloudService):
         .. code-block:: python
 
             bucket = provider.storage.buckets.get('my_bucket_id')
+            # pylint:disable=protected-access
             buck_obj = provider.storage._bucket_objects.get('my_object_id',
                                                            bucket)
             print(buck_obj.id, buck_obj.name)
@@ -1009,6 +1010,7 @@ class BucketObjectService(CloudService):
         .. code-block:: python
 
             bucket = provider.storage.buckets.get('my_bucket_id')
+            # pylint:disable=protected-access
             objs = provider.storage._bucket_objects.find(bucket,
                                                         name='my_obj_name')
             for buck_obj in objs:
@@ -1029,6 +1031,7 @@ class BucketObjectService(CloudService):
         .. code-block:: python
 
             bucket = provider.storage.buckets.get('my_bucket_id')
+            # pylint:disable=protected-access
             objs = provider.storage._bucket_objects.list(bucket)
             for buck_obj in objs:
                 print(buck_obj.id, buck_obj.name)
@@ -1048,6 +1051,7 @@ class BucketObjectService(CloudService):
         .. code-block:: python
 
             bucket = provider.storage.buckets.get('my_bucket_id')
+            # pylint:disable=protected-access
             buck_obj = provider.storage._bucket_objects.create('my_name',
                                                               bucket)
             print(buck_obj.name)

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

@@ -140,6 +140,7 @@ class AWSPlacementZone(BasePlacementZone):
         if isinstance(zone, AWSPlacementZone):
             # pylint:disable=protected-access
             self._aws_zone = zone._aws_zone
+            # pylint:disable=protected-access
             self._aws_region = zone._aws_region
         else:
             self._aws_zone = zone
@@ -328,11 +329,11 @@ class AWSInstance(BaseInstance):
     def add_floating_ip(self, floating_ip):
         fip = (floating_ip if isinstance(floating_ip, AWSFloatingIP)
                else self._get_fip(floating_ip))
+        # pylint:disable=protected-access
         params = trim_empty_params({
             'InstanceId': self.id,
             'PublicIp': None if self._ec2_instance.vpc_id else
             fip.public_ip,
-            # pylint:disable=protected-access
             'AllocationId': fip._ip.allocation_id})
         self._provider.ec2_conn.meta.client.associate_address(**params)
         self.refresh()
@@ -340,10 +341,10 @@ class AWSInstance(BaseInstance):
     def remove_floating_ip(self, floating_ip):
         fip = (floating_ip if isinstance(floating_ip, AWSFloatingIP)
                else self._get_fip(floating_ip))
+        # pylint:disable=protected-access
         params = trim_empty_params({
             'PublicIp': None if self._ec2_instance.vpc_id else
             fip.public_ip,
-            # pylint:disable=protected-access
             'AssociationId': fip._ip.association_id})
         self._provider.ec2_conn.meta.client.disassociate_address(**params)
         self.refresh()

+ 9 - 0
cloudbridge/cloud/providers/aws/services.py

@@ -225,6 +225,7 @@ class AWSVMFirewallRuleService(BaseVMFirewallRuleService):
         rules = [AWSVMFirewallRule(firewall,
                                    TrafficDirection.INBOUND, r)
                  for r in firewall._vm_firewall.ip_permissions]
+        # pylint:disable=protected-access
         rules = rules + [
             AWSVMFirewallRule(
                 firewall, TrafficDirection.OUTBOUND, r)
@@ -269,6 +270,7 @@ class AWSVMFirewallRuleService(BaseVMFirewallRuleService):
     @dispatch(event="provider.security.vm_firewall_rules.delete",
               priority=BaseVMFirewallRuleService.STANDARD_EVENT_PRIORITY)
     def delete(self, firewall, rule):
+        # pylint:disable=protected-access
         ip_perm_entry = rule._construct_ip_perms(
             rule.protocol, rule.from_port, rule.to_port,
             rule.cidr, rule.src_dest_fw_id)
@@ -281,6 +283,7 @@ class AWSVMFirewallRuleService(BaseVMFirewallRuleService):
             firewall._vm_firewall.revoke_ingress(
                 IpPermissions=ip_perms)
         else:
+            # pylint:disable=protected-access
             firewall._vm_firewall.revoke_egress(
                 IpPermissions=ip_perms)
         firewall.refresh()
@@ -547,6 +550,7 @@ class AWSBucketObjectService(BaseBucketObjectService):
                                      limit=limit, marker=marker)
 
     def find(self, bucket, **kwargs):
+        # pylint:disable=protected-access
         obj_list = [AWSBucketObject(self.provider, o)
                     for o in bucket._bucket.objects.all()]
         filters = ['name']
@@ -960,6 +964,7 @@ class AWSNetworkService(BaseNetworkService):
     def get_or_create_default(self):
         # # Look for provided default network
         # for net in self.provider.networking.networks:
+        # pylint:disable=protected-access
         #     if net._vpc.is_default:
         #         return net
 
@@ -1069,6 +1074,7 @@ class AWSSubnetService(BaseSubnetService):
         snl = self.find(label=AWSSubnet.CB_DEFAULT_SUBNET_LABEL + "*")
 
         if snl:
+            # pylint:disable=protected-access
             snl.sort(key=lambda sn: sn._subnet.availability_zone)
             if not zone_name:
                 return snl[0]
@@ -1231,9 +1237,11 @@ class AWSGatewayService(BaseGatewayService):
               else self.svc.get(gateway))
         try:
             if gw.network_id:
+                # pylint:disable=protected-access
                 gw._gateway.detach_from_vpc(VpcId=gw.network_id)
         except ClientError as e:
             log.warn("Error deleting gateway {0}: {1}".format(self.id, e))
+        # pylint:disable=protected-access
         gw._gateway.delete()
 
     @dispatch(event="provider.networking.gateways.list",
@@ -1278,6 +1286,7 @@ class AWSFloatingIPService(BaseFloatingIPService):
               priority=BaseFloatingIPService.STANDARD_EVENT_PRIORITY)
     def delete(self, gateway, fip):
         if isinstance(fip, AWSFloatingIP):
+            # pylint:disable=protected-access
             aws_fip = fip._ip
         else:
             aws_fip = self.svc.get_raw(fip)

+ 2 - 0
cloudbridge/cloud/providers/azure/resources.py

@@ -946,6 +946,7 @@ class AzureSubnet(BaseSubnet):
         # Although Subnet doesn't support labels, we use the parent Network's
         # tags to track the subnet's labels
         network = self.network
+        # pylint:disable=protected-access
         az_network = network._network
         return az_network.tags.get(self.tag_name, None)
 
@@ -954,6 +955,7 @@ class AzureSubnet(BaseSubnet):
     def label(self, value):
         self.assert_valid_resource_label(value)
         network = self.network
+        # pylint:disable=protected-access
         az_network = network._network
         kwargs = {self.tag_name: value or ""}
         az_network.tags.update(**kwargs)

+ 7 - 0
cloudbridge/cloud/providers/azure/services.py

@@ -238,6 +238,7 @@ class AzureVMFirewallRuleService(BaseVMFirewallRuleService):
             delete_vm_firewall_rule(rule_id, fw_name)
         for i, o in enumerate(firewall._vm_firewall.security_rules):
             if o.id == rule_id:
+                # pylint:disable=protected-access
                 del firewall._vm_firewall.security_rules[i]
                 break
 
@@ -721,6 +722,7 @@ class AzureInstanceService(BaseInstanceService):
                                 zone_id):
 
         if image.is_gallery_image:
+            # pylint:disable=protected-access
             reference = image._image.as_dict()
             image_ref = {
                 'publisher': reference['publisher'],
@@ -1016,18 +1018,23 @@ class AzureInstanceService(BaseInstanceService):
             return
 
         # Remove IPs first to avoid a network interface conflict
+        # pylint:disable=protected-access
         for public_ip_id in ins._public_ip_ids:
             ins.remove_floating_ip(public_ip_id)
         self.provider.azure_client.deallocate_vm(ins.id)
         self.provider.azure_client.delete_vm(ins.id)
+        # pylint:disable=protected-access
         for nic_id in ins._nic_ids:
             self.provider.azure_client.delete_nic(nic_id)
+        # pylint:disable=protected-access
         for data_disk in ins._vm.storage_profile.data_disks:
             if data_disk.managed_disk:
+                # pylint:disable=protected-access
                 if ins._vm.tags.get('delete_on_terminate',
                                     'False') == 'True':
                     self.provider.azure_client. \
                         delete_disk(data_disk.managed_disk.id)
+        # pylint:disable=protected-access
         if ins._vm.storage_profile.os_disk.managed_disk:
             self.provider.azure_client. \
                 delete_disk(ins._vm.storage_profile.os_disk.managed_disk.id)

+ 1 - 0
cloudbridge/cloud/providers/gce/helpers.py

@@ -181,6 +181,7 @@ def change_label(resource, key, value, res_att, request):
         request.body = str(request_body)
         request.body_size = len(str(request_body))
         response = request.execute()
+        # pylint:disable=protected-access
         resource._provider.wait_for_operation(
             response, zone=getattr(resource, 'zone_name', None))
     finally:

+ 1 - 0
cloudbridge/cloud/providers/gce/provider.py

@@ -102,6 +102,7 @@ class GCPResources(object):
         #   }
         #   ...
         # }
+        # pylint:disable=protected-access
         desc = connection._resourceDesc
         self._root_url = desc['rootUrl']
         self._service_path = desc['servicePath']

+ 6 - 0
cloudbridge/cloud/providers/gce/resources.py

@@ -524,8 +524,11 @@ class GCEVMFirewall(BaseVMFirewall):
         if fw:
             # pylint:disable=protected-access
             self._delegate = fw._delegate
+            # pylint:disable=protected-access
             self._description = fw._description
+            # pylint:disable=protected-access
             self._network = fw._network
+            # pylint:disable=protected-access
             self._rule_container = fw._rule_container
 
     @property
@@ -962,6 +965,7 @@ class GCEInstance(BaseInstance):
         """
         # Get instance again to avoid stale metadata
         ins = self._provider.compute.instances.get(self.id)
+        # pylint:disable=protected-access
         meta = ins._gce_instance.get('metadata', {})
         if meta:
             items = meta.get("items", [])
@@ -1924,6 +1928,7 @@ class GCSObject(BaseBucketObject):
             data = data.encode()
         media_body = googleapiclient.http.MediaIoBaseUpload(
                 io.BytesIO(data), mimetype='plain/text')
+        # pylint:disable=protected-access
         response = (self._provider
                         .storage._bucket_objects
                         ._create_object_with_media_body(self._bucket,
@@ -1939,6 +1944,7 @@ class GCSObject(BaseBucketObject):
         with open(path, 'rb') as f:
             media_body = googleapiclient.http.MediaIoBaseUpload(
                     f, 'application/octet-stream')
+            # pylint:disable=protected-access
             response = (self._provider
                         .storage._bucket_objects
                         ._create_object_with_media_body(self._bucket,

+ 2 - 0
cloudbridge/cloud/providers/gce/services.py

@@ -205,6 +205,7 @@ class GCEVMFirewallService(BaseVMFirewallService):
         fw.label = label
         # This rule exists implicitly. Add it explicitly so that the firewall
         # is not empty and the rule is shown by list/get/find methods.
+        # pylint:disable=protected-access
         self.provider.security._vm_firewall_rules.create_with_priority(
             fw, direction=TrafficDirection.OUTBOUND, protocol='tcp',
             priority=65534, cidr='0.0.0.0/0')
@@ -1613,6 +1614,7 @@ class GCEFloatingIPService(BaseFloatingIPService):
                else self.get(gateway, fip))
         project_name = self.provider.project_name
         # First, delete the forwarding rule, if there is any.
+        # pylint:disable=protected-access
         if fip._rule:
             response = (self.provider
                         .gce_compute

+ 3 - 0
cloudbridge/cloud/providers/openstack/resources.py

@@ -150,6 +150,7 @@ class OpenStackMachineImage(BaseMachineImage):
         log.debug("Refreshing OpenStack Machine Image")
         image = self._provider.compute.images.get(self.id)
         if image:
+            # pylint:disable=protected-access
             self._os_image = image._os_image  # pylint:disable=protected-access
         else:
             # The image no longer exists and cannot be refreshed.
@@ -658,6 +659,7 @@ class OpenStackVolume(BaseVolume):
         vol = self._provider.storage.volumes.get(
             self.id)
         if vol:
+            # pylint:disable=protected-access
             self._volume = vol._volume  # pylint:disable=protected-access
         else:
             # The volume no longer exists and cannot be refreshed.
@@ -740,6 +742,7 @@ class OpenStackSnapshot(BaseSnapshot):
         snap = self._provider.storage.snapshots.get(
             self.id)
         if snap:
+            # pylint:disable=protected-access
             self._snapshot = snap._snapshot  # pylint:disable=protected-access
         else:
             # The snapshot no longer exists and cannot be refreshed.

+ 1 - 0
cloudbridge/cloud/providers/openstack/services.py

@@ -1250,6 +1250,7 @@ class OpenStackFloatingIPService(BaseFloatingIPService):
               priority=BaseFloatingIPService.STANDARD_EVENT_PRIORITY)
     def delete(self, gateway, fip):
         if isinstance(fip, OpenStackFloatingIP):
+            # pylint:disable=protected-access
             os_ip = fip._ip
         else:
             try:

+ 2 - 0
test/test_block_store_service.py

@@ -21,6 +21,7 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage.volumes', 'storage.volumes'])
     def test_storage_services_event_pattern(self):
+        # pylint:disable=protected-access
         self.assertEqual(
             self.provider.storage.volumes._service_event_pattern,
             "provider.storage.volumes",
@@ -29,6 +30,7 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
                                      "provider.storage.volumes",
                                      self.provider.storage.volumes.
                                      _service_event_pattern))
+        # pylint:disable=protected-access
         self.assertEqual(
             self.provider.storage.snapshots._service_event_pattern,
             "provider.storage.snapshots",

+ 5 - 0
test/test_cloud_helpers.py

@@ -82,21 +82,26 @@ class CloudHelpersTestCase(ProviderTestBase):
     def test_type_validation(self):
         # Make sure internal type checking implementation properly sets types.
         self.provider.config['text_type_check'] = 'test-text'
+        # pylint:disable=protected-access
         config_value = self.provider._get_config_value('text_type_check', None)
         self.assertIsInstance(config_value, six.string_types)
 
+        # pylint:disable=protected-access
         env_value = self.provider._get_config_value(
             'some_config_value', get_env('MOTO_AMIS_PATH'))
         self.assertIsInstance(env_value, six.string_types)
 
+        # pylint:disable=protected-access
         none_value = self.provider._get_config_value(
             'some_config_value', get_env('MISSING_ENV', None))
         self.assertIsNone(none_value)
 
+        # pylint:disable=protected-access
         bool_value = self.provider._get_config_value(
             'some_config_value', get_env('MISSING_ENV', True))
         self.assertIsInstance(bool_value, bool)
 
+        # pylint:disable=protected-access
         int_value = self.provider._get_config_value(
             'default_result_limit', None)
         self.assertIsInstance(int_value, int)

+ 1 - 0
test/test_compute_service.py

@@ -22,6 +22,7 @@ class CloudComputeServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['compute.instances'])
     def test_storage_services_event_pattern(self):
+        # pylint:disable=protected-access
         self.assertEqual(
             self.provider.compute.instances._service_event_pattern,
             "provider.compute.instances",

+ 3 - 0
test/test_network_service.py

@@ -20,6 +20,7 @@ class CloudNetworkServiceTestCase(ProviderTestBase):
                               'networking.networks',
                               'networking.routers'])
     def test_storage_services_event_pattern(self):
+        # pylint:disable=protected-access
         self.assertEqual(
             self.provider.networking.networks._service_event_pattern,
             "provider.networking.networks",
@@ -28,6 +29,7 @@ class CloudNetworkServiceTestCase(ProviderTestBase):
                                      "provider.networking.networks",
                                      self.provider.networking.networks.
                                      _service_event_pattern))
+        # pylint:disable=protected-access
         self.assertEqual(
             self.provider.networking.subnets._service_event_pattern,
             "provider.networking.subnets",
@@ -36,6 +38,7 @@ class CloudNetworkServiceTestCase(ProviderTestBase):
                                      "provider.networking.subnets",
                                      self.provider.networking.subnets.
                                      _service_event_pattern))
+        # pylint:disable=protected-access
         self.assertEqual(
             self.provider.networking.routers._service_event_pattern,
             "provider.networking.routers",

+ 2 - 0
test/test_object_store_service.py

@@ -23,6 +23,7 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage._bucket_objects', 'storage.buckets'])
     def test_storage_services_event_pattern(self):
+        # pylint:disable=protected-access
         self.assertEqual(
             self.provider.storage.buckets._service_event_pattern,
             "provider.storage.buckets",
@@ -31,6 +32,7 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
                                      "provider.storage.buckets",
                                      self.provider.storage.buckets.
                                      _service_event_pattern))
+        # pylint:disable=protected-access
         self.assertEqual(
             self.provider.storage._bucket_objects._service_event_pattern,
             "provider.storage._bucket_objects",

+ 1 - 0
test/test_region_service.py

@@ -13,6 +13,7 @@ class CloudRegionServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['compute.regions'])
     def test_storage_services_event_pattern(self):
+        # pylint:disable=protected-access
         self.assertEqual(
             self.provider.compute.regions._service_event_pattern,
             "provider.compute.regions",