Beispiel #1
0
class SolnSetup(object):
    def __init__(self, test_resource):
        self.test_resource = test_resource

    def setUp(self):
        if 'PARAMS_FILE' in os.environ:
            self.ini_file = os.environ.get('PARAMS_FILE')
        else:
            self.ini_file = 'params.ini'
        self.inputs = ContrailTestInit(self.ini_file)
        self.inputs.setUp()
        self.connections = ContrailConnections(self.inputs)
        self.quantum_h = self.connections.quantum_h
        self.nova_h = self.connections.nova_h
        self.vnc_lib = self.connections.vnc_lib
        self.logger = self.inputs.logger
        return self

    # end setUp

    def tearDown(self):
        pass

    def dirtied(self):
        self.test_resource.dirtied(self)
Beispiel #2
0
    def get_connection_handle(self):

        self.inputs = ContrailTestInit(self.ini_file,logger=self.logger)
        self.inputs.setUp()
        self.connections= ContrailConnections(self.inputs, self.logger)
        self.connections.get_vnc_lib_h() # will set self.vnc_lib in the object
        self.auth = self.connections.get_auth_h()
class SolnSetup(object):

    def __init__(self, test_resource):
        self.test_resource = test_resource

    def setUp(self):
        if 'PARAMS_FILE' in os.environ:
            self.ini_file = os.environ.get('PARAMS_FILE')
        else:
            self.ini_file = 'params.ini'
        self.inputs = ContrailTestInit(self.ini_file)
        self.inputs.setUp()
        self.connections = ContrailConnections(self.inputs)
        self.quantum_h = self.connections.quantum_h
        self.nova_h = self.connections.nova_h
        self.vnc_lib = self.connections.vnc_lib
        self.logger = self.inputs.logger
        return self
    # end setUp

    def tearDown(self):
        pass

    def dirtied(self):
        self.test_resource.dirtied(self)
def main():
    init_obj = ContrailTestInit(sys.argv[1])
    init_obj.read_prov_file()
    if init_obj.inputs.vcenter_gw_setup or (init_obj.inputs.orchestrator == 'vcenter'):
        vcenter=get_vcenter_server_details(init_obj.inputs)
        vcenter_orch = VcenterOrchestrator(init_obj.inputs, vcenter.server, 
                                           vcenter.port, vcenter.user, 
                                           vcenter.password, 
                                           init_obj.inputs.vcenter_dc,
                                           logger = log 
                                           )
        vcenter_orch._nfs_ds.delete_datastore()
Beispiel #5
0
 def setUp(self):
     if 'PARAMS_FILE' in os.environ:
         self.ini_file = os.environ.get('PARAMS_FILE')
     else:
         self.ini_file = 'params.ini'
     self.inputs = ContrailTestInit(self.ini_file)
     self.inputs.setUp()
     self.connections = ContrailConnections(self.inputs)
     self.quantum_h = self.connections.quantum_h
     self.nova_h = self.connections.nova_h
     self.vnc_lib = self.connections.vnc_lib
     self.logger = self.inputs.logger
     return self
 def get_project_inputs(self, username=None, password=None):
     if not username:
         username = self.username
     if not password:
         password = self.password
     self.project_inputs = ContrailTestInit(
         self.inputs.ini_file,
         stack_user=username,
         stack_password=password,
         project_fq_name=['default-domain', self.project_name],
         logger=self.logger)
     self.project_inputs.setUp()
     return self.project_inputs
Beispiel #7
0
def main():
    init_obj = ContrailTestInit(sys.argv[1])
    init_obj.read_prov_file()
    if init_obj.inputs.vcenter_gw_setup:
        vcenter = get_vcenter_server_details(init_obj.inputs)
        vcenter_orch = VcenterOrchestrator(init_obj.inputs,
                                           vcenter.server,
                                           vcenter.port,
                                           vcenter.user,
                                           vcenter.password,
                                           init_obj.inputs.vcenter_dc,
                                           logger=log)
        vcenter_orch._nfs_ds.delete_datastore()
Beispiel #8
0
    def setUpClass(cls):
        # Create the required users, projects and domains
        cmd = 'kubectl config use-context juju-context'
        cti_obj = ContrailTestInit(input_file='contrail_test_input.yaml')
        cti_obj.run_cmd_on_server(server_ip=cti_obj.juju_server,
                                  username='******',
                                  password='******',
                                  issue_cmd=cmd)
        super(TestPolicyCombo, cls).setUpClass()
        cls.admin = ExampleUser.admin()
        cls.admin.create_all(user_name='userD',
                             password='******',
                             role='Member',
                             project_name='userD_project',
                             domain_name='userD_domain')
        cls.admin.create_all(user_name='userA',
                             password='******',
                             role='Member',
                             project_name='userA_project',
                             domain_name='userA_domain')
        cls.admin.create_all(user_name='userB',
                             password='******',
                             role='Member',
                             project_name='userB_project',
                             domain_name='userB_domain')
        cls.admin.create_all(user_name='userC',
                             password='******',
                             role='Member',
                             project_name='userC_project',
                             domain_name='userC_domain')

        cmd = 'kubectl create ns zomsrc; kubectl create ns easy'
        cls.inputs.run_cmd_on_server(server_ip=cti_obj.juju_server,
                                     username='******',
                                     password='******',
                                     issue_cmd=cmd)
        admin_policy = create_policy.get_admin_policy()
        userA_policy = create_policy.get_userA_policy()
        userB_policy = create_policy.get_userB_policy()
        userC_policy = create_policy.get_userC_policy()
        userD_policy = create_policy.get_userD_policy()
        policies = [
            admin_policy, userA_policy, userB_policy, userC_policy,
            userD_policy
        ]
        filename = create_policy.insert_policies_in_template_file(
            policies, filename='all_in_one_policy.yaml', inputs=cls.inputs)
        create_policy.apply_policies_and_check_in_config_map(
            policies, filename, cti_obj.juju_server)
Beispiel #9
0
def setup_test_infra(testbed_file):
    import logging
    from common.log_orig import ContrailLogger
    logging.getLogger('urllib3.connectionpool').setLevel(logging.WARN)
    logging.getLogger('paramiko.transport').setLevel(logging.WARN)
    logging.getLogger('keystoneclient.session').setLevel(logging.WARN)
    logging.getLogger('keystoneclient.httpclient').setLevel(logging.WARN)
    logging.getLogger('neutronclient.client').setLevel(logging.WARN)
    logger = ContrailLogger('verify')
    logger.setUp()
    mylogger = logger.logger
    inputs = ContrailTestInit(testbed_file, logger=mylogger)
    inputs.setUp()
    connections = ContrailConnections(inputs=inputs, logger=mylogger)
    return connections
