JIRA: FUNCTEST-93
Change-Id: I9472c1183eea86b0c018059aa17b76bd2932ad8e
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
print "Error:", sys.exc_info()[0]
return False
print "Error:", sys.exc_info()[0]
return False
+def delete_neutron_port(neutron_client, port_id):
+ try:
+ neutron_client.delete_port(port_id)
+ return True
+ except:
+ print "Error:", sys.exc_info()[0]
+ return False
def get_network_id(neutron_client, network_name):
networks = neutron_client.list_networks()['networks']
def get_network_id(neutron_client, network_name):
networks = neutron_client.list_networks()['networks']
-def cleanup(nova, neutron, network_dic):
+def cleanup(nova, neutron, network_dic, port_id1, port_id2):
# delete both VMs
logger.info("Cleaning up...")
# delete both VMs
logger.info("Cleaning up...")
subnet_id = network_dic["subnet_id"]
router_id = network_dic["router_id"]
subnet_id = network_dic["subnet_id"]
router_id = network_dic["router_id"]
+
+ if not functest_utils.delete_neutron_port(neutron, port_id1):
+ logger.error("Unable to remove port '%s'" %port_id1)
+ return False
+ logger.debug("Port '%s' removed successfully" %port_id1)
+
+ if not functest_utils.delete_neutron_port(neutron, port_id2):
+ logger.error("Unable to remove port '%s'" %port_id2)
+ return False
+ logger.debug("Port '%s' removed successfully" %port_id2)
+
if not functest_utils.remove_interface_router(neutron, router_id,
subnet_id):
logger.error("Unable to remove subnet '%s' from router '%s'" % (
if not functest_utils.remove_interface_router(neutron, router_id,
subnet_id):
logger.error("Unable to remove subnet '%s' from router '%s'" % (
# create VM
logger.debug("Creating port 'vping-port-1' with IP %s..." % IP_1)
# create VM
logger.debug("Creating port 'vping-port-1' with IP %s..." % IP_1)
- port_id = functest_utils.create_neutron_port(neutron_client,
+ port_id1 = functest_utils.create_neutron_port(neutron_client,
"vping-port-1", network_id,
IP_1)
"vping-port-1", network_id,
IP_1)
logger.error("Unable to create port.")
exit(-1)
logger.error("Unable to create port.")
exit(-1)
flavor=flavor,
image=image,
# nics = [{"net-id": network_id, "v4-fixed-ip": IP_1}]
flavor=flavor,
image=image,
# nics = [{"net-id": network_id, "v4-fixed-ip": IP_1}]
- nics=[{"port-id": port_id}]
+ nics=[{"port-id": port_id1}]
)
# wait until VM status is active
)
# wait until VM status is active
# create VM
logger.debug("Creating port 'vping-port-2' with IP %s..." % IP_2)
# create VM
logger.debug("Creating port 'vping-port-2' with IP %s..." % IP_2)
- port_id = functest_utils.create_neutron_port(neutron_client,
+ port_id2 = functest_utils.create_neutron_port(neutron_client,
"vping-port-2", network_id,
IP_2)
"vping-port-2", network_id,
IP_2)
logger.error("Unable to create port.")
exit(-1)
logger.info("Creating instance '%s' with IP %s..." % (NAME_VM_2, IP_2))
logger.error("Unable to create port.")
exit(-1)
logger.info("Creating instance '%s' with IP %s..." % (NAME_VM_2, IP_2))
flavor=flavor,
image=image,
# nics = [{"net-id": network_id, "v4-fixed-ip": IP_2}],
flavor=flavor,
image=image,
# nics = [{"net-id": network_id, "v4-fixed-ip": IP_2}],
- nics=[{"port-id": port_id}],
+ nics=[{"port-id": port_id2}],
logger.debug("No vPing detected...")
sec += 1
logger.debug("No vPing detected...")
sec += 1
- cleanup(nova_client, neutron_client, network_dic)
+ cleanup(nova_client, neutron_client, network_dic, port_id1, port_id2)
test_status = "NOK"
if EXIT_CODE == 0:
test_status = "NOK"
if EXIT_CODE == 0: