diff options
author | Luc Provoost <luc.provoost@intel.com> | 2018-06-15 22:39:28 +0200 |
---|---|---|
committer | Deepak S <deepak.s@linux.intel.com> | 2018-06-17 12:50:56 +0000 |
commit | 56d346c9b5faf21654b1a72eca53389c9dbd8add (patch) | |
tree | 3e33cb27be59011dbf8ac480f85c6220e0e475be /VNFs/DPPD-PROX/helper-scripts/openstackrapid/createrapid.py | |
parent | ca5ac3a8b9b3c148ce783749c0243da3ecbdfe98 (diff) |
Adding centos.json to be used with packer to generate a VM with PROX
Based on a CentOS cloud image downloadable from the web, you can now use
packer to create an image that has DPDK and PROX installed in the
proper directories. The VM is also tuned for guest VNFs.
A service is also created to deal with the proper isolated_cpu settings
for tuned. The service will also make sure uio and igb_uio are loaded.
The prox_user_data.sh is not needed any more and hence deleted.
ctrl-c of runrapid.py will now also stop prox in all the VMs so a new
test can be started.
Change-Id: I16cc59878e2d4912757f42e05f98d51dff5feb89
Signed-off-by: Luc Provoost <luc.provoost@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX/helper-scripts/openstackrapid/createrapid.py')
-rwxr-xr-x | VNFs/DPPD-PROX/helper-scripts/openstackrapid/createrapid.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/VNFs/DPPD-PROX/helper-scripts/openstackrapid/createrapid.py b/VNFs/DPPD-PROX/helper-scripts/openstackrapid/createrapid.py index ffba5013..f21b91d7 100755 --- a/VNFs/DPPD-PROX/helper-scripts/openstackrapid/createrapid.py +++ b/VNFs/DPPD-PROX/helper-scripts/openstackrapid/createrapid.py @@ -31,7 +31,7 @@ from logging import handlers from prox_ctrl import prox_ctrl import ConfigParser -version="18.3.27" +version="18.6.15" stack = "rapid" #Default string for stack. This is not an OpenStack Heat stack, just a group of VMs vms = "rapidVMs" #Default string for vms file key = "prox" # default name for kay @@ -296,7 +296,8 @@ else: log.exception("Failed to create subnet: " + subnet) raise Exception("Failed to create subnet: " + subnet) - +ServerToBeCreated=[] +ServerName=[] config = ConfigParser.RawConfigParser() vmconfig = ConfigParser.RawConfigParser() vmconfig.read(vms+'.vms') @@ -306,16 +307,18 @@ for vm in range(1, int(total_number_of_VMs)+1): flavor_meta_data = vmconfig.get('VM%d'%vm, 'flavor_meta_data') boot_info = vmconfig.get('VM%d'%vm, 'boot_info') SRIOV_port = vmconfig.get('VM%d'%vm, 'SRIOV_port') - server_name = '%s-VM%d'%(stack,vm) + ServerName.append('%s-VM%d'%(stack,vm)) flavor_name = '%s-VM%d-flavor'%(stack,vm) - log.debug("Checking server: "+server_name) - cmd = 'openstack server show '+server_name + log.debug("Checking server: "+ServerName[-1]) + cmd = 'openstack server show '+ServerName[-1] log.debug (cmd) cmd = cmd + ' |grep "\sname\s" | tr -s " " | cut -d" " -f 4' ServerExist = subprocess.check_output(cmd , shell=True).strip() - if ServerExist == server_name: - log.info("Server ("+server_name+") already active") + if ServerExist == ServerName[-1]: + log.info("Server ("+ServerName[-1]+") already active") + ServerToBeCreated.append("no") else: + ServerToBeCreated.append("yes") # Checking if the flavor already exists, if not create it log.debug("Checking flavor: "+flavor_name) cmd = 'openstack flavor show '+flavor_name @@ -353,24 +356,25 @@ for vm in range(1, int(total_number_of_VMs)+1): else: wait = ' ' log.info("Creating server...") - cmd = 'openstack server create --flavor %s --key-name %s --image %s %s %s%s%s'%(flavor_name,key,image,nic_info,boot_info,wait,server_name) + cmd = 'openstack server create --flavor %s --key-name %s --image %s %s %s%s%s'%(flavor_name,key,image,nic_info,boot_info,wait,ServerName[-1]) log.debug(cmd) cmd = cmd + ' |grep "\sname\s" | tr -s " " | cut -d" " -f 4' ServerExist = subprocess.check_output(cmd , shell=True).strip() - if floating_network <> 'NO': +if floating_network <> 'NO': + for vm in range(0, int(total_number_of_VMs)): + if ServerToBeCreated[vm] =="yes": log.info('Creating floating IP ...') cmd = 'openstack floating ip create ' + floating_network log.debug(cmd) cmd = cmd + ' |grep "floating_ip_address " | tr -s " " | cut -d"|" -f 3' vmAdminIP = subprocess.check_output(cmd , shell=True).strip() log.info('Associating floating IP ...') - cmd = 'openstack server add floating ip %s %s'%(server_name,vmAdminIP) + cmd = 'openstack server add floating ip %s %s'%(ServerName[vm],vmAdminIP) log.debug(cmd) output = subprocess.check_output(cmd , shell=True).strip() - print (output) + for vm in range(1, int(total_number_of_VMs)+1): - server_name = '%s-VM%d'%(stack,vm) - cmd = 'openstack server show %s'%(server_name) + cmd = 'openstack server show %s'%(ServerName[vm-1]) log.debug(cmd) output = subprocess.check_output(cmd , shell=True).strip() searchString = '.*%s.*?([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*)' %(dataplane_network) @@ -381,15 +385,15 @@ for vm in range(1, int(total_number_of_VMs)+1): vmAdminIP = matchObj.group(2) if vmAdminIP == None: vmAdminIP = matchObj.group(1) - cmd = 'openstack port list |grep %s | tr -s " " | cut -d"|" -f 4'%(vmDPIP) + cmd = 'openstack port list |egrep "\\b%s\\b" | tr -s " " | cut -d"|" -f 4'%(vmDPIP) log.debug(cmd) vmDPmac = subprocess.check_output(cmd , shell=True).strip() config.add_section('M%d'%vm) - config.set('M%d'%vm, 'name', server_name) + config.set('M%d'%vm, 'name', ServerName[vm-1]) config.set('M%d'%vm, 'admin_ip', vmAdminIP) config.set('M%d'%vm, 'dp_ip', vmDPIP) config.set('M%d'%vm, 'dp_mac', vmDPmac) - log.info('%s: (admin IP: %s), (dataplane IP: %s), (dataplane MAC: %s)' % (server_name,vmAdminIP,vmDPIP,vmDPmac)) + log.info('%s: (admin IP: %s), (dataplane IP: %s), (dataplane MAC: %s)' % (ServerName[vm-1],vmAdminIP,vmDPIP,vmDPmac)) config.add_section('OpenStack') config.set('OpenStack', 'stack', stack) |