def openstack_add_subnet(self, tenantName, netName, subnetName, subnet_ip, dnsNameServers=None): '''create subnet Input: network name , Subnet name , Subnet (e.g app-net , app-net1, 50.0.0.0/24) Return: id for created subnet ''' t = test.Test() os1 = t.openstack_server('os1') tenantId = self.openstack_show_tenant(tenantName) if dnsNameServers is None: try: os1.bash( "neutron subnet-create --tenant-id %s --name %s %s %s" % (tenantId, netName, subnetName, subnet_ip)) except: output = helpers.exception_info_value() helpers.log("Output: %s" % output) return False else: try: os1.bash( "neutron subnet-create --tenant-id %s --name %s %s %s --dns_nameservers list=true %s" % (tenantId, netName, subnetName, subnet_ip, dnsNameServers)) except: output = helpers.exception_info_value() helpers.log("Output: %s" % output) return False return True
def openstack_add_net(self, tenantName, netName, external=False): '''create network Input: 'networkNum` Network name neutron net-create --tenant-id $adminid External-Network --router:external=True Return: id of created Router ''' t = test.Test() os1 = t.openstack_server('os1') tenantId = self.openstack_show_tenant(tenantName) if external is False: try: os1.bash("neutron net-create --tenant-id %s %s " % (tenantId, netName)) except: output = helpers.exception_info_value() helpers.log("Output: %s" % output) return False else: try: os1.bash( "neutron net-create --tenant-id %s %s --router:external=True" % (tenantId, netName)) except: output = helpers.exception_info_value() helpers.log("Output: %s" % output) return False return True
def bash_delete_tag(self, node, intf, soft_error=True): """ Function to remove the vlan tag from the host eth interfaces. Note: soft_error=True because in the common use case, we just want to log the error but not trigger failure. """ t = test.Test() n = t.node(node) try: n.sudo("vconfig rem %s" % intf) except: output = helpers.exception_info_value() helpers.log("Output: %s" % output) # Catch error: # ERROR: trying to remove VLAN -:eth1.20:- error: No such device if helpers.any_match(str(output), r'error: No such devices'): helpers.test_error( "vconfig rem error - no such device '%s'" % intf, soft_error) return False else: helpers.test_error( 'Uncaught exception:\n%s' % helpers.exception_info(), soft_error) return False return True
def openstack_delete_net(self, netName): '''delete network Input: 'networkNum` Network name Return: True ''' t = test.Test() os1 = t.openstack_server('os1') try: os1.bash("neutron net-delete %s " % (netName)) except: output = helpers.exception_info_value() helpers.log("Output: %s" % output) return True return True
def openstack_delete_instance(self, instanceName): '''delete instance Input: source the tenant rc file which which includes , tenant name , user, passowrd `instanceName` instance name to be deleted. Return: empty string ''' t = test.Test() os1 = t.openstack_server('os1') try: os1.bash("nova delete %s" % (instanceName)) except: output = helpers.exception_info_value() helpers.log("Output: %s" % output) return True return True