Beispiel #10
0
def setup_test_infra(testbed_file):
    import logging
    from common.log_orig import ContrailLogger
    logging.getLogger('urllib3.connectionpool').setLevel(logging.WARN)
    logging.getLogger('paramiko.transport').setLevel(logging.WARN)
    logging.getLogger('keystoneclient.session').setLevel(logging.WARN)
    logging.getLogger('keystoneclient.httpclient').setLevel(logging.WARN)
    logging.getLogger('neutronclient.client').setLevel(logging.WARN)
    logger = ContrailLogger('verify')
    logger.setUp()
    mylogger = logger.logger
    inputs = ContrailTestInit(testbed_file, logger=mylogger)
    inputs.setUp()
    connections = ContrailConnections(inputs=inputs, logger=mylogger)
    return connections
Beispiel #11
0
    def get_connection_handle(self):

        self.inputs = ContrailTestInit(self.ini_file, logger=self.logger)
        self.inputs.setUp()
        self.connections = ContrailConnections(self.inputs, self.logger)
        self.connections.get_vnc_lib_h()  # will set self.vnc_lib in the object
        self.auth = self.connections.get_auth_h()
Beispiel #12
0
 def get_auth_url():
     cti_obj = ContrailTestInit(input_file='contrail_test_input.yaml')
     cmd = ["juju status | grep 5000 | awk '{print $5}'"]
     auth_ip, err = Util.execute_cmds_on_remote(ip=cti_obj.juju_server,
                                                cmd_list=cmd)
     auth_ip = auth_ip.strip()
     auth_url = 'http://%s:5000/v3' % auth_ip
     return auth_url
 def get_inputs(self, project_fixture):
     project_inputs = ContrailTestInit(
         self.ini_file,
         stack_user=project_fixture.username,
         stack_password=project_fixture.password,
         project_fq_name=['default-domain', self.project_name],
         logger=self.logger)
     return project_inputs
Beispiel #14
0
 def get_inputs(self, project_fixture):
     project_inputs = ContrailTestInit(
         self.ini_file,
         stack_user=project_fixture.project_username,
         stack_password=project_fixture.project_user_password,
         stack_tenant=self.project_name,
         logger=self.logger)
     return project_inputs
Beispiel #15
0
    def get_connections_handle(self):

        self.inputs = ContrailTestInit(self.input_file, logger=self.logger)
        self.connections = ContrailConnections(self.inputs, self.logger)
        self.vnc_lib = self.connections.vnc_lib
        self.auth = self.connections.auth
        self.lib_handle = ConfigScale(self.inputs, self.logger,
                                      self.connections, self.vnc_lib,
                                      self.auth)
    def get_inputs(self):

        self.project_inputs = self.useFixture(
            ContrailTestInit(
                self.ini_file,
                stack_user=self.project.username,
                stack_password=self.project.password,
                project_fq_name=['default-domain', self.project_name],
                logger=self.logger))
        return self.project_inputs
Beispiel #17
0
    def setUpClass(cls):
        if hasattr(super(BaseTestCase, cls), 'setUpClass'):
            super(BaseTestCase, cls).setUpClass()
        cls.setUpClassCalled = True

        if 'TEST_CONFIG_FILE' in os.environ:
            cls.ini_file = os.environ.get('TEST_CONFIG_FILE')
        else:
            cls.ini_file = 'sanity_params.ini'
        cls.logger = contrail_logging.getLogger(cls.__name__)
        cls.inputs = ContrailTestInit(cls.ini_file, logger=cls.logger)
 def setUp(self):
     super(AnalyticsScaleTest, self).setUp()
     if 'PARAMS_FILE' in os.environ:
         self.ini_file = os.environ.get('PARAMS_FILE')
     else:
         self.ini_file = 'params.ini'
     self.inputs = self.useFixture(ContrailTestInit(self.ini_file))
     self.connections = ContrailConnections(self.inputs)
     self.logger = self.inputs.logger
     self.analytics_obj = self.connections.analytics_obj
     self.ops_inspect = self.connections.ops_inspect
Beispiel #19
0
 def get_inputs(self, username=None, password=None):
     username = username or self.project_username or self.inputs.stack_user
     password = password or self.project_user_password or self.inputs.stack_password
     if username not in self.project_inputs:
         self.project_inputs[username] = ContrailTestInit(self.inputs.ini_file,
              stack_domain=self.orch_domain_name,
              stack_user=username,
              stack_password=password,
              stack_tenant=self.project_name,
              logger=self.logger)
     return self.project_inputs[username]
Beispiel #20
0
 def setUp(self):
     super(VPCSanityTests, self).setUp()
     if 'PARAMS_FILE' in os.environ:
         self.ini_file = os.environ.get('PARAMS_FILE')
     else:
         self.ini_file = 'params.ini'
     self.inputs = self.useFixture(ContrailTestInit(self.ini_file))
     self.connections = ContrailConnections(self.inputs)
     self.quantum_h = self.connections.quantum_h
     self.nova_h = self.connections.nova_h
     self.agent_inspect_h = self.connections.agent_inspect
     self.logger = self.inputs.logger
Beispiel #21
0
 def get_project_inputs(self, username=None, password=None):
     if not username:
         username = self.username
     if not password:
         password = self.password
     self.project_inputs= ContrailTestInit(self.inputs.ini_file,
                                  stack_user=username,
                                  stack_password=password,
                                  project_fq_name=['default-domain',self.project_name],
                                  logger = self.logger)
     self.project_inputs.setUp()
     return self.project_inputs
    def __init__(self, inputs=None, logger=None, project_name=None,
                 username=None, password=None, domain_name=None, ini_file=None):
        self.inputs = inputs or ContrailTestInit(ini_file,
                                stack_tenant=project_name)
        self.project_name = project_name or self.inputs.project_name
        self.domain_name = domain_name or self.inputs.domain_name
        self.username = username or self.inputs.stack_user
        self.password = password or self.inputs.stack_password
        self.logger = logger or self.inputs.logger
        self.nova_h = None
        self.quantum_h = None
        self.api_server_inspects = custom_dict(self.get_api_inspect_handle,
                        'api_inspect:'+self.project_name+':'+self.username)
        self.dnsagent_inspect = custom_dict(self.get_dns_agent_inspect_handle,
                                            'dns_inspect')
        self.agent_inspect = custom_dict(self.get_vrouter_agent_inspect_handle,
                                         'agent_inspect')
        self.ops_inspects = custom_dict(self.get_opserver_inspect_handle,
                                        'ops_inspect')
        self.cn_inspect = custom_dict(self.get_control_node_inspect_handle,
                                      'cn_inspect')
        self.ds_inspect = custom_dict(self.get_discovery_service_inspect_handle,
                                      'ds_inspect')

        # ToDo: msenthil/sandipd rest of init needs to be better handled
        self.vnc_lib = self.get_vnc_lib_h()
        self.auth = self.get_auth_h()
        if self.inputs.orchestrator == 'openstack':
            self.project_id = self.get_project_id()
            if self.inputs.verify_thru_gui():
                self.ui_login = UILogin(self, self.inputs, project_name, username, password)
                self.browser = self.ui_login.browser
                self.browser_openstack = self.ui_login.browser_openstack

            self.orch = OpenstackOrchestrator(username=self.username,
                                              password=self.password,
                                              project_id=self.project_id,
                                              project_name=self.project_name,
                                              inputs=self.inputs,
                                              vnclib=self.vnc_lib,
                                              logger=self.logger,
                                             auth_server_ip=self.inputs.auth_ip)
            self.nova_h = self.orch.get_compute_handler()
            self.quantum_h = self.orch.get_network_handler()
        else: # vcenter
            self.orch = VcenterOrchestrator(user=self.username,
                                            pwd=self.password,
                                            host=self.inputs.auth_ip,
                                            port=self.inputs.auth_port,
                                            dc_name=self.inputs.vcenter_dc,
                                            vnc=self.vnc_lib,
                                            inputs=self.inputs,
                                            logger=self.logger)
