This is an automated email from the ASF dual-hosted git repository.
lfrolov pushed a commit to branch DATALAB-2321
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
The following commit(s) were added to refs/heads/DATALAB-2321 by this push:
new d002836 [DATALAB-2321]: added rule removal from predefined edge sg
d002836 is described below
commit d0028367f6286cdfa0c06b63afb94b83c1280f93
Author: leonidfrolov <[email protected]>
AuthorDate: Mon May 17 17:31:39 2021 +0300
[DATALAB-2321]: added rule removal from predefined edge sg
---
.../src/general/lib/azure/meta_lib.py | 15 +++++++++++++++
.../src/general/scripts/azure/ssn_terminate.py | 15 +++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/infrastructure-provisioning/src/general/lib/azure/meta_lib.py
b/infrastructure-provisioning/src/general/lib/azure/meta_lib.py
index 9d23cb4..06e4400 100644
--- a/infrastructure-provisioning/src/general/lib/azure/meta_lib.py
+++ b/infrastructure-provisioning/src/general/lib/azure/meta_lib.py
@@ -133,6 +133,21 @@ class AzureMeta:
file=sys.stdout)}))
traceback.print_exc(file=sys.stdout)
+ def list_security_group_rules(self, resource_group_name, sg_name):
+ try:
+ result =
self.network_client.network_security_groups.list(resource_group_name, sg_name)
+ return result
+ except AzureExceptions.CloudError as err:
+ if err.status_code == 404:
+ return ''
+ except Exception as err:
+ logging.info(
+ "Unable to get list of security group rules: " + str(err) +
"\n Traceback: " + traceback.print_exc(file=sys.stdout))
+ append_result(str({"error": "Unable to get list of rules",
+ "error_message": str(err) + "\n Traceback: " +
traceback.print_exc(
+ file=sys.stdout)}))
+ traceback.print_exc(file=sys.stdout)
+
def list_subnets(self, resource_group_name, vpc_name):
try:
result = self.network_client.subnets.list(resource_group_name,
vpc_name)
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/ssn_terminate.py
b/infrastructure-provisioning/src/general/scripts/azure/ssn_terminate.py
index f4e209e..90f6f06 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/ssn_terminate.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/ssn_terminate.py
@@ -126,6 +126,21 @@ def terminate_ssn_node(resource_group_name,
service_base_name, vpc_name, region)
datalab.fab.append_result("Failed to remove subnets in predefined
VPC", str(err))
sys.exit(1)
+ print("Removing rules in predefined edge security group")
+ try:
+ if 'azure_edge_security_group_name' in os.environ:
+ for rule in
AzureMeta.list_security_group_rules(resource_group_name,
os.environ['azure_edge_security_group_name']):
+ print('=======')
+ print(rule)
+ rule_name = str(rule)[str(rule).find("'name': '") + 9 :
str(rule).find("', 'etag':")]
+ print(rule_name)
+ sys.exit(1)
+
AzureActions.remove_security_rules(os.environ['azure_edge_security_group_name'],
+ resource_group_name, rule_name)
+ except Exception as err:
+ datalab.fab.append_result("Failed to remove rules in predefined edge
security group", str(err))
+ sys.exit(1)
+
print("Removing VPC")
try:
if AzureMeta.get_vpc(resource_group_name, service_base_name + '-vpc'):
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]