I cannot believe that it took this long to write a test for this.
This commit is contained in:
72
secdep.py
72
secdep.py
@@ -963,17 +963,17 @@ def create_node(provider, name=None, location=None, size=None, image=None, confi
|
||||
if provider == "gce":
|
||||
node = driver.create_node(name=name, image=image, size=size, location=location, ex_service_accounts=sa_scopes, ex_metadata=metadata)
|
||||
elif provider == "azure":
|
||||
# sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
# for sec_group in sec_groups:
|
||||
# if sec_group.name == name+"-sec_group":
|
||||
# print("A security group with that name already exists, please try a different virtual machine name to differentiate the security group name")
|
||||
# exit(0)
|
||||
sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
for sec_group in sec_groups:
|
||||
if sec_group.name == name+"-sec_group":
|
||||
print("A security group with that name already exists, please try a different virtual machine name to differentiate the security group name")
|
||||
exit(0)
|
||||
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
# for ip in ips:
|
||||
# if ip.name == name+"-ip":
|
||||
# print("An ip with that name already exists, please try a different virtual machine name to differentiate the ip name")
|
||||
# exit(0)
|
||||
# driver.ex_create_network_security_group(name=name+"-sec_group", resource_group=SECDEP_AZURE_RESOURCE_GROUP, location=location)
|
||||
driver.ex_create_network_security_group(name=name+"-sec_group", resource_group=SECDEP_AZURE_RESOURCE_GROUP, location=location)
|
||||
networks = driver.ex_list_networks()
|
||||
for network in networks:
|
||||
if network.name == SECDEP_AZURE_VIRTUAL_NETWORK:
|
||||
@@ -988,7 +988,7 @@ def create_node(provider, name=None, location=None, size=None, image=None, confi
|
||||
exit(0)
|
||||
subnet = driver.ex_list_subnets(network=ex_network)[0]
|
||||
# public_ip = driver.ex_create_public_ip(name=name+"-ip", resource_group=SECDEP_AZURE_RESOURCE_GROUP, location=location, public_ip_allocation_method="Static")
|
||||
print(public_ip = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP))
|
||||
public_ip = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)[0]
|
||||
network_interface = driver.ex_create_network_interface(name=name+"-nic", subnet=subnet, resource_group=SECDEP_AZURE_RESOURCE_GROUP, location=location, public_ip=public_ip)
|
||||
node = driver.create_node(name=name, size=size, image=image, location=location, auth=auth, ex_user_name="secdep", ex_resource_group=SECDEP_AZURE_RESOURCE_GROUP, ex_use_managed_disks=True, ex_nic=network_interface, ex_os_disk_delete=True)
|
||||
else:
|
||||
@@ -1024,11 +1024,11 @@ def create_node(provider, name=None, location=None, size=None, image=None, confi
|
||||
if provider == "gce":
|
||||
node = driver.create_node(name=name, image=image, size=size, location=location, ex_service_accounts=sa_scopes, ex_metadata=metadata)
|
||||
elif provider == "azure":
|
||||
# sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
# for sec_group in sec_groups:
|
||||
# if sec_group.name == name+"-sec_group":
|
||||
# print("A security group with that name already exists, please try a different virtual machine name to differentiate the security group name")
|
||||
# exit(0)
|
||||
sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
for sec_group in sec_groups:
|
||||
if sec_group.name == name+"-sec_group":
|
||||
print("A security group with that name already exists, please try a different virtual machine name to differentiate the security group name")
|
||||
exit(0)
|
||||
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
# for ip in ips:
|
||||
# if ip.name == name+"-ip":
|
||||
@@ -1149,18 +1149,18 @@ def delete_node():
|
||||
print("%s node deleted successfully" % (providerName.upper()))
|
||||
else:
|
||||
print("%s node could not be deleted" % (providerName.upper()))
|
||||
# if providerName == "azure":
|
||||
# driver = get_corresponding_driver("azure")
|
||||
# node_location = node.extra['location']
|
||||
# locations = driver.list_locations()
|
||||
# for loc in locations:
|
||||
# if loc.id == node_location:
|
||||
# location = loc
|
||||
# break
|
||||
# sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
# for sec_group in sec_groups:
|
||||
# if sec_group.name == node.name+"-sec_group":
|
||||
# driver.ex_delete_network_security_group(name=sec_group.name, resource_group=SECDEP_AZURE_RESOURCE_GROUP, location=location)
|
||||
if providerName == "azure":
|
||||
driver = get_corresponding_driver("azure")
|
||||
node_location = node.extra['location']
|
||||
locations = driver.list_locations()
|
||||
for loc in locations:
|
||||
if loc.id == node_location:
|
||||
location = loc
|
||||
break
|
||||
sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
for sec_group in sec_groups:
|
||||
if sec_group.name == node.name+"-sec_group":
|
||||
driver.ex_delete_network_security_group(name=sec_group.name, resource_group=SECDEP_AZURE_RESOURCE_GROUP, location=location)
|
||||
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
# for ip in ips:
|
||||
# if ip.name == node.name+"-ip":
|
||||
@@ -1184,18 +1184,18 @@ def delete_all_nodes():
|
||||
print("%s node deleted successfully" % (node.name))
|
||||
else:
|
||||
print("%s node could not be deleted" % (node.name))
|
||||
# if providerName == "azure":
|
||||
# driver = get_corresponding_driver("azure")
|
||||
# node_location = node.extra['location']
|
||||
# locations = driver.list_locations()
|
||||
# for loc in locations:
|
||||
# if loc.id == node_location:
|
||||
# location = loc
|
||||
# break
|
||||
# sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
# for sec_group in sec_groups:
|
||||
# if sec_group.name == node.name+"-sec_group":
|
||||
# driver.ex_delete_network_security_group(name=sec_group.name, resource_group=SECDEP_AZURE_RESOURCE_GROUP, location=location)
|
||||
if providerName == "azure":
|
||||
driver = get_corresponding_driver("azure")
|
||||
node_location = node.extra['location']
|
||||
locations = driver.list_locations()
|
||||
for loc in locations:
|
||||
if loc.id == node_location:
|
||||
location = loc
|
||||
break
|
||||
sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
for sec_group in sec_groups:
|
||||
if sec_group.name == node.name+"-sec_group":
|
||||
driver.ex_delete_network_security_group(name=sec_group.name, resource_group=SECDEP_AZURE_RESOURCE_GROUP, location=location)
|
||||
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
||||
# for ip in ips:
|
||||
# if ip.name == node.name+"-ip":
|
||||
|
||||
Reference in New Issue
Block a user