Beispiel #23
0
 def setUp(self):
     if 'PARAMS_FILE' in os.environ:
         self.ini_file = os.environ.get('PARAMS_FILE')
     else:
         self.ini_file = 'params.ini'
     self.inputs = ContrailTestInit(self.ini_file)
     self.inputs.setUp()
     self.connections = ContrailConnections(self.inputs)
     self.quantum_h = self.connections.quantum_h
     self.nova_h = self.connections.nova_h
     self.vnc_lib = self.connections.vnc_lib
     self.logger = self.inputs.logger
     return self
 def setUp(self):
     super(SecurityGroupSanityTestsBase, self).setUp()
     if 'PARAMS_FILE' in os.environ:
         self.ini_file = os.environ.get('PARAMS_FILE')
     else:
         self.ini_file = 'params.ini'
     self.inputs = self.useFixture(ContrailTestInit(self.ini_file))
     self.connections = ContrailConnections(self.inputs)
     self.quantum_h = self.connections.quantum_h
     self.nova_h = self.connections.nova_h
     self.vnc_lib = self.connections.vnc_lib
     self.logger = self.inputs.logger
     self.analytics_obj = self.connections.analytics_obj
Beispiel #25
0
 def setUp(self):
     super(SolnSetup, self).setUp()
     if 'PARAMS_FILE' in os.environ:
         self.ini_file = os.environ.get('PARAMS_FILE')
     else:
         self.ini_file = 'params.ini'
     self.inputs = ContrailTestInit(self.ini_file)
     self.connections = ContrailConnections(self.inputs)
     self.quantum_h = self.connections.quantum_h
     self.nova_h = self.connections.nova_h
     self.vnc_lib = self.connections.vnc_lib
     self.logger = self.inputs.logger
     self.setup_common_objects()
     return self
Beispiel #26
0
class ConfigScaleSetup:
    def __init__(self):

        self.ini_file = "sanity_params.ini"
        self.log_name = "tor-scale.log"
        Logger = logging.ContrailLogger(self.log_name)
        Logger.setUp()
        self.logger = Logger.logger

    def get_connection_handle(self):

        self.inputs = ContrailTestInit(self.ini_file, logger=self.logger)
        self.inputs.setUp()
        self.connections = ContrailConnections(self.inputs, self.logger)
        self.connections.get_vnc_lib_h()  # will set self.vnc_lib in the object
        self.auth = self.connections.get_auth_h()

    def config_test(self):

        self.get_connection_handle()
        tenant_name = "tenant" + "".join([random.choice(string.ascii_uppercase + string.digits) for i in xrange(10)])
        project_obj = Project(self.connections)
        project_obj.create(tenant_name)
 def setUp(self):
     super(Upgradeonly, self).setUp()
     if 'PARAMS_FILE' in os.environ:
         self.ini_file = os.environ.get('PARAMS_FILE')
     else:
         self.ini_file = 'params.ini'
     self.inputs = self.useFixture(ContrailTestInit(self.ini_file))
     self.connections = ContrailConnections(self.inputs)
     self.agent_inspect = self.connections.agent_inspect
     self.quantum_h = self.connections.quantum_h
     self.nova_h = self.connections.nova_h
     self.vnc_lib = self.connections.vnc_lib
     self.logger = self.inputs.logger
     self.analytics_obj = self.connections.analytics_obj
Beispiel #28
0
class ConfigScaleSetup:
    def __init__(self):

        self.ini_file= 'sanity_params.ini'
        self.log_name='tor-scale.log'
        Logger = logging.ContrailLogger(self.log_name)
        Logger.setUp()
        self.logger = Logger.logger

    def get_connection_handle(self):

        self.inputs = ContrailTestInit(self.ini_file,logger=self.logger)
        self.inputs.setUp()
        self.connections= ContrailConnections(self.inputs, self.logger)
        self.connections.get_vnc_lib_h() # will set self.vnc_lib in the object
        self.auth = self.connections.get_auth_h()

    def config_test(self):

        self.get_connection_handle()
        tenant_name = "tenant" + "".join([random.choice(string.ascii_uppercase + string.digits) for i in xrange(10)])
        project_obj = Project(self.connections)
        project_obj.create(tenant_name)
Beispiel #29
0
 def setUp(self):
     super(PerformanceSanity, self).setUp()
     if 'TEST_CONFIG_FILE' in os.environ:
         self.input_file = os.environ.get('TEST_CONFIG_FILE')
     else:
         self.input_file = 'params.ini'
     self.inputs = ContrailTestInit(self.input_file)
     self.connections = ContrailConnections(self.inputs)
     self.agent_inspect = self.connections.agent_inspect
     self.quantum_h = self.connections.quantum_h
     self.nova_h = self.connections.nova_h
     self.vnc_lib = self.connections.vnc_lib
     self.logger = self.inputs.logger
     self.analytics_obj = self.connections.analytics_obj
Beispiel #30
0
def setup_test_infra():
    import logging
    from common.contrail_test_init import ContrailTestInit
    from common.connections import ContrailConnections
    from common.log_orig import ContrailLogger
    logging.getLogger('urllib3.connectionpool').setLevel(logging.WARN)
    logging.getLogger('paramiko.transport').setLevel(logging.WARN)
    logging.getLogger('keystoneclient.session').setLevel(logging.WARN)
    logging.getLogger('keystoneclient.httpclient').setLevel(logging.WARN)
    logging.getLogger('neutronclient.client').setLevel(logging.WARN)
    logger = ContrailLogger('event')
    logger.setUp()
    mylogger = logger.logger
    inputs = ContrailTestInit('./sanity_params.ini', logger=mylogger)
    connections = ContrailConnections(inputs=inputs, logger=mylogger)
    return connections
