Explorar o código

Added tag specification to aws gateway

Nuwan Goonasekera %!s(int64=4) %!d(string=hai) anos
pai
achega
b108fd4ef2
Modificáronse 1 ficheiros con 13 adicións e 15 borrados
  1. 13 15
      cloudbridge/providers/aws/services.py

+ 13 - 15
cloudbridge/providers/aws/services.py

@@ -6,8 +6,6 @@ import uuid
 
 from botocore.exceptions import ClientError
 
-import tenacity
-
 import cloudbridge.base.helpers as cb_helpers
 from cloudbridge.base.middleware import dispatch
 from cloudbridge.base.resources import ClientPagedResultList
@@ -1335,19 +1333,19 @@ class AWSGatewayService(BaseGatewayService):
         if gtw:
             return gtw[0]  # There can be only one gtw attached to a VPC
         # Gateway does not exist so create one and attach to the supplied net
-        cb_gateway = self.svc.create('create_internet_gateway')
-
-        @tenacity.retry(stop=tenacity.stop_after_attempt(5),
-                        retry=tenacity.retry_if_exception_type(ClientError),
-                        wait=tenacity.wait_fixed(5),
-                        reraise=True)
-        def _set_tag(gateway):
-            gateway._gateway.create_tags(
-                Tags=[{'Key': 'Name',
-                       'Value': AWSInternetGateway.CB_DEFAULT_INET_GATEWAY_NAME
-                       }])
-
-        _set_tag(cb_gateway)
+        cb_gateway = self.svc.create('create_internet_gateway',
+                                     TagSpecifications=[
+                                         {
+                                             'ResourceType': 'internet-gateway',
+                                             'Tags': [
+                                                 {
+                                                     'Key': 'Name',
+                                                     'Value': AWSInternetGateway.CB_DEFAULT_INET_GATEWAY_NAME
+                                                 }
+                                             ]
+                                         }
+                                     ]
+                                     )
         cb_gateway._gateway.attach_to_vpc(VpcId=network_id)
         return cb_gateway