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":
|
if provider == "gce":
|
||||||
node = driver.create_node(name=name, image=image, size=size, location=location, ex_service_accounts=sa_scopes, ex_metadata=metadata)
|
node = driver.create_node(name=name, image=image, size=size, location=location, ex_service_accounts=sa_scopes, ex_metadata=metadata)
|
||||||
elif provider == "azure":
|
elif provider == "azure":
|
||||||
# sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||||
# for sec_group in sec_groups:
|
for sec_group in sec_groups:
|
||||||
# if sec_group.name == name+"-sec_group":
|
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")
|
print("A security group with that name already exists, please try a different virtual machine name to differentiate the security group name")
|
||||||
# exit(0)
|
exit(0)
|
||||||
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
||||||
# for ip in ips:
|
# for ip in ips:
|
||||||
# if ip.name == name+"-ip":
|
# 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")
|
# print("An ip with that name already exists, please try a different virtual machine name to differentiate the ip name")
|
||||||
# exit(0)
|
# 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()
|
networks = driver.ex_list_networks()
|
||||||
for network in networks:
|
for network in networks:
|
||||||
if network.name == SECDEP_AZURE_VIRTUAL_NETWORK:
|
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)
|
exit(0)
|
||||||
subnet = driver.ex_list_subnets(network=ex_network)[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")
|
# 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)
|
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)
|
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:
|
else:
|
||||||
@@ -1024,11 +1024,11 @@ def create_node(provider, name=None, location=None, size=None, image=None, confi
|
|||||||
if provider == "gce":
|
if provider == "gce":
|
||||||
node = driver.create_node(name=name, image=image, size=size, location=location, ex_service_accounts=sa_scopes, ex_metadata=metadata)
|
node = driver.create_node(name=name, image=image, size=size, location=location, ex_service_accounts=sa_scopes, ex_metadata=metadata)
|
||||||
elif provider == "azure":
|
elif provider == "azure":
|
||||||
# sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||||
# for sec_group in sec_groups:
|
for sec_group in sec_groups:
|
||||||
# if sec_group.name == name+"-sec_group":
|
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")
|
print("A security group with that name already exists, please try a different virtual machine name to differentiate the security group name")
|
||||||
# exit(0)
|
exit(0)
|
||||||
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
||||||
# for ip in ips:
|
# for ip in ips:
|
||||||
# if ip.name == name+"-ip":
|
# if ip.name == name+"-ip":
|
||||||
@@ -1149,18 +1149,18 @@ def delete_node():
|
|||||||
print("%s node deleted successfully" % (providerName.upper()))
|
print("%s node deleted successfully" % (providerName.upper()))
|
||||||
else:
|
else:
|
||||||
print("%s node could not be deleted" % (providerName.upper()))
|
print("%s node could not be deleted" % (providerName.upper()))
|
||||||
# if providerName == "azure":
|
if providerName == "azure":
|
||||||
# driver = get_corresponding_driver("azure")
|
driver = get_corresponding_driver("azure")
|
||||||
# node_location = node.extra['location']
|
node_location = node.extra['location']
|
||||||
# locations = driver.list_locations()
|
locations = driver.list_locations()
|
||||||
# for loc in locations:
|
for loc in locations:
|
||||||
# if loc.id == node_location:
|
if loc.id == node_location:
|
||||||
# location = loc
|
location = loc
|
||||||
# break
|
break
|
||||||
# sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||||
# for sec_group in sec_groups:
|
for sec_group in sec_groups:
|
||||||
# if sec_group.name == node.name+"-sec_group":
|
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)
|
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)
|
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
||||||
# for ip in ips:
|
# for ip in ips:
|
||||||
# if ip.name == node.name+"-ip":
|
# if ip.name == node.name+"-ip":
|
||||||
@@ -1184,18 +1184,18 @@ def delete_all_nodes():
|
|||||||
print("%s node deleted successfully" % (node.name))
|
print("%s node deleted successfully" % (node.name))
|
||||||
else:
|
else:
|
||||||
print("%s node could not be deleted" % (node.name))
|
print("%s node could not be deleted" % (node.name))
|
||||||
# if providerName == "azure":
|
if providerName == "azure":
|
||||||
# driver = get_corresponding_driver("azure")
|
driver = get_corresponding_driver("azure")
|
||||||
# node_location = node.extra['location']
|
node_location = node.extra['location']
|
||||||
# locations = driver.list_locations()
|
locations = driver.list_locations()
|
||||||
# for loc in locations:
|
for loc in locations:
|
||||||
# if loc.id == node_location:
|
if loc.id == node_location:
|
||||||
# location = loc
|
location = loc
|
||||||
# break
|
break
|
||||||
# sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
sec_groups = driver.ex_list_network_security_groups(SECDEP_AZURE_RESOURCE_GROUP)
|
||||||
# for sec_group in sec_groups:
|
for sec_group in sec_groups:
|
||||||
# if sec_group.name == node.name+"-sec_group":
|
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)
|
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)
|
# ips = driver.ex_list_public_ips(SECDEP_AZURE_RESOURCE_GROUP)
|
||||||
# for ip in ips:
|
# for ip in ips:
|
||||||
# if ip.name == node.name+"-ip":
|
# if ip.name == node.name+"-ip":
|
||||||
|
|||||||
Reference in New Issue
Block a user