Beispiel #31
0
 def setUp(self):
     super(AnalyticsTestPerformance, self).setUp()
     if 'PARAMS_FILE' in os.environ:
         self.ini_file = os.environ.get('PARAMS_FILE')
     else:
         self.ini_file = 'params.ini'
     self.inputs = self.useFixture(ContrailTestInit(self.ini_file))
     self.connections = ContrailConnections(self.inputs)
     self.quantum_h = self.connections.quantum_h
     self.nova_h = self.connections.nova_h
     self.vnc_lib = self.connections.vnc_lib
     self.logger = self.inputs.logger
     self.agent_inspect = self.connections.agent_inspect
     self.cn_inspect = self.connections.cn_inspect
     self.analytics_obj = self.connections.analytics_obj
     self.sender_list = []
     self.receiver_list = []
Beispiel #32
0
    def setUp(self):
        super(SecurityGroupSetup, self).setUp()
        if 'PARAMS_FILE' in os.environ:
            self.ini_file = os.environ.get('PARAMS_FILE')
        else:
            self.ini_file = 'params.ini'
        self.inputs = self.useFixture(ContrailTestInit(self.ini_file))
        self.connections = ContrailConnections(self.inputs)
        self.quantum_h = self.connections.quantum_h
        self.nova_h = self.connections.nova_h
        self.vnc_lib = self.connections.vnc_lib
        self.logger = self.inputs.logger

        self.logger.info("Configuring setup for security group tests.")
        self.setup()
        self.logger.info("Verifying setup of security group tests.")
        self.verify()
        self.logger.info(
            "Finished configuring setup for security group tests.")
        return self
def main():
    init_obj = ContrailTestInit(sys.argv[1])
    if init_obj.inputs.vcenter_gw_setup or (init_obj.inputs.orchestrator
                                            == 'vcenter'):
        vcenter = get_vcenter_server_details(init_obj.inputs)
        vcenter_orch = VcenterOrchestrator(init_obj.inputs,
                                           vcenter.server,
                                           vcenter.port,
                                           vcenter.user,
                                           vcenter.password,
                                           init_obj.inputs.vcenter_dc,
                                           logger=log)
        images = [
            'ubuntu', 'ubuntu-traffic', 'vcenter_tiny_vm', 'tiny_nat_fw',
            'tiny_in_net'
        ]
        for image in images:
            try:
                vcenter_orch.load_and_register_template(image)
            except:
                log.info('Not able to load template %s' % image)
Beispiel #34
0
import os
import re
import sys
import logging

from common.contrail_test_init import ContrailTestInit


logging.getLogger('paramiko.transport').setLevel(logging.WARN)

if __name__ == "__main__":
    init_obj = ContrailTestInit(sys.argv[1])
    ips = set(init_obj.cfgm_ips + init_obj.collector_ips)
    collected = {}
    for host_ip in ips:
        # copy the python script
        script_file = 'search-bt.py'
        ignore_tb_file = 'ignore_tracebacks.json'
        src_file = 'tools/%s' % (script_file)
        src_ignore_tb_file = 'tools/%s' % (ignore_tb_file)
        dest = '/tmp'

        containers = ['controller', 'analytics']

        for container in containers:
            if not init_obj.host_data[host_ip].get('containers', {}).get(container):
                container_str = ''
            else:
                container_str = container
            if collected.get('%s-%s' % (host_ip, container_str)):
                continue
Beispiel #35
0
import os
import sys
import json
import ConfigParser
import ast

from tor_fixture import ToRFixtureFactory
from physical_router_fixture import PhysicalRouterFixture
from common.contrail_test_init import ContrailTestInit

