Fix the support of VMTP on provider network
1. Fix the support of running VMTP on provider network; 2. Add CLI command to parse the reusing network; Change-Id: I90b972902508ef24ac4f348b02e9ff801c72e567
This commit is contained in:
parent
e194dbeacc
commit
92dacb0588
@ -54,15 +54,18 @@ vm_image_url: ''
|
|||||||
# a specific existing external network. If empty, the script will reuse the
|
# a specific existing external network. If empty, the script will reuse the
|
||||||
# first external network it can find (the cloud must have at least 1
|
# first external network it can find (the cloud must have at least 1
|
||||||
# external network defined and available for use)
|
# external network defined and available for use)
|
||||||
# When set, ignore floating ip creation and reuse existing management network for tests
|
#
|
||||||
reuse_network_name :
|
# NOTE: When set, router and floating ip creation will be ignored, and the
|
||||||
|
# existing management network will be used for tests. This is used for runnig
|
||||||
|
# VMTP on a provider network.
|
||||||
|
reuse_network_name:
|
||||||
|
|
||||||
# Use of the script for special deployments
|
# Use of the script for special deployments
|
||||||
floating_ip: True
|
floating_ip: True
|
||||||
|
|
||||||
# Set this to an existing VM name if the script should not create new VM
|
# Set this to an existing VM name if the script should not create new VM
|
||||||
# and reuse existing VM
|
# and reuse existing VM
|
||||||
reuse_existing_vm :
|
reuse_existing_vm:
|
||||||
|
|
||||||
# Set config drive to true to bypass metadata service and use config drive
|
# Set config drive to true to bypass metadata service and use config drive
|
||||||
# An option of config_drive to True is provided to nova boot to enable this
|
# An option of config_drive to True is provided to nova boot to enable this
|
||||||
|
134
vmtp/network.py
134
vmtp/network.py
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from vmtp import VmtpException
|
||||||
|
|
||||||
# Module containing a helper class for operating on OpenStack networks
|
# Module containing a helper class for operating on OpenStack networks
|
||||||
from neutronclient.common.exceptions import NetworkInUseClient
|
from neutronclient.common.exceptions import NetworkInUseClient
|
||||||
from neutronclient.common.exceptions import NeutronException
|
from neutronclient.common.exceptions import NeutronException
|
||||||
@ -45,85 +47,89 @@ class Network(object):
|
|||||||
|
|
||||||
# If reusing existing management network just find this network
|
# If reusing existing management network just find this network
|
||||||
if self.config.reuse_network_name:
|
if self.config.reuse_network_name:
|
||||||
# An existing management network must be reused
|
try:
|
||||||
int_net = self.lookup_network(self.config.reuse_network_name)
|
# An existing management network must be reused
|
||||||
self.vm_int_net.append(int_net)
|
int_net = self.lookup_network(self.config.reuse_network_name)
|
||||||
return
|
self.vm_int_net.append(int_net)
|
||||||
|
except IndexError:
|
||||||
##############################################
|
raise VmtpException("Unable to find the network to be reused.")
|
||||||
# If a user provided ext_net_name is not available,
|
return
|
||||||
# then find the first network that is external
|
else:
|
||||||
##############################################
|
##############################################
|
||||||
for network in self.networks:
|
# If a user provided ext_net_name is not available,
|
||||||
if network['router:external']:
|
# then find the first network that is external
|
||||||
try:
|
##############################################
|
||||||
if network['name'] == config.ext_net_name:
|
for network in self.networks:
|
||||||
|
if network['router:external']:
|
||||||
|
try:
|
||||||
|
if network['name'] == config.ext_net_name:
|
||||||
|
self.ext_net = network
|
||||||
|
break
|
||||||
|
if not self.ext_net:
|
||||||
|
self.ext_net = network
|
||||||
|
except AttributeError:
|
||||||
|
###############################################
|
||||||
|
# A attribute error indicates, no user defined
|
||||||
|
# external network defined, so use the first one
|
||||||
|
###############################################
|
||||||
self.ext_net = network
|
self.ext_net = network
|
||||||
break
|
break
|
||||||
if not self.ext_net:
|
|
||||||
self.ext_net = network
|
|
||||||
except AttributeError:
|
|
||||||
###############################################
|
|
||||||
# A attribute error indicates, no user defined
|
|
||||||
# external network defined, so use the first one
|
|
||||||
###############################################
|
|
||||||
self.ext_net = network
|
|
||||||
break
|
|
||||||
|
|
||||||
if not self.ext_net:
|
if not self.ext_net:
|
||||||
print "No external network found."
|
print "No external network found."
|
||||||
return
|
return
|
||||||
|
|
||||||
print "Using external network: " + self.ext_net['name']
|
print "Using external network: " + self.ext_net['name']
|
||||||
|
|
||||||
# Find or create the router to the external network
|
# Find or create the router to the external network
|
||||||
ext_net_id = self.ext_net['id']
|
ext_net_id = self.ext_net['id']
|
||||||
routers = neutron_client.list_routers()['routers']
|
routers = neutron_client.list_routers()['routers']
|
||||||
for router in routers:
|
for router in routers:
|
||||||
external_gw_info = router['external_gateway_info']
|
external_gw_info = router['external_gateway_info']
|
||||||
if external_gw_info:
|
if external_gw_info:
|
||||||
if external_gw_info['network_id'] == ext_net_id:
|
if external_gw_info['network_id'] == ext_net_id:
|
||||||
self.ext_router = router
|
self.ext_router = router
|
||||||
print 'Found external router: %s' % \
|
print 'Found external router: %s' % \
|
||||||
(self.ext_router['name'])
|
(self.ext_router['name'])
|
||||||
break
|
break
|
||||||
|
|
||||||
# create a new external router if none found and a name was given
|
# create a new external router if none found and a name was given
|
||||||
self.ext_router_name = config.router_name
|
self.ext_router_name = config.router_name
|
||||||
if (not self.ext_router) and self.ext_router_name:
|
if (not self.ext_router) and self.ext_router_name:
|
||||||
self.ext_router = self.create_router(self.ext_router_name,
|
self.ext_router = self.create_router(self.ext_router_name,
|
||||||
self.ext_net['id'])
|
self.ext_net['id'])
|
||||||
print '[%s] Created ext router' % (self.ext_router_name)
|
print '[%s] Created ext router' % (self.ext_router_name)
|
||||||
self.ext_router_created = True
|
self.ext_router_created = True
|
||||||
|
|
||||||
if config.ipv6_mode:
|
if config.ipv6_mode:
|
||||||
self.ipv6_enabled = True
|
self.ipv6_enabled = True
|
||||||
|
|
||||||
# Create the networks and subnets depending on v4 or v6
|
# Create the networks and subnets depending on v4 or v6
|
||||||
if config.ipv6_mode:
|
if config.ipv6_mode:
|
||||||
for (net, subnet, cidr, subnet_ipv6, cidr_ipv6) in zip(config.internal_network_name,
|
for (net, subnet, cidr, subnet_v6, cidr_v6) in zip(config.internal_network_name,
|
||||||
config.internal_subnet_name,
|
config.internal_subnet_name,
|
||||||
config.internal_cidr,
|
config.internal_cidr,
|
||||||
config.internal_subnet_name_ipv6,
|
config.internal_subnet_name_v6,
|
||||||
config.internal_cidr_v6):
|
config.internal_cidr_v6):
|
||||||
int_net = self.create_net(net, subnet, cidr,
|
int_net = self.create_net(net, subnet, cidr,
|
||||||
config.dns_nameservers,
|
config.dns_nameservers,
|
||||||
subnet_ipv6, cidr_ipv6, config.ipv6_mode)
|
subnet_v6, cidr_v6, config.ipv6_mode)
|
||||||
self.vm_int_net.append(int_net)
|
self.vm_int_net.append(int_net)
|
||||||
else:
|
else:
|
||||||
for (net, subnet, cidr) in zip(config.internal_network_name,
|
for (net, subnet, cidr) in zip(config.internal_network_name,
|
||||||
config.internal_subnet_name,
|
config.internal_subnet_name,
|
||||||
config.internal_cidr):
|
config.internal_cidr):
|
||||||
int_net = self.create_net(net, subnet, cidr,
|
int_net = self.create_net(net, subnet, cidr,
|
||||||
config.dns_nameservers)
|
config.dns_nameservers)
|
||||||
self.vm_int_net.append(int_net)
|
self.vm_int_net.append(int_net)
|
||||||
|
|
||||||
|
# Add both internal networks to router interface to enable
|
||||||
|
# network to network connectivity
|
||||||
|
self.__add_router_interface()
|
||||||
|
|
||||||
self.l2agent_type = self._get_l2agent_type()
|
self.l2agent_type = self._get_l2agent_type()
|
||||||
self.internal_iface_dict = self._get_internal_iface_dict()
|
self.internal_iface_dict = self._get_internal_iface_dict()
|
||||||
|
|
||||||
# Add both internal networks to router interface to enable network to network connectivity
|
|
||||||
self.__add_router_interface()
|
|
||||||
|
|
||||||
# Create a network with associated subnet
|
# Create a network with associated subnet
|
||||||
# Check first if a network with the same name exists, if it exists
|
# Check first if a network with the same name exists, if it exists
|
||||||
# return that network.
|
# return that network.
|
||||||
|
12
vmtp/vmtp.py
12
vmtp/vmtp.py
@ -262,7 +262,9 @@ class VmtpTest(object):
|
|||||||
if self.config.reuse_network_name:
|
if self.config.reuse_network_name:
|
||||||
# VM needs to connect to existing management and new data network
|
# VM needs to connect to existing management and new data network
|
||||||
# Reset the management network name
|
# Reset the management network name
|
||||||
self.config.internal_network_name[0] = self.config.reuse_network_name
|
int_net_name = list(self.config.internal_network_name)
|
||||||
|
int_net_name[0] = self.config.reuse_network_name
|
||||||
|
self.config.internal_network_name = int_net_name
|
||||||
else:
|
else:
|
||||||
# Make sure we have an external network and an external router
|
# Make sure we have an external network and an external router
|
||||||
self.assert_true(self.net.ext_net)
|
self.assert_true(self.net.ext_net)
|
||||||
@ -756,6 +758,11 @@ def parse_opts_from_cli():
|
|||||||
'e.g. --udpbuf 128,2048. (default=128,1024,8192)',
|
'e.g. --udpbuf 128,2048. (default=128,1024,8192)',
|
||||||
metavar='<udp_pkt_size1,...>')
|
metavar='<udp_pkt_size1,...>')
|
||||||
|
|
||||||
|
parser.add_argument('--reuse_network_name', dest='reuse_network_name',
|
||||||
|
action='store',
|
||||||
|
default=None,
|
||||||
|
help='the network to be reused for performing tests')
|
||||||
|
|
||||||
parser.add_argument('--no-env', dest='no_env',
|
parser.add_argument('--no-env', dest='no_env',
|
||||||
default=False,
|
default=False,
|
||||||
action='store_true',
|
action='store_true',
|
||||||
@ -903,6 +910,9 @@ def merge_opts_to_configs(opts):
|
|||||||
'integers seperated by comma.'
|
'integers seperated by comma.'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if opts.reuse_network_name:
|
||||||
|
config.reuse_network_name = opts.reuse_network_name
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
# Set Ganglia server ip and port if the monitoring (-m)
|
# Set Ganglia server ip and port if the monitoring (-m)
|
||||||
# option is enabled.
|
# option is enabled.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user