Exemple #1
0
def SetUpConfig(cntlr_ip,apic_ip,agg_name,avail_zone_name,az_comp_node_name,heat_stack_name,heat_temp_file,):
        """
        Test Step using Heat, setup the Test Config
        """
        gbpheat = gbpHeat(cntlr_ip)
        gbpnova = gbpNova(cntlr_ip)
        print ("\nSetupCfg: Create Aggregate & Availability Zone to be executed\n")
        agg_id = self.gbpnova.avail_zone('api','create',agg_name,avail_zone_name=avail_zone_name)
        if agg_id == 0:
            print ("\n ABORTING THE TESTSUITE RUN,nova host aggregate creation Failed")
            return 0
        print (" Agg %s" %(self.agg_id))
        if gbpnova.avail_zone('api','addhost',agg_id,hostname=az_comp_node_name) == 0:
            print ("\n ABORTING THE TESTSUITE RUN, availability zone creation Failed")
            gbpnova.avail_zone('api','delete',self.nova_agg,avail_zone_name=self.nova_az) # Cleaning up
            return 0
        sleep(3)
        if self.gbpheat.cfg_all_cli(1,heat_stack_name,heat_temp=heat_temp_file) == 0:
           print ("\n ABORTING THE TESTSUITE RUN, HEAT STACK CREATE of %s Failed" %(heat_stack_name))
           CleanUp(agg_id,az_comp_node_name,heat_stack_name)
           return 0
        sleep(5) # Sleep 5s assuming that all objects areated in APIC
        print ("\n ADDING SSH-Filter to Svc_epg created for every dhcp_agent")
        svc_epg_list = ['demo_bd']
        create_add_filter(apic_ip,svc_epg_list)
        return 1
    def __init__(self, ostack_cntrlr_ip, vm_list, ntk_node):

        self.ntk_node = ntk_node
        self.gbpcfg = gbpCfgCli(ostack_cntrlr_ip, cntrlr_username=CNTRLR_USR,
                 cntrlr_passwd=CNTRLR_PASSWD, rcfile=RCFILE)
        self.gbpnova = gbpNova(ostack_cntrlr_ip,cntrlr_uname=CNTRLR_USR,cntrlr_passwd=CNTRLR_PASSWD,
                  keystone_user=KEY_USER,keystone_password=KEY_PASSWD)
        self.vm_list = vm_list
        #print " List of VMs passed from the testsuite ", vm_list
        self.vm_to_ip_ns = {}
        """
Exemple #3
0
    def __init__(self):
        """
        Iniatizing the test-cfg variables & classes
        """
	self.apicsystemID = conf['apic_system_id']
        self.nova_agg = conf['nova_agg_name']
        self.nova_az = conf['nova_az_name']
        self.comp_node = conf['az_comp_node']
        self.network_node = conf['network_node']
        self.cntlr_ip = conf['controller_ip']
        self.cntlr_user = conf.get('controller_user') or 'root'
        self.cntlr_passwd = conf.get('controller_password') or 'noir0123'
        self.key_ip = conf.get('keystone_ip') or self.cntlr_ip
        self.key_user = conf.get('keystone_user') or 'admin'
        self.key_passwd = conf.get('keystone_password') or 'noir0123'
        self.apic_ip = conf['apic_ip']
        self.leaf1_ip = conf['leaf1_ip']
        self.leaf2_ip = conf['leaf2_ip']
        self.spine_ip = conf['spine_ip']
        self.apic_passwd = conf.get('apic_passwd')
        self.heat_temp_test = conf['main_setup_heat_temp']
        self.num_hosts = conf['num_comp_nodes']
        self.heat_stack_name = conf['heat_dp_stack_name']
	self.pausetodebug = conf['pausetodebug']
        self.test_parameters = conf['test_parameters']
	self.plugin = conf['plugin-type']
        self.gbpnova = gbpNova(self.cntlr_ip,cntrlr_uname=self.cntlr_user,cntrlr_passwd=self.cntlr_passwd,
                  keystone_user=self.key_user,keystone_password=self.key_passwd)
        self.gbpheat = gbpHeat(self.cntlr_ip,cntrlr_uname=self.cntlr_user, cntrlr_passwd=self.cntlr_passwd)
	if self.plugin: #Incase of MergedPlugin
            if self.apic_passwd:
                self.gbpaci = gbpApic(self.apic_ip, mode='aim',
                                      password=self.apic_passwd)
            else:
                self.gbpaci = gbpApic(self.apic_ip, mode='aim')
	else:
            self.gbpaci = gbpApic(self.apic_ip, password=self.apic_passwd,
			       apicsystemID=self.apicsystemID) 
	self.vmlist = ['VM1','VM2','VM3','VM4',
		       'VM5','VM6','VM7','VM8',
		       'VM9','VM10','VM11','VM12'	
		      ]
        #Below L2Ps needed for APIC Verification
        self.L2plist = [
                        'demo_same_ptg_l2p_l3p_bd',
                        'demo_diff_ptg_same_l2p_l3p_bd',
                        'demo_diff_ptg_l2p_same_l3p_bd_1',
                        'demo_diff_ptg_l2p_same_l3p_bd_2',
                        'demo_srvr_bd', 'demo_clnt_bd'
                       ]
Exemple #4
0
    def __init__(self,params):

      self.gbpaci = Gbp_Aci()
      self.heat_stack_name = 'gbpapic1'
      cntlr_ip = params['cntlr_ip']
      self.heat_temp_test = params['heat_temp_file']
      self.gbpheat = gbpHeat(cntlr_ip)
      self.gbpnova = gbpNova(cntlr_ip)
      self.leaf_ip = params['leaf1_ip']
      self.apic_ip = params['apic_ip']
      self.network_node = params['network_node']
      self.az_comp_node = params['az_comp_node']
      self.nova_agg = params['nova_agg']
      self.nova_az = params['nova_az']
      self.debug = params['pausetodebug']
class super_hdr(object):
    # Name of the config file is static
    nova_az = conf['nova_az_name']
    cntlr_ip = conf['controller_ip']
    cntlr_user = conf.get('controller_user') or 'root'
    cntlr_passwd = conf.get('controller_password') or 'noir0123'
    apic_ip = conf['apic_ip']
    apic_passwd = conf['apic_passwd']
    num_host = conf['num_comp_nodes']
    heat_temp = conf['main_setup_heat_temp']
    stack_name = conf['heat_dp_stack_name']
    vm_image = conf['vm_image']
    sshkeyname = conf['key_name']
    network_node = conf['network_node']
    apicsystemID = conf['apic_system_id']
    pausetodebug = conf['pausetodebug']
    plugin = conf['plugin-type']
    gbpcfg = gbpCfgCli(cntlr_ip,
                       cntrlr_username=cntlr_user,
                       cntrlr_passwd=cntlr_passwd,
                       rcfile=rcfile)
    gbpnova = gbpNova(cntlr_ip)
    gbpheat = gbpHeat(cntlr_ip)

    def vm_create(self, ptgs, vmlist):
        """
        Create VMs
        """
        # ptg_id should be a dict with keys as 'data' & 'mgmt'
        # vm_list: list of dicts
        for vm in vmlist:
            for key, val in ptgs.iteritems():
                port = self.gbpcfg.gbp_policy_cfg_all(
                    1,
                    'target',
                    'vm_%s' % (key),
                    policy_target_group='%s' % (val))
                if port != 0:
                    vm[key] = port[1]
                else:
                    raise TestSuiteAbort("Policy Targets creation Failed")
                print vm
            # removed mgmt_nic
            if self.gbpnova.vm_create_cli(vm['name'],
                                          self.vm_image,
                                          vm['data'],
                                          avail_zone=vm['az']) == 0:
                return 0
    def __init__(self,params):

      self.gbpcfg = gbpCfgCli()
      self.gbpaci = Gbp_Aci()
      self.heat_stack_name = 'gbpleaf5'
      cntlr_ip = params['cntlr_ip']
      self.heat_temp_test = params['heat_temp_file']
      self.gbpheat = gbpHeat(cntlr_ip)
      self.gbpnova = gbpNova(cntlr_ip)
      self.leaf_ip = params['leaf1_ip']
      self.apic_ip = params['apic_ip']
      self.network_node = params['network_node']
      self.az_comp_node = params['az_comp_node']
      self.nova_agg = params['nova_agg']
      self.nova_az = params['nova_az']
      self.comp_nodes = params['comp_node_ips']
    def __init__(self,params):

      self.gbpaci = Gbp_Aci()
      self.heat_stack_name = 'gbpvpc5'
      cntlr_ip = params['cntlr_ip']
      self.heat_temp_test = params['heat_temp_file']
      self.gbpheat = gbpHeat(cntlr_ip)
      self.gbpnova = gbpNova(cntlr_ip)
      self.apic_ip = params['apic_ip']
      self.az_comp_node = params['az_comp_node']
      self.nova_agg = params['nova_agg']
      self.nova_az = params['nova_az']
      self.network_node = params['network_node']
      self.leaf1_port_comp_node1 = params['leaf1_port1'] #This connects Leaf1 to Comp-node1
      self.leaf1_port_comp_node2 = params['leaf1_port2'] #This connects Leaf1 to Comp-node2
      self.node_id = params['leaf1_node_id']
Exemple #8
0
    def __init__(self, ostack_cntrlr_ip, vm_list, ntk_node):

        self.ntk_node = ntk_node
        self.gbpcfg = gbpCfgCli(ostack_cntrlr_ip,
                                cntrlr_username=CNTRLR_USR,
                                cntrlr_passwd=CNTRLR_PASSWD,
                                rcfile=RCFILE)
        self.gbpnova = gbpNova(ostack_cntrlr_ip,
                               cntrlr_uname=CNTRLR_USR,
                               cntrlr_passwd=CNTRLR_PASSWD,
                               keystone_user=KEY_USER,
                               keystone_password=KEY_PASSWD)
        self.vm_list = vm_list
        #print " List of VMs passed from the testsuite ", vm_list
        self.vm_to_ip_ns = {}
        """
    def __init__(self, params):

        self.gbpaci = Gbp_Aci()
        self.heat_stack_name = 'gbpleaf1'
        cntlr_ip = params['cntlr_ip']
        self.heat_temp_test = params['heat_temp_file']
        self.gbpheat = gbpHeat(cntlr_ip)
        self.gbpnova = gbpNova(cntlr_ip)
        self.leaf_ip = params['leaf1_ip']
        self.apic_ip = params['apic_ip']
        self.network_node = params['network_node']
        self.az_comp_node = params['az_comp_node']
        self.nova_agg = params['nova_agg']
        self.nova_az = params['nova_az']
        self.leaf_port_comp_node1 = params[
            'leaf1_port1']  #This connects Leaf to Comp-node1
        self.node_id = params['leaf1_node_id']