if __name__ == "__main__":
    init_obj = ContrailTestInit(sys.argv[1])
    init_obj.read_prov_file()
    for (device, device_dict) in init_obj.physical_routers_data.iteritems():
        if device_dict['type'] == 'tor':
            tor_obj = ToRFixtureFactory.get_tor(
                device_dict['name'],
                device_dict['mgmt_ip'],
                vendor=device_dict['vendor'],
                ssh_username=device_dict['ssh_username'],
                ssh_password=device_dict['ssh_password'],
                tunnel_ip=device_dict['tunnel_ip'],
                ports=device_dict['ports'],
                tor_ovs_port=device_dict['tor_ovs_port'],
                tor_ovs_protocol=device_dict['tor_ovs_protocol'],
                controller_ip=device_dict['controller_ip'],
                bringup=True)
            tor_obj.setUp()
        if device_dict['type'] == 'router':
            phy_router_obj = PhysicalRouterFixture(
                device_dict['name'], device_dict['mgmt_ip'],
Beispiel #36
0
    def __init__(self,
                 inputs=None,
                 logger=None,
                 project_name=None,
                 username=None,
                 password=None,
                 domain_name=None,
                 input_file=None,
                 domain_obj=None,
                 scope='domain'):
        self.inputs = inputs or ContrailTestInit(input_file,
                                                 stack_tenant=project_name)
        self.project_name = project_name or self.inputs.project_name
        self.domain_name = domain_name or self.inputs.domain_name
        self.orch_domain_name = domain_name or self.inputs.domain_name
        if self.orch_domain_name == 'Default':
            self.domain_name = 'default-domain'
        self.scope = scope
        self.username = username or self.inputs.stack_user
        self.password = password or self.inputs.stack_password
        self.logger = logger or self.inputs.logger
        self.nova_h = None
        self.quantum_h = None
        self.vnc_lib_fixture = None
        self.api_server_inspects = custom_dict(
            self.get_api_inspect_handle,
            'api_inspect:' + self.project_name + ':' + self.username)
        self.dnsagent_inspect = custom_dict(self.get_dns_agent_inspect_handle,
                                            'dns_inspect')
        self.agent_inspect = custom_dict(self.get_vrouter_agent_inspect_handle,
                                         'agent_inspect')
        self.ops_inspects = custom_dict(
            self.get_opserver_inspect_handle,
            'ops_inspect:' + self.project_name + ':' + self.username)
        self.cn_inspect = custom_dict(self.get_control_node_inspect_handle,
                                      'cn_inspect')
        self.k8s_client = self.get_k8s_api_client_handle()

        # ToDo: msenthil/sandipd rest of init needs to be better handled
        self.domain_id = None
        if self.inputs.domain_isolation:
            #get admin auth to list domains and get domain_id
            auth = self.get_auth_h(username=self.inputs.admin_username,
                                   password=self.inputs.admin_password,
                                   project_name=self.inputs.admin_tenant,
                                   domain_name=self.inputs.admin_domain)
            self.domain_id = auth.get_domain_id(self.domain_name)
        self.auth = self.get_auth_h()
        self.vnc_lib = self.get_vnc_lib_h()
        self.project_id = self.get_project_id()
        if self.inputs.orchestrator == 'openstack':
            if self.inputs.verify_thru_gui():
                self.ui_login = UILogin(self, self.inputs, project_name,
                                        username, password)
                self.browser = self.ui_login.browser
                self.browser_openstack = self.ui_login.browser_openstack

            self.orch = OpenstackOrchestrator(inputs=self.inputs,
                                              vnclib=self.vnc_lib,
                                              logger=self.logger,
                                              auth_h=self.auth)
            self.nova_h = self.orch.get_compute_handler()
            self.quantum_h = self.orch.get_network_handler()
            self.glance_h = self.orch.get_image_handler()
        elif self.inputs.orchestrator == 'vcenter' and self.inputs.slave_orchestrator == 'vro':
            self.orch = VroWorkflows(user=self.inputs.vcenter_username,
                                     pwd=self.inputs.vcenter_password,
                                     host=self.inputs.vcenter_server,
                                     port=self.inputs.vcenter_port,
                                     dc_name=self.inputs.vcenter_dc,
                                     vnc=self.vnc_lib,
                                     inputs=self.inputs,
                                     logger=self.logger)
        elif self.inputs.orchestrator == 'vcenter':  # vcenter
            self.orch = VcenterOrchestrator(user=self.inputs.vcenter_username,
                                            pwd=self.inputs.vcenter_password,
                                            host=self.inputs.vcenter_server,
                                            port=self.inputs.vcenter_port,
                                            dc_name=self.inputs.vcenter_dc,
                                            vnc=self.vnc_lib,
                                            inputs=self.inputs,
                                            logger=self.logger)
        elif self.inputs.orchestrator == 'kubernetes':
            self.orch = None
        if self.inputs.vcenter_gw_setup:  # vcenter_gateway
            self.slave_orch = VcenterGatewayOrch(
                user=self.inputs.vcenter_username,
                pwd=self.inputs.vcenter_password,
                host=self.inputs.vcenter_server,
                port=int(self.inputs.vcenter_port),
                dc_name=self.inputs.vcenter_dc,
                vnc=self.vnc_lib,
                inputs=self.inputs,
                logger=self.logger)
        self._kube_manager_inspect = None
Beispiel #37
0
    def test_vdns_with_diff_zone(self):
        ''' Test vdns in different zones with multi projects '''
        var_obj = self.InitForZoneTests()
        vdns_fixt1 = {}
        ipam_mgmt_obj = {}
        for project in var_obj.project_list:
            dns_server_name = var_obj.proj_vdns[project]
            self.logger.info(
                'Creating vdns server:%s in project:%s',
                dns_server_name,
                project)
            domain_name = '%s.net' % (project)
            ttl = 100
            # VDNS creation
            dns_data = VirtualDnsType(
                domain_name=domain_name, dynamic_records_from_client=True,
                default_ttl_seconds=ttl, record_order='random')
            vdns_fixt1[project] = self.useFixture(
                VdnsFixture(
                    self.inputs,
                    self.connections,
                    vdns_name=dns_server_name,
                    dns_data=dns_data))
            result, msg = vdns_fixt1[project].verify_on_setup()
            self.assertTrue(result, msg)
            dns_server = IpamDnsAddressType(
                virtual_dns_server_name=vdns_fixt1[project].vdns_fq_name)
            ipam_mgmt_obj[project] = IpamType(
                ipam_dns_method='virtual-dns-server',
                ipam_dns_server=dns_server)
        ipam_fixt = {}
        vn_fixt = {}
        vm_fix = {}
        pol_fixt = {}
        for proj in var_obj.project_list:
            # User creation
            user_fixture = self.useFixture(
                UserFixture(
                    connections=self.admin_connections,
                    username=var_obj.proj_user[proj],
                    password=var_obj.proj_pass[proj]))
            # Project creation
            project_fixture = self.useFixture(
                ProjectFixture(
                    project_name=proj,
                    username=var_obj.proj_user[proj],
                    password=var_obj.proj_pass[proj],
                    connections=self.admin_connections))
            user_fixture.add_user_to_tenant(proj, var_obj.proj_user[proj], 'admin')
            project_fixture.set_user_creds(var_obj.proj_user[proj], var_obj.proj_pass[proj])
            project_inputs = ContrailTestInit(
                    self.ini_file,
                    stack_user=project_fixture.project_username,
                    stack_password=project_fixture.project_user_password,
                    stack_tenant=proj,
                    logger=self.logger)
            project_connections = ContrailConnections(project_inputs,
                                                      logger=self.logger)
            self.logger.info(
                'Default SG to be edited for allow all on project: %s' % proj)
            project_fixture.set_sec_group_for_allow_all(proj, 'default')
            # Ipam creation
            ipam_fixt[proj] = self.useFixture(IPAMFixture(var_obj.ipam_list[proj], vdns_obj= vdns_fixt1[proj].obj,
                        project_obj=project_fixture, ipamtype=ipam_mgmt_obj[proj]))
            # VN Creation
            vn_fixt[proj] = self.useFixture(
                VNFixture(
                    project_name=proj,
                    connections=project_connections,
                    vn_name=var_obj.vn_list[proj],
                    inputs=project_inputs,
                    subnets=var_obj.vn_nets[proj],
                    ipam_fq_name=ipam_fixt[proj].getObj().get_fq_name()))
            vn_quantum_obj = self.orch.get_vn_obj_if_present(vn_name=var_obj.vn_list[proj], project_id=project_fixture.uuid)
            # VM creation
            vm_fix[proj] = self.useFixture(
                VMFixture(
                    project_name=proj,
                    connections=project_connections,
                    vn_obj=vn_quantum_obj,
                    vm_name=var_obj.vm_list[proj]))
            vm_fix[proj].verify_vm_launched()
            vm_fix[proj].verify_on_setup()
            vm_fix[proj].wait_till_vm_is_up()
            msg = "Ping by using name %s is failed. Dns server \
                  should resolve VM name to IP" % (var_obj.vm_list[proj])
            self.assertTrue(
                vm_fix[proj].ping_with_certainty(ip=var_obj.vm_list[proj]), msg)
            vm_ip = vm_fix[proj].get_vm_ip_from_vm(
                vn_fq_name=vm_fix[proj].vn_fq_name)
            vm_rev_ip = vm_ip.split('.')
            vm_rev_ip = '.'.join(
                (vm_rev_ip[3], vm_rev_ip[2], vm_rev_ip[1], vm_rev_ip[0]))
            vm_rev_ip = vm_rev_ip + '.in-addr.arpa'
            rev_zone = var_obj.vn_nets[proj][0].split('/')[0].split('.')
            rev_zone = '.'.join((rev_zone[0], rev_zone[1], rev_zone[2]))
            rev_zone = rev_zone + '.in-addr.arpa'
            # Frame the Expected DNS data for VM, one for 'A' record and
            # another 'PTR' record.
            domain_name = '%s.net' % (proj)
            rec_name = var_obj.vm_list[proj] + "." + domain_name
            agent_inspect_h = self.agent_inspect[vm_fix[proj].vm_node_ip]
            assigned_dns_ips = agent_inspect_h.get_vna_discovered_dns_server()
            vm_dns_exp_data = [{'rec_data': vm_ip,
                                'rec_type': 'A',
                                'rec_class': 'IN',
                                'rec_ttl': str(ttl),
                                'rec_name': rec_name,
                                'installed': 'yes',
                                'zone': domain_name},
                               {'rec_data': rec_name,
                                'rec_type': 'PTR',
                                'rec_class': 'IN',
                                'rec_ttl': str(ttl),
                                'rec_name': vm_rev_ip,
                                'installed': 'yes',
                                'zone': rev_zone}]
            self.verify_vm_dns_data(vm_dns_exp_data, assigned_dns_ips[0])
            vm_dns_exp_data = []
        self.logger.info(
            'Restart supervisor-config & supervisor-control and test ping')
        for bgp_ip in self.inputs.bgp_ips:
            self.inputs.restart_service('supervisor-control', [bgp_ip],
										container='controller')
        for cfgm_ip in self.inputs.cfgm_ips:
            self.inputs.restart_service('supervisor-config', [cfgm_ip],
										container='controller')
        status_checker = ContrailStatusChecker(self.inputs)
        self.logger.debug("Waiting for all the services to be UP")
        assert status_checker.wait_till_contrail_cluster_stable()[0],\
                "All services could not come UP after restart"
        for proj in var_obj.project_list:
            msg = "Ping by using name %s is failed. Dns server \
                  should resolve VM name to IP" % (var_obj.vm_list[proj])
            self.assertTrue(
                vm_fix[proj].ping_with_certainty(ip=var_obj.vm_list[proj]), msg)
        return True
from tests import TestSanityFixture
from securitygroup.sanity import SecurityGroupSanityTests
from servicechain.firewall.sanity_with_setup import SvcMonSanityFixture
from common.contrail_test_init import ContrailTestInit
from tcutils.contrailtestrunner import ContrailHTMLTestRunner


if __name__ == "__main__":

    if not get_os_env('SCRIPT_TS'):
        os.environ['SCRIPT_TS'] = time.strftime("%Y_%m_%d_%H_%M_%S")
    if 'PARAMS_FILE' in os.environ:
        ini_file = os.environ.get('PARAMS_FILE')
    else:
        ini_file = 'params.ini'
    inputs = ContrailTestInit(ini_file)
    inputs.setUp()
    print "\nTest Log File : %s" % (inputs.log_file)
    suite = unittest.TestSuite()
    test_result = unittest.TestResult()
    suite.addTest(Upgrade('test_fiptraffic_before_upgrade'))
    suite.addTest(Upgrade('test_upgrade'))
    suite.addTest(Upgrade('test_traffic_after_upgrade'))
    suite.addTest(TestVMVN('test_vn_add_delete'))
    suite.addTest(TestVMVN('test_vm_add_delete'))
    suite.addTest(TestVMVN('test_ipam_add_delete'))
    suite.addTest(TestSanityFixture('test_project_add_delete'))
    suite.addTest(SecurityGroupSanityTests('test_sec_group_add_delete'))
    suite.addTest(SvcMonSanityFixture('test_svc_in_network_datapath'))
    suite.addTest(SvcMonSanityFixture('test_svc_transparent_with_3_instance'))
    descr = inputs.get_html_description()
import ConfigParser
import ast
import logging

from physical_router_fixture import PhysicalRouterFixture
from common.contrail_test_init import ContrailTestInit
from physical_device_fixture import PhysicalDeviceFixture
from vcpe_router_fixture import VpeRouterFixture
from virtual_router_fixture import VirtualRouterFixture

logging.getLogger('urllib3.connectionpool').setLevel(logging.WARN)
logging.getLogger('paramiko.transport').setLevel(logging.WARN)


if __name__ == "__main__":
    init_obj = ContrailTestInit(sys.argv[1])
    for (device, device_dict) in init_obj.physical_routers_data.iteritems():
        if device_dict.get('role') in ['leaf', 'spine']:
            continue
        phy_router_obj = PhysicalRouterFixture(
                device_dict['name'],
                device_dict['mgmt_ip'],
                asn=device_dict['asn'],
                model=device_dict.get('model', 'mx'),
                vendor=device_dict.get('vendor', 'juniper'),
                ssh_username=device_dict.get('ssh_username'),
                ssh_password=device_dict.get('ssh_password'),
                tunnel_ip=device_dict.get('tunnel_ip'),
                ports=device_dict.get('ports'),
                dm_managed=device_dict.get('dm_managed'),
                tsn=device_dict.get('tsn'),
Beispiel #40
0
import sys
#import json
#import ConfigParser
import logging
from fabric.context_managers import settings
from fabric.operations import put

from common.contrail_test_init import ContrailTestInit

logging.getLogger('urllib3.connectionpool').setLevel(logging.WARN)
logging.getLogger('paramiko.transport').setLevel(logging.WARN)

CONTRAIL_CONF_PATH = '/etc/contrail'

if __name__ == "__main__":
    init_obj = ContrailTestInit(sys.argv[1])
    if init_obj.tor_agent_data:
        print('Configuring any cert files required for tor-agents')
    else:
        print('No tor-agents in the setup, no cert files will be configured')
        sys.exit(0)

    for ta_host_string, ta_list in init_obj.tor_agent_data.iteritems():
        (user, ip) = ta_host_string.split('@')
        password = init_obj.host_data[ip]['password']
        with settings(host_string=ta_host_string, password=password):
            # Copy cacert.pem
            cacert_file = '%s/ssl/certs/cacert.pem' % (CONTRAIL_CONF_PATH)
            put('tools/tor/cacert.pem', cacert_file)
            for tor_agent in ta_list:
                if tor_agent.get('tor_ovs_protocol') != 'pssl':
Beispiel #41
0
import ast
import logging

from tor_fixture import ToRFixtureFactory
from physical_router_fixture import PhysicalRouterFixture
from common.contrail_test_init import ContrailTestInit
from physical_device_fixture import PhysicalDeviceFixture
from vcpe_router_fixture import VpeRouterFixture
from virtual_router_fixture import VirtualRouterFixture

logging.getLogger('urllib3.connectionpool').setLevel(logging.WARN)
logging.getLogger('paramiko.transport').setLevel(logging.WARN)


if __name__ == "__main__":
    init_obj = ContrailTestInit(sys.argv[1])
    init_obj.read_prov_file()
    for (device, device_dict) in init_obj.physical_routers_data.iteritems():
        if device_dict['type'] == 'tor':
            tor_obj = ToRFixtureFactory.get_tor(
                device_dict['name'],
                device_dict['mgmt_ip'],
                vendor=device_dict['vendor'],
                ssh_username=device_dict['ssh_username'],
                ssh_password=device_dict['ssh_password'],
                tunnel_ip=device_dict['tunnel_ip'],
                ports=device_dict['ports'],
                tor_ovs_port=device_dict['tor_ovs_port'],
                tor_ovs_protocol=device_dict['tor_ovs_protocol'],
                controller_ip=device_dict['controller_ip'],
                cfgm_ip=init_obj.cfgm_ip,
Beispiel #42
0
import ConfigParser
import ast
import logging

from tor_fixture import ToRFixtureFactory
from physical_router_fixture import PhysicalRouterFixture
from common.contrail_test_init import ContrailTestInit
from physical_device_fixture import PhysicalDeviceFixture
from vcpe_router_fixture import VpeRouterFixture
from virtual_router_fixture import VirtualRouterFixture

logging.getLogger('urllib3.connectionpool').setLevel(logging.WARN)
logging.getLogger('paramiko.transport').setLevel(logging.WARN)

if __name__ == "__main__":
    init_obj = ContrailTestInit(sys.argv[1])
    for (device, device_dict) in init_obj.physical_routers_data.iteritems():
        if device_dict['type'] == 'tor':
            tor_obj = ToRFixtureFactory.get_tor(
                device_dict['name'],
                device_dict['mgmt_ip'],
                vendor=device_dict['vendor'],
                ssh_username=device_dict['ssh_username'],
                ssh_password=device_dict['ssh_password'],
                tunnel_ip=device_dict['tunnel_ip'],
                ports=device_dict['ports'],
                tor_ovs_port=device_dict['tor_ovs_port'],
                tor_ovs_protocol=device_dict['tor_ovs_protocol'],
                controller_ip=device_dict['controller_ip'],
                cfgm_ip=init_obj.cfgm_ip,
                auth_server_ip=init_obj.auth_ip,
import sys
#import json
#import ConfigParser
import logging
from fabric.context_managers import settings
from fabric.operations import put

from common.contrail_test_init import ContrailTestInit

logging.getLogger('urllib3.connectionpool').setLevel(logging.WARN)
logging.getLogger('paramiko.transport').setLevel(logging.WARN)

CONTRAIL_CONF_PATH = '/etc/contrail'

if __name__ == "__main__":
    init_obj = ContrailTestInit(sys.argv[1])
    init_obj.read_prov_file()
    if init_obj.tor_agent_data:
        print 'Configuring any cert files required for tor-agents'
    else:
        print 'No tor-agents in the setup, no cert files will be configured'
        sys.exit(0)

    for ta_host_string, ta_list in init_obj.tor_agent_data.iteritems():
        (user, ip) = ta_host_string.split('@')
        password = init_obj.host_data[ip]['password']
        with settings(host_string=ta_host_string, password=password):
            # Copy cacert.pem
            cacert_file = '%s/ssl/certs/cacert.pem' % (CONTRAIL_CONF_PATH)
            put('tools/tor/cacert.pem', cacert_file)
            for tor_agent in ta_list:
Beispiel #44
0
class ProjectFixture(fixtures.Fixture):
    def __init__(self, connections, project_name=None,
                 username=None, password=None, role='admin',
                 domain_name=None, uuid=None):
        self.inputs = connections.inputs
        if not project_name:
            project_name = self.inputs.stack_tenant
        self.connections = connections
        self.project_name = project_name
        self.domain_name = domain_name or self.inputs.domain_name
        self.logger = connections.inputs.logger
        self.username = username or self.inputs.stack_user
        self.password = password or self.inputs.stack_password
        self.role = role
        self.user_dict = {}
        self._create_user_set = {}
        self.auth = self.connections.get_auth_h()
        self.vnc_lib_h = self.connections.get_vnc_lib_h()
        self.already_present = False
        self.verify_is_run = False
        self.project_fq_name = [self.domain_name, self.project_name]
        if uuid:
            self.project_obj = self.vnc_lib_h.project_read(id=uuid)
            self.project_name = self.project_obj.name
            self.project_fq_name = self.project_obj.get_fq_name()
            self.uuid = uuid
    # end __init__

    def _create_project(self):
        if self.project_name == self.inputs.stack_tenant:
            self.uuid = self.auth.get_project_id(self.domain_name,
                                                 self.project_name)
            if not self.uuid:
                self.logger.info('Project %s not found' % (
                    self.project_name))
                raise Exception('Project %s not found' % (
                    self.project_name))

            self.already_present = True
            self.logger.debug(
                        'Project %s already present.Not creating it' %
                        self.project_fq_name)
            self.project_obj = self.vnc_lib_h.project_read(id=self.uuid)
            return

        self.connections.inputs.domain_name = self.domain_name
        self.connections.project_name = self.project_name

        self.logger.info('Proceed with creation of new project.')
        #if self.domain_name:
        #   try:
        #     dom_obj   = self.connections.vnc_lib.domain_read(fq_name=[self.domain_name])
        #   except:
        #d_obj     = Domain(self.domain_name)
        #     d_obj.set_domain_limits(gen.resource_xsd.DomainLimitsType.populate())
        #     d_obj.set_id_perms(gen.resource_xsd.IdPermsType.populate())
        #     d_obj.set_perms2(gen.resource_xsd.PermType2.populate())

        #domain_id = self.connections.vnc_lib.domain_create(d_obj)
        #sys.exit()
        #dom_obj   = self.connections.vnc_lib.domain_read(id=domain_id)
        #if self.domain_name:
        #pobj = Project(self.project_name,parent_obj=dom_obj)
        #else:
        #   pobj = Project(self.project_name)
        #pobj = Project(self.project_name)
        #self.uuid = self.connections.vnc_lib.project_create(pobj) 
        self.uuid = self.auth.create_project(self.project_name)
        self.logger.info('Created Project:%s, ID : %s ' % (self.project_name,
                                                           self.uuid))
    # end _create_project

    def _delete_project(self):
        self.logger.info('Deleting Project %s' % self.project_fq_name)
        self.auth.delete_project(self.project_name)
    # end _delete_project

    def setUp(self):
        super(ProjectFixture, self).setUp()
        self._create()

    def _create(self):
        self.uuid = self.auth.get_project_id(self.domain_name,
                                             self.project_name)
        if self.uuid:
            self.already_present = True
            self.logger.debug(
                    'Project %s already present.Not creating it' %
                    self.project_fq_name)
        else:
            self.logger.info('Project %s not found, creating it' % (
                self.project_name))
            self._create_project()
            time.sleep(2)
        self.project_obj = self.vnc_lib_h.project_read(id=self.uuid)
    # end setUp

    def get_uuid(self):
        return self.uuid

    def get_fq_name(self):
        return self.project_fq_name

    def getObj(self):
        return getattr(self, 'project_obj', None)

    def cleanUp(self):
        super(ProjectFixture, self).cleanUp()
        self.delete()

    def delete(self, verify=False):
        if self.inputs.orchestrator == 'vcenter':
            self.logger.debug('No need to verify projects in case of vcenter')
            return
        do_cleanup = True
        if self.inputs.fixture_cleanup == 'no':
            do_cleanup = False
        if self.already_present:
            do_cleanup = False
        if self.inputs.fixture_cleanup == 'force':
            do_cleanup = True
        if do_cleanup:
            if not self.check_no_project_references():
                self.logger.warn('One or more references still present' 
                    ', will not delete the project %s' % (self.project_name))
                return
            self.auth.reauth()
            self._delete_project()
            if self.verify_is_run or verify:
                assert self.verify_on_cleanup()
        else:
            self.logger.debug('Skipping the deletion of Project %s' %
                              self.project_fq_name)
    # end cleanUp

    @retry(delay=2, tries=10)
    def check_no_project_references(self):
        vnc_project_obj = self.vnc_lib_h.project_read(id=self.uuid)
        vns = vnc_project_obj.get_virtual_networks()
        if vns:
            self.logger.warn('Project %s still has VNs %s before deletion' %(
                self.project_name, vns))
            return False
        vmis = vnc_project_obj.get_virtual_machine_interfaces()
        if vmis:
            self.logger.warn('Project %s still has VMIs %s before deletion' %(
                self.project_name, vmis))
            return False
        sgs = vnc_project_obj.get_security_groups()
        if sgs and len(sgs) > 1:
            self.logger.warn('Project %s still has SGs %s before deletion' %(
                self.project_name, sgs))
            return False
        return True
    # end check_no_project_references

    def get_project_inputs(self, username=None, password=None):
        if not username:
            username = self.username
        if not password:
            password = self.password
        self.project_inputs= ContrailTestInit(self.inputs.ini_file,
                                     stack_user=username,
                                     stack_password=password,
                                     project_fq_name=['default-domain',self.project_name],
                                     logger = self.logger)
        self.project_inputs.setUp()
        return self.project_inputs

    def get_project_connections(self, username=None, password=None):
        if not username:
            username = self.username
        if not password:
            password = self.password
        project_inputs = self.get_project_inputs()
        if not getattr(self, 'project_connections', None):
            self.project_connections = ContrailConnections(
                inputs=project_inputs,
                logger=project_inputs.logger,
                project_name=self.project_name,
                username=username,
                password=password)
        return self.project_connections
    # end get_project_connections

    def verify_on_setup(self):
        result = True
        if not self.verify_project_in_api_server():
            result &= False
            self.logger.error('Verification of project %s in APIServer '
                              'failed!! ' % (self.project_name))
        self.verify_is_run = True
        return result
    # end verify_on_setup

    @retry(delay=2, tries=6)
    def verify_project_in_api_server(self):
        if self.inputs.orchestrator == 'vcenter':
            self.logger.debug('No need to verify projects in case of vcenter')
            return True
        result = True
        api_server_inspect_handles = self.connections.get_api_server_inspect_handles()
        for api_s_inspect in api_server_inspect_handles.values():
            cs_project_obj = api_s_inspect.get_cs_project(self.domain_name,
                                                          self.project_name)
            if not cs_project_obj:
                self.logger.warn('Project %s not found in API Server %s'
                                 ' ' % (self.project_name, api_s_inspect._ip))
                result &= False
                return result
            if cs_project_obj['project']['uuid'] != self.uuid:
                self.logger.warn('Project id %s got from API Server is'
                                 ' not matching expected ID %s' % (
                                     cs_project_obj['project']['uuid'], self.uuid))
                result &= False
        if result:
            self.logger.info('Verification of project %s in API Server %s'
                             ' passed ' % (self.project_name, api_s_inspect._ip))
        return result
    # end verify_project_in_api_server

    @retry(delay=10, tries=12)
    def verify_project_not_in_api_server(self):
        if self.inputs.orchestrator == 'vcenter':
            self.logger.debug('No need to verify projects in case of vcenter')
            return True
        result = True
        api_server_inspect_handles = self.connections.get_api_server_inspect_handles()
        for api_s_inspect in api_server_inspect_handles.values():
            cs_project_obj = api_s_inspect.get_cs_project(self.domain_name,
                                                          self.project_name)
            self.logger.info("Check for project %s after deletion, got cs_project_obj %s" %
                (self.project_name, cs_project_obj))
            if cs_project_obj:
                self.logger.warn('Project %s is still found in API Server %s'
                                 'with ID %s ' % (self.project_name, api_s_inspect._ip,
                                                  cs_project_obj['project']['uuid']))
                result &= False
        if result:
            self.logger.info('Verification of project %s removal in API Server '
                             ' %s passed ' % (self.project_name, api_s_inspect._ip))
        return result
    # end verify_project_not_in_api_server

    def set_sec_group_for_allow_all(self, sg_name='default'):
        uuid_1 = uuid.uuid1().urn.split(':')[2]
        uuid_2 = uuid.uuid1().urn.split(':')[2]
        rule1 = [{'direction': '>',
                 'protocol': 'any',
                  'dst_addresses': [{'security_group': 'local', 'subnet': None}],
                  'dst_ports': [{'start_port': 0, 'end_port': 65535}],
                  'src_ports': [{'start_port': 0, 'end_port': 65535}],
                  'src_addresses': [{'subnet': {'ip_prefix': '0.0.0.0', 'ip_prefix_len': 0}}],
                  'rule_uuid': uuid_1
                  },
                 {'direction': '>',
                  'protocol': 'any',
                  'src_addresses': [{'security_group': 'local', 'subnet': None}],
                  'src_ports': [{'start_port': 0, 'end_port': 65535}],
                  'dst_ports': [{'start_port': 0, 'end_port': 65535}],
                  'dst_addresses': [{'subnet': {'ip_prefix': '0.0.0.0', 'ip_prefix_len': 0}}],
                  'rule_uuid': uuid_2
                  },
                 ]
        self.update_sec_group(sg_name, rule1)
    # end set_sec_group_for_allow_all

    def update_sec_group(self, sg_name, rules):
        vnc_lib_h = self.get_project_connections().get_vnc_lib_h()
        old_rules = vnc_lib_h.get_sg_rules(sg_name)
        self.logger.info(
            "Adding rules to the %s security group in Project %s" %
            (sg_name, self.project_name))
        vnc_lib_h.set_sg_rules(sg_name, rules)
        #self.addCleanup(vnc_lib_h.set_sg_rules, sg_name, old_rules)

    @retry(delay=2, tries=10)
    def verify_on_cleanup(self):
        result = True
        if not self.verify_project_not_in_api_server():
            result &= False
            self.logger.error('Project %s is still present in API Server' % (
                self.project_name))
        return result