sudo brctl delbr {bridge}
"""
compute_node.run_cmd(cmd.format(bridge=bridge))
+
+
+def cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, subnet_ids,
+ router_ids, network_ids):
+
+ if len(bgpvpn_ids) != 0:
+ for bgpvpn_id in bgpvpn_ids:
+ os_utils.delete_bgpvpn(neutron_client, bgpvpn_id)
+
+ if len(interfaces) != 0:
+ for router_id, subnet_id in interfaces:
+ if not os_utils.remove_interface_router(neutron_client,
+ router_id, subnet_id):
+ logger.error('Fail to delete all interface routers. '
+ 'Interface router with id {} was not deleted.'.
+ format(router_id))
+
+ if len(router_ids) != 0:
+ for router_id in router_ids:
+ if not os_utils.remove_gateway_router(neutron_client, router_id):
+ logger.error('Fail to delete all gateway routers. '
+ 'Gateway router with id {} was not deleted.'.
+ format(router_id))
+
+ if len(subnet_ids) != 0:
+ for subnet_id in subnet_ids:
+ if not os_utils.delete_neutron_subnet(neutron_client, subnet_id):
+ logger.error('Fail to delete all subnets. '
+ 'Subnet with id {} was not deleted.'.
+ format(subnet_id))
+ return False
+
+ if len(router_ids) != 0:
+ for router_id in router_ids:
+ if not os_utils.delete_neutron_router(neutron_client, router_id):
+ logger.error('Fail to delete all routers. '
+ 'Router with id {} was not deleted.'.
+ format(router_id))
+ return False
+
+ if len(network_ids) != 0:
+ for network_id in network_ids:
+ if not os_utils.delete_neutron_net(neutron_client, network_id):
+ logger.error('Fail to delete all networks. '
+ 'Network with id {} was not deleted.'.
+ format(network_id))
+ return False
+ return True
+
+
+def cleanup_nova(nova_client, floatingip_ids, instance_ids, image_ids):
+
+ if len(floatingip_ids) != 0:
+ for floatingip_id in floatingip_ids:
+ if not os_utils.delete_floating_ip(nova_client, floatingip_id):
+ logger.error('Fail to delete all floating ips. '
+ 'Floating ip with id {} was not deleted.'.
+ format(floatingip_id))
+ return False
+
+ if len(instance_ids) != 0:
+ for instance_id in instance_ids:
+ if not os_utils.delete_instance(nova_client, instance_id):
+ logger.error('Fail to delete all instances. '
+ 'Instance with id {} was not deleted.'.
+ format(instance_id))
+ return False
+
+ if len(image_ids) != 0:
+ for image_id in image_ids:
+ if not os_utils.delete_glance_image(nova_client, image_id):
+ logger.error('Fail to delete all images. '
+ 'Image with id {} was not deleted.'.
+ format(image_id))
+ return False
+ return True
neutron_client = os_utils.get_neutron_client()
glance_client = os_utils.get_glance_client()
+ (floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
+ subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
+
image_id = os_utils.create_glance_image(glance_client,
TESTCASE_CONFIG.image_name,
COMMON_CONFIG.image_path,
disk=COMMON_CONFIG.image_format,
container="bare",
public='public')
+ image_ids.append(image_id)
+
network_1_id = test_utils.create_net(neutron_client,
TESTCASE_CONFIG.net_1_name)
- test_utils.create_subnet(neutron_client,
- TESTCASE_CONFIG.subnet_1_name,
- TESTCASE_CONFIG.subnet_1_cidr,
- network_1_id)
+ subnet_1_id = test_utils.create_subnet(neutron_client,
+ TESTCASE_CONFIG.subnet_1_name,
+ TESTCASE_CONFIG.subnet_1_cidr,
+ network_1_id)
network_2_id = test_utils.create_net(neutron_client,
TESTCASE_CONFIG.net_2_name)
- test_utils.create_subnet(neutron_client,
- TESTCASE_CONFIG.subnet_2_name,
- TESTCASE_CONFIG.subnet_2_cidr,
- network_2_id)
+ subnet_2_id = test_utils.create_subnet(neutron_client,
+ TESTCASE_CONFIG.subnet_2_name,
+ TESTCASE_CONFIG.subnet_2_cidr,
+ network_2_id)
+ network_ids.extend([network_1_id, network_2_id])
+ subnet_ids.extend([subnet_1_id, subnet_2_id])
sg_id = os_utils.create_security_group_full(neutron_client,
TESTCASE_CONFIG.secgroup_name,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1,
userdata=u1)
+ instance_ids.extend([vm_1.id, vm_2.id, vm_3.id, vm_4.id, vm_5.id])
msg = ("Create VPN with eRT<>iRT")
results.record_action(msg)
bgpvpn = os_utils.create_bgpvpn(neutron_client, **kwargs)
bgpvpn_id = bgpvpn['bgpvpn']['id']
logger.debug("VPN created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
msg = ("Associate network '%s' to the VPN." % TESTCASE_CONFIG.net_1_name)
results.record_action(msg)
results.get_ping_status(vm_1, vm_4, expected="PASS", timeout=30)
results.get_ping_status(vm_1, vm_5, expected="PASS", timeout=30)
+ test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids,
+ image_ids)
+ test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces,
+ subnet_ids, router_ids, network_ids)
+
return results.compile_summary()
neutron_client = os_utils.get_neutron_client()
glance_client = os_utils.get_glance_client()
+ (floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
+ subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
+
logger.debug("Using private key %s injected to the VMs."
% COMMON_CONFIG.keyfile_path)
keyfile = open(COMMON_CONFIG.keyfile_path, 'r')
disk=COMMON_CONFIG.image_format,
container="bare",
public='public')
+ image_ids.append(image_id)
+
network_1_id = test_utils.create_net(
neutron_client,
TESTCASE_CONFIG.net_1_name)
- test_utils.create_subnet(
+ subnet_1a_id = test_utils.create_subnet(
neutron_client,
TESTCASE_CONFIG.subnet_1a_name,
TESTCASE_CONFIG.subnet_1a_cidr,
network_1_id)
- test_utils.create_subnet(
+ subnet_1b_id = test_utils.create_subnet(
neutron_client,
TESTCASE_CONFIG.subnet_1b_name,
TESTCASE_CONFIG.subnet_1b_cidr,
network_2_id = test_utils.create_net(
neutron_client,
TESTCASE_CONFIG.net_2_name)
- test_utils.create_subnet(
+ subnet_2a_id = test_utils.create_subnet(
neutron_client,
TESTCASE_CONFIG.subnet_2a_name,
TESTCASE_CONFIG.subnet_2a_cidr,
network_2_id)
- test_utils.create_subnet(
+ subnet_2b_id = test_utils.create_subnet(
neutron_client,
TESTCASE_CONFIG.subnet_2b_name,
TESTCASE_CONFIG.subnet_2b_cidr,
network_2_id)
+ network_ids.extend([network_1_id, network_2_id])
+ subnet_ids.extend([subnet_1a_id, subnet_1b_id, subnet_2a_id, subnet_2b_id])
sg_id = os_utils.create_security_group_full(neutron_client,
TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1,
userdata=u1,
files=files)
+ instance_ids.extend([vm_1.id, vm_2.id, vm_3.id, vm_4.id, vm_5.id])
msg = ("Create VPN1 with eRT=iRT")
results.record_action(msg)
bgpvpn1 = os_utils.create_bgpvpn(neutron_client, **kwargs)
bgpvpn1_id = bgpvpn1['bgpvpn']['id']
logger.debug("VPN1 created details: %s" % bgpvpn1)
+ bgpvpn_ids.append(bgpvpn1_id)
msg = ("Associate network '%s' to the VPN." % TESTCASE_CONFIG.net_1_name)
results.record_action(msg)
bgpvpn2 = os_utils.create_bgpvpn(neutron_client, **kwargs)
bgpvpn2_id = bgpvpn2['bgpvpn']['id']
logger.debug("VPN created details: %s" % bgpvpn2)
+ bgpvpn_ids.append(bgpvpn2_id)
msg = ("Associate network '%s' to the VPN2." % TESTCASE_CONFIG.net_2_name)
results.record_action(msg)
expected="not reachable",
timeout=30)
+ test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids,
+ image_ids)
+ test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces,
+ subnet_ids, router_ids, network_ids)
+
return results.compile_summary()
nova_client = os_utils.get_nova_client()
neutron_client = os_utils.get_neutron_client()
+ (floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
+ subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
+
sg_id = os_utils.create_security_group_full(neutron_client,
TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
test_utils.open_http_port(neutron_client, sg_id)
test_utils.open_bgp_port(neutron_client, sg_id)
- net_id, _, _ = test_utils.create_network(neutron_client,
- TESTCASE_CONFIG.net_1_name,
- TESTCASE_CONFIG.subnet_1_name,
- TESTCASE_CONFIG.subnet_1_cidr,
- TESTCASE_CONFIG.router_1_name)
-
- quagga_net_id, _, _ = test_utils.create_network(
+ net_id, subnet_1_id, router_1_id = test_utils.create_network(
neutron_client,
- TESTCASE_CONFIG.quagga_net_name,
- TESTCASE_CONFIG.quagga_subnet_name,
- TESTCASE_CONFIG.quagga_subnet_cidr,
- TESTCASE_CONFIG.quagga_router_name)
+ TESTCASE_CONFIG.net_1_name,
+ TESTCASE_CONFIG.subnet_1_name,
+ TESTCASE_CONFIG.subnet_1_cidr,
+ TESTCASE_CONFIG.router_1_name)
+
+ quagga_net_id, subnet_quagga_id, \
+ router_quagga_id = test_utils.create_network(
+ neutron_client,
+ TESTCASE_CONFIG.quagga_net_name,
+ TESTCASE_CONFIG.quagga_subnet_name,
+ TESTCASE_CONFIG.quagga_subnet_cidr,
+ TESTCASE_CONFIG.quagga_router_name)
+
+ interfaces.append(tuple((router_1_id, subnet_1_id)))
+ interfaces.append(tuple((router_quagga_id, subnet_quagga_id)))
+ network_ids.extend([net_id, quagga_net_id])
+ router_ids.extend([router_1_id, router_quagga_id])
+ subnet_ids.extend([subnet_1_id, subnet_quagga_id])
installer_type = str(os.environ['INSTALLER_TYPE'].lower())
if installer_type == "fuel":
container="bare",
public="public")
+ image_ids.append(ubuntu_image_id)
+
# NOTE(rski) The order of this seems a bit weird but
# there is a reason for this, namely
# https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-99
# fake_fip is needed to bypass NAT
# see below for the reason why.
fake_fip = os_utils.create_floating_ip(neutron_client)
+
+ floatingip_ids.extend([fip['fip_id'], fake_fip['fip_id']])
# pin quagga to some compute
compute_node = nova_client.hypervisors.list()[0]
quagga_compute_node = "nova:" + compute_node.hypervisor_hostname
userdata=quagga_bootstrap_script,
compute_node=quagga_compute_node)
+ instance_ids.append(quagga_vm)
+
fip_added = os_utils.add_floating_ip(nova_client,
quagga_vm.id,
fip['fip_addr'])
finally:
test_utils.detach_instance_from_ext_br(quagga_vm, compute)
+ test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids,
+ image_ids)
+ test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces,
+ subnet_ids, router_ids, network_ids)
+
return results.compile_summary()
neutron_client = os_utils.get_neutron_client()
glance_client = os_utils.get_glance_client()
+ (floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
+ subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
+
image_id = os_utils.create_glance_image(glance_client,
TESTCASE_CONFIG.image_name,
COMMON_CONFIG.image_path,
disk=COMMON_CONFIG.image_format,
container="bare",
public='public')
- network_1_id, _, router_1_id = test_utils.create_network(
+ image_ids.append(image_id)
+
+ network_1_id, subnet_1_id, router_1_id = test_utils.create_network(
neutron_client,
TESTCASE_CONFIG.net_1_name,
TESTCASE_CONFIG.subnet_1_name,
network_2_id = test_utils.create_net(
neutron_client,
TESTCASE_CONFIG.net_2_name)
- test_utils.create_subnet(neutron_client,
- TESTCASE_CONFIG.subnet_2_name,
- TESTCASE_CONFIG.subnet_2_cidr,
- network_2_id)
- sg_id = os_utils.create_security_group_full(neutron_client,
- TESTCASE_CONFIG.secgroup_name,
- TESTCASE_CONFIG.secgroup_descr)
+ subnet_2_id = test_utils.create_subnet(
+ neutron_client,
+ TESTCASE_CONFIG.subnet_2_name,
+ TESTCASE_CONFIG.subnet_2_cidr,
+ network_2_id)
+ interfaces.append(tuple((router_1_id, subnet_1_id)))
+ network_ids.extend([network_1_id, network_2_id])
+ router_ids.append(router_1_id)
+ subnet_ids.extend([subnet_1_id, subnet_2_id])
+
+ sg_id = os_utils.create_security_group_full(
+ neutron_client,
+ TESTCASE_CONFIG.secgroup_name,
+ TESTCASE_CONFIG.secgroup_descr)
compute_nodes = test_utils.assert_and_get_compute_nodes(nova_client)
compute_node=av_zone_1,
userdata=u1)
+ instance_ids.extend([vm_1.id, vm_2.id, vm_3.id, vm_4.id, vm_5.id])
+
msg = ("Create VPN with eRT<>iRT")
results.record_action(msg)
vpn_name = "sdnvpn-" + str(randint(100000, 999999))
bgpvpn = os_utils.create_bgpvpn(neutron_client, **kwargs)
bgpvpn_id = bgpvpn['bgpvpn']['id']
logger.debug("VPN created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
msg = ("Associate router '%s' to the VPN." % TESTCASE_CONFIG.router_1_name)
results.record_action(msg)
results.add_to_summary(0, "=")
logger.info("\n%s" % results.summary)
+ test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids,
+ image_ids)
+ test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces,
+ subnet_ids, router_ids, network_ids)
+
return results.compile_summary()
neutron_client = os_utils.get_neutron_client()
glance_client = os_utils.get_glance_client()
+ (floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
+ subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
+
image_id = os_utils.create_glance_image(glance_client,
TESTCASE_CONFIG.image_name,
COMMON_CONFIG.image_path,
disk=COMMON_CONFIG.image_format,
container="bare",
public='public')
- network_1_id, _, _ = test_utils.create_network(
+ image_ids.append(image_id)
+
+ network_1_id, subnet_1_id, router_1_id = test_utils.create_network(
neutron_client,
TESTCASE_CONFIG.net_1_name,
TESTCASE_CONFIG.subnet_1_name,
TESTCASE_CONFIG.subnet_1_cidr,
TESTCASE_CONFIG.router_1_name)
- network_2_id, _, _ = test_utils.create_network(
+
+ network_2_id, subnet_2_id, router_2_id = test_utils.create_network(
neutron_client,
TESTCASE_CONFIG.net_2_name,
TESTCASE_CONFIG.subnet_2_name,
TESTCASE_CONFIG.subnet_2_cidr,
TESTCASE_CONFIG.router_2_name)
+ interfaces.append(tuple((router_1_id, subnet_1_id)))
+ interfaces.append(tuple((router_2_id, subnet_2_id)))
+ network_ids.extend([network_1_id, network_2_id])
+ router_ids.extend([router_1_id, router_2_id])
+ subnet_ids.extend([subnet_1_id, subnet_2_id])
+
sg_id = os_utils.create_security_group_full(neutron_client,
TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
secgroup_name=TESTCASE_CONFIG.secgroup_name,
userdata=u1)
+ instance_ids.extend([vm_1.id, vm_2.id])
+
msg = ("Create VPN with eRT==iRT")
results.record_action(msg)
vpn_name = "sdnvpn-7"
bgpvpn = os_utils.create_bgpvpn(neutron_client, **kwargs)
bgpvpn_id = bgpvpn['bgpvpn']['id']
logger.debug("VPN created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
msg = ("Associate networks '%s', '%s' to the VPN."
% (TESTCASE_CONFIG.net_1_name,
results.ping_ip_test(fip['fip_addr'])
+ floatingip_ids.append(fip['fip_id'])
+ test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids,
+ image_ids)
+ test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces,
+ subnet_ids, router_ids, network_ids)
+
return results.compile_summary()
neutron_client = os_utils.get_neutron_client()
glance_client = os_utils.get_glance_client()
+ (floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
+ subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
+
image_id = os_utils.create_glance_image(glance_client,
TESTCASE_CONFIG.image_name,
COMMON_CONFIG.image_path,
disk=COMMON_CONFIG.image_format,
container="bare",
public='public')
- network_1_id, _, router_1_id = test_utils.create_network(
+ image_ids.append(image_id)
+
+ network_1_id, subnet_1_id, router_1_id = test_utils.create_network(
neutron_client,
TESTCASE_CONFIG.net_1_name,
TESTCASE_CONFIG.subnet_1_name,
network_2_id = test_utils.create_net(
neutron_client,
TESTCASE_CONFIG.net_2_name)
- test_utils.create_subnet(neutron_client,
- TESTCASE_CONFIG.subnet_2_name,
- TESTCASE_CONFIG.subnet_2_cidr,
- network_2_id)
+
+ subnet_2_id = test_utils.create_subnet(
+ neutron_client,
+ TESTCASE_CONFIG.subnet_2_name,
+ TESTCASE_CONFIG.subnet_2_cidr,
+ network_2_id)
+
+ interfaces.append(tuple((router_1_id, subnet_1_id)))
+ network_ids.extend([network_1_id, network_2_id])
+ router_ids.append(router_1_id)
+ subnet_ids.extend([subnet_1_id, subnet_2_id])
sg_id = os_utils.create_security_group_full(neutron_client,
TESTCASE_CONFIG.secgroup_name,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
userdata=u1)
+ instance_ids.extend([vm_1.id, vm_2.id])
results.record_action("Create VPN with eRT==iRT")
- vpn_name = "sdnvpn-7"
+ vpn_name = "sdnvpn-8"
kwargs = {"import_targets": TESTCASE_CONFIG.targets,
"export_targets": TESTCASE_CONFIG.targets,
"route_distinguishers": TESTCASE_CONFIG.route_distinguishers,
bgpvpn = os_utils.create_bgpvpn(neutron_client, **kwargs)
bgpvpn_id = bgpvpn['bgpvpn']['id']
logger.debug("VPN created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
msg = ("Associate router '%s' and net '%s' to the VPN."
% (TESTCASE_CONFIG.router_1_name,
results.record_action(msg)
fip = os_utils.create_floating_ip(neutron_client)
+
fip_added = os_utils.add_floating_ip(nova_client, vm_1.id, fip['fip_addr'])
if fip_added:
results.add_success(msg)
results.add_to_summary(0, "-")
results.ping_ip_test(fip['fip_addr'])
+ floatingip_ids.append(fip['fip_id'])
+
+ test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids,
+ image_ids)
+ test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces,
+ subnet_ids, router_ids, network_ids)
return results.compile_summary()