Exemple #10
0
    def __init__(self, ostack_cntrlr_ip, vm_list, ntk_node):

        self.ntk_node = ntk_node
        gbpcfg = gbpCfgCli(ostack_cntrlr_ip)
        gbpnova = gbpNova(ostack_cntrlr_ip)
        self.vm_list = vm_list
        print " List of VMs passed from the testsuite ", vm_list
        self.vm_to_ip_ns = {}
        for vm in self.vm_list:
            #vm_to_ip_list = gbpnova.get_any_vm_property(vm)['networks'][0]
            vm_to_ip_list = gbpnova.get_any_vm_property(vm)[0]
            vm_to_ip_list = [ip.encode('ascii') for ip in vm_to_ip_list]
            src_vm_pvt_ip_subnet = re.search('(\d+.\d+.\d+).\d+',
                                             vm_to_ip_list[0].encode('ascii'),
                                             re.I).group(1)
            src_vm_dhcp_ns = gbpcfg.get_netns(vm)
            #src_vm_dhcp_ns = gbpcfg.get_netns(
            #    self.ntk_node, src_vm_pvt_ip_subnet)
            self.vm_to_ip_ns[vm] = [vm_to_ip_list, src_vm_dhcp_ns]
        print 'VM-to-IP-NS == %s' % (self.vm_to_ip_ns)
    def __init__(self, objs_uuid, dest_vm_fips):
        """
        Traffic Test Class between ExternalGWRtr and Tenant VM
        VMs/Endpoints behind Border and Non-Border Leaf
        In this class we send Traffic b/w ExtGWRtr and end-points Web-Server(compnode-1)
        And App-Server(compnode-2)
        """
        self.extgwrtr = objs_uuid['external_gw']
        self.ostack_controller = objs_uuid['ostack_controller']
        self.network_node = objs_uuid['network_node']
        self.external_pol_1 = objs_uuid['mgmt_external_policy_id']
        self.external_pol_2 = objs_uuid['dc_external_policy_id']
        self.ext_seg_1 = objs_uuid['mgmt_external_segment_id']
        self.ext_seg_2 = objs_uuid['dc_external_segment_id']
        self.websrvr_ptg = objs_uuid['web_srvr_ptg_id']
        self.webclnt_ptg = objs_uuid['web_clnt_ptg_id']
        self.appsrvr_ptg = objs_uuid['app_ptg_id']
        self.test_3_prs = {objs_uuid['shared_ruleset_icmp_id']}
        self.test_4_prs = {objs_uuid['shared_ruleset_tcp_id']}
        self.test_5_prs = {objs_uuid['shared_ruleset_icmp_tcp_id']}
        self.pausetodebug = objs_uuid['pausetodebug']
	self.routefordest = objs_uuid['routefordest']
        self.vmfortraff = ['App-Server', 'Web-Server', 'Web-Client-1', 'Web-Client-2']
        self.vmtuple = ('App-Server', 'Web-Server', 'Web-Client-1', 'Web-Client-2')
        # Note: vmfortraff & vmtuple could have been addressed as a single
        # datastructure. However inside Traff Lib we need a mutable ds. Thereby
        # when Traff Lib restores the inherited list from the parent class, the
        # original list was going out of order. That affected the testcase for loop.
        # So for the test case for loop resorted to a immutable ds, hence vmtuple
        # I could have still fixed this by taking care of insertion of the element
        # back to its original positional while restoring the inherited list, but
        # kept it simple but keeping two diff type of ds
        self.vm_to_ptg_dict = {
            'App-Server': self.appsrvr_ptg, 'Web-Server': self.websrvr_ptg,
            'Web-Client-1': self.webclnt_ptg, 'Web-Client-2': self.webclnt_ptg
        }
        self.dest_vm_fips = dest_vm_fips
        self.gbpcrud = GBPCrud(self.ostack_controller)
        self.gbpnova = gbpNova(self.ostack_controller)
        self.nat_traffic = NatTraffic(
            self.ostack_controller, self.vmfortraff, self.network_node)
    def __init__(self,cntlrip,apicip):
        self.gbpcrud = GBPCrud(cntlrip)
        self.gbpnova = gbpNova(cntlrip)
	self.gbpapic = gbpApic(apicip)
