Просмотр исходного кода

Fix a small bug

The security group was exposing "network" as a public property
which causes network be written in the JSON string which causes
one of the tests fail.
Ehsan Chiniforooshan 9 лет назад
Родитель
Сommit
35eec9ccf5
2 измененных файлов с 6 добавлено и 10 удалено
  1. 5 9
      cloudbridge/cloud/providers/gce/resources.py
  2. 1 1
      test/test_security_service.py

+ 5 - 9
cloudbridge/cloud/providers/gce/resources.py

@@ -429,7 +429,7 @@ class GCESecurityGroup(BaseSecurityGroup):
         network and the target tag corresponding to this security group.
         """
         return GCEFirewallsDelegate.tag_network_id(self._security_group,
-                                                   self.network)
+                                                   self._network)
 
     @property
     def name(self):
@@ -451,7 +451,7 @@ class GCESecurityGroup(BaseSecurityGroup):
         if self._description is not None:
             return self._description
         for firewall in self._delegate.iter_firewalls(self._security_group,
-                                                      self.network):
+                                                      self._network):
             if 'description' in firewall:
                 return firewall['description']
         return None
@@ -460,14 +460,10 @@ class GCESecurityGroup(BaseSecurityGroup):
     def rules(self):
         out = []
         for firewall in self._delegate.iter_firewalls(self._security_group,
-                                                      self.network):
+                                                      self._network):
             out.append(GCESecurityGroupRule(self._delegate, firewall['id']))
         return out
 
-    @property
-    def network(self):
-        return self._network
-
     @staticmethod
     def to_port_range(from_port, to_port):
         if from_port is not None and to_port is not None:
@@ -483,7 +479,7 @@ class GCESecurityGroup(BaseSecurityGroup):
         src_tag = src_group.name if src_group is not None else None
         self._delegate.add_firewall(self._security_group, ip_protocol, port,
                                     cidr_ip, src_tag, self.description,
-                                    self.network)
+                                    self._network)
         return self.get_rule(ip_protocol, from_port, to_port, cidr_ip,
                              src_group)
 
@@ -493,7 +489,7 @@ class GCESecurityGroup(BaseSecurityGroup):
         src_tag = src_group.name if src_group is not None else None
         firewall_id = self._delegate.find_firewall(
                 self._security_group, ip_protocol, port, cidr_ip, src_tag,
-                self.network)
+                self._network)
         if firewall_id is None:
             return None
         return GCESecurityGroupRule(self._delegate, firewall_id)

+ 1 - 1
test/test_security_service.py

@@ -99,7 +99,7 @@ class CloudSecurityServiceTestCase(ProviderTestBase):
         sg = self.provider.security.security_groups.create(
             name=name, description=name)
         #Empty security groups don't exist in GCE. Let's add a dummy rule.
-        sg.add_rule(ip_protocol='tcp')
+        sg.add_rule(ip_protocol='tcp', cidr_ip='0.0.0.0/0')
         with helpers.cleanup_action(
             lambda:
                 self.provider.security.security_groups.delete(group_id=sg.id)