소스 검색

Fix assignment of floating IP to an instance

(admitently, it's a bit awkward to have to implement it this way but the .get method requires ID of the instance rather than the IP so we might want to change that in the interface)
Enis Afgan 8 년 전
부모
커밋
717f7fc3b0
2개의 변경된 파일5개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 1
      cloudbridge/cloud/providers/aws/resources.py
  2. 3 4
      cloudbridge/cloud/providers/aws/services.py

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

@@ -294,7 +294,8 @@ class AWSInstance(BaseInstance):
     def add_floating_ip(self, floating_ip):
         fip = (
             floating_ip if isinstance(floating_ip, AWSFloatingIP) else
-            self._provider.networking.floating_ips.get(floating_ip))
+            [ip for ip in self._provider.networking.floating_ips.list()
+             if ip.public_ip == floating_ip][0])
         params = trim_empty_params({
             'InstanceId': self.id,
             'PublicIp': None if self._ec2_instance.vpc_id else fip.public_ip,

+ 3 - 4
cloudbridge/cloud/providers/aws/services.py

@@ -731,10 +731,9 @@ class AWSFloatingIPService(BaseFloatingIPService):
                                   cb_resource=AWSFloatingIP,
                                   boto_collection_name='vpc_addresses')
 
-    def get(self, router_id):
-        log.debug("Getting AWS Floating IP Service with the id: %s",
-                  router_id)
-        return self.svc.get(router_id)
+    def get(self, fip_id):
+        log.debug("Getting AWS Floating IP Service with the id: %s", fip_id)
+        return self.svc.get(fip_id)
 
     def list(self, limit=None, marker=None):
         return self.svc.list(limit=limit, marker=marker)