Exemple #13
0
EXTPOL_MGMT = EXTSEG_PRI_NET
EXTPOL_DC = EXTSEG_SEC_NET
VM1_NAME = 'TestVM1'
VM2_NAME = 'TestVM2'
VMLIST = [VM1_NAME, VM2_NAME]
traffic = NatTraffic(CNTRLRIP, VMLIST, NTKNODE)
ACTION = 'ActAllow'
CLSF_ICMP = 'ClsIcmp'
CLSF_TCP = 'ClsTcp'
PR_ICMP = 'PrIcmp'
PR_TCP = 'PrTcp'
PRS_ICMP_TCP = 'PrsIcmpTcp'
PRS_ICMP = 'PrsIcmp'
PRS_TCP = 'PrsTcp'
gbpcrud = GBPCrud(CNTRLRIP)
gbpnova = gbpNova(CNTRLRIP)
neutron = neutronCli(CNTRLRIP, username=CTRLR_USER, password=CTRLR_PSWD)


class NatFuncTestMethods(object):
    """
    This is a GBP NAT Functionality TestCase
    """

    # NOTE: In this code structure, we have mostly re-used the same
    # local variable, as on every instance/invoke of the method new
    # value will be associated to the local variable within the
    # function scope

    def create_external_networks(self):
        LOG.info("\n## Create External Networks for L3Outs:: %s & %s ##" %
Exemple #14
0
cntlr_passwd = conf.get('controller_password') or 'noir0123'
key_user = conf.get('keystone_user') or 'admin'
key_passwd = conf.get('keystone_password') or 'noir0123'
apic_ip = conf['apic_ip']
leaf1_ip = conf['leaf1_ip']
leaf2_ip = conf['leaf2_ip']
spine_ip = conf['spine_ip']
apic_passwd = conf.get('apic_passwd')
heat_temp_test = conf['main_setup_heat_temp']
num_hosts = conf['num_comp_nodes']
heat_stack_name = conf['heat_dp_stack_name']
pausetodebug = conf['pausetodebug']
test_parameters = conf['test_parameters']
plugin = conf['plugin-type']
CONTAINERIZED_SERVICES=conf.get('containerized_services', [])
gbpnova = gbpNova(cntlr_ip,cntrlr_uname=cntlr_user,cntrlr_passwd=cntlr_passwd,
                  keystone_user=key_user,keystone_password=key_passwd)
gbpheat = gbpHeat(cntlr_ip,cntrlr_uname=cntlr_user, cntrlr_passwd=cntlr_passwd)

if plugin: #Incase of MergedPlugin
    if apic_passwd:
        gbpaci = gbpApic(apic_ip, mode='aim',
                         password=apic_passwd)
    else:
        gbpaci = gbpApic(apic_ip, mode='aim')
else:
    gbpaci = gbpApic(apic_ip, password=apic_passwd,
		       apicsystemID=APICSYSTEM_ID) 
vmlist = ['VM1','VM2','VM3','VM4',
          'VM5','VM6','VM7','VM8',
	  'VM9','VM10','VM11','VM12'	
	 ]
EXTPOL_DC = EXTSEG_SEC_NET
VM1_NAME = 'TestVM1'
VM2_NAME = 'TestVM2'
VMLIST = [VM1_NAME, VM2_NAME]
traffic = NatTraffic(
            CNTRLRIP, VMLIST, NTKNODE)
ACTION = 'ActAllow'
CLSF_ICMP = 'ClsIcmp'
CLSF_TCP = 'ClsTcp'
PR_ICMP = 'PrIcmp'
PR_TCP = 'PrTcp'
PRS_ICMP_TCP = 'PrsIcmpTcp'
PRS_ICMP = 'PrsIcmp'
PRS_TCP = 'PrsTcp'
gbpcrud = GBPCrud(CNTRLRIP)
gbpnova = gbpNova(CNTRLRIP)
neutron = neutronCli(CNTRLRIP, username=CTRLR_USER, password=CTRLR_PSWD)

class NatFuncTestMethods(object):
    """
    This is a GBP NAT Functionality TestCase
    """
    # NOTE: In this code structure, we have mostly re-used the same
    # local variable, as on every instance/invoke of the method new
    # value will be associated to the local variable within the
    # function scope

    def create_external_networks(self):
            LOG.info(
            "\n## Create External Networks for L3Outs:: %s & %s ##" %(EXTSEG_PRI, EXTSEG_SEC))
            try:
Exemple #16
0
from libs.raise_exceptions import *
from libs.gbp_crud_libs import GBPCrud
from libs.gbp_nova_libs import gbpNova
from libs.gbp_utils_libs import *
from okeystone import Keystone

for j in range(1, 7):

    tenantName = 'scale_tenant_%s' % (j)
    #    key_stone = Keystone(ostack_controller=sys.argv[1])
    print "tenant name = " + tenantName

    for i in range(1, 18):

        # delete the VMs
        gbp_nova = gbpNova(ostack_controller=sys.argv[1], os_tenant=tenantName)
        vm_name = '%s_scale_vm_%s' % (j, i)
        gbp_nova.vm_delete(vm_name, 'api')

print 'Done deleting VMs'

gbp_crud = GBPCrud(ostack_controller=sys.argv[1])
""" 
action_ids = gbp_crud.get_gbp_policy_action_list(getlist=True)
classifier_ids = gbp_crud.get_gbp_policy_classifier_list(getlist=True)	
policy_rule_ids = gbp_crud.get_gbp_policy_rule_list(getlist=True)
policy_ruleset_ids = gbp_crud.get_gbp_policy_rule_set_list(getlist=True)
"""

l3p_list_ids = gbp_crud.get_gbp_l3policy_list(getlist=True)
l2p_list_ids = gbp_crud.get_gbp_l2policy_list(getlist=True)
#!/usr/bin/env python
import sys
from libs.gbp_crud_libs import GBPCrud
from libs.gbp_nova_libs import gbpNova
from testcases.config import conf
from libs.neutron import *

CNTRLIP = conf['controller_ip']
AVZONE = conf['nova_az_name']
neutron = neutronPy(CNTRLIP)
nova = gbpNova(CNTRLIP)
crud = GBPCrud(CNTRLIP)

def alternate_az():
    "Alternately returns AvailZone for alternate VM placement"
    while True:
	    yield AVZONE
            yield 'nova'
az = alternate_az()

class scale(object):

    def create_vm(self):
        network = neutron.create_net('SCALE-NET1')
        neutron.create_subnet('SCALE-SUB',
                              '41.41.41.0/24',
                              network)
        """
        for i in range(0,2):
            nova.vm_create_api('SCALE-VM','cirros',
                [{'net-id': network}],
Exemple #18
0
#!/usr/bin/env python
import sys
import logging
import os
import datetime
import string
import pdb
from libs.raise_exceptions import *
from libs.gbp_crud_libs import GBPCrud
from libs.gbp_nova_libs import gbpNova

for j in range(1, 7):                                                                                      

    tenantName = 'scale_tenant_%s' % (j)
    gbp_crud = GBPCrud(sys.argv[1], tenant=tenantName)

    pt_dict = gbp_crud.get_gbp_policy_target_list()
    print '\nPT Dict == \n', pt_dict

    gbp_nova = gbpNova(sys.argv[1], os_tenant=tenantName)
    
    i = 1
    for pt in pt_dict.itervalues():
        vm_name = '%s_scale_vm_%s' % (j, i)   
        print vm_name
        gbp_nova.vm_create_api(vm_name, 'cirros',
                               [{'port-id': pt}], 'm1.tiny', 'nova')
        #gbp_nova.vm_delete(vm_name, 'api')
        i = i + 1
Exemple #19
0
from libs.raise_exceptions import *
from libs.gbp_crud_libs import GBPCrud
from libs.gbp_nova_libs import gbpNova
from libs.gbp_utils_libs import *
from okeystone import Keystone

for j in range(1, 7):

    tenantName = 'scale_tenant_%s' %(j)	
#    key_stone = Keystone(ostack_controller=sys.argv[1])
    print "tenant name = " + tenantName

    for i in range(1, 18):

        # delete the VMs
        gbp_nova = gbpNova(ostack_controller=sys.argv[1], os_tenant=tenantName)
        vm_name = '%s_scale_vm_%s' % (j, i)
        gbp_nova.vm_delete(vm_name, 'api')

print 'Done deleting VMs'

gbp_crud = GBPCrud(ostack_controller=sys.argv[1])
    
""" 
action_ids = gbp_crud.get_gbp_policy_action_list(getlist=True)
classifier_ids = gbp_crud.get_gbp_policy_classifier_list(getlist=True)	
policy_rule_ids = gbp_crud.get_gbp_policy_rule_list(getlist=True)
policy_ruleset_ids = gbp_crud.get_gbp_policy_rule_set_list(getlist=True)
"""

l3p_list_ids = gbp_crud.get_gbp_l3policy_list(getlist=True)    
Exemple #20
0
def setup(controller_ip,apic_ip,ntknode,cntlr_user='******',apic_user='******',
          apic_pwd = 'noir0123', cntlr_pwd='noir0123'):

    env.host_string = controller_ip
    env.user = cntlr_user
    env.password = cntlr_pwd

    #Step-0.5: Make sure GBP client is installed on the controller
    cmd = "sudo yum -y install python-gbpclient.noarch"
    run(cmd)

    #Step-1: Copy the Heat Templates to the Controller
    for heat_templt in ['~/noirotest/testcases/heat_temps/heat_dnat_only.yaml',
			'~/noirotest/testcases/heat_temps/heat_snat_only.yaml',
			'~/noirotest/testcases/heat_temps/preexist_dnat_only.yaml',
			'~/noirotest/testcases/heat_temps/preexist_snat_only.yaml',
			'~/noirotest/testcases/heat_temps/heat_tmpl_regular_dp_tests.yaml',
			'~/noirotest/add_ssh_filter.py'
			]:
         put(heat_templt,'~/')
    if CONTAINERIZED_SERVICES and 'aim' in CONTAINERIZED_SERVICES:
         cmd = "sudo docker ps | grep aim$"
         output = run(cmd)
         cid = output.split()[0]
         cmd = "sudo docker exec -i %s /bin/bash -c 'cat > /home/add_ssh_filter.py' < /home/heat-admin/add_ssh_filter.py" % cid
         run(cmd)
    #Step-2: Restart the below services
    for cmd in ['sudo systemctl restart openstack-nova-api.service',
		'sudo systemctl restart openstack-nova-scheduler.service',
		'sudo systemctl restart openstack-heat-engine.service',
		'sudo systemctl restart openstack-heat-api.service'
               ]:
       if not CONTAINERIZED_SERVICES:
           run(cmd)
       else:
           # For newer releases, it's containerized, so restart the containers
           service = cmd.split()[-1][10:-8].replace('-','_')
           cmd = "sudo docker ps | grep %s$" % service
           output = run(cmd)
           print(output)
           container_id = output.split()[0]
           cmd = "sudo docker restart %s" % container_id
           print cmd
           run(cmd)


    #Step-3: Update the Nova-quotas and Enable ACI Route-reflector
    with settings(warn_only=True):
        os_flvr = run('cat /etc/os-release')
        if 'Red Hat' in os_flvr:
            cmd_src = 'source ~/overcloudrc'
	if 'Ubuntu' in os_flvr:
            cmd_src = 'source ~/overcloudrc'
        rr_cmd = 'apic route-reflector-create --ssl --no-secure '+\
                 '--apic-ip %s --apic-username %s --apic-password %s' %(apic_ip,apic_user,apic_pwd)
	with prefix(cmd_src):
            for cmd in ['nova quota-class-update --instances -1 default',
			'nova quota-class-update --ram -1 default',
			'nova quota-class-update --cores -1 default',
			'nova quota-show',
                        rr_cmd]:
		run(cmd)
 
    #Step-4: Add availability zone 
    NOVA_AGG = conf['nova_agg_name']
    AVAIL_ZONE = conf['nova_az_name']
    AZ_COMP_NODE = conf['az_comp_node']
    gbpnova = gbpNova(CNTRLRIP,cntrlr_uname=cntlr_user,cntrlr_passwd=cntlr_pwd,
                      keystone_user=KEY_USER,keystone_password=KEY_PASSWORD)
    try:
    	# Check if Agg already exists then delete
        cmdagg = run_openstack_cli("nova aggregate-list", CNTRLRIP, username=cntlr_user,passwd=cntlr_pwd)
        if NOVA_AGG in cmdagg:
        	print("Residual Nova Agg exits, hence deleting it")
                gbpnova.avail_zone('cli', 'removehost',
                                           NOVA_AGG,
                                           hostname=AZ_COMP_NODE)
                gbpnova.avail_zone('cli', 'delete', NOVA_AGG)
        print("\nCreating Nova Host-aggregate & its Availability-zone")
        agg_id = gbpnova.avail_zone(
                       'cli', 'create', NOVA_AGG, avail_zone_name=AVAIL_ZONE)
    except Exception:
                print(
                    "\n ABORTING THE TESTSUITE RUN,nova host aggregate creation Failed")
                sys.exit(1)
    print(" Agg %s" % (agg_id))
    try:
        print("\nAdding Nova host to availaibility-zone")
        gbpnova.avail_zone('cli', 'addhost', agg_id, hostname=AZ_COMP_NODE)
    except Exception:
        print("\n ABORTING THE TESTSUITE RUN, availability zone creation Failed")
        gbpnova.avail_zone('cli', 'delete', agg_id)  # Cleanup Agg_ID
        sys.exit(1)
   
    #Step-5: Copy the iptools-arping to the network-node of the fabric
    env.host_string = ntknode
    put('~/noirotest/iputils-arping_20121221-4ubuntu1_amd64.deb', '~/')
Exemple #21
0
#!/usr/bin/env python
import sys
from libs.gbp_crud_libs import GBPCrud
from libs.gbp_nova_libs import gbpNova
from testcases.config import conf
from libs.neutron import *

CNTRLIP = conf['controller_ip']
AVZONE = conf['nova_az_name']
neutron = neutronPy(CNTRLIP)
nova = gbpNova(CNTRLIP)
crud = GBPCrud(CNTRLIP)


def alternate_az():
    "Alternately returns AvailZone for alternate VM placement"
    while True:
        yield AVZONE
        yield 'nova'


az = alternate_az()


class scale(object):
    def create_vm(self):
        network = neutron.create_net('SCALE-NET1')
        neutron.create_subnet('SCALE-SUB', '41.41.41.0/24', network)
        """
        for i in range(0,2):
            nova.vm_create_api('SCALE-VM','cirros',
Exemple #22
0
def setup(controller_ip,
          apic_ip,
          ntknode,
          cntlr_user='******',
          apic_user='******',
          apic_pwd='noir0123',
          cntlr_pwd='noir0123'):

    env.host_string = controller_ip
    env.user = cntlr_user
    env.password = cntlr_pwd

    #Step-0.5: Make sure GBP client is installed on the controller
    cmd = "sudo yum -y install python-gbpclient.noarch"
    run(cmd)

    #Step-1: Copy the Heat Templates to the Controller
    for heat_templt in [
            '~/noirotest/testcases/heat_temps/heat_dnat_only.yaml',
            '~/noirotest/testcases/heat_temps/heat_snat_only.yaml',
            '~/noirotest/testcases/heat_temps/preexist_dnat_only.yaml',
            '~/noirotest/testcases/heat_temps/preexist_snat_only.yaml',
            '~/noirotest/testcases/heat_temps/heat_tmpl_regular_dp_tests.yaml',
            '~/noirotest/add_ssh_filter.py'
    ]:
        put(heat_templt, '~/')
    if CONTAINERIZED_SERVICES and 'aim' in CONTAINERIZED_SERVICES:
        cmd = "sudo docker ps | grep aim$"
        output = run(cmd)
        cid = output.split()[0]
        cmd = "sudo docker exec -i %s /bin/bash -c 'cat > /home/add_ssh_filter.py' < /home/heat-admin/add_ssh_filter.py" % cid
        run(cmd)
    #Step-2: Restart the below services
    for cmd in [
            'sudo systemctl restart openstack-nova-api.service',
            'sudo systemctl restart openstack-nova-scheduler.service',
            'sudo systemctl restart openstack-heat-engine.service',
            'sudo systemctl restart openstack-heat-api.service'
    ]:
        if not CONTAINERIZED_SERVICES:
            run(cmd)
        else:
            # For newer releases, it's containerized, so restart the containers
            service = cmd.split()[-1][10:-8].replace('-', '_')
            cmd = "sudo docker ps | grep %s$" % service
            output = run(cmd)
            print(output)
            container_id = output.split()[0]
            cmd = "sudo docker restart %s" % container_id
            print cmd
            run(cmd)

    #Step-3: Update the Nova-quotas and Enable ACI Route-reflector
    with settings(warn_only=True):
        os_flvr = run('cat /etc/os-release')
        if 'Red Hat' in os_flvr:
            cmd_src = 'source ~/overcloudrc'
        if 'Ubuntu' in os_flvr:
            cmd_src = 'source ~/overcloudrc'
        rr_cmd = 'apic route-reflector-create --ssl --no-secure '+\
                 '--apic-ip %s --apic-username %s --apic-password %s' %(apic_ip,apic_user,apic_pwd)
        with prefix(cmd_src):
            for cmd in [
                    'nova quota-class-update --instances -1 default',
                    'nova quota-class-update --ram -1 default',
                    'nova quota-class-update --cores -1 default',
                    'nova quota-show', rr_cmd
            ]:
                run(cmd)

    #Step-4: Add availability zone
    NOVA_AGG = conf['nova_agg_name']
    AVAIL_ZONE = conf['nova_az_name']
    AZ_COMP_NODE = conf['az_comp_node']
    gbpnova = gbpNova(CNTRLRIP,
                      cntrlr_uname=cntlr_user,
                      cntrlr_passwd=cntlr_pwd,
                      keystone_user=KEY_USER,
                      keystone_password=KEY_PASSWORD)
    try:
        # Check if Agg already exists then delete
        cmdagg = run_openstack_cli("nova aggregate-list",
                                   CNTRLRIP,
                                   username=cntlr_user,
                                   passwd=cntlr_pwd)
        if NOVA_AGG in cmdagg:
            print("Residual Nova Agg exits, hence deleting it")
            gbpnova.avail_zone('cli',
                               'removehost',
                               NOVA_AGG,
                               hostname=AZ_COMP_NODE)
            gbpnova.avail_zone('cli', 'delete', NOVA_AGG)
        print("\nCreating Nova Host-aggregate & its Availability-zone")
        agg_id = gbpnova.avail_zone('cli',
                                    'create',
                                    NOVA_AGG,
                                    avail_zone_name=AVAIL_ZONE)
    except Exception:
        print(
            "\n ABORTING THE TESTSUITE RUN,nova host aggregate creation Failed"
        )
        sys.exit(1)
    print(" Agg %s" % (agg_id))
    try:
        print("\nAdding Nova host to availaibility-zone")
        gbpnova.avail_zone('cli', 'addhost', agg_id, hostname=AZ_COMP_NODE)
    except Exception:
        print(
            "\n ABORTING THE TESTSUITE RUN, availability zone creation Failed")
        gbpnova.avail_zone('cli', 'delete', agg_id)  # Cleanup Agg_ID
        sys.exit(1)

    #Step-5: Copy the iptools-arping to the network-node of the fabric
    env.host_string = ntknode
    put('~/noirotest/iputils-arping_20121221-4ubuntu1_amd64.deb', '~/')
Exemple #23
0
dnat_heat_temp = conf['preexist_dnat_temp']
dnat_heat_temp = conf['dnat_heat_temp']
#SNAT: Prexisting L3Out in Common, Ext-Seg being tenant-specific
#will result in tenant-specific NAT-EPG where SNAT EPs will get
#learned. Apparently thats will cause inconsistency and we should
#not support such config. Discussed with Amit 
snat_heat_temp = conf['snat_heat_temp']
num_hosts = conf['num_comp_nodes']
heat_stack_name = conf['heat_dp_nat_stack_name']
ips_of_extgw = [conf['extrtr_ip1'],
                conf['extrtr_ip2'], extgw]
routefordest = re.search(
       '\\b(\d+.\d+.\d+.)\d+' '',conf['extrtr_ip2'], re.I).group(1)+'0/24'
pausetodebug = conf['pausetodebug']
neutronconffile = conf['neutronconffile']
gbpnova = gbpNova(cntlr_ip)
gbpheat = gbpHeat(cntlr_ip)
gbpaci = gbpApic(apic_ip, apicsystemID=apicsystemID)
gbpcrud = GBPCrud(cntlr_ip)
hostpoolcidrL3OutA = '55.55.55.1/24'
hostpoolcidrL3OutB = '66.66.66.1/24'
#Instead of defining the below static labels/vars
#could have sourced the heat.yaml file and read it
#But since this TestConfig defined in yaml file
#WILL NOT change hence being lazy as a mule
targetvm_list = ['Web-Server', 'Web-Client-1',
		'Web-Client-2', 'App-Server']
L3plist = ['DCL3P1','DCL3P2']
#Note: change the order of list will affect the below dict
Epglist = ['APPPTG','WEBSRVRPTG','WEBCLNTPTG']
L2plist = ['APPL2P','WEBSRVRL2P','WEBCLNTL2P']
Exemple #24
0
#!/usr/bin/env python
import sys
import logging
import os
import datetime
import string
import pdb
from libs.raise_exceptions import *
from libs.gbp_crud_libs import GBPCrud
from libs.gbp_nova_libs import gbpNova

for j in range(1, 7):

    tenantName = 'scale_tenant_%s' % (j)
    gbp_crud = GBPCrud(sys.argv[1], tenant=tenantName)

    pt_dict = gbp_crud.get_gbp_policy_target_list()
    print '\nPT Dict == \n', pt_dict

    gbp_nova = gbpNova(sys.argv[1], os_tenant=tenantName)

    i = 1
    for pt in pt_dict.itervalues():
        vm_name = '%s_scale_vm_%s' % (j, i)
        print vm_name
        gbp_nova.vm_create_api(vm_name, 'cirros', [{
            'port-id': pt
        }], 'm1.tiny', 'nova')
        #gbp_nova.vm_delete(vm_name, 'api')
        i = i + 1