You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by lf...@apache.org on 2020/10/26 10:34:32 UTC

[incubator-datalab] 01/01: [DATALAB-2118]: changed call of GCPActions and GCPMeta

This is an automated email from the ASF dual-hosted git repository.

lfrolov pushed a commit to branch DATALAB-2118
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit 3ef57d3042d086151cbc81f122c1ca48d8d62a52
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Mon Oct 26 12:34:09 2020 +0200

    [DATALAB-2118]: changed call of GCPActions and GCPMeta
---
 .../scripts/gcp/ssn_terminate_gcp_resources.py     | 42 +++++++++++-----------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/infrastructure-provisioning/src/general/scripts/gcp/ssn_terminate_gcp_resources.py b/infrastructure-provisioning/src/general/scripts/gcp/ssn_terminate_gcp_resources.py
index ddabc3f..5119690 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/ssn_terminate_gcp_resources.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/ssn_terminate_gcp_resources.py
@@ -41,15 +41,17 @@ args = parser.parse_args()
 ##############
 
 if __name__ == "__main__":
+    GCPMeta = datalab.meta_lib.GCPMeta()
+    GCPActions = datalab.actions_lib.GCPActions()
     print("Terminating Dataengine-service clusters")
     try:
         labels = [
             {'sbn': args.service_base_name}
         ]
-        clusters_list = meta_lib.GCPMeta().get_dataproc_list(labels)
+        clusters_list = GCPMeta.get_dataproc_list(labels)
         if clusters_list:
             for cluster_name in clusters_list:
-                actions_lib.GCPActions().delete_dataproc_cluster(cluster_name, args.region)
+                GCPActions.delete_dataproc_cluster(cluster_name, args.region)
                 print('The Dataproc cluster {} has been terminated successfully'.format(cluster_name))
         else:
             print("There are no Dataproc clusters to terminate.")
@@ -59,76 +61,76 @@ if __name__ == "__main__":
 
     print("Terminating instances")
     try:
-        instances = GCPMeta().get_list_instances(args.zone, args.service_base_name)
+        instances = GCPMeta.get_list_instances(args.zone, args.service_base_name)
         if 'items' in instances:
             for i in instances['items']:
-                GCPActions().remove_instance(i['name'], args.zone)
+                GCPActions.remove_instance(i['name'], args.zone)
     except Exception as err:
         print('Error: {0}'.format(err))
         sys.exit(1)
 
     print("Removing images")
     try:
-        images = GCPMeta().get_list_images(args.service_base_name)
+        images = GCPMeta.get_list_images(args.service_base_name)
         if 'items' in images:
             for i in images['items']:
-                GCPActions().remove_image(i['name'])
+                GCPActions.remove_image(i['name'])
     except Exception as err:
         print('Error: {0}'.format(err))
         sys.exit(1)
 
     print("Removing static addresses")
     try:
-        static_addresses = GCPMeta().get_list_static_addresses(args.region, args.service_base_name)
+        static_addresses = GCPMeta.get_list_static_addresses(args.region, args.service_base_name)
         if 'items' in static_addresses:
             for i in static_addresses['items']:
-                GCPActions().remove_static_address(i['name'], args.region)
+                GCPActions.remove_static_address(i['name'], args.region)
     except Exception as err:
         print('Error: {0}'.format(err))
         sys.exit(1)
 
     print("Removing firewalls")
     try:
-        firewalls = GCPMeta().get_list_firewalls(args.service_base_name)
+        firewalls = GCPMeta.get_list_firewalls(args.service_base_name)
         if 'items' in firewalls:
             for i in firewalls['items']:
-                GCPActions().remove_firewall(i['name'])
+                GCPActions.remove_firewall(i['name'])
     except Exception as err:
         print('Error: {0}'.format(err))
         sys.exit(1)
 
     print("Removing Service accounts and roles")
     try:
-        list_service_accounts = GCPMeta().get_list_service_accounts()
+        list_service_accounts = GCPMeta.get_list_service_accounts()
         for service_account in list_service_accounts:
             if service_account.startswith(args.service_base_name):
-                GCPActions().remove_service_account(service_account, args.service_base_name)
-        list_roles_names = GCPMeta().get_list_roles()
+                GCPActions.remove_service_account(service_account, args.service_base_name)
+        list_roles_names = GCPMeta.get_list_roles()
         for role in list_roles_names:
             if role.startswith(args.service_base_name):
-                GCPActions().remove_role(role)
+                GCPActions.remove_role(role)
     except Exception as err:
         print('Error: {0}'.format(err))
         sys.exit(1)
 
     print("Removing subnets")
     try:
-        list_subnets = GCPMeta().get_list_subnetworks(args.region, '', args.service_base_name)
+        list_subnets = GCPMeta.get_list_subnetworks(args.region, '', args.service_base_name)
         if 'items' in list_subnets:
             vpc_selflink = list_subnets['items'][0]['network']
-            subnets = GCPMeta().get_list_subnetworks(args.region, args.vpc_name, args.service_base_name)
+            subnets = GCPMeta.get_list_subnetworks(args.region, args.vpc_name, args.service_base_name)
             for i in subnets['items']:
-                GCPActions().remove_subnet(i['name'], args.region)
+                GCPActions.remove_subnet(i['name'], args.region)
     except Exception as err:
         print('Error: {0}'.format(err))
         sys.exit(1)
 
     print("Removing s3 buckets")
     try:
-        buckets = GCPMeta().get_list_buckets(args.service_base_name)
+        buckets = GCPMeta.get_list_buckets(args.service_base_name)
         if 'items' in buckets:
             for i in buckets['items']:
-                GCPActions().remove_bucket(i['name'])
+                GCPActions.remove_bucket(i['name'])
     except Exception as err:
         print('Error: {0}'.format(err))
         sys.exit(1)
@@ -136,7 +138,7 @@ if __name__ == "__main__":
     print("Removing SSN VPC")
     if args.pre_defined_vpc != 'True':
         try:
-            GCPActions().remove_vpc(args.vpc_name)
+            GCPActions.remove_vpc(args.vpc_name)
         except Exception as err:
             print('Error: {0}'.format(err))
             print("No such VPC")


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org