diff --git a/common/connections.py b/common/connections.py index 68fa8049c..e854efc76 100755 --- a/common/connections.py +++ b/common/connections.py @@ -1,6 +1,4 @@ -from quantum_test import * from vnc_api_test import * -from nova_test import * from tcutils.config.vnc_introspect_utils import * from tcutils.control.cn_introspect_utils import * from tcutils.agent.vna_introspect_utils import * @@ -11,9 +9,9 @@ from tcutils.vdns.dns_introspect_utils import DnsAgentInspect from tcutils.config.ds_introspect_utils import * from tcutils.config.discovery_tests import * -from keystoneclient.v2_0 import client as ks_client -from tcutils.util import get_dashed_uuid import os +from openstack import OpenstackAuth, OpenstackOrchestrator +from vcenter import VcenterAuth, VcenterOrchestrator try: from webui.ui_login import UILogin @@ -33,28 +31,6 @@ def __init__(self, inputs,logger, self.password = password self.project_name = project_name - insecure = bool(os.getenv('OS_INSECURE', True)) - self.ks_client = ks_client.Client( - username=username, - password=password, - tenant_name=project_name, - auth_url = os.getenv('OS_AUTH_URL') or \ - 'http://' + self.inputs.auth_ip + ':5000/v2.0', - insecure=insecure) - self.project_id = get_dashed_uuid(self.ks_client.tenant_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.quantum_fixture = QuantumFixture( - username=username, inputs=self.inputs, - project_id=self.project_id, - password=password, cfgm_ip=self.inputs.cfgm_ip, - openstack_ip=self.inputs.openstack_ip) - self.quantum_fixture.setUp() - inputs.openstack_ip = self.inputs.openstack_ip - self.vnc_lib_fixture = VncLibFixture( username=username, password=password, domain=self.inputs.domain_name, project=project_name, @@ -63,11 +39,31 @@ def __init__(self, inputs,logger, self.vnc_lib_fixture.setUp() self.vnc_lib = self.vnc_lib_fixture.get_handle() - self.nova_fixture = NovaFixture(inputs=inputs, - project_name=project_name, - username=username, - password=password) - self.nova_fixture.setUp() + self.nova_h = None + self.quantum_h = None + if self.inputs.orchestrator == 'openstack': + self.auth = OpenstackAuth(username, password, project_name, self.inputs, logger) + self.project_id = self.auth.get_project_id(self.inputs.domain_name, project_name) + + 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=username, password=password, + project_id=self.project_id, project_name=project_name, + inputs=inputs, vnclib=self.vnc_lib, logger=logger) + self.nova_h = self.orch.nova_h + self.quantum_h = self.orch.quantum_h + else: # vcenter + self.auth = VcenterAuth(username, password, project_name, self.inputs) + self.orch = VcenterOrchestrator(user=username, pwd=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=logger) + self.api_server_inspects = {} self.dnsagent_inspect = {} self.cn_inspect = {} diff --git a/common/contrail_test_init.py b/common/contrail_test_init.py index c5557ec3b..f1edbcc7a 100755 --- a/common/contrail_test_init.py +++ b/common/contrail_test_init.py @@ -285,10 +285,7 @@ def setUp(self): 'supervisor-analytics', 'contrail-alarm-gen', 'contrail-snmp-collector', 'contrail-topology'] self.correct_states = ['active', 'backup'] - if self.devstack: - self.mysql_token = 'contrail123' - else: - self.mysql_token = self.get_mysql_token() + self.mysql_token = self.get_mysql_token() self.copy_fabfile_to_agents() # end setUp @@ -778,6 +775,10 @@ def run_provision_control( # end run_provision_control def get_mysql_token(self): + if self.orchestrator == 'vcenter': + return None + if self.devstack: + return 'contrail123' username = self.host_data[self.openstack_ip]['username'] password = self.host_data[self.openstack_ip]['password'] cmd = 'cat /etc/contrail/mysql.token' diff --git a/common/ecmp/ecmp_traffic.py b/common/ecmp/ecmp_traffic.py index 331b25684..9ff1ed732 100644 --- a/common/ecmp/ecmp_traffic.py +++ b/common/ecmp/ecmp_traffic.py @@ -66,7 +66,7 @@ def start_traffic(self, src_vm, dst_vm_list, stream_list, src_ip=None, dst_ip=No sender = {} receiver = {} tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(src_vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(src_vm.vm_obj)]['host_ip'] tx_local_host = Host( tx_vm_node_ip, self.inputs.host_data[tx_vm_node_ip]['username'], @@ -79,7 +79,7 @@ def start_traffic(self, src_vm, dst_vm_list, stream_list, src_ip=None, dst_ip=No for dst_vm in dst_vm_list: rx_vm_node_ip[dst_vm] = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(dst_vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(dst_vm.vm_obj)]['host_ip'] rx_local_host[dst_vm] = Host( rx_vm_node_ip[dst_vm], self.inputs.host_data[rx_vm_node_ip[dst_vm]]['username'], diff --git a/common/ecmp/ecmp_verify.py b/common/ecmp/ecmp_verify.py index bb5c098b5..00b740eab 100644 --- a/common/ecmp/ecmp_verify.py +++ b/common/ecmp/ecmp_verify.py @@ -40,7 +40,7 @@ def find_rt_in_ctrl_node(self, src_vn, src_vm, dst_vm, svm_ids): assert count > 0, 'Some Problem with the setup. Pls chk XMPP connection' svm_route_entry = {} for svm_id in svm_ids: - svc_obj = self.nova_fixture.get_vm_by_id( + svc_obj = self.nova_h.get_vm_by_id( svm_id, self.inputs.project_name) left_ip[svm_id] = svc_obj.addresses[self.si_fixtures[0] .left_vn_name.split(':')[2]][0]['addr'] @@ -160,6 +160,6 @@ def get_svms_in_si(self, si, proj_name): svm_ids= si.svm_ids svm_list= [] for svm_id in svm_ids: - svm_list.append(self.nova_fixture.get_vm_by_id(svm_id, proj_name)) + svm_list.append(self.nova_h.get_vm_by_id(svm_id, proj_name)) return svm_list #end get_svms_in_si diff --git a/common/isolated_creds.py b/common/isolated_creds.py index b685892f4..33f7fb5ae 100644 --- a/common/isolated_creds.py +++ b/common/isolated_creds.py @@ -1,7 +1,6 @@ import project_test from common.contrail_test_init import ContrailTestInit from common.connections import ContrailConnections -from keystone_tests import KeystoneCommands import os import fixtures from test import BaseTestCase @@ -30,18 +29,23 @@ def __init__(self,project_name, inputs, ini_file=None, logger=None, self.password = project_name self.ini_file = ini_file self.logger = logger + if self.inputs.orchestrator == 'vcenter': + self.project_name = self.inputs.stack_tenant + self.user = self.inputs.stack_user + self.password = self.inputs.stack_password def setUp(self): super(IsolatedCreds, self).setUp() self.connections= ContrailConnections(self.inputs, self.logger) self.vnc_lib= self.connections.vnc_lib + self.auth = self.connections.auth def create_tenant(self): self.project = None time.sleep(4) try: - self.project = project_test.ProjectFixture(project_name = self.project_name, + self.project = project_test.ProjectFixture(project_name = self.project_name, auth=self.auth, vnc_lib_h= self.vnc_lib,username= self.user,password= self.password, connections= self.connections) self.project.setUp() @@ -55,56 +59,23 @@ def delete_tenant(self): self.project.cleanUp() def delete_user(self,user=None): - + if self.inputs.orchestrator == 'vcenter': + return if user: user = user else: user = self.user - insecure = bool(os.getenv('OS_INSECURE',True)) - try: - self.auth_url = os.getenv('OS_AUTH_URL') or \ - 'http://' + self.inputs.openstack_ip + ':5000/v2.0' - self.key_stone_clients= KeystoneCommands(username= self.inputs.stack_user, - password= self.inputs.stack_password, - tenant= self.inputs.project_name, - auth_url= auth_url, insecure=insecure) - - except Exception as e: - self.logger.warn("Failed - Keystone client instance") - self.key_stone_clients.delete_user(user) + self.auth.delete_user(user) def create_and_attach_user_to_tenant(self,user = None , password=None): - insecure = bool(os.getenv('OS_INSECURE',True)) - try: - auth_url = os.getenv('OS_AUTH_URL') or \ - 'http://' + self.inputs.openstack_ip + ':5000/v2.0' - self.key_stone_clients= KeystoneCommands(username= self.inputs.stack_user, - password= self.inputs.stack_password, - tenant= self.inputs.project_name, - auth_url= auth_url, insecure=insecure) - - user = user if user else self.user - password = password if password else self.password - try: - self.key_stone_clients.create_user(user,password, - email='',tenant_name=self.inputs.stack_tenant,enabled=True) - except: - self.logger.info("%s user already created"%(self.user)) - - try: - self.key_stone_clients.add_user_to_tenant(self.project_name,user , 'admin') - - except Exception as e: - self.logger.info("%s user already added to project"%(user)) - - try: - self.key_stone_clients.add_user_to_tenant(self.project_name,'admin' , 'admin') - except Exception as e: - self.logger.info("Admin user already added to project") - - time.sleep(4) - except Exception as e: - self.logger.info("Failed - Keystone client instance") + if self.inputs.orchestrator == 'vcenter': + return + user = user if user else self.user + password = password if password else self.password + self.auth.create_user(user,password) + self.auth.add_user_to_project(user, self.project_name) + self.auth.add_user_to_project('admin', self.project_name) + time.sleep(4) def get_inputs(self): diff --git a/common/neutron/base.py b/common/neutron/base.py index 7cda3478b..ef239f89d 100644 --- a/common/neutron/base.py +++ b/common/neutron/base.py @@ -35,8 +35,8 @@ def setUpClass(cls): cls.connections = cls.isolated_creds.get_conections() cls.admin_inputs = cls.isolated_creds.get_admin_inputs() cls.admin_connections = cls.isolated_creds.get_admin_connections() - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect @@ -80,18 +80,18 @@ def create_vm(self, vn_fixture, vm_name, node_name=None, port_ids=port_ids)) def create_router(self, router_name, tenant_id=None): - obj = self.quantum_fixture.create_router(router_name, tenant_id) + obj = self.quantum_h.create_router(router_name, tenant_id) if obj: - self.addCleanup(self.quantum_fixture.delete_router, obj['id']) + self.addCleanup(self.quantum_h.delete_router, obj['id']) return obj def delete_router(self, router_id=None): - val = self.quantum_fixture.delete_router(router_id) + val = self.quantum_h.delete_router(router_id) def create_port(self, net_id, subnet_id=None, ip_address=None, mac_address=None, no_security_group=False, security_groups=[], extra_dhcp_opts=None): - port_rsp = self.quantum_fixture.create_port( + port_rsp = self.quantum_h.create_port( net_id, subnet_id, ip_address, @@ -103,26 +103,26 @@ def create_port(self, net_id, subnet_id=None, ip_address=None, return port_rsp def delete_port(self, port_id, quiet=False): - self._remove_from_cleanup(self.quantum_fixture.delete_port, (port_id)) - if quiet and not self.quantum_fixture.get_port(port_id): + self._remove_from_cleanup(self.quantum_h.delete_port, (port_id)) + if quiet and not self.quantum_h.get_port(port_id): return - self.quantum_fixture.delete_port(port_id) + self.quantum_h.delete_port(port_id) def update_port(self, port_id, port_dict): - if not self.quantum_fixture.get_port(port_id): + if not self.quantum_h.get_port(port_id): self.logger.error('Port with port_id %s not found' % port_id) return else: - port_rsp = self.quantum_fixture.update_port(port_id, port_dict) + port_rsp = self.quantum_h.update_port(port_id, port_dict) return port_rsp def add_router_interface(self, router_id, subnet_id=None, port_id=None, cleanup=True): if subnet_id: - result = self.quantum_fixture.add_router_interface( + result = self.quantum_h.add_router_interface( router_id, subnet_id) elif port_id: - result = self.quantum_fixture.add_router_interface(router_id, + result = self.quantum_h.add_router_interface(router_id, port_id=port_id) if cleanup: @@ -133,7 +133,7 @@ def add_router_interface(self, router_id, subnet_id=None, port_id=None, def delete_router_interface(self, router_id, subnet_id=None, port_id=None): self._remove_from_cleanup(self.delete_router_interface, (router_id, subnet_id, port_id)) - self.quantum_fixture.delete_router_interface( + self.quantum_h.delete_router_interface( router_id, subnet_id, port_id) def add_vn_to_router(self, router_id, vn_fixture, cleanup=True): @@ -151,7 +151,7 @@ def create_security_group(self, name, quantum_handle=None): if quantum_handle: q_h = quantum_handle else: - q_h = self.quantum_fixture + q_h = self.quantum_h obj = q_h.create_security_group(name) if obj: self.addCleanup(self.delete_security_group, obj['id']) @@ -163,7 +163,7 @@ def delete_security_group(self, sg_id, quantum_handle=None): if quantum_handle: q_h = quantum_handle else: - q_h = self.quantum_fixture + q_h = self.quantum_h q_h.delete_security_group(sg_id) def update_default_quota_list( @@ -446,11 +446,11 @@ def _remove_from_cleanup(self, func_call, *args): def create_lb_pool(self, name, lb_method, protocol, subnet_id): lb_pool_resp = None - lb_pool_resp = self.quantum_fixture.create_lb_pool( + lb_pool_resp = self.quantum_h.create_lb_pool( name, lb_method, protocol, subnet_id) if lb_pool_resp: self.addCleanup(self.verify_on_pool_delete, lb_pool_resp['id']) - self.addCleanup(self.quantum_fixture.delete_lb_pool, + self.addCleanup(self.quantum_h.delete_lb_pool, lb_pool_resp['id']) return lb_pool_resp # end create_lb_pool @@ -474,11 +474,11 @@ def verify_pool_not_in_api_server(self, pool_id): def create_lb_member(self, ip_address, protocol_port, pool_id): lb_member_resp = None - lb_member_resp = self.quantum_fixture.create_lb_member( + lb_member_resp = self.quantum_h.create_lb_member( ip_address, protocol_port, pool_id) if lb_member_resp: self.addCleanup(self.verify_on_member_delete, lb_member_resp['id']) - self.addCleanup(self.quantum_fixture.delete_lb_member, + self.addCleanup(self.quantum_h.delete_lb_member, lb_member_resp['id']) return lb_member_resp # end create_lb_member @@ -502,11 +502,11 @@ def verify_member_not_in_api_server(self, member_id): def create_health_monitor(self, delay, max_retries, probe_type, timeout): hm_resp = None - hm_resp = self.quantum_fixture.create_health_monitor( + hm_resp = self.quantum_h.create_health_monitor( delay, max_retries, probe_type, timeout) if hm_resp: self.addCleanup(self.verify_on_healthmonitor_delete, hm_resp['id']) - self.addCleanup(self.quantum_fixture.delete_health_monitor, + self.addCleanup(self.quantum_h.delete_health_monitor, hm_resp['id']) return hm_resp # end create_health_monitor @@ -532,11 +532,11 @@ def verify_healthmonitor_not_in_api_server(self, healthmonitor_id): def create_vip(self, name, protocol, protocol_port, subnet_id, pool_id): vip_resp = None - vip_resp = self.quantum_fixture.create_vip( + vip_resp = self.quantum_h.create_vip( name, protocol, protocol_port, subnet_id, pool_id) if vip_resp: self.addCleanup(self.verify_on_vip_delete, pool_id, vip_resp['id']) - self.addCleanup(self.quantum_fixture.delete_vip, + self.addCleanup(self.quantum_h.delete_vip, vip_resp['id']) return vip_resp # end create_vip @@ -557,7 +557,7 @@ def verify_on_vip_delete(self, pool_id, vip_id): @retry(delay=10, tries=10) def verify_vip_delete(self, vip_id): - vip = self.quantum_fixture.show_vip(vip_id) + vip = self.quantum_h.show_vip(vip_id) if vip: errmsg = "vip %s still exists after delete" % vip_id self.logger.error(errmsg) @@ -569,7 +569,7 @@ def verify_vip_delete(self, vip_id): @retry(delay=10, tries=10) def verify_netns_delete(self, compute_ip, pool_id): cmd = 'ip netns list | grep %s' % pool_id - pool_obj = self.quantum_fixture.get_lb_pool(pool_id) + pool_obj = self.quantum_h.get_lb_pool(pool_id) out = self.inputs.run_cmd_on_server( compute_ip, cmd, self.inputs.host_data[compute_ip]['username'], @@ -588,7 +588,7 @@ def verify_netns_delete(self, compute_ip, pool_id): @retry(delay=10, tries=10) def verify_haproxy_kill(self, compute_ip, pool_id): cmd = 'ps -aux | grep loadbalancer | grep %s' % pool_id - pool_obj = self.quantum_fixture.get_lb_pool(pool_id) + pool_obj = self.quantum_h.get_lb_pool(pool_id) pid = [] out = self.inputs.run_cmd_on_server( compute_ip, cmd, @@ -625,12 +625,12 @@ def verify_vip_not_in_api_server(self, vip_id): return True, None def associate_health_monitor(self, pool_id, hm_id): - hm_resp = self.quantum_fixture.associate_health_monitor( + hm_resp = self.quantum_h.associate_health_monitor( pool_id, hm_id) if hm_resp: self.addCleanup(self.verify_on_disassociate_health_monitor, pool_id, hm_id) - self.addCleanup(self.quantum_fixture.disassociate_health_monitor, + self.addCleanup(self.quantum_h.disassociate_health_monitor, pool_id, hm_id) # end associate_health_monitor diff --git a/common/openstack_libs.py b/common/openstack_libs.py new file mode 100644 index 000000000..c3f9d9bb6 --- /dev/null +++ b/common/openstack_libs.py @@ -0,0 +1,51 @@ +# import handling for quantum & neutron +try: + from quantumclient.quantum import client as quantum_client + from quantumclient.client import HTTPClient as quantum_http_client + from quantumclient.common import exceptions as quantum_exception + from quantumclient.common.exceptions import QuantumClientException as quantum_client_exception +except: + quantum_client = None + quantum_http_client = None + quantum_exception = None + quantum_client_exception = None + +try: + from neutronclient.neutron import client as neutron_client + from neutronclient.client import HTTPClient as neutron_http_client + from neutronclient.common import exceptions as neutron_exception + from neutronclient.common.exceptions import NeutronClientException as neutron_client_exception +except: + neutron_client = None + neutron_http_client = None + neutron_exception = None + neutron_client_exception = None + +network_client = quantum_client if quantum_client else neutron_client +network_http_client = quantum_http_client if quantum_http_client else neutron_http_client +network_exception = quantum_exception if quantum_exception else neutron_exception +if quantum_client_exception: + network_client_exception = quantum_client_exception +elif neutron_client_exception: + network_client_exception = neutron_client_exception +else: + network_client_exception = Exception + +# import handling for keystone +try: + from keystoneclient.v2_0 import client as ks_client + from keystoneclient import exceptions as ks_exceptions + import keystoneclient +except: + ks_client = None + ks_exceptions = None + keystoneclient = None + +# import handling for nova +try: + from novaclient import client as nova_client + from novaclient import exceptions as nova_exception +except: + nova_client = None + nova_exception = None + diff --git a/common/policy/config.py b/common/policy/config.py index 2f6c1e715..ea82ac7e9 100644 --- a/common/policy/config.py +++ b/common/policy/config.py @@ -17,7 +17,7 @@ class AttachPolicyFixture(fixtures.Fixture): def __init__(self, inputs, connections, vn_fixture, policy_fixture, policy_type=None): self.inputs = inputs self.logger = self.inputs.logger - self.quantum_fixture = connections.quantum_fixture + self.quantum_h = connections.quantum_h self.vnc_lib = connections.vnc_lib self.vn_fixture = vn_fixture self.policy_fixture = policy_fixture @@ -38,7 +38,7 @@ def setUp(self): self.vn_obj.add_network_policy(self.policy_obj, self.policy_type) self.vnc_lib.virtual_network_update(self.vn_obj) # Required for verification by VNFixture in vn_test.py - policy = self.quantum_fixture.get_policy_if_present( + policy = self.quantum_h.get_policy_if_present( self.policy_fixture.project_name, self.policy_fixture.policy_name) policy_name_objs = dict((policy_obj['policy']['name'], policy_obj) for policy_obj in self.vn_fixture.policy_objs) @@ -52,7 +52,7 @@ def cleanUp(self): self.vn_obj.del_network_policy(self.policy_obj) self.vnc_lib.virtual_network_update(self.vn_obj) # Required for verification by VNFixture in vn_test.py - policy = self.quantum_fixture.get_policy_if_present( + policy = self.quantum_h.get_policy_if_present( self.policy_fixture.project_name, self.policy_fixture.policy_name) policy_name_objs = dict((policy_obj['policy']['name'], policy_obj) for policy_obj in self.vn_fixture.policy_objs) diff --git a/common/policy/policy_test_helper.py b/common/policy/policy_test_helper.py index 1458121ea..cd0136b2e 100644 --- a/common/policy/policy_test_helper.py +++ b/common/policy/policy_test_helper.py @@ -16,8 +16,9 @@ def comp_rules_from_policy_to_system(self): # Initializing the connections to quantum/api/nova/agent fixtures from self self.connections = ContrailConnections(self.project_inputs, self.logger) self.agent_inspect = self.connections.agent_inspect - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + self.quantum_h = self.connections.quantum_h + self.nova_h = self.connections.nova_h + self.orch = self.connections.orch self.api_s_inspect = self.connections.api_server_inspect self.logger = self.inputs.logger self.project_name = self.project_inputs.project_name @@ -31,8 +32,7 @@ def comp_rules_from_policy_to_system(self): pro_vm_list = None if self.project_name == project_names[pr]: # Step 2:Check VMs are exist for selected project - pro_vm_list = self.nova_fixture.get_vm_list( - project_id=project_ids[pr]) + pro_vm_list = self.orch.get_vm_list(project_id=project_ids[pr]) else: pro_vm_list = None if pro_vm_list is not None: @@ -49,7 +49,7 @@ def comp_rules_from_policy_to_system(self): vn_list = [] # Step 3 :Get All VNs of selected VM - vns_of_vm = pro_vm_list[vm].networks.keys() + vns_of_vm = self.orch.get_networks_of_vm(pro_vm_list[vm]) for i in range(len(vns_of_vm)): vn_obj = str(vns_of_vm[i]) vn_list.append(vn_obj) @@ -78,9 +78,8 @@ def comp_rules_from_policy_to_system(self): for policy in policys_list: # Get the rules from quantum client - policy_detail = self.quantum_fixture.get_policy_if_present( - project_names[pr], - policy) + policy_detail = self.vnc_lib.network_policy_read(fq_name=[u'default-domain', + unicode(project_names[pr]), unicode(policy)]) self.logger.info( "%s, %s, %s, %s, %s" % @@ -90,8 +89,8 @@ def comp_rules_from_policy_to_system(self): pro_vm_list, vn_list)) # Total no of rules for each policy - list_of_rules = policy_detail['policy'][ - 'entries']['policy_rule'] + list_of_rules = policy_detail.network_policy_entries.exportDict() + list_of_rules = list_of_rules['PolicyEntriesType']['policy_rule'] no_of_rules = [] for each_rule in list_of_rules: diff --git a/common/servicechain/config.py b/common/servicechain/config.py index eab085cc8..f57e8f01c 100644 --- a/common/servicechain/config.py +++ b/common/servicechain/config.py @@ -157,7 +157,7 @@ def delete_vm(self, vm_fix): self.remove_from_cleanups(vm_fix) def get_svm_obj(self, vm_name): - for vm_obj in self.nova_fixture.get_vm_list(): + for vm_obj in self.nova_h.get_vm_list(): if vm_obj.name == vm_name: return vm_obj errmsg = "No VM named '%s' found in the compute" % vm_name @@ -178,14 +178,14 @@ def is_svm_active(self, vm_name): def get_svm_compute(self, svm_name): svm_obj = self.get_svm_obj(svm_name) vm_nodeip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(svm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(svm_obj)]['host_ip'] return self.inputs.host_data[vm_nodeip] def get_svm_tapintf(self, svm_name): self.is_svm_active(svm_name) svm_obj = self.get_svm_obj(svm_name) vm_nodeip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(svm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(svm_obj)]['host_ip'] inspect_h = self.agent_inspect[vm_nodeip] self.logger.debug( "svm_obj:'%s' compute_ip:'%s' agent_inspect:'%s'", svm_obj.__dict__, @@ -196,7 +196,7 @@ def get_bridge_svm_tapintf(self, svm_name, direction): self.is_svm_active(svm_name) svm_obj = self.get_svm_obj(svm_name) vm_nodeip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(svm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(svm_obj)]['host_ip'] inspect_h = self.agent_inspect[vm_nodeip] self.logger.debug( "svm_obj:'%s' compute_ip:'%s' agent_inspect:'%s'", svm_obj.__dict__, @@ -215,7 +215,7 @@ def get_svm_tapintf_of_vn(self, svm_name, vn): self.is_svm_active(svm_name) svm_obj = self.get_svm_obj(svm_name) vm_nodeip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(svm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(svm_obj)]['host_ip'] inspect_h = self.agent_inspect[vm_nodeip] self.logger.debug( "svm_obj:'%s' compute_ip:'%s' agent_inspect:'%s'", svm_obj.__dict__, diff --git a/common/servicechain/mirror/verify.py b/common/servicechain/mirror/verify.py index e596f1c20..cd89897a2 100644 --- a/common/servicechain/mirror/verify.py +++ b/common/servicechain/mirror/verify.py @@ -8,11 +8,7 @@ from common.ecmp.ecmp_verify import ECMPVerify from common.floatingip.config import CreateAssociateFip from random import randint -try: - from quantumclient.common import exceptions -except ImportError: - from neutronclient.common import exceptions - +from common.openstack_libs import network_exception as exceptions class VerifySvcMirror(ConfigSvcMirror, VerifySvcChain, ECMPVerify): @@ -101,8 +97,8 @@ def verify_svc_mirroring(self, si_count=1, svc_mode='transparent'): self.vn2_fixture, self.vm2_name, node_name=compute_2) assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) result, msg = self.validate_vn( self.vn1_name, project_name=self.inputs.project_name) assert result, msg @@ -243,8 +239,8 @@ def verify_svc_mirroring_with_floating_ip(self, si_count=1): self.vn2_fixture, self.vm2_name, node_name=compute_2) assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) result, msg = self.validate_vn( self.vn1_name, project_name=self.inputs.project_name) @@ -375,8 +371,8 @@ def verify_svc_mirror_with_deny(self, si_count=1): self.vn2_fixture, self.vm2_name, node_name=compute_2) assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) self.st_fixture, self.si_fixtures = self.config_st_si(self.st_name, self.si_prefix, si_count, svc_type='analyzer', left_vn=self.vn1_name, project=self.inputs.project_name) @@ -556,8 +552,8 @@ def verify_add_new_vns(self, si_prefix, si_count=1): assert new_left_vm_fix.verify_on_setup() assert new_right_vm_fix.verify_on_setup() # Wait for VM's to come up - self.nova_fixture.wait_till_vm_is_up(new_left_vm_fix.vm_obj) - self.nova_fixture.wait_till_vm_is_up(new_right_vm_fix.vm_obj) + self.nova_h.wait_till_vm_is_up(new_left_vm_fix.vm_obj) + self.nova_h.wait_till_vm_is_up(new_right_vm_fix.vm_obj) # Add rule to policy to allow traffic from new left_vn to right_vn # through SI @@ -764,8 +760,8 @@ def verify_svc_mirroring_unidirection(self, si_count=1, svc_mode='transparent'): self.vn2_fixture, self.vm2_name, node_name=compute_2) assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) result, msg = self.validate_vn( self.vn1_name, project_name=self.inputs.project_name) @@ -886,8 +882,8 @@ def verify_attach_detach_policy_with_svc_mirroring(self, si_count=1): self.vn2_fixture, self.vm2_name, node_name=compute_2) assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) result, msg = self.validate_vn( self.vn1_name, project_name=self.inputs.project_name) @@ -1010,8 +1006,8 @@ def verify_detach_attach_diff_policy_with_mirroring(self, si_count=1): assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) result, msg = self.validate_vn( self.vn1_name, project_name=self.inputs.project_name) @@ -1145,8 +1141,8 @@ def verify_detach_attach_policy_change_rules(self, si_count=1): assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) result, msg = self.validate_vn( self.vn1_name, project_name=self.inputs.project_name) @@ -1267,8 +1263,8 @@ def verify_policy_order_change(self, si_count=1): assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) result, msg = self.validate_vn( self.vn1_name, project_name=self.inputs.project_name) diff --git a/common/vcenter_libs.py b/common/vcenter_libs.py new file mode 100644 index 000000000..b06b3861a --- /dev/null +++ b/common/vcenter_libs.py @@ -0,0 +1,35 @@ + +try: + from pyVim import connect as vcenter_connect + from pyVmomi import vim as vcenter_vim + + vimtype_dict = { + 'dc' : vim.Datacenter, + 'cluster' : vim.ClusterComputeResource, + 'vm' : vim.VirtualMachine, + 'host' : vim.HostSystem, + 'network' : vim.Network, + 'ds' : vim.Datastore, + 'dvs.PortGroup' : vim.dvs.DistributedVirtualPortgroup, + 'dvs.VSwitch' : vim.dvs.VmwareDistributedVirtualSwitch, + 'dvs.PVLan' : vim.dvs.VmwareDistributedVirtualSwitch.PvlanSpec, + 'dvs.PortConfig' : vim.dvs.VmwareDistributedVirtualSwitch.VmwarePortConfigPolicy, + 'dvs.ConfigSpec' : vim.dvs.DistributedVirtualPortgroup.ConfigSpec, + 'dvs.PortConn' : vim.dvs.PortConnection, + 'ip.Config' : vim.vApp.IpPool.IpPoolConfigInfo, + 'ip.Association' : vim.vApp.IpPool.Association, + 'ip.Pool' : vim.vApp.IpPool, + 'dev.E1000' : vim.vm.device.VirtualE1000, + 'dev.VD' : vim.vm.device.VirtualDeviceSpec, + 'dev.ConnectInfo' : vim.vm.device.VirtualDevice.ConnectInfo, + 'dev.DVPBackingInfo' : vim.vm.device.VirtualEthernetCard.DistributedVirtualPortBackingInfo, + 'vm.Config' : vim.vm.ConfigSpec, + 'vm.Reloc' : vim.vm.RelocateSpec, + 'vm.Clone' : vim.vm.CloneSpec, + } + + +except: + vimtype_dict = {} + vcenter_connect = None + vcenter_vim = None diff --git a/configs/images.cfg b/configs/images.cfg index d6aa2876d..f8c371c34 100644 --- a/configs/images.cfg +++ b/configs/images.cfg @@ -24,6 +24,7 @@ username = password = type = os flavor = contrail_flavor_small +vcpath = /images/vcenter/ params = --container-format bare --disk-format vmdk --property vmware_disktype="sparse" --property vmware_adaptertype="ide" #params = --container-format ovf --disk-format qcow2 --property hypervisor_type=qemu @@ -77,6 +78,8 @@ name = ubuntu.vmdk.gz username = ubuntu password = ubuntu flavor = contrail_flavor_tiny +vctmpl = ubuntu.vmtx +vcname = ubuntu-disk1.vmdk [zeroshell] name = ZeroShell-qemu-bridge.vmdk.gz @@ -104,6 +107,8 @@ params = --container-format ovf --disk-format qcow2 --property hypervisor_typ name = ubuntu-traffic.vmdk.gz username = ubuntu password = ubuntu +vctmpl = ubuntu-traffic.vmtx +vcname = ubuntu-traffic-disk1.vmdk [ubuntu-in-net] name = ubuntu-in-net.vmdk.gz diff --git a/fixtures/control_node.py b/fixtures/control_node.py index cf914fcab..6a17f6c28 100755 --- a/fixtures/control_node.py +++ b/fixtures/control_node.py @@ -26,7 +26,7 @@ class CNFixture(fixtures.Fixture): def __init__(self, connections, inputs, router_name, router_ip, router_type='contrail', router_asn='64512'): self.connections = connections self.inputs = inputs - self.quantum_fixture = self.connections.quantum_fixture + self.quantum_h = self.connections.quantum_h self.vnc_lib_h = self.connections.vnc_lib self.api_s_inspect = self.connections.api_server_inspect self.agent_inspect = self.connections.agent_inspect diff --git a/fixtures/floating_ip.py b/fixtures/floating_ip.py index d44efc01a..37eb5dee9 100644 --- a/fixtures/floating_ip.py +++ b/fixtures/floating_ip.py @@ -22,7 +22,8 @@ def __init__(self, inputs, pool_name, vn_id, connections, vn_name=None, project_ if not project_name: project_name = self.inputs.stack_tenant self.api_s_inspect = self.connections.api_server_inspect - self.quantum_fixture = self.connections.quantum_fixture + self.orch = self.connections.orch + self.quantum_h = self.connections.quantum_h self.agent_inspect = self.connections.agent_inspect self.cn_inspect = self.connections.cn_inspect self.vnc_lib_h = self.connections.vnc_lib @@ -205,10 +206,9 @@ def create_and_assoc_fip(self, fip_pool_vn_id, vm_id, project=None): ''' try: fip_obj = self.create_floatingip(fip_pool_vn_id, project) - self.logger.debug('Associating FIP %s to %s' %( - fip_obj['floatingip']['floating_ip_address'], vm_id)) - self.assoc_floatingip(fip_obj['floatingip']['id'], vm_id) - return fip_obj['floatingip']['id'] + self.logger.debug('Associating FIP %s to %s' %(fip_obj[0], vm_id)) + self.assoc_floatingip(fip_obj[1], vm_id) + return fip_obj[1] except: self.logger.error('Failed to create or asscociate FIP. Error: %s' % (sys.exc_info()[0])) @@ -217,8 +217,7 @@ def create_and_assoc_fip(self, fip_pool_vn_id, vm_id, project=None): def verify_fip(self, fip_id, vm_fixture, fip_vn_fixture): result = True - fip = self.quantum_fixture.get_floatingip( - fip_id)['floatingip']['floating_ip_address'] + fip = self.orch.get_floating_ip(fip_id) self.fip[fip_id] = fip if not self.verify_fip_in_control_node(fip, vm_fixture, fip_vn_fixture): result &= False @@ -421,9 +420,9 @@ def create_floatingip(self, fip_pool_vn_id, project_obj=None): ''' if project_obj is None: project_obj = self.project_obj - fip_resp = self.quantum_fixture.create_floatingip( - fip_pool_vn_id, project_obj.uuid) - self.logger.debug('Created Floating IP : %s' %(fip_resp)) + fip_resp = self.orch.create_floating_ip(pool_vn_id=fip_pool_vn_id, + project_obj=project_obj, pool_obj=self.fip_pool_obj) + self.logger.debug('Created Floating IP : %s' % str(fip_resp)) return fip_resp # end create_floatingip @@ -460,29 +459,15 @@ def delete_floatingips(self, fip_obj_list): def delete_floatingip(self, fip_id): self.logger.debug('Deleting FIP ID %s' %(fip_id)) - self.quantum_fixture.delete_floatingip(fip_id) + self.orch.delete_floating_ip(fip_id) # end delete_floatingip def assoc_floatingip(self, fip_id, vm_id): - update_dict = {} - update_dict['port_id'] = self.quantum_fixture.get_port_id(vm_id) - self.logger.debug('Associating FIP ID %s with Port ID %s' %(fip_id, - update_dict['port_id'])) - if update_dict['port_id']: - fip_resp = self.quantum_fixture.update_floatingip( - fip_id, {'floatingip': update_dict}) - return fip_resp - else: - return None + return self.orch.assoc_floating_ip(fip_id, vm_id) # end assoc_floatingip def disassoc_floatingip(self, fip_id): - update_dict = {} - update_dict['port_id'] = None - self.logger.debug('Disassociating port from FIP ID : %s' %(fip_id)) - fip_resp = self.quantum_fixture.update_floatingip( - fip_id, {'floatingip': update_dict}) - return fip_resp + return self.orch.disassoc_floating_ip(fip_id) # end def assoc_project(self, fip_fixture, project, domain='default-domain'): diff --git a/fixtures/heat_test.py b/fixtures/heat_test.py index e89e5f32b..471dcd1fa 100644 --- a/fixtures/heat_test.py +++ b/fixtures/heat_test.py @@ -4,7 +4,7 @@ import logging import six import sys -from keystoneclient.v2_0 import client as ksclient +from common.openstack_libs import ks_client as ksclient import heatclient from heatclient import client as heat_client from heatclient.common import utils diff --git a/fixtures/ipam_test.py b/fixtures/ipam_test.py index 160fbb7f6..a545f5f7e 100644 --- a/fixtures/ipam_test.py +++ b/fixtures/ipam_test.py @@ -40,6 +40,10 @@ def __init__(self, name=None, project_obj=None, ipamtype=IpamType("dhcp"), vdns_ self.browser_openstack = self.connections.browser_openstack self.webui = WebuiTest(self.connections, self.inputs) self.vdns_obj = vdns_obj + if self.inputs.orchestrator == 'vcenter': + # Overide for vcenter, IPAM is created in vcenter and + # represented as 'vCenter-ipam' in contrail-cfgm + self.name = 'vCenter-ipam' # end __init__ def setUp(self): @@ -143,6 +147,9 @@ def verify_ipam_not_in_api_server(self): '''Verify that IPAM is removed in API Server. ''' + if self.inputs.orchestrator == 'vcenter': + # vcenter IPAM object is never deleted + return True try: if self.project_fixture_obj.vnc_lib_h.network_ipam_read(self.fq_name): self.logger.warn("IPAM %s is still found in API-Server" % @@ -181,6 +188,9 @@ def verify_ipam_in_control_nodes(self): @retry(delay=5, tries=10) def verify_ipam_not_in_control_nodes(self): # Verify that IPAM details are not in any Control-node + if self.inputs.orchestrator == 'vcenter': + # vcenter IPAM object is never deleted + return True fqname = str(":".join(self.fq_name)) self.ri_name = fqname + ':' + self.name result = True diff --git a/fixtures/keystone_tests.py b/fixtures/keystone_tests.py index 4e26dce2a..a59367e96 100755 --- a/fixtures/keystone_tests.py +++ b/fixtures/keystone_tests.py @@ -1,7 +1,8 @@ import os -from keystoneclient.v2_0 import client as keystone_client -from keystoneclient import exceptions as ks_exceptions -from common import log as logging +from common.openstack_libs import ks_client as keystone_client +from common.openstack_libs import ks_exceptions +from common.openstack_libs import keystoneclient +from common import log_orig as logging from tcutils.util import retry LOG = logging.getLogger(__name__) diff --git a/fixtures/multiple_vn_vm_test.py b/fixtures/multiple_vn_vm_test.py index 568deb76b..4d3353df4 100644 --- a/fixtures/multiple_vn_vm_test.py +++ b/fixtures/multiple_vn_vm_test.py @@ -8,8 +8,8 @@ import os from time import sleep -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import fixtures from common.contrail_test_init import ContrailTestInit from vn_test import * @@ -46,12 +46,12 @@ def __init__(self, connections, inputs, policy_objs=[], subnets=[], project_name self.vm_count = vm_count self.image_name = image_name self.flavor = flavor - self.nova_fixture = self.connections.nova_fixture + self.nova_h = self.connections.nova_h self.q = Queue.Queue() self.vn_threads = [] self.vm_threads = [] self.userdata = userdata - self.nova_fixture.get_image(self.image_name) + self.nova_h.get_image(self.image_name) self.random_subnets = [] def calculateSubnetAF(self, af): diff --git a/fixtures/nova_test.py b/fixtures/nova_test.py index afc866cdd..f485ada82 100644 --- a/fixtures/nova_test.py +++ b/fixtures/nova_test.py @@ -1,7 +1,6 @@ import os -import fixtures -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException from fabric.context_managers import settings, hide, cd, shell_env from fabric.api import run, local, env from fabric.operations import get, put @@ -17,7 +16,7 @@ #@contrail_fix_ext (ignore_verify=True, ignore_verify_on_setup=True) -class NovaFixture(fixtures.Fixture): +class NovaHelper(): def __init__(self, inputs, project_name, @@ -45,10 +44,10 @@ def __init__(self, inputs, self.flavor_info = parse_cfg_file('configs/flavors.cfg') self.endpoint_type = inputs.endpoint_type self.docker_vm = False + self._connect_to_openstack() # end __init__ - def setUp(self): - super(NovaFixture, self).setUp() + def _connect_to_openstack(self): insecure = bool(os.getenv('OS_INSECURE',True)) self.obj = mynovaclient.Client('2', username=self.username, @@ -70,9 +69,6 @@ def setUp(self): self.hosts = self._list_hosts() # end setUp - def cleanUp(self): - super(NovaFixture, self).cleanUp() - def get_hosts(self, zone='nova'): return self.hosts[zone][:] @@ -523,6 +519,9 @@ def delete_vm(self, vm_obj): vm_obj.delete() # end _delete_vm + def get_key_file(self): + return self.tmp_key_file + def put_key_file_to_host(self, host_ip): username = self.inputs.host_data[self.cfgm_ip]['username'] password = self.inputs.host_data[self.cfgm_ip]['password'] @@ -644,4 +643,4 @@ def is_vm_deleted_in_nova_db(self, vm_obj, node_ip): return False # end is_vm_in_nova_db -# end NovaFixture +# end NovaHelper diff --git a/fixtures/openstack.py b/fixtures/openstack.py new file mode 100644 index 000000000..d3e663215 --- /dev/null +++ b/fixtures/openstack.py @@ -0,0 +1,209 @@ + +import os +from orchestrator import Orchestrator, OrchestratorAuth +from nova_test import NovaHelper +from quantum_test import QuantumHelper +from tcutils.util import get_dashed_uuid +from keystone_tests import KeystoneCommands +from common.openstack_libs import ks_client as ksclient +from common.openstack_libs import ks_exceptions + +class OpenstackOrchestrator(Orchestrator): + + def __init__(self, inputs, username, password, project_name, project_id, + vnclib, logger): + self.inputs = inputs + self.logger = logger + self.quantum_h = QuantumHelper(username=username, password=password, + inputs=inputs, project_id=project_id, + cfgm_ip=inputs.cfgm_ip, + openstack_ip=inputs.openstack_ip) + self.nova_h = NovaHelper(inputs=inputs, project_name=project_name, + username=username, password=password) + + def get_image_account(self, image_name): + return self.nova_h.get_image_account(image_name) + + def get_hosts(self, zone=None): + if not zone: + return self.nova_h.get_hosts() + else: + return self.nova_h.get_hosts(zone) + + def get_zones(self): + return self.nova_h.get_zones() + + def create_vm(self, vm_name, image_name, vn_objs, count=1, zone=None, node_name=None, **kwargs): + vn_ids = [vn['network']['id'] for vn in vn_objs] + return self.nova_h.create_vm(vm_name=vm_name, image_name=image_name, vn_ids=vn_ids, + zone=zone, node_name=node_name, count=count, **kwargs) + + def delete_vm(self, vm_obj): + return self.nova_h.delete_vm(vm_obj) + + def is_vm_deleted(self, vm_obj): + return self.nova_h.is_vm_deleted_in_nova_db(vm_obj, self.inputs.openstack_ip) + + def get_host_of_vm(self, vm_obj): + return self.nova_h.get_nova_host_of_vm(vm_obj) + + def get_networks_of_vm(self, vm_obj): + return vm_obj.networks.keys() + + def wait_till_vm_is_active(self, vm_obj): + return self.nova_h.wait_till_vm_is_active(vm_obj) + + def get_vm_if_present(self, vm_name, **kwargs): + return self.nova_h.get_vm_if_present(vm_name, **kwargs) + + def get_vm_list(self, name_pattern='', **kwargs): + return self.nova_h.get_vm_list(name_pattern=name_pattern, **kwargs) + + def get_vm_detail(self, vm_obj): + return self.nova_h.get_vm_detail(vm_obj) + + def get_vm_ip(self, vm_obj, vn_name): + return self.nova_h.get_vm_ip(vm_obj, vn_name) + + def get_key_file(self): + return self.nova_h.get_key_file() + + def put_key_file_to_host(self, host_ip): + self.nova_h.put_key_file_to_host(host_ip) + + def get_tmp_key_file(self): + return self.nova_h.tmp_key_file + + def create_vn(self, name, subnets, **kwargs): + return self.quantum_h.create_network(name, subnets, **kwargs) + + def delete_vn(self, vn_obj): + return self.quantum_h.delete_vn(vn_obj['network']['id']) + + def get_vn_id(self, vn_obj): + return vn_obj['network']['id'] + + def get_vn_name(self, vn_obj): + return vn_obj['network']['name'] + + def get_vn_obj_if_present(self, vn_name, **kwargs): + return self.quantum_h.get_vn_obj_if_present(vn_name, **kwargs) + + def add_security_group(self, vm_obj, secgrp): + return self.nova_h.add_security_group(vm_obj.id, secgrp) + + def remove_security_group(self, vm_obj, secgrp): + return self.nova_h.remove_security_group(vm_obj.id, secgrp) + + def get_console_output(self, vm_obj): + return self.nova_h.get_vm_console_output(vm_obj) + + def wait_till_vm_status(self, vm_obj, status): + return self.nova_h.wait_till_vm_status(vm_obj, status) + + def get_policy(self, fq_name): + return self.quantum_h.get_policy_if_present(fq_name[1], fq_name[2]) + + def get_floating_ip(self, fip_id): + fip = self.quantum_h.get_floatingip(fip_id) + return fip['floatingip']['floating_ip_address'] + + def create_floating_ip(self, pool_vn_id, project_obj, **kwargs): + fip_resp = self.quantum_h.create_floatingip( + pool_vn_id, project_obj.uuid) + return (fip_resp['floatingip']['floating_ip_address'], + fip_resp['floatingip']['id']) + + def delete_floating_ip(self, fip_id): + self.quantum_h.delete_floatingip(fip_id) + + def assoc_floating_ip(self, fip_id, vm_id): + update_dict = {} + update_dict['port_id'] = self.quantum_h.get_port_id(vm_id) + self.logger.debug('Associating FIP ID %s with Port ID %s' %(fip_id, + update_dict['port_id'])) + if update_dict['port_id']: + fip_resp = self.quantum_h.update_floatingip(fip_id, + {'floatingip': update_dict}) + return fip_resp + else: + return None + + def disassoc_floating_ip(self, fip_id): + update_dict = {} + update_dict['port_id'] = None + self.logger.debug('Disassociating port from FIP ID : %s' %(fip_id)) + fip_resp = self.quantum_h.update_floatingip(fip_id, + {'floatingip': update_dict}) + return fip_resp + + +class OpenstackAuth(OrchestratorAuth): + + def __init__(self, user, passwd, project_name, inputs, logger): + self.inputs = inputs + self.user = user + self.passwd = passwd + self.project = project_name + self.logger = logger + self.insecure = bool(os.getenv('OS_INSECURE',True)) + self.auth_url = os.getenv('OS_AUTH_URL') or \ + 'http://%s:5000/v2.0' % (self.inputs.openstack_ip) + self.reauth() + + def reauth(self): + self.keystone = ksclient.Client( + username=self.user, + password=self.passwd, + tenant_name=self.project, + auth_url=self.auth_url, + insecure=self.insecure) + + def get_project_id(self, domain, name): + try: + obj = self.keystone.tenants.find(name=name) + return get_dashed_uuid(obj.id) + except ks_exceptions.NotFound: + return None + + def create_project(self, name): + return get_dashed_uuid(self.keystone.tenants.create(name).id) + + def delete_project(self, name): + try: + self.keystone.tenants.delete(self.keystone.tenants.find(name=name)) + except ks_exceptions.ClientException, e: + # TODO Remove this workaround + if 'Unable to add token to revocation list' in str(e): + self.logger.warn('Exception %s while deleting project' % ( + str(e))) + + def delete_user(self, user): + kc = KeystoneCommands(username= self.inputs.stack_user, + password= self.inputs.stack_password, + tenant= self.inputs.project_name, + auth_url= self.auth_url, insecure=self.insecure) + kc.delete_user(user) + + def create_user(self, user, password): + kc = KeystoneCommands(username= self.inputs.stack_user, + password= self.inputs.stack_password, + tenant= self.inputs.project_name, + auth_url= self.auth_url, insecure=self.insecure) + try: + kc.create_user(user,password,email='', + tenant_name=self.inputs.stack_tenant,enabled=True) + except: + self.logger.info("%s user already created"%(self.user)) + + def add_user_to_project(self, user, project): + kc = KeystoneCommands(username= self.inputs.stack_user, + password= self.inputs.stack_password, + tenant= self.inputs.project_name, + auth_url= self.auth_url, insecure=self.insecure) + try: + kc.add_user_to_tenant(project, user, 'admin') + except Exception as e: + self.logger.info("%s user already added to project"%(user)) + + diff --git a/fixtures/orchestrator.py b/fixtures/orchestrator.py new file mode 100644 index 000000000..38a991284 --- /dev/null +++ b/fixtures/orchestrator.py @@ -0,0 +1,151 @@ + +class Orchestrator: + """Base class for orchestrator.""" + + def get_image_account(self, image_name): + '''Returns username, password for the image.''' + raise Exception('Unimplemented interface') + + def get_hosts(self, zone=None): + '''Returns a list of computes.''' + raise Exception('Unimplemented interface') + + def get_zones(self): + '''Returns a list of zones/clusters into which computes are grouped.''' + raise Exception('Unimplemented interface') + + def create_vm(self, vm_name, image_name, vn_objs, count=1, zone=None, node_name=None, **kwargs): + '''Returns a list of VM objects else None.''' + raise Exception('Unimplemented interface') + + def delete_vm(self, vm_obj): + '''Deletes the given VM.''' + raise Exception('Unimplemented interface') + + def get_host_of_vm(self, vm_obj): + '''Returns name of the compute, on which the VM was created.''' + raise Exception('Unimplemented interface') + + def get_networks_of_vm(self, vm_obj): + '''Returns names of the networks, associated with the VM.''' + raise Exception('Unimplemented interface') + + def get_vm_if_present(self, vm_name, **kwargs): + '''Returns VM object if present else None.''' + raise Exception('Unimplemented interface') + + def get_vm_by_id(self, vm_id): + '''Returns VM object if present else None.''' + raise Exception('Unimplemented interface') + + def get_vm_list(self, name_pattern='', **kwargs): + '''Returns a list of VM object matching pattern.''' + raise Exception('Unimplemented interface') + + def get_vm_detail(self, vm_obj): + '''Refreshes VM object.''' + raise Exception('Unimplemented interface') + + def get_vm_ip(self, vm_obj, vn_name): + '''Returns a list of IP of VM in VN.''' + raise Exception('Unimplemented interface') + + def is_vm_deleted(self, vm_obj): + '''Returns True if VM has been deleted, else False.''' + raise Exception('Unimplemented interface') + + def wait_till_vm_is_active(self, vm_obj): + '''Return True if VM is powered on, else False.''' + raise Exception('Unimplemented interface') + + def get_key_file(self): + '''Returns the key file path.''' + raise Exception('Unimplemented interface') + + def put_key_file_to_host(self, host_ip): + '''Copy RSA key to host.''' + raise Exception('Unimplemented interface') + + def get_tmp_key_file(self): + raise Exception('Unimplemented interface') + + def create_vn(self, name, subnets, **kwargs): + raise Exception('Unimplemented interface') + + def delete_vn(self, vn_obj): + '''Delete the VN.''' + raise Exception('Unimplemented interface') + + def get_vn_obj_if_present(self, vn_name, **kwargs): + '''Returns VN if already present.''' + raise Exception('Unimplemented interface') + + def get_vn_name(self, vn_obj): + '''Returns VN name.''' + raise Exception('Unimplemented interface') + + def get_vn_id(self, vn_obj): + '''Returns VN Id.''' + raise Exception('Unimplemented interface') + + def add_security_group(self, vm_obj, secgrp): + raise Exception('Unimplemented interface') + + def remove_security_group(self, vm_obj, secgrp): + raise Exception('Unimplemented interface') + + def get_console_output(self, vm_obj): + raise Exception('Unimplemented interface') + + def wait_till_vm_status(self, vm_obj, status): + raise Exception('Unimplemented interface') + + def get_policy(self, fq_name): + raise Exception('Unimplemented interface') + + def get_floating_ip(self, fip_id): + raise Exception('Unimplemented interface') + + def create_floating_ip(self, pool_vn_id, pool_obj, project_obj): + raise Exception('Unimplemented interface') + + def delete_floatingip(self, fip_id): + raise Exception('Unimplemented interface') + + def assoc_floating_ip(self, fip_id, vm_id): + raise Exception('Unimplemented interface') + + def disassoc_floatingip(self, fip_id): + raise Exception('Unimplemented interface') + + +class OrchestratorAuth: + + def reauth(self): + '''Reauthenticates to auth server, returns none.''' + raise Exception('Unimplemented interface') + + def get_project_id(self, domain, name): + '''Returns project Id.''' + raise Exception('Unimplemented interface') + + def create_project(self, name): + '''Creates a new project and returns Id.''' + raise Exception('Unimplemented interface') + + def delete_project(self, name): + '''Delete project.''' + raise Exception('Unimplemented interface') + + def create_user(self, user, passwd): + '''Create user.''' + raise Exception('Unimplemented interface') + + def delete_user(self, user): + '''Delete user.''' + raise Exception('Unimplemented interface') + + def add_user_to_project(self, user, project): + '''Add user to specified project.''' + raise Exception('Unimplemented interface') + diff --git a/fixtures/policy_test.py b/fixtures/policy_test.py index 2f74c724e..0f8c7cf2d 100644 --- a/fixtures/policy_test.py +++ b/fixtures/policy_test.py @@ -27,7 +27,7 @@ def __init__(self, policy_name, rules_list, inputs, connections, api=None, self.connections = connections self.agent_inspect = self.connections.agent_inspect self.cn_inspect = self.connections.cn_inspect - self.quantum_fixture = self.connections.quantum_fixture + self.quantum_h = self.connections.quantum_h self.api_s_inspect = self.connections.api_server_inspect self.vnc_lib = self.connections.vnc_lib self.policy_name = policy_name @@ -37,6 +37,8 @@ def __init__(self, policy_name, rules_list, inputs, connections, api=None, self.verify_is_run = False self.project_name = self.inputs.project_name self.api_flag = api + if self.inputs.orchestrator == 'vcenter': + self.api_flag = True if self.inputs.verify_thru_gui(): self.browser = self.connections.browser self.browser_openstack = self.connections.browser_openstack @@ -53,7 +55,7 @@ def setUp(self): super(PolicyFixture, self).setUp() if self.api_flag is None: if not self.scale: - self.policy_obj = self.quantum_fixture.get_policy_if_present( + self.policy_obj = self.quantum_h.get_policy_if_present( self.project_name, self.policy_name) if not self.policy_obj: if self.inputs.is_gui_based_config(): @@ -66,10 +68,19 @@ def setUp(self): 'Policy %s already present, not creating any policy' % (self.policy_name)) - self.policy_fq_name = self.quantum_fixture.get_policy_fq_name( + self.policy_fq_name = self.quantum_h.get_policy_fq_name( self.policy_obj) else: - self._create_policy_api(self.policy_name, self.rules_list) + try: + self.policy_obj = self.vnc_lib.network_policy_read(fq_name=self.project_fq_name+[unicode(self.policy_name)]) + except: + self.policy_fq_name = self._create_policy_api(self.policy_name, self.rules_list) + else: + self.already_present = True + self.policy_fq_name=self.policy_obj.fq_name + self.logger.info( + 'Policy %s already present, not creating any policy' % + (self.policy_name)) # end setUp def verify_on_setup(self): @@ -297,7 +308,7 @@ def serialize(obj): default=serialize)) policy_req = {'name': policy_name, 'entries': pol_entries_dict} - policy_rsp = self.quantum_fixture.create_policy({'policy': policy_req}) + policy_rsp = self.quantum_h.create_policy({'policy': policy_req}) self.logger.debug("Policy Creation Response " + str(policy_rsp)) self.policy_obj = policy_rsp return policy_rsp @@ -335,9 +346,13 @@ def _create_policy_api(self, policy_name, rules_list): 'simple_action': 'pass', 'protocol': 'any', 'source_network': None, + 'source_policy': None, + 'source_subnet': None, 'src_ports': [PortType(-1, -1)], 'application': None, 'dest_network': None, + 'dest_policy': None, + 'dest_subnet': None, 'dst_ports': [PortType(-1, -1)], 'action_list': None } @@ -379,34 +394,126 @@ def _create_policy_api(self, policy_name, rules_list): "Error in Destination ports arguments, should be (Start port, end port) or any ") return None - source_vn = ':'.join(self.project_fq_name) + \ - ':' + new_rule['source_network'] - dest_vn = ':'.join(self.project_fq_name) + \ - ':' + new_rule['dest_network'] + if new_rule['source_network'] is not None: + m = re.match(r"(\S+):(\S+):(\S+)", new_rule['source_network']) + if m: + source_vn = new_rule['source_network'] + else: + source_vn = ':'.join(self.project_fq_name) + \ + ':' + new_rule['source_network'] + if new_rule['dest_network'] is not None: + m = re.match(r"(\S+):(\S+):(\S+)", new_rule['dest_network']) + if m: + dest_vn = new_rule['dest_network'] + else: + dest_vn = ':'.join(self.project_fq_name) + \ + ':' + new_rule['dest_network'] + if new_rule['source_policy'] is not None: + m = re.match(r"(\S+):(\S+):(\S+)", new_rule['source_policy']) + if m: + source_policy = new_rule['source_policy'] + else: + source_policy = ':'.join(self.project_fq_name) + \ + ':' + new_rule['source_policy'] + if new_rule['dest_policy'] is not None: + m = re.match(r"(\S+):(\S+):(\S+)", new_rule['dest_policy']) + if m: + dest_policy = new_rule['dest_policy'] + else: + dest_policy = ':'.join(self.project_fq_name) + \ + ':' + new_rule['dest_policy'] + if new_rule['source_subnet'] is not None: + try: + source_subnet_prefix = str(new_rule['source_subnet'].split('/')[0]) + source_subnet_prefix_length = int(new_rule['source_subnet'].split('/')[1]) + source_subnet_dict = {'ip_prefix':source_subnet_prefix, + 'ip_prefix_len':source_subnet_prefix_length} + except: + self.logger.debug("Subnet should be defined as ip/prefix_length \ + where ip = xx.xx.xx.xx and prefix_length is the subnet mask \ + length.") + if new_rule['dest_subnet'] is not None: + try: + dest_subnet_prefix = str(new_rule['dest_subnet'].split('/')[0]) + dest_subnet_prefix_length = int(new_rule['dest_subnet'].split('/')[1]) + dest_subnet_dict = {'ip_prefix':dest_subnet_prefix, + 'ip_prefix_len':dest_subnet_prefix_length} + except: + self.logger.debug("Subnet should be defined as ip/prefix_length \ + where ip = xx.xx.xx.xx and prefix_length is the subnet mask \ + length.") + # handle 'any' network case - if rule_dict['source_network'] == 'any': - source_vn = 'any' - if rule_dict['dest_network'] == 'any': - dest_vn = 'any' + try: + if rule_dict['source_network'] == 'any': + source_vn = 'any' + except: + self.logger.debug("No source network defined") + try: + if rule_dict['dest_network'] == 'any': + dest_vn = 'any' + except: + self.logger.debug("No destination network defined") # end code to handle 'any' network - new_rule['source_network'] = [ - AddressType(virtual_network=source_vn)] - new_rule['dest_network'] = [ - AddressType(virtual_network=dest_vn)] + + try: + if source_vn: + new_rule['source_network'] = [ + AddressType(virtual_network=source_vn)] + src_address = new_rule['source_network'] + except: + self.logger.debug("No source vn defined in this rule of %s \ + policy" % (policy_name)) + try: + if dest_vn: + new_rule['dest_network'] = [ + AddressType(virtual_network=dest_vn)] + dest_address = new_rule['dest_network'] + except: + self.logger.debug("No dest vn defined in this rule of %s \ + policy" % (policy_name)) + try: + if source_policy: + new_rule['source_policy'] = [ + AddressType(network_policy=source_policy)] + src_address = new_rule['source_policy'] + except: + self.logger.debug("No source policy defined in this rule of %s \ + policy" % (policy_name)) + try: + if dest_policy: + new_rule['dest_policy'] = [ + AddressType(network_policy=dest_policy)] + dest_address = new_rule['dest_policy'] + except: + self.logger.debug("No dest policy defined in this rule of %s \ + policy" % (policy_name)) + try: + if source_subnet_dict: + new_rule['source_subnet'] = [ + AddressType(subnet=source_subnet_dict)] + src_address = new_rule['source_subnet'] + except: + self.logger.debug("No source subnet defined in this rule of %s \ + policy" % (policy_name)) + try: + if dest_subnet_dict: + new_rule['dest_subnet'] = [ + AddressType(subnet=dest_subnet_dict)] + dest_address = new_rule['dest_subnet'] + except: + self.logger.debug("No destination subnet defined in this rule of %s \ + policy" % (policy_name)) + np_rules.append( PolicyRuleType(direction=new_rule['direction'], - simple_action=new_rule[ - 'simple_action'], - protocol=new_rule[ - 'protocol'], - src_addresses=new_rule[ - 'source_network'], + protocol=new_rule['protocol'], + src_addresses=src_address, src_ports=new_rule['src_ports'], application=new_rule['application'], - dst_addresses=new_rule[ - 'dest_network'], + dst_addresses=dest_address, dst_ports=new_rule['dst_ports'], - action_list=new_rule['action_list'])) + action_list={'simple_action':new_rule['simple_action']})) # end for self.logger.debug("Policy np_rules : %s" % (np_rules)) @@ -414,8 +521,9 @@ def _create_policy_api(self, policy_name, rules_list): proj = self.vnc_lib.project_read(self.project_fq_name) self.policy_obj = NetworkPolicy( policy_name, network_policy_entries=pol_entries, parent_obj=proj) - policy_rsp = self.policy_obj - return policy_rsp + uid = self.vnc_lib.network_policy_create(self.policy_obj) + self.policy_obj = self.vnc_lib.network_policy_read(id=uid) + return self.policy_obj.fq_name # end _create_policy_api def cleanUp(self): @@ -428,28 +536,40 @@ def cleanUp(self): if self.inputs.fixture_cleanup == 'force': do_cleanup = True if do_cleanup: - if self.inputs.is_gui_based_config(): - self.webui.delete_policy(self) - self.logger.info("Deleted policy %s" % (self.policy_name)) - elif self.quantum_fixture.get_policy_if_present( - project_name=self.project_name, - policy_name=self.policy_name): - self._delete_policy() - self.logger.info("Deleted policy %s" % (self.policy_name)) - else: - self.logger.info("No Policy present, to be deleted.") + self._delete_policy() + if self.verify_is_run: + assert self.verify_policy_not_in_api_server() else: self.logger.info('Skipping deletion of policy %s' % (self.policy_name)) # end cleanUp + def get_id(self): + if isinstance(self.policy_obj, NetworkPolicy): + return self.policy_obj.uuid + else: + return self.policy_obj['policy']['id'] + def _delete_policy(self): - self.quantum_fixture.delete_policy(self.policy_obj['policy']['id']) + if self.api_flag: + self.vnc_lib.network_policy_delete(id=self.policy_obj.uuid) + self.logger.info("Deleted policy %s" % (self.policy_name)) + return + if self.inputs.is_gui_based_config(): + self.webui.delete_policy(self) + self.logger.info("Deleted policy %s" % (self.policy_name)) + elif self.quantum_h.get_policy_if_present( + project_name=self.project_name, + policy_name=self.policy_name): + self.quantum_h.delete_policy(self.policy_obj['policy']['id']) + self.logger.info("Deleted policy %s" % (self.policy_name)) + else: + self.logger.info("No Policy present, to be deleted.") # end _delete_policy def update_policy(self, policy_id, policy_data): # policy_data format {'policy': {'entries': new_policy_entries}} - policy_rsp = self.quantum_fixture.update_policy(policy_id, policy_data) + policy_rsp = self.quantum_h.update_policy(policy_id, policy_data) self.logger.debug("Policy Update Response " + str(policy_rsp)) self.policy_obj = policy_rsp return policy_rsp @@ -899,14 +1019,16 @@ def verify_policy_in_vna(self, scn, policy_attch_to_vn=None): def refresh_quantum_policy_obj(self): # Rebuild the policy object to take care of cases where it takes time to update after instantiating the object - self.policy_obj=self.quantum_fixture.get_policy_if_present(self.project_name, self.policy_name) + if self.api_flag: + return self + self.policy_obj=self.quantum_h.get_policy_if_present(self.project_name, self.policy_name) return self def verify_policy_in_api_server(self): '''Validate policy information in API-Server. Compare data with quantum based policy fixture data. Check specifically for following: api_server_keys: 1> fq_name, 2> uuid, 3> rules - quantum_fixture_keys: 1> policy_fq_name, 2> id in policy_obj, 3> policy_obj [for rules] + quantum_h_keys: 1> policy_fq_name, 2> id in policy_obj, 3> policy_obj [for rules] ''' self.refresh_quantum_policy_obj() me = inspect.getframeinfo(inspect.currentframe())[2] @@ -925,15 +1047,21 @@ def verify_policy_in_api_server(self): if out: err_msg.append(out) # compare policy_uuid + if isinstance(self.policy_obj, NetworkPolicy): + uuid = self.policy_obj.uuid + rules = self.policy_obj.network_policy_entries.exportDict()['PolicyEntriesType'] + else: + uuid = self.policy_obj['policy']['id'] + rules = self.policy_obj['policy']['entries'] + out = policy_test_utils.compare_args( - 'policy_uuid', self.api_s_policy_obj_x['uuid'], self.policy_obj['policy']['id']) + 'policy_uuid', self.api_s_policy_obj_x['uuid'], uuid) if out: err_msg.append(out) # compare policy_rules out = policy_test_utils.compare_args( 'policy_rules', self.api_s_policy_obj_x[ - 'network_policy_entries']['policy_rule'], - self.policy_obj['policy']['entries']['policy_rule']) + 'network_policy_entries']['policy_rule'], rules['policy_rule']) if out: err_msg.append(out) @@ -944,6 +1072,7 @@ def verify_policy_in_api_server(self): return {'result': result, 'msg': err_msg} # end verify_policy_in_api_server + @retry(delay=5, tries=3) def verify_policy_not_in_api_server(self): '''Verify that policy is removed in API Server. @@ -973,7 +1102,7 @@ def verify_policy_not_in_api_server(self): if not pol_found: self.logger.info("policy %s is not found in API Server" % (self.policy_name)) - return pol_found + return pol_found == False # end verify_policy_not_in_api_server @retry(delay=3, tries=5) @@ -1018,9 +1147,12 @@ def verify_policy_in_control_nodes(self): else: cn_rules = [] self.logger.info("policy info in control node: %s" % cn_rules) - qntm_policy_info = self.policy_obj['policy']['entries']['policy_rule'] - self.logger.info("policy info in quantum: %s" % qntm_policy_info) - out = policy_test_utils.compare_args('policy_rules', cn_rules, qntm_policy_info, + if isinstance(self.policy_obj, NetworkPolicy): + policy_info = self.policy_obj.network_policy_entries.exportDict()['PolicyEntriesType']['policy_rule'] + else: + policy_info = self.policy_obj['policy']['entries']['policy_rule'] + self.logger.info("policy info in quantum: %s" % policy_info) + out = policy_test_utils.compare_args('policy_rules', cn_rules, policy_info, exp_name='cn_rules', act_name='quantum_rules') if out: msg = "Rules view in control-node %s is not matching, detailed msg follows %s" % ( diff --git a/fixtures/project_test.py b/fixtures/project_test.py index 47082199d..8fa1ccd07 100644 --- a/fixtures/project_test.py +++ b/fixtures/project_test.py @@ -1,6 +1,5 @@ import os import fixtures -from keystoneclient.v2_0 import client as ksclient from vnc_api.vnc_api import * import uuid import fixtures @@ -11,19 +10,20 @@ from common.connections import ContrailConnections from tcutils.util import retry from time import sleep -from keystoneclient import exceptions as ks_exceptions -from tcutils.util import get_dashed_uuid +from openstack import OpenstackAuth +from vcenter import VcenterAuth class ProjectFixture(fixtures.Fixture): - def __init__(self, vnc_lib_h, connections, project_name=None, + def __init__(self, vnc_lib_h, connections, auth=None, project_name=None, username=None, password=None, role='admin', scale= False): self.inputs = connections.inputs if not project_name: project_name = self.inputs.stack_tenant self.vnc_lib_h = vnc_lib_h self.connections = connections + self.auth = auth self.project_name = project_name self.project_obj = None self.domain_name = 'default-domain' @@ -33,110 +33,69 @@ def __init__(self, vnc_lib_h, connections, project_name=None, self.username = username self.password = password self.role = role - self.tenant_dict = {} self.user_dict = {} self._create_user_set = {} - insecure = bool(os.getenv('OS_INSECURE',True)) - if not self.inputs.ha_setup: - self.auth_url = os.getenv('OS_AUTH_URL') or \ - 'http://%s:5000/v2.0' % (self.inputs.openstack_ip) - else: - self.auth_url = os.getenv('OS_AUTH_URL') or \ - 'http://%s:5000/v2.0' % (self.inputs.openstack_ip) - self.kc = ksclient.Client( - username=self.inputs.stack_user, - password=self.inputs.stack_password, - tenant_name=self.inputs.project_name, - auth_url=self.auth_url, - insecure=insecure) self.project_connections = None self.api_server_inspects = self.connections.api_server_inspects self.verify_is_run = False self.scale = scale + if not self.auth: + if self.inputs.orchestrator == 'openstack': + self.auth = OpenstackAuth(self.inputs.stack_user, + self.inputs.stack_password, + self.inputs.project_name, self.inputs, self.logger) + else: # vcenter + self.auth = VcenterAuth(self.inputs.stack_user, + self.inputs.stack_password, + self.inputs.project_name, self.inputs) # end __init__ def _create_project(self): - project = Project(self.project_name) - self.vnc_lib_h.project_create(project) - project = self.vnc_lib_h.project_read(project.get_fq_name()) - self.logger.info('Created Project %s ' % - (str(project.get_fq_name()))) - ipam = NetworkIpam('default-network-ipam', project, IpamType("dhcp")) - self.vnc_lib_h.network_ipam_create(ipam) - self.logger.info('Created network ipam') - # end _create_project - - def _delete_project(self): - self.vnc_lib_h.project_delete(fq_name=self.project_fq_name) - # end _delete_project - - def _create_project_keystone(self): if self.project_name == self.inputs.stack_tenant: - try: - ks_project = self.kc.tenants.find(name=self.project_name) - if ks_project: - self.already_present = True - self.project_id = get_dashed_uuid(ks_project.id) - self.logger.debug( - 'Project %s already present.Not creating it' % - self.project_fq_name) - except ks_exceptions.NotFound, e: + 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 e - self.project_obj = self.vnc_lib_h.project_read(id=self.project_id) - self.uuid = self.project_id + 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 - # create project using keystone self.logger.info('Proceed with creation of new project.') - self.ks_project_id = self.kc.tenants.create(self.project_name).id + self.uuid = self.auth.create_project(self.project_name) self.logger.info('Created Project:%s, ID : %s ' % (self.project_name, - self.ks_project_id)) - self.project_id = get_dashed_uuid(self.ks_project_id) - self.tenant_dict = dict((tenant.name, tenant) - for tenant in self.kc.tenants.list()) - # end _create_project_keystone + self.uuid)) + # end _create_project - def _delete_project_keystone(self): + def _delete_project(self): self.logger.info('Deleting Project %s' % self.project_fq_name) - try: - self.kc.tenants.delete(self.tenant_dict[self.project_name]) - except ks_exceptions.ClientException, e: - # TODO Remove this workaround - if 'Unable to add token to revocation list' in str(e): - self.logger.warn('Exception %s while deleting project' % ( - str(e))) + self.auth.delete_project(self.project_name) # end _delete_project - def _reauthenticate_keystone(self): - self.kc = ksclient.Client( - username=self.inputs.stack_user, - password=self.inputs.stack_password, - tenant_name=self.inputs.project_name, - auth_url=self.auth_url) - # end _reauthenticate_keystone - def setUp(self): super(ProjectFixture, self).setUp() if self.scale: - self._create_project_keystone() + self._create_project() else: - try: - ks_project = self.kc.tenants.find(name=self.project_name) - if ks_project: - self.already_present = True - self.project_id = get_dashed_uuid(ks_project.id) - self.logger.debug( + 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) - except ks_exceptions.NotFound, e: + else: self.logger.info('Project %s not found, creating it' % ( self.project_name)) - self._create_project_keystone() + self._create_project() time.sleep(2) - self.project_obj = self.vnc_lib_h.project_read(id=self.project_id) - self.uuid = self.project_id + self.project_obj = self.vnc_lib_h.project_read(id=self.uuid) # end setUp def getObj(self): @@ -144,6 +103,9 @@ def getObj(self): def cleanUp(self): super(ProjectFixture, self).cleanUp() + 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 @@ -156,8 +118,8 @@ def cleanUp(self): self.logger.warn('One or more references still present' ', will not delete the project %s' % (self.project_name)) return - self._reauthenticate_keystone() - self._delete_project_keystone() + self.auth.reauth() + self._delete_project() if self.verify_is_run: assert self.verify_on_cleanup() else: @@ -168,7 +130,7 @@ def cleanUp(self): @retry(delay=2, tries=10) def check_no_project_references(self): - vnc_project_obj = self.vnc_lib_h.project_read(id=self.project_id) + 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' %( @@ -187,23 +149,6 @@ def check_no_project_references(self): return True # end check_no_project_references - def get_from_api_server(self): - self.project_obj = self.vnc_lib_h.project_read( - fq_name=self.project_fq_name) - return self.project_obj - - @retry(delay=2, tries=10) - def check_for_VN_in_api(self): - self.project_obj = self.vnc_lib_h.project_read( - fq_name=self.project_fq_name) - has_vns = self.project_obj.get_virtual_networks() - if has_vns: - self.logger.info("Following VNs exist in project: %s" %has_vns) - return False - else: - self.logger.info("Don't see any VNs in the project %s" %self.project_fq_name) - return True - def get_project_connections(self, username=None, password=None): if not username: username = self.username or self.inputs.stack_user @@ -231,6 +176,9 @@ def verify_on_setup(self): @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 for api_s_inspect in self.api_server_inspects.values(): cs_project_obj = api_s_inspect.get_cs_project( @@ -241,10 +189,10 @@ def verify_project_in_api_server(self): ' ' % (self.project_name, api_s_inspect._ip)) result &= False return result - if cs_project_obj['project']['uuid'] != self.project_id: + 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. project_id)) + cs_project_obj['project']['uuid'], self.uuid)) result &= False if result: self.logger.info('Verification of project %s in API Server %s' @@ -254,6 +202,9 @@ def verify_project_in_api_server(self): @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 for api_s_inspect in self.api_server_inspects.values(): cs_project_obj = api_s_inspect.get_cs_project( diff --git a/fixtures/quantum_fixture.py b/fixtures/quantum_fixture.py index b8f51f8b0..042fe59ff 100644 --- a/fixtures/quantum_fixture.py +++ b/fixtures/quantum_fixture.py @@ -2,9 +2,9 @@ import fixtures import time import uuid -from quantumclient.quantum import client -from quantumclient.client import HTTPClient -from quantumclient.common import exceptions +from common.openstack_libs import quantum_client as client +from common.openstack_libs import quantum_http_client as HTTPClient +from common.openstack_libs import quantum_exception as exceptions from contrail_fixtures import * cmt = lambda: int(round(time.time() * 1000)) @@ -17,7 +17,7 @@ def __init__(self, connections, tid, inputs, vn_count, vms_per_vn): self._vns = [] self._vms = [] self._subs = [] - self.obj = connections.quantum_fixture.obj + self.obj = connections.quantum_h.obj self.logger = inputs.logger self.inputs = inputs self.tid = tid diff --git a/fixtures/quantum_test.py b/fixtures/quantum_test.py index 9687899cc..6076a76ba 100644 --- a/fixtures/quantum_test.py +++ b/fixtures/quantum_test.py @@ -1,15 +1,8 @@ import os -import fixtures from tcutils.util import * - -try: - from quantumclient.quantum import client - from quantumclient.client import HTTPClient - from quantumclient.common.exceptions import QuantumClientException as CommonNetworkClientException -except ImportError: - from neutronclient.neutron import client - from neutronclient.client import HTTPClient - from neutronclient.common.exceptions import NeutronClientException as CommonNetworkClientException +from common.openstack_libs import network_client as client +from common.openstack_libs import network_http_client as HTTPClient +from common.openstack_libs import network_client_exception as CommonNetworkClientException class NetworkClientException(CommonNetworkClientException): @@ -25,7 +18,7 @@ def __str__(self): return repr(self.message) -class QuantumFixture(fixtures.Fixture): +class QuantumHelper(): def __init__( self, @@ -51,10 +44,6 @@ def __init__( self.auth_url = os.getenv('OS_AUTH_URL') or \ 'http://' + openstack_ip + ':5000/v2.0' self.logger = self.inputs.logger - # end __init__ - - def setUp(self): - super(QuantumFixture, self).setUp() insecure = bool(os.getenv('OS_INSECURE', True)) # Quantum Client class does not have tenant_id as argument # So, do quantum auth differently @@ -65,10 +54,7 @@ def setUp(self): password=self.password, tenant_id=self.project_id, auth_url=self.auth_url) - # end setUp - - def cleanUp(self): - super(QuantumFixture, self).cleanUp() + # end __init__ def _do_quantum_authentication(self): try: @@ -838,4 +824,4 @@ def show_lb_member(self, lb_member_id): return None # end show_lb_member -# end QuantumFixture +# end QuantumHelper diff --git a/fixtures/sdn_ui_topo_setup.py b/fixtures/sdn_ui_topo_setup.py index 4ee3da5da..785c76110 100644 --- a/fixtures/sdn_ui_topo_setup.py +++ b/fixtures/sdn_ui_topo_setup.py @@ -1,7 +1,7 @@ import os import copy -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import fixtures import testtools from tcutils.topo import topo_steps @@ -33,8 +33,8 @@ def __init__(self, connections, topo): self.ini_file = os.environ.get('TEST_CONFIG_FILE') self.connections = connections self.inputs = self.connections.inputs - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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.topo = topo diff --git a/fixtures/security_group.py b/fixtures/security_group.py index 64d0fc59d..e92b287cb 100644 --- a/fixtures/security_group.py +++ b/fixtures/security_group.py @@ -34,7 +34,7 @@ def __init__( self.project_name, self.secgrp_name] self.connections = connections self.cn_inspect = self.connections.cn_inspect - self.quantum_fixture = self.connections.quantum_fixture + self.quantum_h = self.connections.quantum_h self.secgrp_rules = secgrp_entries self.secgrp_rule_q = [] self.option = option @@ -54,7 +54,7 @@ def setUp(self): (self.secgrp_name)) else: if self.option == 'neutron': - secgrp_q = self.quantum_fixture.create_security_group(self.secgrp_name) + secgrp_q = self.quantum_h.create_security_group(self.secgrp_name) if not secgrp_q: self.logger.error("security group creation failed through quantum") return False @@ -78,20 +78,20 @@ def setUp(self): def delete_default_egress_rule(self, sg_id): #currently this method can be only used before adding any custom rule to sg - rules = self.quantum_fixture.list_security_group_rules( - tenant_id=self.quantum_fixture.project_id) + rules = self.quantum_h.list_security_group_rules( + tenant_id=self.quantum_h.project_id) for rule in rules['security_group_rules']: if rule['security_group_id'] == sg_id and rule['remote_ip_prefix'] == '0.0.0.0/0': - self.quantum_fixture.delete_security_group_rule(rule['id']) + self.quantum_h.delete_security_group_rule(rule['id']) break def delete_all_rules(self, sg_id): #deletes all the rules of the sg sg_id - rules = self.quantum_fixture.list_security_group_rules( - tenant_id=self.quantum_fixture.project_id) + rules = self.quantum_h.list_security_group_rules( + tenant_id=self.quantum_h.project_id) for rule in rules['security_group_rules']: if rule['security_group_id'] == sg_id: - self.quantum_fixture.delete_security_group_rule(rule['id']) + self.quantum_h.delete_security_group_rule(rule['id']) def create_sg_rule_quantum(self, sg_id, secgrp_rules=None): if secgrp_rules: @@ -129,7 +129,7 @@ def create_sg_rule_quantum(self, sg_id, secgrp_rules=None): for addr in rule['src_addresses']: if addr.has_key('subnet') and addr['subnet'] != None: remote_ip_prefix = addr['subnet']['ip_prefix'] + '/' + str(addr['subnet']['ip_prefix_len']) - rule_dict = self.quantum_fixture.create_security_group_rule( + rule_dict = self.quantum_h.create_security_group_rule( sg_id,direction=direction, port_range_min=port_range_min, port_range_max=port_range_max, @@ -148,7 +148,7 @@ def create_sg_rule_quantum(self, sg_id, secgrp_rules=None): for addr in rule['dst_addresses']: if addr.has_key('subnet') and addr['subnet'] != None: remote_ip_prefix = addr['subnet']['ip_prefix'] + '/' + str(addr['subnet']['ip_prefix_len']) - rule_dict = self.quantum_fixture.create_security_group_rule( + rule_dict = self.quantum_h.create_security_group_rule( sg_id,direction=direction, port_range_min=port_range_min, port_range_max=port_range_max, @@ -164,7 +164,7 @@ def create_sg_rule_quantum(self, sg_id, secgrp_rules=None): return False #when remote is security group if remote_group_id: - rule_dict = self.quantum_fixture.create_security_group_rule( + rule_dict = self.quantum_h.create_security_group_rule( sg_id,direction=direction, port_range_min=port_range_min, port_range_max=port_range_max, @@ -189,7 +189,7 @@ def cleanUp(self): do_cleanup = True if do_cleanup: if self.option == 'neutron': - self.quantum_fixture.delete_security_group(self.secgrp_id) + self.quantum_h.delete_security_group(self.secgrp_id) elif self.inputs.is_gui_based_config(): self.webui.delete_security_group(self) else: @@ -424,6 +424,6 @@ def list_sg_rules(connections,sg_id): return sg_info['security_group']['security_group_rules'] def show_secgrp(connections,sg_id): - sg_info = connections.quantum_fixture.show_security_group(sg_id) + sg_info = connections.quantum_h.show_security_group(sg_id) return sg_info diff --git a/fixtures/svc_instance_fixture.py b/fixtures/svc_instance_fixture.py index ac7c933e8..709ee28ad 100644 --- a/fixtures/svc_instance_fixture.py +++ b/fixtures/svc_instance_fixture.py @@ -15,7 +15,7 @@ def __init__(self, connections, inputs, domain_name, project_name, si_name, svc_template, if_list, left_vn_name=None, right_vn_name=None, do_verify=True, max_inst=1, static_route=['None', 'None', 'None']): self.vnc_lib = connections.vnc_lib self.api_s_inspect = connections.api_server_inspect - self.nova_fixture = connections.nova_fixture + self.nova_h = connections.nova_h self.inputs = connections.inputs self.domain_name = domain_name self.project_name = project_name @@ -215,10 +215,10 @@ def svm_compute_node_ip(self): # handle change in to ____ svm_name = self.inputs.domain_name + '__' + \ self.inputs.project_name + '__' + svm_name - svm_obj = self.nova_fixture.get_vm_if_present( + svm_obj = self.nova_h.get_vm_if_present( svm_name, admin_project_uuid) svm_compute_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(svm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(svm_obj)]['host_ip'] return svm_compute_node_ip @retry(delay=1, tries=5) diff --git a/fixtures/svc_template_fixture.py b/fixtures/svc_template_fixture.py index c4b5a24f9..af1b023e2 100644 --- a/fixtures/svc_template_fixture.py +++ b/fixtures/svc_template_fixture.py @@ -10,7 +10,7 @@ class SvcTemplateFixture(fixtures.Fixture): def __init__(self, connections, inputs, domain_name, st_name, svc_img_name, svc_type, if_list, svc_scaling, ordered_interfaces, svc_mode='transparent', flavor='contrail_flavor_2cpu'): - self.nova_fixture = connections.nova_fixture + self.nova_h = connections.nova_h self.vnc_lib_h = connections.vnc_lib self.domain_name = domain_name self.st_name = st_name @@ -18,7 +18,7 @@ def __init__(self, connections, inputs, domain_name, st_name, svc_img_name, self.domain_fq_name = [self.domain_name] self.st_fq_name = [self.domain_name, self.st_name] self.image_name = svc_img_name - self.nova_fixture.get_image(self.image_name) + self.nova_h.get_image(self.image_name) self.svc_type = svc_type self.if_list = if_list self.svc_mode = svc_mode @@ -28,7 +28,7 @@ def __init__(self, connections, inputs, domain_name, st_name, svc_img_name, self.logger = inputs.logger self.inputs = inputs self.connections = connections - self.nova_fixture = connections.nova_fixture + self.nova_h = connections.nova_h if self.inputs.verify_thru_gui(): self.browser = connections.browser self.browser_openstack = connections.browser_openstack @@ -66,7 +66,7 @@ def _create_st(self): svc_properties.set_service_mode(self.svc_mode) svc_properties.set_service_scaling(self.svc_scaling) # Add flavor if not already added - self.nova_fixture.get_flavor(self.flavor) + self.nova_h.get_flavor(self.flavor) svc_properties.set_flavor(self.flavor) svc_properties.set_ordered_interfaces(self.ordered_interfaces) for itf in self.if_list: diff --git a/fixtures/traffic_tests.py b/fixtures/traffic_tests.py index c8ee0f6c4..698d7b7e5 100755 --- a/fixtures/traffic_tests.py +++ b/fixtures/traffic_tests.py @@ -15,7 +15,7 @@ class trafficTestFixture(fixtures.Fixture): def __init__(self, connections): self.connections = connections self.inputs = self.connections.inputs - self.nova_fixture = self.connections.nova_fixture + self.nova_h = self.connections.nova_h self.logger = self.inputs.logger # end __init__ @@ -65,9 +65,9 @@ def startTraffic( self.traffic_fip = True if not self.traffic_fip: self.tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(self.tx_vm_fixture.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(self.tx_vm_fixture.vm_obj)]['host_ip'] self.rx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(self.rx_vm_fixture.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(self.rx_vm_fixture.vm_obj)]['host_ip'] self.tx_local_host = Host( self.tx_vm_node_ip, self.inputs.host_data[self.tx_vm_node_ip]['username'], diff --git a/fixtures/user_test.py b/fixtures/user_test.py index 11f1f76da..cdbfdd693 100644 --- a/fixtures/user_test.py +++ b/fixtures/user_test.py @@ -1,15 +1,16 @@ import os import fixtures -from keystoneclient.v2_0 import client as ksclient import uuid import fixtures from common.connections import ContrailConnections from tcutils.util import retry from time import sleep -from keystoneclient import exceptions as ks_exceptions from tcutils.util import get_dashed_uuid +from common.openstack_libs import ks_client as ksclient +from common.openstack_libs import ks_exceptions +from common.openstack_libs import keystoneclient class UserFixture(fixtures.Fixture): @@ -17,6 +18,10 @@ def __init__(self, connections, username=None, password=None, tenant=None, role= self.inputs= connections.inputs self.connections= connections self.logger = self.inputs.logger + if self.inputs.orchestrator == 'vcenter': + # No concept of user in vcenter, However we satisfy the test infra + # with dummy fixture objects + return insecure = bool(os.getenv('OS_INSECURE', True)) if not self.inputs.ha_setup: self.auth_url = os.getenv('OS_AUTH_URL') or \ @@ -68,7 +73,9 @@ def get_tenant_dct(self, tenant_name): return None def add_user_to_tenant(self, tenant, user, role): - + if self.inputs.orchestrator == 'vcenter': + # No concept of user in vcenter + return configure_role = True kuser = self.get_user_dct(user) krole = self.get_role_dct(role) @@ -85,7 +92,9 @@ def add_user_to_tenant(self, tenant, user, role): self.keystone.tenants.add_user(ktenant, kuser, krole) def remove_user_from_tenant(self, tenant, user, role): - + if self.inputs.orchestrator == 'vcenter': + # No concept of user in vcenter + return user = self.get_user_dct(user) role = self.get_role_dct(role) tenant = self.get_tenant_dct(tenant) @@ -164,6 +173,9 @@ def _reauthenticate_keystone(self): def setUp(self): super(UserFixture, self).setUp() + if self.inputs.orchestrator == 'vcenter': + # No concept of user in vcenter + return try: ks_project = self.keystone.tenants.find(name=self.inputs.project_name) if ks_project: @@ -194,6 +206,9 @@ def setUp(self): def cleanUp(self): super(UserFixture, self).cleanUp() + if self.inputs.orchestrator == 'vcenter': + # No concept of user in vcenter + return do_cleanup = True if self.inputs.fixture_cleanup == 'no': do_cleanup = False @@ -214,6 +229,9 @@ def cleanUp(self): # end cleanUp def verify_on_setup(self): + if self.inputs.orchestrator == 'vcenter': + # No concept of user in vcenter + return True result = True if not self.get_user_dct(self.username): result &= False @@ -224,6 +242,9 @@ def verify_on_setup(self): # end verify_on_setup def verify_on_cleanup(self): + if self.inputs.orchestrator == 'vcenter': + # No concept of user in vcenter + return True result = True if self.get_user_dct(self.username): result &= False diff --git a/fixtures/vcenter.py b/fixtures/vcenter.py new file mode 100644 index 000000000..08fc7f41c --- /dev/null +++ b/fixtures/vcenter.py @@ -0,0 +1,536 @@ + +import time +import random +import uuid +import re +import os +from netaddr import IPNetwork +from fabric.context_managers import settings, hide +from fabric.api import run, env +from fabric.operations import get, put +from orchestrator import Orchestrator, OrchestratorAuth +from tcutils.util import * +from tcutils.cfgparser import parse_cfg_file +from vnc_api.vnc_api import * +from common.vcenter_libs import vimtype_dict +from common.vcenter_libs import vcenter_connect as connect +from common.vcenter_libs import vcenter_vim as vim + +def _vim_obj(typestr, **kwargs): + return vimtype_dict[typestr](**kwargs) + +def _wait_for_task (task): + while (task.info.state == vim.TaskInfo.State.running or + task.info.state == vim.TaskInfo.State.queued): + time.sleep(2) + if task.info.state != vim.TaskInfo.State.success: + raise ValueError("Something went wrong in wait_for_task") + return + +def _match_obj(obj, param): + attr = param.keys()[0] + attrs = [attr] + if '.' in attr: + attrs = attr.split('.') + for i in range(len(attrs) - 1): + if not hasattr(obj, attrs[i]): + break + obj = getattr(obj, attrs[i]) + attr = attrs[-1] + return hasattr(obj, attr) and getattr(obj, attr) == param.values()[0] + + +class VcenterVlanMgr: + + __metaclass__ = Singleton + + def __init__(self, dvs): + self._vlans = [(vlan.primaryVlanId, vlan.secondaryVlanId) for vlan in dvs.config.pvlanConfig if vlan.pvlanType == 'isolated'] + + def allocate_vlan(self): + return self._vlans.pop(0) + + def free_vlan(self, vlan): + self._vlans.append(vlan) + + +class VcenterOrchestrator(Orchestrator): + + def __init__(self, inputs, host, port, user, pwd, dc_name, vnc, logger): + self._inputs = inputs + self._host = host + self._port = port + self._user = user + self._passwd = pwd + self._dc_name = dc_name + self._vnc = vnc + self._log = logger + self._images_info = parse_cfg_file('configs/images.cfg') + self._connect_to_vcenter() + self._vlanmgmt = VcenterVlanMgr(self._vs) + self._create_keypair() + + def _connect_to_vcenter(self): + self._si = connect.SmartConnect(host=self._host, port=self._port, user=self._user, pwd=self._passwd) + if not self._si: + raise Exception("Unable to connect to vcenter: %s:%d %s/%s" % (self._host, + self._port, self._user, self._passwd)) + self._content = self._si.RetrieveContent() + if not self._content: + raise Exception("Unable to retrieve content from vcenter") + self._dc = self._find_obj(self._content.rootFolder, 'dc' , {'name' : self._dc_name}) + if not self._dc: + raise Exception("Datacenter %s not found" % self._dc_name) + dvs = self._get_obj_list(self._dc, 'dvs.VSwitch') + if not dvs: + raise Exception("Datacenter %s does not have a distributed virtual switch" % self._dc_name) + if len(dvs) > 1: + raise Exception("Datacenter %s has %d distributed virtual switches, excepting only one" % (self._dc_name, + len(dvs))) + self._vs = dvs[0] + self._clusters_hosts = self._get_clusters_hosts() + if len(self.get_zones()) == 0: + raise Exception("Datacenter %s has no clusters" % self._dc_name) + if len(self.get_hosts()) == 0: + raise Exception("Datacenter %s has no hosts" % self._dc_name) + self._computes = self._get_computes() + + def _find_obj (self, root, vimtype, param): + if vimtype == 'ip.Pool': + items = self._content.ipPoolManager.QueryIpPools(self._dc) + else: + items = self._content.viewManager.CreateContainerView(root, [vimtype_dict[vimtype]], True).view + for obj in items: + if _match_obj(obj, param): + return obj + return None + + def _get_obj_list (self, root, vimtype): + view = self._content.viewManager.CreateContainerView(root, [vimtype_dict[vimtype]], True) + return [obj for obj in view.view] + + def _get_clusters_hosts(self): + dd = {} + for cluster in self._get_obj_list(self._dc, 'cluster'): + hosts = [host.name for host in self._get_obj_list(cluster, 'host')] + dd[cluster.name] = hosts + self._log.debug('Vcenter clusters & hosts\n%s' % str(dd)) + return dd + + def get_hosts(self, zone=None): + if zone: + return self._clusters_hosts[zone][:] + return [host for hosts in self._clusters_hosts.values() for host in hosts] + + def get_zones(self): + return self._clusters_hosts.keys() + + def get_image_account(self, image_name): + return (self._images_info[image_name]['username'], + self._images_info[image_name]['password']) + + @threadsafe_generator + def _get_computes(self): + while True: + hosts = [(server, cluster) for cluster, servers in self._clusters_hosts.items() for server in servers] + for host in hosts: + yield host + + def _upload_to_host(self, host, image): + vmx = self._images_info[image].get('vctmpl', None) + loc = self._images_info[image].get('vcpath', None) + vmdk = self._images_info[image].get('vcname', None) + webserver = self._images_info[image]['webserver'] or \ + getattr(env, 'IMAGE_WEB_SERVER', '10.204.216.51') + if not vmdk: + vmdk = self._images_info[image]['name'] + if not vmx or not loc or not vmdk or ('vmdk' not in vmdk): + raise Exception("no suitable vmdk or template for %s" % image) + + user = self._inputs.host_data[host.name]['username'] + pwd = self._inputs.host_data[host.name]['password'] + url = 'http://%s/%s/' % (webserver, loc) + url_vmx = url + vmx + url_vmdk = url + vmdk + ds = host.datastore[0] + dst = '/vmfs/volumes/' + ds.name + '/' + image + '/' + dst_vmdk = dst + image + '.vmdk' + tmp_vmdk = dst + vmdk + with settings(host_string='%s@%s' % (user, host.name), password=pwd, + warn_only = True, shell = '/bin/sh -l -c'): + run('mkdir -p %s' % dst) + run('wget %s -P %s' % (url_vmx, dst)) + run('wget %s -P %s' % (url_vmdk, dst)) + run('vmkfstools -i %s -d zeroedthick %s' % (tmp_vmdk, dst_vmdk)) + run('rm %s' % tmp_vmdk) + + return ds.name, image+ '/' + vmx + + def _load_and_register_template(self, image): + host_name, cluster_name = next(self._computes) + host = self._find_obj(self._find_obj(self._dc, 'cluster', {'name' : cluster_name}), + 'host', {'name' : host_name}) + ds, vmtx = self._upload_to_host(host, image) + folder = self._dc.vmFolder + _wait_for_task(folder.RegisterVM_Task(path='[%s] %s' % (ds, vmtx), name=image, + asTemplate=True, host=host, pool=None)) + + def create_vm(self, vm_name, image_name, vn_objs, count=1, zone=None, node_name=None, **kwargs): + if self._find_obj(self._dc, 'vm', {'name' : vm_name}): + raise Exception("VM exists with the name %s" % vm_name) + + if zone and ((zone not in self._clusters_hosts) or (not len(self._clusters_hosts[zone]))): + raise Exception("No cluster named %s or no hosts in it" % zone) + + host = None + if node_name: + host = self._find_obj(self._dc, 'host', {'name' : node_name}) + if not host: + raise Exception("host %s not found" % node_name) + + tmpl = self._find_obj(self._dc, "vm", {'name' : image_name}) + if not tmpl: + self._load_and_register_template(image_name) + tmpl = self._find_obj(self._dc, "vm", {'name' : image_name}) + if not tmpl: + raise Exception("template not found") + + nets = [self._find_obj(self._dc, 'dvs.PortGroup', {'name' : vn.name}) for vn in vn_objs] + objs = [] + for _ in range(count): + if host: + tgthost = host + elif zone: + while True: + host_name, cluster_name = next(self._computes) + if cluster_name == zone: + break + tgthost = self._find_obj(self._find_obj(self._dc, 'cluster', {'name' : cluster_name}), + 'host', {'name' : host_name}) + else: + host_name, cluster_name = next(self._computes) + tgthost = self._find_obj(self._find_obj(self._dc, 'cluster', {'name' : cluster_name}), + 'host', {'name' : host_name}) + + vm = VcenterVM.create_in_vcenter(self, vm_name, tmpl, nets, tgthost) + objs.append(vm) + + return objs + + def delete_vm(self, vm): + vm_obj = self._find_obj(self._dc, 'vm', {'name' : vm.name}) + if vm_obj: + if vm_obj.runtime.powerState != 'poweredOff': + _wait_for_task(vm_obj.PowerOff()) + _wait_for_task(vm_obj.Destroy()) + + @retry(tries=30, delay=5) + def wait_till_vm_is_active(self, vm_obj): + vm = self._find_obj(self._dc, 'vm', {'name' : vm_obj.name}) + return vm.runtime.powerState == 'poweredOn' + + def get_host_of_vm(self, vm_obj): + host = self._find_obj(self._dc, 'host', {'name' : vm_obj.host}) + contrail_vm = None + for vm in host.vm: + if 'ContrailVM' in vm.name: + contrail_vm = vm + break + return self._inputs.host_data[contrail_vm.summary.guest.ipAddress]['name'] + + def get_networks_of_vm(self, vm_obj): + return vm_obj.nets[:] + + @retry(tries=10, delay=5) + def is_vm_deleted(self, vm_obj): + return self._find_obj(self._dc, 'vm', {'name' : vm_obj.name}) == None + + def get_vm_if_present(self, vm_name, **kwargs): + vmobj = self._find_obj(self._dc, 'vm', {'name' : vm_name}) + if vmobj: + return VcenterVM.create_from_vmobj(self, vmobj) + return None + + def get_vm_by_id(self, vm_id): + vmobj = self._find_obj(self._dc, 'vm', {'summary.config.instanceUuid':vm_id}) + if vmobj: + return VcenterVM.create_from_vmobj(self, vmobj) + return None + + def get_vm_list(self, name_pattern='', **kwargs): + vm_list = [] + vms = self._get_obj_list(self._dc, 'vm') + for vmobj in vms: + if 'ContrailVM' in vmobj.name: + continue + if re.match(r'%s' % name_pattern, vmobj.name, re.M | re.I): + vm_list.append(vmobj) + vm_list = [VcenterVM.create_from_vmobj(self, vmobj) for vmobj in vm_list] + return vm_list + + @retry(delay=5, tries=35) + def get_vm_detail(self, vm_obj): + return vm_obj.get() + + def get_console_output(self, vm_obj): + return None + + def get_vm_ip(self, vm_obj, vn_name): + self.get_vm_detail(vm_obj) + ret = vm_obj.ips.get(vn_name, None) + return [ret] + + def _create_keypair(self): + username = self._inputs.host_data[self._inputs.cfgm_ip]['username'] + password = self._inputs.host_data[self._inputs.cfgm_ip]['password'] + with settings( + host_string='%s@%s' % (username, self._inputs.cfgm_ip), + password=password, warn_only=True, abort_on_prompts=True): + rsa_pub_arg = '.ssh/id_rsa' + if exists('.ssh/id_rsa.pub'): # If file exists on remote m/c + get('.ssh/id_rsa.pub', '/tmp/') + else: + run('mkdir -p .ssh') + run('rm -f .ssh/id_rsa*') + run('ssh-keygen -f %s -t rsa -N \'\'' % (rsa_pub_arg)) + get('.ssh/id_rsa.pub', '/tmp/') + + def get_key_file(self): + return self.tmp_key_file + + def put_key_file_to_host(self, host_ip): + username = self._inputs.host_data[self._inputs.cfgm_ip]['username'] + password = self._inputs.host_data[self._inputs.cfgm_ip]['password'] + with hide('everything'): + with settings(host_string='%s@%s' % ( + username, self._inputs.cfgm_ip), + password=password, + warn_only=True, abort_on_prompts=False): + get('.ssh/id_rsa', '/tmp/') + get('.ssh/id_rsa.pub', '/tmp/') + with hide('everything'): + with settings( + host_string='%s@%s' % (self._inputs.host_data[host_ip]['username'], + host_ip), password=self._inputs.host_data[ + host_ip]['password'], + warn_only=True, abort_on_prompts=False): + if self._inputs.cfgm_ips[0] != host_ip: + put('/tmp/id_rsa', '/tmp/id_rsa') + put('/tmp/id_rsa.pub', '/tmp/id_rsa.pub') + run('chmod 600 /tmp/id_rsa') + self.tmp_key_file = '/tmp/id_rsa' + + def create_vn(self, name, subnets, **kwargs): + if self._find_obj(self._dc, 'dvs.PortGroup', {'name' : name}) or self._find_obj(self._dc, + 'ip.Pool', {'name' : 'pool-'+name}): + raise Exception('A VN %s or ip pool %s, exists with the name' % (name, 'pool-'+name)) + if len(subnets) != 1: + raise Exception('Cannot create VN with %d subnets' % len(subnets)) + vlan = self._vlanmgmt.allocate_vlan() + if not vlan: + raise Exception("Vlans exhausted") + try: + return VcenterVN.create_in_vcenter(self, name, vlan, subnets[0]['cidr']) + except: + self._vlanmgmt.free_vlan(vlan) + raise + + def delete_vn(self, vn_obj): + self._vlanmgmt.free_vlan(vn_obj.vlan) + self._content.ipPoolManager.DestroyIpPool(self._dc, vn_obj.ip_pool_id, True) + pg = self._find_obj(self._dc, 'dvs.PortGroup', {'name' : vn_obj.name}) + pg.Destroy() + return True + + def get_vn_obj_if_present(self, vn_name, **kwargs): + pg = self._find_obj(self._dc, 'dvs.PortGroup', {'name' : vn_name}) + if pg: + return VcenterVN.create_from_vnobj(self, pg) + return None + + def get_vn_name(self, vn_obj): + return vn_obj.name + + def get_vn_id(self, vnobj): + if not vnobj.uuid: + vnobj.get() + return vnobj.uuid + + def get_policy(self, fq_name): + self._vnc.network_policy_read(fq_name=fq_name) + + def get_floating_ip(self, fip_id): + fip_obj = self._vnc.floating_ip_read(id=fip_id) + return fip_obj.get_floating_ip_address() + + def create_floating_ip(self, pool_obj, project_obj, **kwargs): + fip_obj = FloatingIp(get_random_name('fip'), pool_obj) + fip_obj.set_project(project_obj) + self._vnc.floating_ip_create(fip_obj) + fip_obj = self._vnc.floating_ip_read(fq_name=fip_obj.fq_name) + return (fip_obj.get_floating_ip_address(), fip_obj.uuid) + + def delete_floating_ip(self, fip_id): + self._vnc.floating_ip_delete(id=fip_id) + + def assoc_floating_ip(self, fip_id, vm_id): + fip_obj = self._vnc.floating_ip_read(id=fip_id) + vm_obj = self._vnc.virtual_machine_read(id=vm_id) + vmi = vm_obj.get_virtual_machine_interface_back_refs()[0]['uuid'] + vmintf = self._vnc.virtual_machine_interface_read(id=vmi) + fip_obj.set_virtual_machine_interface(vmintf) + self._log.debug('Associating FIP:%s with VMI:%s' % (fip_id, vm_id)) + self._vnc.floating_ip_update(fip_obj) + return fip_obj + + def disassoc_floating_ip(self, fip_id): + self._log.debug('Disassociating FIP %s' % fip) + fip_obj = self._vnc.floating_ip_read(id=fip_id) + fip_obj.virtual_machine_interface_refs=None + self._vnc.floating_ip_update(fip_obj) + return fip_obj + + +class VcenterVN: + + @staticmethod + def create_in_vcenter(vcenter, name, vlan, prefix): + vn = VcenterVN() + vn.vcenter = vcenter + vn.name = name + vn.vlan = vlan + vn.uuid = None + vn.prefix = IPNetwork(prefix) + ip_list = list(vn.prefix.iter_hosts()) + + spec = _vim_obj('dvs.ConfigSpec', name=name, type='earlyBinding', numPorts = len(ip_list), + defaultPortConfig=_vim_obj('dvs.PortConfig', + vlan=_vim_obj('dvs.PVLan', pvlanId=vlan[1]))) + _wait_for_task(vcenter._vs.AddDVPortgroup_Task([spec])) + pg = vcenter._find_obj(vcenter._dc, 'dvs.PortGroup', {'name' : name}) + + ip_pool = _vim_obj('ip.Pool', name='pool-'+name, + ipv4Config=_vim_obj('ip.Config', + subnetAddress = str(vn.prefix.network), + netmask = str(vn.prefix.netmask), + range = str(ip_list[0]) + '#' + str(len(ip_list)), + ipPoolEnabled = True), + networkAssociation = [_vim_obj('ip.Association', + network=pg, + networkName=name)]) + vn.ip_pool_id = vcenter._content.ipPoolManager.CreateIpPool(vcenter._dc, ip_pool) + return vn + + @staticmethod + def create_from_vnobj(vcenter, vn_obj): + vn = VcenterVN() + vn.vcenter = vcenter + vn.name = vn_obj.name + vn.uuid = None + vlan = vn_obj.config.defaultPortConfig.vlan.pvlanId + vn.vlan = (vlan - 1, vlan) + vn.ip_pool_id = vn_obj.summary.ipPoolId + pool = vcenter._find_obj(vcenter._dc, 'ip.Pool', {'id':vn.ip_pool_id}) + vn.prefix = IPNetwork(pool.ipv4Config.subnetAddress+'/'+pool.ipv4Config.netmask) + ip_list = list(vn.prefix.iter_hosts()) + return vn + + @retry(tries=30, delay=5) + def _get_vnc_vn_id(self, fq_name): + try: + obj = self.vcenter._vnc.virtual_network_read(fq_name) + self.uuid = obj.uuid + return True + except: + return False + + def get(self): + fq_name = [u'default-domain',u'vCenter',unicode(self.name)] + if not self._get_vnc_vn_id(fq_name): + raise Exception("Unable to query VN %s from vnc" % self.name) + + +class VcenterVM: + + @staticmethod + def create_from_vmobj(vcenter, vmobj): + vm = VcenterVM() + vm.vcenter = vcenter + vm.name = vmobj.name + vm.host = vmobj.runtime.host.name + vm.nets = [net.name for net in vmobj.network] + vm.get(vmobj) + return vm + + @staticmethod + def create_in_vcenter(vcenter, name, template, networks, host): + vm = VcenterVM() + vm.vcenter = vcenter + vm.name = name + vm.host = host.name + vm.nets = [net.name for net in networks] + + intfs = [] + switch_id = vcenter._vs.uuid + for net in networks: + spec = _vim_obj('dev.VD', operation=vim.vm.device.VirtualDeviceSpec.Operation.add, + device=_vim_obj('dev.E1000', + addressType='Generated', + connectable=_vim_obj('dev.ConnectInfo', + startConnected=True, + allowGuestControl=True), + backing=_vim_obj('dev.DVPBackingInfo', + port = _vim_obj('dvs.PortConn', + switchUuid=switch_id, + portgroupKey=net.key)))) + intfs.append(spec) + + spec = _vim_obj('vm.Clone', + location=_vim_obj('vm.Reloc', + datastore=host.datastore[0], + pool=host.parent.resourcePool), + config=_vim_obj('vm.Config', deviceChange=intfs), + powerOn=True) + _wait_for_task(template.Clone(folder=vcenter._dc.vmFolder, name=vm.name, + spec=spec)) + vmobj = vcenter._find_obj(vcenter._dc, 'vm', {'name' : vm.name}) + vm.get(vmobj) + return vm + + def get(self, vm=None): + if not vm: + vm = self.vcenter._find_obj(self.vcenter._dc, 'vm', {'name' : self.name}) + self.id = vm.summary.config.instanceUuid + self.macs = {} + self.ips = {} + for intf in vm.guest.net: + self.macs[intf.network] = intf.macAddress + self.ips[intf.network] = intf.ipAddress[0] + return len(self.ips) == len(self.nets) + + def reboot(r): + vm = self.vcenter._find_obj(self.vcenter._dc, 'vm', {'name' : self.name}) + if r == 'SOFT': + vm.RebootGuest() + else: + _wait_for_task(vm.ResetVM()) + + +class VcenterAuth(OrchestratorAuth): + + def __init__(self, user, passwd, project_name, inputs): + self.inputs = inputs + self.user = user + self.passwd = passwd + self.vnc = VncApi(username=user, password=passwd, + tenant_name=project_name, + api_server_host=self.inputs.cfgm_ip, + api_server_port=self.inputs.api_server_port) + + def get_project_id(self, domain, name): + fq_name = [unicode(domain), unicode(name)] + obj = self.vnc.project_read(fq_name=fq_name) + if obj: + return obj.get_uuid() + return None + diff --git a/fixtures/vm_test.py b/fixtures/vm_test.py index 48a80e39c..786923135 100644 --- a/fixtures/vm_test.py +++ b/fixtures/vm_test.py @@ -54,11 +54,11 @@ def __init__(self, connections, vm_name=None, vn_obj=None, self.agent_inspect = self.connections.agent_inspect self.cn_inspect = self.connections.cn_inspect self.ops_inspect = self.connections.ops_inspects - self.quantum_fixture = self.connections.quantum_fixture + self.orch = self.connections.orch + self.quantum_h = self.connections.quantum_h self.vnc_lib_fixture = self.connections.vnc_lib_fixture - self.quantum_h = self.quantum_fixture.get_handle() self.vnc_lib_h = self.connections.vnc_lib - self.nova_fixture = self.connections.nova_fixture + self.nova_h = self.connections.nova_h self.node_name = node_name self.zone = zone self.sg_ids = sg_ids @@ -93,10 +93,10 @@ def __init__(self, connections, vm_name=None, vn_obj=None, self.vm_obj = None self.vm_ip = None self.agent_vn_obj = {} - self.vn_names = [x['network']['name'] for x in self.vn_objs] + self.vn_names = [self.orch.get_vn_name(x) for x in self.vn_objs] # self.vn_fq_names = [':'.join(x['network']['contrail:fq_name']) # for x in self.vn_objs] - self.vn_fq_names = [':'.join(self.vnc_lib_h.id_to_fq_name(x['network']['id'])) + self.vn_fq_names = [':'.join(self.vnc_lib_h.id_to_fq_name(self.orch.get_vn_id(x))) for x in self.vn_objs] if len(vn_objs) == 1: self.vn_name = self.vn_names[0] @@ -153,11 +153,11 @@ def setUp(self): project_name=self.project_name, connections=self.connections)) self.scale = self.project_fixture.scale - self.vn_ids = [x['network']['id'] for x in self.vn_objs] + self.vn_ids = [self.orch.get_vn_id(x) for x in self.vn_objs] if not self.scale: - self.vm_obj = self.nova_fixture.get_vm_if_present( - self.vm_name, self.project_fixture.uuid) - self.vm_objs = self.nova_fixture.get_vm_list(name_pattern=self.vm_name, + self.vm_obj = self.orch.get_vm_if_present( + self.vm_name, project_id = self.project_fixture.uuid) + self.vm_objs = self.orch.get_vm_list(name_pattern=self.vm_name, project_id=self.project_fixture.uuid) if self.vm_obj: self.already_present = True @@ -168,12 +168,12 @@ def setUp(self): if self.inputs.is_gui_based_config(): self.webui.create_vm(self) else: - objs = self.nova_fixture.create_vm( + objs = self.orch.create_vm( project_uuid=self.project_fixture.uuid, image_name=self.image_name, flavor=self.flavor, vm_name=self.vm_name, - vn_ids=self.vn_ids, + vn_objs=self.vn_objs, node_name=self.node_name, zone=self.zone, sg_ids=self.sg_ids, @@ -184,7 +184,7 @@ def setUp(self): time.sleep(5) self.vm_obj = objs[0] self.vm_objs = objs - (self.vm_username, self.vm_password) = self.nova_fixture.get_image_account( + (self.vm_username, self.vm_password) = self.orch.get_image_account( self.image_name) # end setUp @@ -200,16 +200,16 @@ def verify_vm_launched(self): self.vm_id = self.vm_objs[0].id for vm_obj in self.vm_objs: vm_id = vm_obj.id - self.nova_fixture.get_vm_detail(vm_obj) + self.orch.get_vm_detail(vm_obj) for vn_name in self.vn_names: - if len(self.nova_fixture.get_vm_ip(vm_obj, vn_name)) == 0: + if len(self.orch.get_vm_ip(vm_obj, vn_name)) == 0: with self.printlock: self.logger.error('VM %s didnt seem to have got any IP' % (vm_obj.name)) self.vm_launch_flag = self.vm_launch_flag and False return False - for ip in self.nova_fixture.get_vm_ip(vm_obj, vn_name): + for ip in self.orch.get_vm_ip(vm_obj, vn_name): if self.hack_for_v6(ip): continue # ToDo: msenthil revisit it self.vm_ip is used in many tests @@ -219,7 +219,7 @@ def verify_vm_launched(self): self.vm_ips.append(ip) with self.printlock: self.logger.info('VM %s launched on Node %s' - % (vm_obj.name, self.nova_fixture.get_nova_host_of_vm(vm_obj))) + % (vm_obj.name, self.orch.get_host_of_vm(vm_obj))) with self.printlock: self.logger.info("VM %s ID is %s" % (vm_obj.name, vm_obj.id)) # end for vm_obj @@ -228,10 +228,10 @@ def verify_vm_launched(self): # end verify_vm_launched def add_security_group(self, secgrp): - self.nova_fixture.add_security_group(self.vm_obj.id, secgrp) + self.orch.add_security_group(self.vm_obj, secgrp) def remove_security_group(self, secgrp): - self.nova_fixture.remove_security_group(self.vm_obj.id, secgrp) + self.orch.remove_security_group(self.vm_obj, secgrp) def verify_security_group(self, secgrp): @@ -279,7 +279,7 @@ def verify_sec_grp_in_agent(self, secgrp, domain='default-domain'): secgrp_fq_name) nova_host = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(self.vm_obj)] + self.orch.get_host_of_vm(self.vm_obj)] self.vm_node_ip = nova_host['host_ip'] inspect_h = self.agent_inspect[self.vm_node_ip] sg_info = inspect_h.get_sg(sg_id) @@ -304,7 +304,7 @@ def verify_sg_acls_in_agent(self, secgrp, domain='default-domain'): rules = list_sg_rules(self.connections, sg_id) nova_host = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(self.vm_obj)] + self.orch.get_host_of_vm(self.vm_obj)] self.vm_node_ip = nova_host['host_ip'] inspect_h = self.agent_inspect[self.vm_node_ip] acls_list = inspect_h.get_sg_acls_list(sg_id) @@ -333,36 +333,36 @@ def verify_on_setup(self, force=False): result = True self.verify_vm_launched() if len(self.vm_ips) < 1: - result = result and False - return result - vm_status = self.nova_fixture.wait_till_vm_is_active(self.vm_obj) - if vm_status[1] in 'ERROR': - self.logger.warn("VM in error state. Asserting...") + return False + vm_status = self.orch.wait_till_vm_is_active(self.vm_obj) + if type(vm_status) is tuple: + if vm_status[1] in 'ERROR': + self.logger.warn("VM in error state. Asserting...") + return False + if vm_status[1] != 'ACTIVE': + return False + elif not vm_status: return False - if vm_status[1] != 'ACTIVE': - result = result and False - return result - - self.verify_vm_flag = result and vm_status[0] + self.verify_vm_flag = True if self.inputs.verify_thru_gui(): self.webui.verify_vm(self) - result = result and self.verify_vm_in_api_server() + result = self.verify_vm_in_api_server() if not result: self.logger.error('VM %s verification in API Server failed' % (self.vm_name)) return result - result = result and self.verify_vm_in_agent() + result = self.verify_vm_in_agent() if not result: self.logger.error('VM %s verification in Agent failed' % (self.vm_name)) return result - result = result and self.verify_vm_in_control_nodes() + result = self.verify_vm_in_control_nodes() if not result: self.logger.error('Route verification for VM %s in Controlnodes' ' failed ' % (self.vm_name)) return result - result = result and self.verify_vm_in_opserver() + result = self.verify_vm_in_opserver() if not result: self.logger.error('VM %s verification in Opserver failed' % (self.vm_name)) @@ -561,7 +561,7 @@ def verify_vm_in_agent(self): ''' self.vm_in_agent_flag = True nova_host = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(self.vm_obj)] + self.orch.get_host_of_vm(self.vm_obj)] self.vm_node_ip = nova_host['host_ip'] self.vm_node_data_ip = nova_host['host_data_ip'] inspect_h = self.agent_inspect[self.vm_node_ip] @@ -979,7 +979,7 @@ def ping_to_ip(self, ip, return_output=False, other_opt='', size='56', count='5' fab_connections.clear() af = get_af_type(ip) try: - self.nova_fixture.put_key_file_to_host(self.vm_node_ip) + self.orch.put_key_file_to_host(self.vm_node_ip) with hide('everything'): with settings(host_string='%s@%s' %(host['username'], self.vm_node_ip), password=host['password'], @@ -995,7 +995,6 @@ def ping_to_ip(self, ip, return_output=False, other_opt='', size='56', count='5' else: util = 'ping6' if af == 'v6' else 'ping' cmd = '%s -s %s -c %s %s %s'%(util, str(size), str(count), other_opt, ip) - key_file = self.nova_fixture.tmp_key_file output = run_fab_cmd_on_node(host_string=vm_host_string, password=self.vm_password, cmd=cmd) @@ -1057,7 +1056,7 @@ def verify_vm_not_in_agent(self): result = True self.verify_vm_not_in_agent_flag = True inspect_h = self.agent_inspect[self.vm_node_ip] - if self.vm_obj in self.nova_fixture.get_vm_list(): + if not self.orch.is_vm_deleted(self.vm_obj): with self.printlock: self.logger.warn("VM %s is still found in Compute(nova) " "server-list" % (self.vm_name)) @@ -1534,7 +1533,7 @@ def cleanUp(self): if self.inputs.is_gui_based_config(): self.webui.delete_vm(self) else: - self.nova_fixture.delete_vm(vm_obj) + self.orch.delete_vm(vm_obj) self.vm_objs.remove(vm_obj) time.sleep(5) # Not expected to do verification when self.count is > 1, right now @@ -1566,8 +1565,7 @@ def verify_vm_not_in_nova(self): if not self.inputs.mysql_token: return result for vm_obj in self.vm_objs: - result = result and self.nova_fixture.is_vm_deleted_in_nova_db( - vm_obj, self.inputs.openstack_ip) + result = result and self.orch.is_vm_deleted(vm_obj) self.verify_vm_not_in_nova_flag =\ self.verify_vm_not_in_nova_flag and result return result @@ -1590,7 +1588,6 @@ def tftp_file_to_vm(self, file, vm_ip): host['username'], self.vm_node_ip), password=host['password'], warn_only=True, abort_on_prompts=False): - key_file = self.nova_fixture.tmp_key_file if os.environ.has_key('ci_image'): i = 'tftp -p -r %s -l %s %s' % (file, file, vm_ip) else: @@ -1618,13 +1615,12 @@ def scp_file_to_vm(self, file, vm_ip, dest_vm_username='ubuntu'): timeout = math.floor(40 * float(delay_factor)) try: - self.nova_fixture.put_key_file_to_host(self.vm_node_ip) + self.orch.put_key_file_to_host(self.vm_node_ip) with hide('everything'): with settings(host_string='%s@%s' % ( host['username'], self.vm_node_ip), password=host['password'], warn_only=True, abort_on_prompts=False): - key_file = self.nova_fixture.tmp_key_file self.get_rsa_to_vm() i = 'timeout %d scp -o StrictHostKeyChecking=no -i id_rsa %s %s@[%s]:' % ( timeout, file, dest_vm_username, vm_ip) @@ -1637,7 +1633,7 @@ def scp_file_to_vm(self, file, vm_ip, dest_vm_username='ubuntu'): def put_pub_key_to_vm(self): self.logger.debug('Copying public key to VM %s' % (self.vm_name)) - self.nova_fixture.put_key_file_to_host(self.vm_node_ip) + self.orch.put_key_file_to_host(self.vm_node_ip) auth_file = '.ssh/authorized_keys' self.run_cmd_on_vm(['mkdir -p ~/.ssh']) host = self.inputs.host_data[self.vm_node_ip] @@ -1646,7 +1642,6 @@ def put_pub_key_to_vm(self): host_string='%s@%s' % (host['username'], self.vm_node_ip), password=host['password'], warn_only=True, abort_on_prompts=False): - key_file = self.nova_fixture.tmp_key_file fab_put_file_to_vm(host_string='%s@%s' % ( self.vm_username, self.local_ip), password=self.vm_password, @@ -1656,6 +1651,8 @@ def put_pub_key_to_vm(self): 'chmod 600 ~/%s' % (auth_file), 'cat /tmp/id_rsa.pub >> /root/%s' % (auth_file), 'chmod 600 /root/%s' % (auth_file), + 'chown %s ~/%s' % (self.vm_username, auth_file), + 'chgrp %s ~/%s' % (self.vm_username, auth_file), '''sed -i -e 's/no-port-forwarding.*sleep 10\" //g' ~root/.ssh/authorized_keys'''] self.run_cmd_on_vm(cmds, as_sudo=True) @@ -1724,14 +1721,14 @@ def get_rsa_to_vm(self): host = self.inputs.host_data[self.vm_node_ip] output = '' try: - self.nova_fixture.put_key_file_to_host(self.vm_node_ip) + self.orch.put_key_file_to_host(self.vm_node_ip) with hide('everything'): with settings( host_string='%s@%s' % ( host['username'], self.vm_node_ip), password=host['password'], warn_only=True, abort_on_prompts=False): - key_file = self.nova_fixture.tmp_key_file + key_file = self.orch.get_key_file() fab_put_file_to_vm(host_string='%s@%s' % ( self.vm_username, self.local_ip), password=self.vm_password, @@ -1754,14 +1751,13 @@ def run_cmd_on_vm(self, cmds=[], as_sudo=False, timeout=30, as_daemon=False): host = self.inputs.host_data[self.vm_node_ip] output = '' try: - self.nova_fixture.put_key_file_to_host(self.vm_node_ip) + self.orch.put_key_file_to_host(self.vm_node_ip) fab_connections.clear() with hide('everything'): with settings( host_string='%s@%s' % (host['username'], self.vm_node_ip), password=host['password'], warn_only=True, abort_on_prompts=False): - key_file = self.nova_fixture.tmp_key_file for cmd in cmdList: self.logger.debug('Running Cmd on %s: %s' % ( self.vm_node_ip, cmd)) @@ -1812,7 +1808,7 @@ def wait_till_vm_is_up(self): return return_status def wait_till_vm_is_active(self): - status = self.nova_fixture.wait_till_vm_is_active(self.vm_obj) + status = self.orch.wait_till_vm_is_active(self.vm_obj) if type(status) == tuple: if status[1] in 'ERROR': return False @@ -1823,7 +1819,7 @@ def wait_till_vm_is_active(self): @retry(delay=5, tries=10) def wait_till_vm_up(self): - vm_status = self.nova_fixture.wait_till_vm_is_active(self.vm_obj) + vm_status = self.orch.wait_till_vm_is_active(self.vm_obj) if type(vm_status) == tuple: if vm_status[1] in 'ERROR': self.logger.warn("VM in error state. Asserting...") @@ -1833,12 +1829,12 @@ def wait_till_vm_up(self): if vm_status[1] != 'ACTIVE': result = result and False return result - elif type(vm_status) == bool: + elif type(vm_status) == bool and not vm_status: return (vm_status, 'final') result = self.verify_vm_launched() - #console_check = self.nova_fixture.wait_till_vm_is_up(self.vm_obj) - #result = result and self.nova_fixture.wait_till_vm_is_up(self.vm_obj) + #console_check = self.nova_h.wait_till_vm_is_up(self.vm_obj) + #result = result and self.nova_h.wait_till_vm_is_up(self.vm_obj) # if not console_check : # import pdb; pdb.set_trace() # self.logger.warn('Console logs didnt give enough info on bootup') @@ -1908,11 +1904,8 @@ def scp_file_transfer_cirros(self, dest_vm_fixture, fip = None, size = '100'): #end scp_file_transfer_cirros - def wait_till_vm_boots(self): - return self.nova_fixture.wait_till_vm_is_up(self.vm_obj) - def get_console_output(self): - return self.nova_fixture.get_vm_console_output(self.vm_obj) + return self.orch.get_console_output(self.vm_obj) @retry(delay=5, tries=20) def wait_for_ssh_on_vm(self): @@ -1980,8 +1973,8 @@ def install_pkg(self, pkgname="Traffic"): password = self.inputs.host_data[self.inputs.cfgm_ip]['password'] pkgsrc = PkgHost(self.inputs.cfgm_ips[0], self.vm_node_ip, username, password) - self.nova_fixture.put_key_file_to_host(self.vm_node_ip) - key = self.nova_fixture.tmp_key_file + self.orch.put_key_file_to_host(self.vm_node_ip) + key = self.orch.get_tmp_key_file() pkgdst = PkgHost(self.local_ip, key=key, user=self.vm_username, password=self.vm_password) fab_connections.clear() @@ -2057,7 +2050,7 @@ def _gather_details(self): self.vm_id = self.vm_objs[0].id # Figure out the local metadata IP of the VM reachable from host nova_host = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(self.vm_obj)] + self.orch.get_host_of_vm(self.vm_obj)] self.vm_node_ip = nova_host['host_ip'] self.vm_node_data_ip = nova_host['host_data_ip'] inspect_h = self.agent_inspect[self.vm_node_ip] @@ -2116,7 +2109,7 @@ def reboot(self, type='SOFT'): self.vm_obj.reboot(type) def wait_till_vm_status(self, status='ACTIVE'): - return self.nova_fixture.wait_till_vm_status(self.vm_obj, status) + return self.orch.wait_till_vm_status(self.vm_obj, status) def wait_till_vm_boots(self): return self.nova_h.wait_till_vm_is_up(self.vm_obj) @@ -2157,7 +2150,7 @@ def __init__(self, connections, vms=[], vn_objs=[], image_name='ubuntu', """ self.connections = connections - self.nova_fixture = self.connections.nova_fixture + self.nova_h = self.connections.nova_h if not project_name: project_name = connections.inputs.project_name self.project_name = project_name diff --git a/fixtures/vn_policy_test.py b/fixtures/vn_policy_test.py index 793e18640..d7b0ac01a 100644 --- a/fixtures/vn_policy_test.py +++ b/fixtures/vn_policy_test.py @@ -19,7 +19,7 @@ def __init__(self, connections, vn_name, vn_obj, vn_policys, project_name, optio self.connections = connections self.inputs = self.connections.inputs - self.quantum_fixture = self.connections.quantum_fixture + self.quantum_h = self.connections.quantum_h self.project_name = project_name self.vnc_lib = self.connections.vnc_lib self.api_s_inspect = self.connections.api_server_inspect @@ -30,7 +30,7 @@ def __init__(self, connections, vn_name, vn_obj, vn_policys, project_name, optio self.skip_verify = 'no' self.vn = vn_name self.already_present = False - self.option = options + self.option = options if self.inputs.orchestrator == 'openstack' else 'contrail' if self.inputs.verify_thru_gui(): self.browser = self.connections.browser self.browser_openstack = self.connections.browser_openstack @@ -53,7 +53,7 @@ def setUp(self): self.logger.info("Setup step: Associating the policy to VN'") if self.option == 'openstack': policy_fq_names = [ - self.quantum_fixture.get_policy_fq_name(x) for x in self.policy_obj[self.vn]] + self.quantum_h.get_policy_fq_name(x) for x in self.policy_obj[self.vn]] if self.inputs.is_gui_based_config(): self.webui.bind_policies(self) else: @@ -64,11 +64,13 @@ def setUp(self): elif self.option == 'contrail': ref_tuple = [] vn_update_rsp = None - for conf_policy in self.policy_obj[self.vn]: - self.vn_obj[self.vn].add_network_policy( - conf_policy, vnc_api.VirtualNetworkPolicyType(sequence=vnc_api.SequenceType(major=0, minor=0))) - vn_update_rsp = self.vnc_lib.virtual_network_update( - self.vn_obj[self.vn]._obj) + vnc_obj = self.vn_obj[self.vn].get_api_obj() + policys = self.policy_obj[self.vn] + for seq, conf_policy in enumerate(policys): + vnc_obj.add_network_policy(conf_policy, + vnc_api.VirtualNetworkPolicyType( + sequence=vnc_api.SequenceType(major=seq, minor=0))) + vn_update_rsp = self.vnc_lib.virtual_network_update(vnc_obj) self.logger.info('Associated Policy to %s' % (self.vn)) return self # end attachPolicytoVN @@ -110,11 +112,10 @@ def detach_Policy_VN(self): (policy_fq_names, self.vn)) elif self.option == 'contrail': vn_update_rsp = None + vnc_obj = self.vn_obj[self.vn].get_api_obj() for conf_policy in self.policy_obj[self.vn]: - self.vn_obj[self.vn]._obj.del_network_policy( - conf_policy) - vn_update_rsp = self.vnc_lib.virtual_network_update( - self.vn_obj[self.vn]._obj) + vnc_obj.del_network_policy(conf_policy) + vn_update_rsp = self.vnc_lib.virtual_network_update(vnc_obj) self.logger.info('Detached Policy from %s' % (self.vn)) # end of detach_policy_VN diff --git a/fixtures/vn_test.py b/fixtures/vn_test.py index dfeba2fa0..bcce36eaf 100644 --- a/fixtures/vn_test.py +++ b/fixtures/vn_test.py @@ -41,7 +41,8 @@ class VNFixture(fixtures.Fixture): def __init__(self, connections, inputs, vn_name=None, policy_objs=[], subnets=[], project_name=None, router_asn='64512', rt_number=None, ipam_fq_name=None, option='quantum', forwarding_mode=None, vxlan_id=None, shared=False, router_external=False, clean_up=True, project_obj= None, af=None, empty_vn=False, enable_dhcp=True, dhcp_option_list=None, disable_gateway=False): self.connections = connections self.inputs = inputs - self.quantum_fixture = self.connections.quantum_fixture + self.orch = self.connections.orch + self.quantum_h = self.connections.quantum_h self.vnc_lib_h = self.connections.vnc_lib self.api_s_inspect = self.connections.api_server_inspect self.agent_inspect = self.connections.agent_inspect @@ -55,6 +56,8 @@ def __init__(self, connections, inputs, vn_name=None, policy_objs=[], subnets=[] project_name = self.inputs.project_name if not vn_name: vn_name = get_random_name(project_name) + if self.inputs.orchestrator == 'vcenter' and subnets and (len(subnets) != 1): + raise Exception('vcenter: Multiple subnets not supported') if not subnets and not empty_vn: subnets = get_random_cidrs(stack=self.af) if subnets and self.get_af_from_subnet(subnets=subnets) == 'v6': @@ -135,28 +138,29 @@ def get_af_from_subnet(self, subnets): return af @retry(delay=10, tries=10) - def _create_vn_quantum(self): + def _create_vn_orch(self): try: if not self.scale: - self.obj = self.quantum_fixture.get_vn_obj_if_present( - self.vn_name, self.project_id) + self.obj = self.orch.get_vn_obj_if_present( + self.vn_name, project_id=self.project_id) if not self.obj: - self.obj = self.quantum_fixture.create_network( + self.obj = self.orch.create_vn( self.vn_name, self.vn_subnets, - self.ipam_fq_name, - self.shared, - self.router_external, - self.enable_dhcp, - self.disable_gateway) + ipam_fq_name=self.ipam_fq_name, + shared=self.shared, + router_external=self.router_external, + enable_dhcp=self.enable_dhcp, + disable_gateway=self.disable_gateway) self.logger.debug('Created VN %s' %(self.vn_name)) else: self.already_present = True self.logger.debug('VN %s already present, not creating it' % (self.vn_name)) - self.vn_id = self.obj['network']['id'] + self.vn_id = self.orch.get_vn_id(self.obj) self.vn_fq_name = ':'.join( self.vnc_lib_h.id_to_fq_name(self.vn_id)) + self.api_vn_obj = self.vnc_lib_h.virtual_network_read(id=self.vn_id) return True except NetworkClientException as e: with self.lock: @@ -200,7 +204,8 @@ def get_vn_uid(self, vn_obj, project_uuid): return uid def _create_vn_api(self, vn_name, project): - + if self.inputs.orchestrator == 'vcenter': + raise Exception('vcenter: no support for VN creation through VNC-api') try: self.api_vn_obj = VirtualNetwork( name=vn_name, parent_obj=project.project_obj) @@ -231,7 +236,7 @@ def _create_vn_api(self, vn_name, project): self.api_vn_obj.add_network_ipam(ipam, VnSubnetsType(ipam_sn_lst)) self.vnc_lib_h.virtual_network_update(self.api_vn_obj) self.vn_fq_name = self.api_vn_obj.get_fq_name_str() - self.obj = self.quantum_fixture.get_vn_obj_if_present(self.vn_name, + self.obj = self.quantum_h.get_vn_obj_if_present(self.vn_name, self.project_id) if self.obj is None: raise ValueError('could not find %s in neutron/quantum' % (self.vn_name)) @@ -260,12 +265,15 @@ def setUp(self): elif (self.option == 'api'): self._create_vn_api(self.vn_name, self.project_obj) else: - self._create_vn_quantum() + self._create_vn_orch() # Bind policies if any if self.policy_objs: - policy_fq_names = [ - self.quantum_fixture.get_policy_fq_name(x) for x in self.policy_objs] + if isinstance(self.policy_objs[0], NetworkPolicy): + policy_fq_names = [obj.fq_name for obj in self.policy_objs] + else: + policy_fq_names = [ + self.quantum_h.get_policy_fq_name(x) for x in self.policy_objs] self.bind_policies(policy_fq_names, self.vn_id) else: # Update self.policy_objs to pick acls which are already @@ -293,12 +301,14 @@ def setUp(self): self.vn_name, self.vxlan_id) # Populate the VN Subnet details - self.vn_subnet_objs = self.quantum_fixture.get_subnets_of_vn( - self.vn_id) + if self.inputs.orchestrator == 'openstack': + self.vn_subnet_objs = self.quantum_h.get_subnets_of_vn(self.vn_id) # end setUp def create_subnet(self, vn_subnet, ipam_fq_name): - self.quantum_fixture.create_subnet(vn_subnet, self.vn_id, ipam_fq_name) + if self.inputs.orchestrator == 'vcenter': + raise Exception('vcenter: subnets not supported') + self.quantum_h.create_subnet(vn_subnet, self.vn_id, ipam_fq_name) self.vn_subnets.append([{'cidr': vn_subnet}]) def create_subnet_af(self, af, ipam_fq_name): @@ -312,7 +322,9 @@ def create_subnet_af(self, af, ipam_fq_name): def create_port(self, net_id, subnet_id=None, ip_address=None, mac_address=None, no_security_group=False, security_groups=[], extra_dhcp_opts=None): - port_rsp = self.quantum_fixture.create_port( + if self.inputs.orchestrator == 'vcenter': + raise Exception('vcenter: ports not supported') + port_rsp = self.quantum_h.create_port( net_id, subnet_id, ip_address, @@ -323,7 +335,9 @@ def create_port(self, net_id, subnet_id=None, ip_address=None, return port_rsp def delete_port(self, port_id, quiet=False): - self.quantum_fixture.delete_port(port_id) + if self.inputs.orchestrator == 'vcenter': + raise Exception('vcenter: ports not supported') + self.quantum_h.delete_port(port_id) def verify_on_setup_without_collector(self): @@ -558,6 +572,10 @@ def get_allowed_peer_vns_by_policy(self): def verify_vn_policy_in_api_server(self): ''' verify VN's policy data in api-server with data in quantum database''' + if self.inputs.orchestrator == 'vcenter': + self.policy_verification_flag = {'result': True, 'msg': None} + return self.policy_verification_flag + me = inspect.getframeinfo(inspect.currentframe())[2] result = True err_msg = [] @@ -932,8 +950,10 @@ def get_rt_info(self): # end get_rt_info def add_subnet(self, subnet): + if self.inputs.orchestrator == 'vcenter': + raise Exception('vcenter: subnets not supported') # Get the Quantum details - quantum_obj = self.quantum_fixture.get_vn_obj_if_present(self.vn_name, + quantum_obj = self.quantum_h.get_vn_obj_if_present(self.vn_name, self.project_id) #cidr = unicode(subnet) if type(subnet) is str: @@ -944,7 +964,7 @@ def add_subnet(self, subnet): net_id = quantum_obj['network']['id'] # Create subnet - self.quantum_fixture.create_subnet(cidr, net_id, ipam_fq_name) + self.quantum_h.create_subnet(cidr, net_id, ipam_fq_name) # end add_subnet def set_vxlan_network_identifier_mode(self, mode): @@ -1024,7 +1044,7 @@ def cleanUp(self): self.vnc_lib_h.virtual_network_delete(id=self.vn_id) else: for i in range(12): - if not self.quantum_fixture.delete_vn(self.vn_id): + if not self.orch.delete_vn(self.obj): # This might be due to caching issues. self.logger.warn("%s. Deleting the VN %s failed" % (i, self.vn_name)) @@ -1047,15 +1067,25 @@ def get_obj(self): # end get_obj def bind_policies(self, policy_fq_names, vn_id): - net_rsp = {} - project_name = self.project_name - if len(policy_fq_names) != 0: - project_name = policy_fq_names[0][1] - net_req = {'contrail:policys': policy_fq_names} - net_rsp = self.quantum_fixture.update_network( - vn_id, {'network': net_req}) - self.logger.debug( - 'Response for mapping policy(s) with vn ' + str(net_rsp)) + if self.inputs.orchestrator == 'vcenter': + self.api_vn_obj = self.vnc_lib_h.virtual_network_read(id=self.vn_id) + self.api_vn_obj.set_network_policy_list([],True) + self.vnc_lib_h.virtual_network_update(self.api_vn_obj) + for seq, policy in enumerate(policy_fq_names): + policy_obj = self.vnc_lib_h.network_policy_read(fq_name=policy) + self.api_vn_obj.add_network_policy(policy_obj, + VirtualNetworkPolicyType(sequence=SequenceType(major=seq, minor=0))) + net_rsp = self.vnc_lib_h.virtual_network_update(self.api_vn_obj) + else: + net_rsp = {} + project_name = self.project_name + if len(policy_fq_names) != 0: + project_name = policy_fq_names[0][1] + net_req = {'contrail:policys': policy_fq_names} + net_rsp = self.quantum_h.update_network( + vn_id, {'network': net_req}) + self.logger.debug( + 'Response for mapping policy(s) with vn ' + str(net_rsp)) # Update VN obj self.update_vn_object() return net_rsp @@ -1071,32 +1101,42 @@ def get_current_policies_bound(self): # end get_current_policies_bound def update_vn_object(self): - self.obj = self.quantum_fixture.get_vn_obj_from_id(self.vn_id) + if self.inputs.orchestrator == 'openstack': + self.obj = self.quantum_h.get_vn_obj_from_id(self.vn_id) if not self.scale: self.policy_objs = [] if not self.policy_objs: for policy_fq_name in self.get_current_policies_bound(): - self.policy_objs.append( - self.quantum_fixture.get_policy_if_present(policy_fq_name[1], policy_fq_name[2])) + policy_obj = self.orch.get_policy(policy_fq_name) + self.policy_objs.append(policy_obj) # end update_vn_object def unbind_policies(self, vn_id, policy_fq_names=[]): - current_obj = self.quantum_fixture.obj.show_network(network=vn_id) - policys = self.get_current_policies_bound() - policys_to_remain = policys - for policy_name in policy_fq_names: - if not policy_name in policys: - self.logger.error('Policy %s is not bound to VN ID %s ' % - (policy_name, vn_id)) - return None + if self.inputs.orchestrator == 'vcenter': + if policy_fq_names == []: + self.api_vn_obj.set_network_policy_list([],True) + net_rsp = self.vnc_lib_h.virtual_network_update(self.api_vn_obj) else: - policys_to_remain.remove(policy_name) - # If no policy is passed, unbind all policys - if len(policy_fq_names) == 0: - policys_to_remain = [] - net_req = {'contrail:policys': policys_to_remain} - net_rsp = self.quantum_fixture.update_network( - vn_id, {'network': net_req}) + for policy in policy_fq_names: + policy_obj = self.vnc_lib_h.network_policy_read(fq_name=policy) + self.api_vn_obj.del_network_policy(policy_obj) + net_rsp = self.vnc_lib_h.virtual_network_update(self.api_vn_obj) + else: + policys = self.get_current_policies_bound() + policys_to_remain = policys + for policy_name in policy_fq_names: + if not policy_name in policys: + self.logger.error('Policy %s is not bound to VN ID %s ' % + (policy_name, vn_id)) + return None + else: + policys_to_remain.remove(policy_name) + # If no policy is passed, unbind all policys + if len(policy_fq_names) == 0: + policys_to_remain = [] + net_req = {'contrail:policys': policys_to_remain} + net_rsp = self.quantum_h.update_network( + vn_id, {'network': net_req}) self.policy_objs= [] self.update_vn_object() @@ -1104,12 +1144,16 @@ def unbind_policies(self, vn_id, policy_fq_names=[]): # end unbind_policy def update_subnet(self, subnet_id, subnet_dict): - self.quantum_fixture.update_subnet(subnet_id, subnet_dict) - self.vn_subnet_objs = self.quantum_fixture.get_subnets_of_vn( + if self.inputs.orchestrator == 'vcenter': + raise Exception('vcenter: subnets not supported') + self.quantum_h.update_subnet(subnet_id, subnet_dict) + self.vn_subnet_objs = self.quantum_h.get_subnets_of_vn( self.vn_id) def get_subnets(self): - return self.quantum_fixture.get_subnets_of_vn(self.vn_id) + if self.inputs.orchestrator == 'vcenter': + raise Exception('vcenter: subnets not supported') + return self.quantum_h.get_subnets_of_vn(self.vn_id) # end VNFixture diff --git a/fixtures/vpc_vm_fixture.py b/fixtures/vpc_vm_fixture.py index 12a18c0fb..4f9509c06 100644 --- a/fixtures/vpc_vm_fixture.py +++ b/fixtures/vpc_vm_fixture.py @@ -42,7 +42,7 @@ def __init__(self, vpc_vn_fixture, self.ec2_base = self.vpc_fixture.ec2_base self.already_present = False - self.nova_fixture = self.connections.nova_fixture + self.nova_h = self.connections.nova_h self.key = self.inputs.stack_user+key self.sg_ids = sg_ids self.cfgm_ip = self.inputs.cfgm_ip @@ -76,7 +76,7 @@ def setUp(self): # end setUp def create_vm(self): - self.nova_fixture.get_image(self.image_name) + self.nova_h.get_image(self.image_name) self.image_id = self._get_image_id() cmd_str = 'euca-run-instances %s -s %s -k %s' % \ (self.image_id, self.subnet_id, self.key) diff --git a/fixtures/webui_test.py b/fixtures/webui_test.py index 71a505313..6a9a060cf 100644 --- a/fixtures/webui_test.py +++ b/fixtures/webui_test.py @@ -45,7 +45,7 @@ def _click_if_element_found(self, element_name, elements_list): def create_vn(self, fixture): result = True try: - fixture.obj = fixture.quantum_fixture.get_vn_obj_if_present( + fixture.obj = fixture.quantum_h.get_vn_obj_if_present( fixture.vn_name, fixture.project_id) if not fixture.obj: if not self.ui.click_on_create( @@ -98,7 +98,7 @@ def create_vn(self, fixture): (fixture.vn_name)) self.logger.debug('VN %s exists, already there' % (fixture.vn_name)) - fixture.obj = fixture.quantum_fixture.get_vn_obj_if_present( + fixture.obj = fixture.quantum_h.get_vn_obj_if_present( fixture.vn_name, fixture.project_id) fixture.vn_id = fixture.obj['network']['id'] fixture.vn_fq_name = ':'.join(self.vnc_lib.id_to_fq_name( @@ -538,7 +538,7 @@ def create_policy(self, fixture): result = True line = 0 try: - fixture.policy_obj = fixture.quantum_fixture.get_policy_if_present( + fixture.policy_obj = fixture.quantum_h.get_policy_if_present( fixture.project_name, fixture.policy_name) if not fixture.policy_obj: if not self.ui.click_on_create( @@ -613,7 +613,7 @@ def create_policy(self, fixture): lists = lists + 1 if not self.ui.click_on_create('Policy', save=True): result = result and False - fixture.policy_obj = fixture.quantum_fixture.get_policy_if_present( + fixture.policy_obj = fixture.quantum_h.get_policy_if_present( fixture.project_name, fixture.policy_name) else: @@ -3950,7 +3950,7 @@ def verify_vn_in_webui(self, fixture): # else: # self.logger.error( "VN %s UUID Verification failed in webui table " %(fixture.vn_name)) # self.browser.get_screenshot_as_file('verify_vn_configure_page_ip_block.png') - fixture.obj = fixture.quantum_fixture.get_vn_obj_if_present( + fixture.obj = fixture.quantum_h.get_vn_obj_if_present( fixture.vn_name, fixture.project_id) fq_type = 'virtual_network' full_fq_name = fixture.vn_fq_name + ':' + fixture.vn_id @@ -4163,7 +4163,7 @@ def create_vm(self, fixture): self.browser_openstack, self.os_release) self.ui.click_instances(self.browser_openstack) fixture.image_name = 'ubuntu' - fixture.nova_fixture.get_image(image_name=fixture.image_name) + fixture.nova_h.get_image(image_name=fixture.image_name) time.sleep(2) self.ui.click_element( 'Launch Instance', @@ -4271,9 +4271,9 @@ def create_vm(self, fixture): self.browser_openstack) break time.sleep(10) - fixture.vm_obj = fixture.nova_fixture.get_vm_if_present( + fixture.vm_obj = fixture.nova_h.get_vm_if_present( fixture.vm_name, fixture.project_fixture.uuid) - fixture.vm_objs = fixture.nova_fixture.get_vm_list( + fixture.vm_objs = fixture.nova_h.get_vm_list( name_pattern=fixture.vm_name, project_id=fixture.project_fixture.uuid) fixture.verify_on_setup() @@ -4495,7 +4495,7 @@ def create_floatingip_pool(self, fixture, pool_name, vn_name): def bind_policies(self, fixture): result = True policy_fq_names = [ - fixture.quantum_fixture.get_policy_fq_name(x) for x in fixture.policy_obj[ + fixture.quantum_h.get_policy_fq_name(x) for x in fixture.policy_obj[ fixture.vn]] result = True try: @@ -4541,7 +4541,7 @@ def bind_policies(self, fixture): def detach_policies(self, fixture): policy_fq_names = [ - fixture.quantum_fixture.get_policy_fq_name(x) for x in fixture.policy_obj[ + fixture.quantum_h.get_policy_fq_name(x) for x in fixture.policy_obj[ fixture.vn]] result = True try: diff --git a/misc/sample_param_test.py b/misc/sample_param_test.py index 172221980..282b49f5b 100644 --- a/misc/sample_param_test.py +++ b/misc/sample_param_test.py @@ -6,8 +6,8 @@ # Set the env variable PARAMS_FILE to point to your ini file. Else it will try to pick params.ini in PWD # import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import unittest import fixtures import testtools @@ -42,8 +42,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 diff --git a/scripts/analytics/base.py b/scripts/analytics/base.py index e8403d719..920d63824 100644 --- a/scripts/analytics/base.py +++ b/scripts/analytics/base.py @@ -15,8 +15,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect @@ -79,7 +79,7 @@ def setup_common_objects(self, inputs , connections): vn_name= self.fip_vn_name, subnets= self.fip_vn_subnets)) # Making sure VM falls on diffrent compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: diff --git a/scripts/analytics/test_analytics.py b/scripts/analytics/test_analytics.py index 5b62e780d..6ea228912 100644 --- a/scripts/analytics/test_analytics.py +++ b/scripts/analytics/test_analytics.py @@ -224,7 +224,7 @@ def itest_object_tables_parallel_query(self): threads=[] first_vm = self.res.vn1_vm1_fixture vm_list = [self.res.vn1_vm2_fixture] - tx_vm_node_ip= self.inputs.host_data[self.nova_fixture.get_nova_host_of_vm(first_vm.vm_obj)]['host_ip'] + tx_vm_node_ip= self.inputs.host_data[self.nova_h.get_nova_host_of_vm(first_vm.vm_obj)]['host_ip'] #start_time=self.analytics_obj.getstarttime(tx_vm_node_ip) start_time=self.analytics_obj.get_time_since_uptime(self.inputs.cfgm_ip) #Configuring static route diff --git a/scripts/discovery_regression/base.py b/scripts/discovery_regression/base.py index 6cf0edae3..826b0ec0b 100644 --- a/scripts/discovery_regression/base.py +++ b/scripts/discovery_regression/base.py @@ -15,8 +15,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/scripts/discovery_regression/test_discovery.py b/scripts/discovery_regression/test_discovery.py index 3ddda85f7..55dcd5061 100644 --- a/scripts/discovery_regression/test_discovery.py +++ b/scripts/discovery_regression/test_discovery.py @@ -25,7 +25,7 @@ def runTest(self): pass # end runTest - @test.attr(type=['sanity', 'ci_sanity']) + @test.attr(type=['sanity', 'ci_sanity', 'vcenter']) @preposttest_wrapper def test_all_publishers_registered_to_discovery_service(self): ''' @@ -44,7 +44,7 @@ def test_all_publishers_registered_to_discovery_service(self): return True - @test.attr(type=['sanity', 'ci_sanity']) + @test.attr(type=['sanity', 'ci_sanity', 'vcenter']) @preposttest_wrapper def test_agent_gets_control_nodes_from_discovery(self): ''' @@ -69,7 +69,7 @@ def test_agents_connected_to_dns_service(self): assert self.ds_obj.verify_agents_connected_to_dns_service(ip) return True - @test.attr(type=['sanity']) + @test.attr(type=['sanity', 'vcenter']) #@test.attr(type=['sanity', 'ci_sanity']) @preposttest_wrapper def test_agents_connected_to_collector_service(self): @@ -106,7 +106,7 @@ def test_control_nodes_connected_to_collector_service(self): ip) return True - @test.attr(type=['sanity', 'ci_sanity']) + @test.attr(type=['sanity', 'ci_sanity', 'vcenter']) @preposttest_wrapper def test_control_nodes_subscribed_to_ifmap_service(self): ''' @@ -227,7 +227,7 @@ def test_cleanup(self): resp = self.ds_obj.cleanup_service_from_discovery(self.inputs.cfgm_ip) return True - @test.attr(type=['sanity', 'ci_sanity']) + @test.attr(type=['sanity', 'ci_sanity', 'vcenter']) @preposttest_wrapper def test_webui_subscribed_to_opserver_service(self): ''' Validate webui subscribed to opserver service @@ -237,7 +237,7 @@ def test_webui_subscribed_to_opserver_service(self): ) return True - @test.attr(type=['sanity', 'ci_sanity']) + @test.attr(type=['sanity', 'ci_sanity', 'vcenter']) @preposttest_wrapper def test_webui_subscribed_to_apiserver_service(self): ''' Validate webui subscribed to apiserver service diff --git a/scripts/ecmp/base.py b/scripts/ecmp/base.py index c0a96d433..27a62d8da 100644 --- a/scripts/ecmp/base.py +++ b/scripts/ecmp/base.py @@ -16,8 +16,8 @@ def setUpClass(cls): cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() #cls.connections= ContrailConnections(cls.inputs) - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib # cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect diff --git a/scripts/ecmp/sanity.py b/scripts/ecmp/sanity.py index e27b13598..e41dd9fbe 100644 --- a/scripts/ecmp/sanity.py +++ b/scripts/ecmp/sanity.py @@ -7,8 +7,8 @@ # try to pick params.ini in PWD import sys import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import unittest import fixtures import testtools @@ -42,8 +42,8 @@ def __init__(self, *args, **kwargs): self.res = ECMPSolnSetupResource.getResource() self.inputs = self.res.inputs self.connections = self.res.connections - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + self.quantum_h = self.connections.quantum_h + self.nova_h = self.connections.nova_h self.vnc_lib = self.connections.vnc_lib self.logger = self.res.logger self.agent_inspect = self.connections.agent_inspect @@ -120,7 +120,7 @@ def test_ecmp_to_non_ecmp_bw_three_vms_same_fip(self): stream_list = [stream1, stream2, stream3] tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] tx_local_host = Host( tx_vm_node_ip, self.inputs.host_data[tx_vm_node_ip]['username'], @@ -134,7 +134,7 @@ def test_ecmp_to_non_ecmp_bw_three_vms_same_fip(self): for vm in vm_list: rx_vm_node_ip[vm] = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] rx_local_host[vm] = Host( rx_vm_node_ip[vm], self.inputs.host_data[vm.vm_node_ip]['username'], @@ -305,7 +305,7 @@ def test_ecmp_bw_three_vms_same_fip_delete_add_fip(self): stream_list = [stream1, stream2, stream3] tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] tx_local_host = Host( tx_vm_node_ip, self.inputs.host_data[tx_vm_node_ip]['username'], @@ -319,7 +319,7 @@ def test_ecmp_bw_three_vms_same_fip_delete_add_fip(self): for vm in vm_list: rx_vm_node_ip[vm] = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] rx_local_host[vm] = Host( rx_vm_node_ip[vm], self.inputs.host_data[vm.vm_node_ip]['username'], @@ -505,7 +505,7 @@ def test_ecmp_bw_three_vms_same_fip_delete_add_fip(self): stream_list = [stream1, stream2, stream3] tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] tx_local_host = Host( tx_vm_node_ip, self.inputs.host_data[tx_vm_node_ip]['username'], @@ -519,7 +519,7 @@ def test_ecmp_bw_three_vms_same_fip_delete_add_fip(self): for vm in vm_list: rx_vm_node_ip[vm] = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] rx_local_host[vm] = Host( rx_vm_node_ip[vm], self.inputs.host_data[vm.vm_node_ip]['username'], @@ -820,7 +820,7 @@ def test_ecmp_bw_three_vms_same_fip_incr_sport(self): stream_list = [stream1, stream2, stream3] tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] tx_local_host = Host( tx_vm_node_ip, self.inputs.host_data[tx_vm_node_ip]['username'], @@ -834,7 +834,7 @@ def test_ecmp_bw_three_vms_same_fip_incr_sport(self): for vm in vm_list: rx_vm_node_ip[vm] = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] rx_local_host[vm] = Host( rx_vm_node_ip[vm], self.inputs.host_data[vm.vm_node_ip]['username'], @@ -1083,7 +1083,7 @@ def test_ecmp_bw_three_vms_same_fip_incr_sip(self): for fvm in fvm_list: tx_vm_node_ip[fvm] = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(fvm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(fvm.vm_obj)]['host_ip'] tx_local_host[fvm] = Host( tx_vm_node_ip[fvm], self.inputs.host_data[fvm.vm_node_ip]['username'], @@ -1097,7 +1097,7 @@ def test_ecmp_bw_three_vms_same_fip_incr_sip(self): for vm in vm_list: rx_vm_node_ip[vm] = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] rx_local_host[vm] = Host( rx_vm_node_ip[vm], self.inputs.host_data[vm.vm_node_ip]['username'], @@ -1324,7 +1324,7 @@ def test_ecmp_bw_three_vms_same_fip(self): stream_list = [stream1, stream2, stream3] tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] tx_local_host = Host( tx_vm_node_ip, self.inputs.host_data[tx_vm_node_ip]['username'], @@ -1338,7 +1338,7 @@ def test_ecmp_bw_three_vms_same_fip(self): for vm in vm_list: rx_vm_node_ip[vm] = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] rx_local_host[vm] = Host( rx_vm_node_ip[vm], self.inputs.host_data[vm.vm_node_ip]['username'], @@ -1741,7 +1741,7 @@ def test_ecmp_bw_two_vms_same_fip(self): stream_list = [stream1, stream2] tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(fvn_vm1.vm_obj)]['host_ip'] tx_local_host = Host( tx_vm_node_ip, self.inputs.host_data[tx_vm_node_ip]['username'], @@ -1755,7 +1755,7 @@ def test_ecmp_bw_two_vms_same_fip(self): for vm in vm_list: rx_vm_node_ip[vm] = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] rx_local_host[vm] = Host( rx_vm_node_ip[vm], self.inputs.host_data[vm.vm_node_ip]['username'], diff --git a/scripts/ecmp/sanity_w_svc.py b/scripts/ecmp/sanity_w_svc.py index 940d22c93..237a2ce40 100644 --- a/scripts/ecmp/sanity_w_svc.py +++ b/scripts/ecmp/sanity_w_svc.py @@ -34,15 +34,15 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 self.api_s_inspect = self.connections.api_server_inspect self.cn_inspect = self.connections.cn_inspect self.agent_inspect = self.connections.agent_inspect - self.quantum_fixture = self.connections.quantum_fixture + self.quantum_h = self.connections.quantum_h def cleanUp(self): self.logger.info("Cleaning up") @@ -322,7 +322,7 @@ def test_ecmp_svc_in_network_with_3_instance_reboot_nodes(self): self.logger.info( 'Will check the state of the SIs and power it ON, if it is in SHUTOFF state') - for vm in self.nova_fixture.get_vm_list(): + for vm in self.nova_h.get_vm_list(): if vm.status != 'ACTIVE': self.logger.info('Will Power-On %s' % vm.name) vm.start() @@ -347,7 +347,7 @@ def test_ecmp_svc_in_network_with_3_instance_reboot_nodes(self): socket.gethostbyaddr(bgp_ip)[0]) self.logger.info( 'Will check the state of the SIs and power it ON, if it is in SHUTOFF state') - for vm in self.nova_fixture.get_vm_list(): + for vm in self.nova_h.get_vm_list(): if vm.status != 'ACTIVE': self.logger.info('Will Power-On %s' % vm.name) vm.start() @@ -444,7 +444,7 @@ def test_ecmp_svc_in_network_with_3_instance_diff_proto(self): self.vm1_fixture.vm_username, self.vm1_fixture.vm_password) rx_vm_node_ip = self.vm2_fixture.vm_node_ip - self.nova_fixture.get_nova_host_of_vm(self.vm2_fixture.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(self.vm2_fixture.vm_obj)]['host_ip'] rx_local_host = Host( rx_vm_node_ip, self.inputs.host_data[rx_vm_node_ip]['username'], @@ -1332,7 +1332,7 @@ def test_ecmp_svc_in_network_with_3_instance_del_add_agent(self): self.verify_traffic_flow(self.vm1_fixture, self.vm2_fixture) self.logger.info( 'Will check the state of the SIs and power it ON, if it is in SHUTOFF state') - for si in self.si_fixtures[0].nova_fixture.get_vm_list(): + for si in self.si_fixtures[0].nova_h.get_vm_list(): if si.status != 'ACTIVE': self.logger.info('Will Power On %s' % si.name) si.start() @@ -1509,7 +1509,7 @@ def test_ecmp_svc_in_network_nat_scale_max_instances(self): Pass criteria: Ping between the VMs should be successful and TCP traffic should reach vm2 from vm1. Maintainer : ganeshahv@juniper.net """ - if len(self.connections.nova_fixture.get_hosts()) > 1: + if len(self.connections.nova_h.get_hosts()) > 1: for i in range(4, 17, 4): self.logger.info( '***** Will launch %s instances in the Service Chain *****' % i) diff --git a/scripts/ecmp/sanity_with_setup.py b/scripts/ecmp/sanity_with_setup.py index 63750060d..102b0770c 100644 --- a/scripts/ecmp/sanity_with_setup.py +++ b/scripts/ecmp/sanity_with_setup.py @@ -40,12 +40,12 @@ def __init__(self, *args, **kwargs): self.inputs = self.res.inputs self.connections = self.res.connections self.logger = self.res.logger - self.nova_fixture = self.res.nova_fixture + self.nova_h = self.res.nova_h self.analytics_obj = self.connections.analytics_obj self.vnc_lib = self.connections.vnc_lib self.agent_inspect = self.connections.agent_inspect self.cn_inspect = self.connections.cn_inspect - self.quantum_fixture = self.connections.quantum_fixture + self.quantum_h = self.connections.quantum_h def __del__(self): print "Deleting test_with_setup now" diff --git a/scripts/encap/base.py b/scripts/encap/base.py index 128137921..d97501487 100644 --- a/scripts/encap/base.py +++ b/scripts/encap/base.py @@ -19,8 +19,8 @@ def setUpClass(cls): cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() #cls.connections= ContrailConnections(cls.inputs) - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib # cls.logger= cls.inputs.logger cls.agent_inspect = cls.connections.agent_inspect diff --git a/scripts/encap_tests.py b/scripts/encap_tests.py index 560e0b2cf..567aba163 100644 --- a/scripts/encap_tests.py +++ b/scripts/encap_tests.py @@ -7,8 +7,8 @@ # Set the env variable MX_GW_TESTto 1 to run the test # import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import unittest import fixtures import testtools @@ -42,8 +42,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + self.quantum_h = self.connections.quantum_h + self.nova_h = self.connections.nova_h self.agent_inspect = self.connections.agent_inspect self.vnc_lib = self.connections.vnc_lib self.logger = self.inputs.logger @@ -63,7 +63,7 @@ def test_encaps_mx_gateway(self): '''Test to validate floating-ip froma a public pool assignment to a VM. It creates a VM, assigns a FIP to it and pings to outside the cluster.''' if (('MX_GW_TEST' in os.environ) and (os.environ.get('MX_GW_TEST') == '1')): - if len(self.connections.nova_fixture.get_hosts()) < 2: + if len(self.connections.nova_h.get_hosts()) < 2: raise self.skipTest( 'Skipping Test. At least 2 compute node required to run the test') @@ -190,7 +190,7 @@ def test_apply_policy_fip_on_same_vn_gw_mx(self): if (('MX_GW_TEST' in os.environ) and (os.environ.get('MX_GW_TEST') == '1')): - if len(self.connections.nova_fixture.get_hosts()) < 2: + if len(self.connections.nova_h.get_hosts()) < 2: self.logger.info( "Skipping Test. At least 2 compute node required to run the test") raise self.skipTest( @@ -247,7 +247,7 @@ def test_apply_policy_fip_on_same_vn_gw_mx(self): self.inputs.project_name, 'default') # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() fvn_fixture = self.useFixture( VNFixture( @@ -378,7 +378,7 @@ def test_apply_policy_fip_vn_with_encaps_change_gw_mx(self): if (('MX_GW_TEST' in os.environ) and (os.environ.get('MX_GW_TEST') == '1')): - if len(self.connections.nova_fixture.get_hosts()) < 2: + if len(self.connections.nova_h.get_hosts()) < 2: self.logger.info( "Skipping Test. At least 2 compute node required to run the test") raise self.skipTest( @@ -435,7 +435,7 @@ def test_apply_policy_fip_vn_with_encaps_change_gw_mx(self): self.inputs.project_name, 'default') # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() fvn_fixture = self.useFixture( VNFixture( diff --git a/scripts/floating_ip_test_resource.py b/scripts/floating_ip_test_resource.py index b53b17653..7d555438b 100755 --- a/scripts/floating_ip_test_resource.py +++ b/scripts/floating_ip_test_resource.py @@ -25,8 +25,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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() @@ -50,7 +50,7 @@ def setup_common_objects(self): (self.vn1_vm1_traffic_name) = 'VN1_VM1_traffic' (self.fvn1_vm1_traffic_name) = 'FVN1_VM1_traffic' # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: diff --git a/scripts/floating_ip_tests.py b/scripts/floating_ip_tests.py index 4b27e6e1a..41dc8dddc 100755 --- a/scripts/floating_ip_tests.py +++ b/scripts/floating_ip_tests.py @@ -7,8 +7,8 @@ # import re import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import fixtures import testtools import unittest @@ -46,7 +46,7 @@ def __init__(self, *args, **kwargs): self.inputs = self.res.inputs self.connections = self.res.connections self.logger = self.res.logger - self.nova_fixture = self.res.nova_fixture + self.nova_h = self.res.nova_h self.agent_inspect = self.connections.agent_inspect self.cn_inspect = self.connections.cn_inspect self.analytics_obj = self.connections.analytics_obj @@ -1446,7 +1446,7 @@ def test_communication_across__diff_proj(self): ('test2', 'test123', 'admin')] # Making sure VM falls on diffrent compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -2184,8 +2184,8 @@ def test_longest_prefix_match_with_fip_and_policy(self): vn_obj=vn2_obj, vm_name=vm2_name, project_name=self.inputs.project_name)) assert vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm2_fixture.vm_obj) rules = [ { @@ -2333,9 +2333,9 @@ def test_longest_prefix_match_with_fip_and_native_staticroute(self): vn_obj=vn3_obj, vm_name= vm3_name, project_name= self.inputs.project_name)) assert vm3_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up( vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up( vm2_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up( vm3_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up( vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up( vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up( vm3_fixture.vm_obj) cmd_to_pass1=['ifconfig eth1 up'] vm2_fixture.run_cmd_on_vm(cmds=cmd_to_pass1, as_sudo=True) @@ -2483,8 +2483,8 @@ def test_longest_prefix_match_with_2fip_different_vn_name(self): vn_obj=vn4_obj, vm_name= vm2_name, project_name= self.inputs.project_name)) assert vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up( vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up( vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up( vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up( vm2_fixture.vm_obj) cmd_to_pass1=['ifconfig eth1 up'] vm1_fixture.run_cmd_on_vm(cmds=cmd_to_pass1, as_sudo=True) diff --git a/scripts/floatingip/base.py b/scripts/floatingip/base.py index 4351bbcc8..91cd8abca 100644 --- a/scripts/floatingip/base.py +++ b/scripts/floatingip/base.py @@ -23,8 +23,8 @@ def setUpClass(cls): cls.connections = cls.isolated_creds.get_conections() cls.admin_inputs = cls.isolated_creds.get_admin_inputs() cls.admin_connections = cls.isolated_creds.get_admin_connections() - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect @@ -93,7 +93,7 @@ def scp_files_to_vm(self, src_vm, dst_vm): return result def get_two_different_compute_hosts(self): - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.orch.get_hosts() self.compute_1 = host_list[0] self.compute_2 = host_list[0] if len(host_list) > 1: diff --git a/scripts/floatingip/test_floatingip.py b/scripts/floatingip/test_floatingip.py index 76439457b..af069959c 100644 --- a/scripts/floatingip/test_floatingip.py +++ b/scripts/floatingip/test_floatingip.py @@ -7,8 +7,8 @@ # import re import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException from user_test import UserFixture import fixtures import testtools @@ -2360,7 +2360,7 @@ def test_ping_to_fip_using_diag(self): return result # end test_ping_to_fip_using_diag - @test.attr(type=['sanity', 'ci_sanity', 'quick_sanity']) + @test.attr(type=['sanity', 'ci_sanity', 'quick_sanity', 'vcenter']) @preposttest_wrapper def test_floating_ip(self): '''Test to validate floating-ip Assignment to a VM. It creates a VM, assigns a FIP to it and pings to a IP in the FIP VN. @@ -2920,8 +2920,8 @@ def test_longest_prefix_match_with_fip_and_policy(self): project_name=self.inputs.project_name)) assert vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm2_fixture.vm_obj) rules = [ { @@ -3065,9 +3065,9 @@ def test_longest_prefix_match_with_fip_and_native_staticroute(self): project_name=self.inputs.project_name)) assert vm3_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(vm2_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(vm3_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm3_fixture.vm_obj) cmd_to_pass1 = ['ifconfig eth1 up'] vm2_fixture.run_cmd_on_vm(cmds=cmd_to_pass1, as_sudo=True) @@ -3278,8 +3278,8 @@ def test_longest_prefix_match_with_2fip_different_vn_name(self): project_name=self.inputs.project_name)) assert vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm2_fixture.vm_obj) cmd_to_pass1 = ['ifconfig eth1 up'] vm1_fixture.run_cmd_on_vm(cmds=cmd_to_pass1, as_sudo=True) diff --git a/scripts/floatingip/test_mx.py b/scripts/floatingip/test_mx.py index 0bedb149c..6e5bc740f 100644 --- a/scripts/floatingip/test_mx.py +++ b/scripts/floatingip/test_mx.py @@ -7,8 +7,8 @@ # Set the env variable MX_GW_TESTto 1 to run the test # import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import unittest import fixtures import testtools @@ -44,7 +44,7 @@ def is_test_applicable(self): return (False, 'Skipping Test. Env variable MX_GW_TEST is not set') return (True, None) - @test.attr(type=['mx_test', 'sanity']) + @test.attr(type=['mx_test', 'sanity', 'vcenter']) @preposttest_wrapper def test_mx_gateway(self): ''' @@ -137,7 +137,7 @@ def test_apply_policy_fip_on_same_vn(self): mx_rt = self.inputs.mx_rt # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: diff --git a/scripts/heat/base.py b/scripts/heat/base.py index 8c0808350..d9c8c0400 100644 --- a/scripts/heat/base.py +++ b/scripts/heat/base.py @@ -39,8 +39,8 @@ def setUpClass(cls): cls.connections = cls.isolated_creds.get_conections() cls.admin_inputs = cls.isolated_creds.get_admin_inputs() cls.admin_connections = cls.isolated_creds.get_admin_connections() - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect diff --git a/scripts/multi_tenancy/base.py b/scripts/multi_tenancy/base.py index fdbc665d6..ecff6409f 100644 --- a/scripts/multi_tenancy/base.py +++ b/scripts/multi_tenancy/base.py @@ -3,7 +3,7 @@ from common.connections import ContrailConnections from vm_test import VMFixture from vn_test import VNFixture -from keystoneclient.v2_0 import client as ksclient +from common.openstack_libs import ks_client as ksclient from vnc_api.vnc_api import * from vnc_api import common from keystone_tests import KeystoneCommands @@ -17,8 +17,8 @@ def setUpClass(cls): username = cls.inputs.stack_user, password = cls.inputs.stack_password, logger = cls.logger) - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/scripts/multi_tenancy/test_perms.py b/scripts/multi_tenancy/test_perms.py index 745f95b55..6e2e0c25e 100644 --- a/scripts/multi_tenancy/test_perms.py +++ b/scripts/multi_tenancy/test_perms.py @@ -1,4 +1,4 @@ -from keystoneclient.v2_0 import client as ksclient +from common.openstack_libs import ks_client as ksclient from vnc_api.vnc_api import * from vnc_api import common import uuid diff --git a/scripts/neutron/lbaas/test_lbaas.py b/scripts/neutron/lbaas/test_lbaas.py index 9edab4f29..95b07e937 100644 --- a/scripts/neutron/lbaas/test_lbaas.py +++ b/scripts/neutron/lbaas/test_lbaas.py @@ -8,7 +8,8 @@ from common.connections import ContrailConnections from tcutils.wrappers import preposttest_wrapper from tcutils.util import run_fab_cmd_on_node -from neutronclient.common.exceptions import NeutronClientException + +from common.openstack_libs import neutron_client_exception as NeutronClientException from common.neutron.lbaas.base import BaseTestLbaas import test @@ -80,13 +81,13 @@ def test_create_pool_member_vip(self): pool_names = [] vip_names = [] - pool_list = self.quantum_fixture.list_lb_pools() + pool_list = self.quantum_h.list_lb_pools() assert pool_list, "failed to get the pool list" for pool in pool_list: pool_names.append(pool['name']) assert pool_name in pool_names, "pool %s is not present in the pool list" % (pool_name) - vip_list = self.quantum_fixture.list_vips() + vip_list = self.quantum_h.list_vips() for vip in vip_list: vip_names.append(vip['name']) assert vip_name in vip_names, "vip %s is not present in the vip list" % (vip_name) @@ -195,7 +196,7 @@ def test_delete_pool_in_use(self): self.associate_health_monitor(lb_pool['id'], healthmonitor['id']) #Check if Health monitor is associated with the pool - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) if pool['pool']['health_monitors'][0] == healthmonitor['id']: self.logger.info("pool %s is associated with healthmonitor %s" % (lb_pool['name'], pool['pool']['health_monitors'])) else: @@ -206,7 +207,7 @@ def test_delete_pool_in_use(self): result,msg = self.verify_healthmonitor_association_in_api_server(lb_pool['id'], healthmonitor['id']) assert result, msg - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) associated_vip = pool['pool']['vip_id'] associated_members = pool['pool']['members'] associated_hm = pool['pool']['health_monitors'] @@ -214,7 +215,7 @@ def test_delete_pool_in_use(self): #Try to delete the pool with VIP,members and HM associated self.logger.info("Try to delete the pool is use") try: - self.quantum_fixture.delete_lb_pool(lb_pool['id']) + self.quantum_h.delete_lb_pool(lb_pool['id']) except NeutronClientException, e: self.logger.debug("Execption: (%s) raised while deleting the pool, as we" " tried to delete the pool in use" % (e)) @@ -225,13 +226,13 @@ def test_delete_pool_in_use(self): assert False, ("Internal server error while deleting the pool in use." " Expected proper error msg here.") - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) if not pool: assert False, ("Expected pool with id %s to be present.But could not get the pool details" " after we tried to delete this pool in use" % (lb_pool['id'])) #Checking to see if VIP is not deleted with pool delete - vip = self.quantum_fixture.show_vip(associated_vip) + vip = self.quantum_h.show_vip(associated_vip) if vip: self.logger.info("Vip with id %s present. Pool delete did not initiate the vip delete." % (associated_vip)) @@ -242,7 +243,7 @@ def test_delete_pool_in_use(self): #Checking to see if pool delete did not delete the members for member_id in associated_members: - member = self.quantum_fixture.show_lb_member(member_id) + member = self.quantum_h.show_lb_member(member_id) if member: self.logger.info("Member with id %s present. Pool delete did not initiate the delete of" " associated member" % member_id) @@ -252,7 +253,7 @@ def test_delete_pool_in_use(self): % (member_id, lb_pool['id'])) #Verify if the pool delete did not delete the HM - health_monitor = self.quantum_fixture.get_health_monitor(associated_hm[0]) + health_monitor = self.quantum_h.get_health_monitor(associated_hm[0]) if health_monitor: self.logger.info("Health monitor with id %s present. Pool delete did not initiate" " the health monitor delete." % (associated_hm)) @@ -324,7 +325,7 @@ def test_member_delete(self): assert self.verify_member_in_api_server(lb_member3['id']), \ "API server verification failed for member with id %s" % (lb_member3['id']) - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) associated_members = pool['pool']['members'] if lb_member2['id'] in associated_members: @@ -334,7 +335,7 @@ def test_member_delete(self): errmsg = ("member with id %s not present in member list associated with pool," " not continuing the test failing the test here" % (lb_member2['id'])) assert False, errmsg - member_list = self.quantum_fixture.list_lb_members() + member_list = self.quantum_h.list_lb_members() out = False errmsg = ("member with id %s not present in member list, not continuing the test" " failing the test here" % (lb_member2['id'])) @@ -347,14 +348,14 @@ def test_member_delete(self): #Delete one of the lb member self.logger.info("deleting the lb member %s" % lb_member2['id']) - self.quantum_fixture.delete_lb_member(lb_member2['id']) - self.remove_method_from_cleanups((self.quantum_fixture.delete_lb_member, (lb_member2['id'],), {})) + self.quantum_h.delete_lb_member(lb_member2['id']) + self.remove_method_from_cleanups((self.quantum_h.delete_lb_member, (lb_member2['id'],), {})) #Verify in the API server if the member is deleted self.verify_on_member_delete(lb_member2['id']) #Verify the member list - member_list = self.quantum_fixture.list_lb_members() + member_list = self.quantum_h.list_lb_members() errmsg = ("member with id %s still present in member list even after member delete" " member list didnt get updated" % (lb_member2['id'])) for member in member_list: @@ -364,7 +365,7 @@ def test_member_delete(self): % (lb_member2['id'])) #Verfy if the pool is updated - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) members_associated = pool['pool']['members'] if lb_member2['id'] not in members_associated: self.logger.info("member with id %s not present in member list associated with" @@ -425,11 +426,11 @@ def test_vip_delete(self): result,errmsg = self.verify_active_standby(self.inputs.compute_ips, pool_uuid) assert result, errmsg - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) associated_vip = pool['pool']['vip_id'] #Verify VIP list is updatedi after vip create - vip_list = self.quantum_fixture.list_vips() + vip_list = self.quantum_h.list_vips() if vip_list: errmsg = ("vip with id %s not present in vip list after vip create" " vip list didnt get updated" % (lb_vip['id'])) @@ -443,15 +444,15 @@ def test_vip_delete(self): #Delete the vip self.logger.info("deleting the vip associated with pool %s" % associated_vip) - self.quantum_fixture.delete_vip(associated_vip) - self.remove_method_from_cleanups((self.quantum_fixture.delete_vip, (associated_vip,), {})) + self.quantum_h.delete_vip(associated_vip) + self.remove_method_from_cleanups((self.quantum_h.delete_vip, (associated_vip,), {})) #Verify netns and Haproxy got terminated after VIP delete and is #removed from API Server self.verify_on_vip_delete(pool_uuid, associated_vip) #Verify VIP list is updated after vip delete - vip_list = self.quantum_fixture.list_vips() + vip_list = self.quantum_h.list_vips() if vip_list: errmsg = ("vip with id %s still present in vip list even after vip delete" " vip list didnt get updated" % (associated_vip)) @@ -463,7 +464,7 @@ def test_vip_delete(self): #Verfy if the pool is updated - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) vip_associated = pool['pool']['vip_id'] if vip_associated: errmsg = ("vip with id %s still shows as associated with pool," @@ -518,7 +519,7 @@ def test_healthmonitor_delete(self): self.associate_health_monitor(lb_pool['id'], healthmonitor['id']) #Check if Health monitor is associated with the pool - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) if pool['pool']['health_monitors'][0] == healthmonitor['id']: self.logger.info("pool %s is associated with healthmonitor %s" % (lb_pool['name'], pool['pool']['health_monitors'])) @@ -532,7 +533,7 @@ def test_healthmonitor_delete(self): assert result, msg #Verify HM list is updatedi after HM create - HM_list = self.quantum_fixture.list_health_monitors() + HM_list = self.quantum_h.list_health_monitors() result = True if HM_list: errmsg = ("healthmonitor with id %s not present in healthmonitor list" @@ -548,13 +549,13 @@ def test_healthmonitor_delete(self): result = False assert result, errmsg - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) associated_hm = pool['pool']['health_monitors'] #Delete HM and verify HM list and associated pool gets updated self.logger.info("deleting the healthmonitor %s" % healthmonitor['id']) try: - self.quantum_fixture.delete_health_monitor(healthmonitor['id']) + self.quantum_h.delete_health_monitor(healthmonitor['id']) except NeutronClientException, e: self.logger.debug("Execption: (%s) raised while deleting the HM, as we" " tried to delete the HM in use" % (e)) @@ -567,7 +568,7 @@ def test_healthmonitor_delete(self): " Expected proper error msg") #Verify HM still exists - HM_list = self.quantum_fixture.list_health_monitors() + HM_list = self.quantum_h.list_health_monitors() result = True if HM_list: errmsg = ("healthmonitor with id %s not present in healthmonitor list" @@ -584,7 +585,7 @@ def test_healthmonitor_delete(self): assert result, errmsg #Verfy if the pool still has the HM associated - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) HM_associated = pool['pool']['health_monitors'] if HM_associated == healthmonitor['id']: self.logger.info("Healthmonitor with id %s is still associated with pool" @@ -799,7 +800,7 @@ def test_healthmonitor(self): self.associate_health_monitor(lb_pool['id'], healthmonitor['id']) #Check if Health monitor is associated with the pool - pool = self.quantum_fixture.get_lb_pool(lb_pool['id']) + pool = self.quantum_h.get_lb_pool(lb_pool['id']) if pool['pool']['health_monitors'][0] == healthmonitor['id']: self.logger.info("pool %s is associated with healthmonitor %s" % (lb_pool['name'], pool['pool']['health_monitors'])) else: diff --git a/scripts/neutron/test_crud.py b/scripts/neutron/test_crud.py index 303f30fc1..a38194f49 100644 --- a/scripts/neutron/test_crud.py +++ b/scripts/neutron/test_crud.py @@ -1,11 +1,6 @@ from common.neutron.attributes import * import testtools -from neutronclient.client import HTTPClient -from neutronclient.neutron import client import json -from neutronclient.common.exceptions import NeutronClientException -from keystoneclient.v2_0 import client as ksclient -from keystoneclient import exceptions as ks_exceptions from tcutils.util import * from tcutils.wrappers import preposttest_wrapper @@ -13,6 +8,11 @@ from common.neutron.base import BaseNeutronTest import test +from common.openstack_libs import neutron_client as client +from common.openstack_libs import neutron_http_client as HTTPClient +from common.openstack_libs import neutron_exception as NeutronClientException +from common.openstack_libs import ks_client as ksclient +from common.openstack_libs import ks_exceptions class TestCRUD(BaseNeutronTest): @@ -22,10 +22,10 @@ def setUpClass(cls): def setUp(self): super(TestCRUD, self).setUp() - self.neutron_test_h = self.admin_connections.quantum_fixture - self.neutron_h = self.admin_connections.quantum_fixture.obj - self.proj_neutron_test_h = self.quantum_fixture - self.proj_neutron_h = self.quantum_fixture.obj + self.neutron_test_h = self.admin_connections.quantum_h + self.neutron_h = self.admin_connections.quantum_h.obj + self.proj_neutron_test_h = self.quantum_h + self.proj_neutron_h = self.quantum_h.obj self.create_security_group(get_random_name('admin-sg1'), self.neutron_test_h) @@ -35,7 +35,7 @@ def setUp(self): self.proj_neutron_test_h) self.create_security_group(get_random_name('proj-sg2'), self.proj_neutron_test_h) - self.ks_project_id = self.project.ks_project_id + self.ks_project_id = self.project.uuid self.log = self.logger self.newline = '=' * 80 + '\n' # end setUp diff --git a/scripts/neutron/test_ports.py b/scripts/neutron/test_ports.py index bf04876c0..a69e64526 100644 --- a/scripts/neutron/test_ports.py +++ b/scripts/neutron/test_ports.py @@ -338,7 +338,7 @@ def test_ports_extra_dhcp_options(self): # Remove the dhcp option and check the result on the VM port_dict = {'extra_dhcp_opts': []} - self.quantum_fixture.update_port(port1_obj['id'], port_dict) + self.quantum_h.update_port(port1_obj['id'], port_dict) vm1_fixture.reboot() assert vm1_fixture.wait_till_vm_is_up() output = vm1_fixture.run_cmd_on_vm(['cat /etc/resolv.conf']) @@ -382,10 +382,10 @@ def test_port_rename(self): vn1_fixture = self.create_vn(vn1_name, [vn1_subnet]) port1_obj = self.create_port(net_id=vn1_fixture.vn_id) port_dict = {'name': "test_port"} - port_rsp = self.quantum_fixture.update_port(port1_obj['id'], port_dict) + port_rsp = self.quantum_h.update_port(port1_obj['id'], port_dict) assert port_rsp['port'][ 'name'] == "test_port", 'Failed to update port name' - self.quantum_fixture.delete_port(port1_obj['id']) + self.quantum_h.delete_port(port1_obj['id']) # end test_port_rename @@ -406,13 +406,13 @@ def test_port_admin_state_up(self): vm2_fixture.wait_till_vm_is_up() assert vm2_fixture.ping_with_certainty(vm1_fixture.vm_ip) port_dict = {'admin_state_up': False} - port_rsp = self.quantum_fixture.update_port(port_obj['id'], port_dict) + port_rsp = self.quantum_h.update_port(port_obj['id'], port_dict) assert port_rsp['port'][ 'admin_state_up'] == False, 'Failed to update port admin_state_up to False' assert vm1_fixture.ping_with_certainty( vm2_fixture.vm_ip, expectation=False), 'Port forwards packets with admin_state_up set to False not expected' port_dict = {'admin_state_up': True} - port_rsp = self.quantum_fixture.update_port(port_obj['id'], port_dict) + port_rsp = self.quantum_h.update_port(port_obj['id'], port_dict) assert port_rsp['port'][ 'admin_state_up'], 'Failed to update port admin_state_up to True ' assert vm1_fixture.ping_with_certainty(vm2_fixture.vm_ip) @@ -449,7 +449,7 @@ def test_ports_update_sg(self): # Update the port with custom sg port_dict = {'security_groups': [sg1['id']]} - self.quantum_fixture.update_port(port1_obj['id'], port_dict) + self.quantum_h.update_port(port1_obj['id'], port_dict) assert vm1_fixture.ping_with_certainty(vm2_fixture.vm_ip, expectation=False), ''\ @@ -487,7 +487,7 @@ def test_ports_device_owner_and_id(self): port_ids=[port1_obj['id']]) assert vm1_fixture.wait_till_vm_is_up(), 'VM does not seem to be up' - port1_obj = self.quantum_fixture.get_port(port1_obj['id']) + port1_obj = self.quantum_h.get_port(port1_obj['id']) assert port1_obj['device_id'] == vm1_fixture.vm_id, \ "Port %s has device id not set to %s on VM Attach" % ( port1_obj, vm1_fixture.vm_id) @@ -510,7 +510,7 @@ def test_shutoff_vm_route_withdrawal(self): (self.vn1_vm1_name, self.vn1_vm2_name) = ( get_random_name('vn1_vm1'), get_random_name('vn1_vm2')) # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: diff --git a/scripts/neutron/test_quota.py b/scripts/neutron/test_quota.py index 07b1f7dd4..b07d64382 100644 --- a/scripts/neutron/test_quota.py +++ b/scripts/neutron/test_quota.py @@ -26,7 +26,7 @@ def test_default_quota_for_admin_tenant(self): '''Test default quota for admin tenant ''' result = True - quota_dict = self.admin_connections.quantum_fixture.show_quota( + quota_dict = self.admin_connections.quantum_h.show_quota( self.admin_connections.project_id) self.logger.info( "Defalult quota set for admin tenant is : \n %s" % @@ -42,7 +42,7 @@ def test_default_quota_for_admin_tenant(self): @preposttest_wrapper def test_default_quota_for_new_tenant(self): result = True - quota_dict = self.connections.quantum_fixture.show_quota( + quota_dict = self.connections.quantum_h.show_quota( self.connections.project_id) self.logger.info( "Defalult quota set for tenant %s is : \n %s" % @@ -71,10 +71,10 @@ def test_update_quota_for_new_tenant(self): self.logger.info( "Update quota for tenant %s to : \n %s" % (self.inputs.project_name, quota_dict)) - quota_rsp = self.connections.quantum_fixture.update_quota( + quota_rsp = self.connections.quantum_h.update_quota( self.connections.project_id, quota_dict) - quota_show_dict = self.connections.quantum_fixture.show_quota( + quota_show_dict = self.connections.quantum_h.show_quota( self.connections.project_id) self.logger.info( "Quota for new tenant %s updated to : \n %s" % @@ -131,11 +131,11 @@ def test_quota_update_of_new_project_by_admin(self): self.logger.info( "Update quota for tenant %s to: \n %s by admin tenat " % (proj_inputs1.project_name, quota_dict)) - quota_rsp = self.admin_connections.quantum_fixture.update_quota( - project_obj1.project_id, + quota_rsp = self.admin_connections.quantum_h.update_quota( + project_obj1.uuid, quota_dict) - quota_show_dict = self.admin_connections.quantum_fixture.show_quota( - project_obj1.project_id) + quota_show_dict = self.admin_connections.quantum_h.show_quota( + project_obj1.uuid) for neutron_obj in quota_rsp['quota']: if quota_rsp['quota'][neutron_obj] != quota_show_dict[ @@ -153,8 +153,8 @@ def test_quota_update_of_new_project_by_admin(self): (proj_inputs1.project_name, quota_dict, proj_inputs.project_name)) - result1 = proj_connection.quantum_fixture.update_quota( - project_obj1.project_id, + result1 = proj_connection.quantum_h.update_quota( + project_obj1.uuid, quota_dict) assert not result1, 'Quota update of %s by %s successful not expected' % ( project_name1, project_name) @@ -203,17 +203,17 @@ def test_quota_update_of_specific_tenant(self): user_fixture1.add_user_to_tenant(project_name1, 'test_usr1', 'Member') assert project_fixture_obj1.verify_on_setup() - quota_show_dict1 = self.admin_connections.quantum_fixture.show_quota( - project_fixture_obj.project_id) + quota_show_dict1 = self.admin_connections.quantum_h.show_quota( + project_fixture_obj.uuid) self.logger.info( "Update quota for tenant %s to: \n %s by admin tenant " % (project_fixture_obj1.inputs.project_name, quota_dict)) - quota_rsp = self.admin_connections.quantum_fixture.update_quota( - project_fixture_obj1.project_id, + quota_rsp = self.admin_connections.quantum_h.update_quota( + project_fixture_obj1.uuid, quota_dict) - quota_show_dict = self.admin_connections.quantum_fixture.show_quota( - project_fixture_obj1.project_id) + quota_show_dict = self.admin_connections.quantum_h.show_quota( + project_fixture_obj1.uuid) for neutron_obj in quota_rsp['quota']: if quota_rsp['quota'][neutron_obj] != quota_show_dict[ @@ -224,8 +224,8 @@ def test_quota_update_of_specific_tenant(self): result = False assert result, 'Quota update by admin tenant failed' - quota_show_dict2 = self.admin_connections.quantum_fixture.show_quota( - project_fixture_obj.project_id) + quota_show_dict2 = self.admin_connections.quantum_h.show_quota( + project_fixture_obj.uuid) self.logger.info( "Quota for tenant %s is updated to : \n %s " % diff --git a/scripts/neutron/test_routers.py b/scripts/neutron/test_routers.py index 00f8c1414..85868e0b8 100644 --- a/scripts/neutron/test_routers.py +++ b/scripts/neutron/test_routers.py @@ -67,7 +67,7 @@ def test_basic_router_behavior(self): router_dict = self.create_router(router_name) self.add_vn_to_router(router_dict['id'], vn1_fixture) self.add_vn_to_router(router_dict['id'], vn2_fixture) - router_ports = self.quantum_fixture.get_router_interfaces( + router_ports = self.quantum_h.get_router_interfaces( router_dict['id']) router_port_ips = [item['fixed_ips'][0]['ip_address'] for item in router_ports] @@ -90,7 +90,7 @@ def test_router_rename(self): router_name = get_random_name('router1') router_dict = self.create_router(router_name) router_update_dict = {'name': "test_router"} - router_rsp = self.quantum_fixture.update_router( + router_rsp = self.quantum_h.update_router( router_dict['id'], router_update_dict) assert router_rsp['router'][ @@ -124,7 +124,7 @@ def test_router_admin_state_up(self): self.add_vn_to_router(router_dict['id'], vn2_fixture) assert vn1_vm1_fixture.ping_with_certainty(vn2_vm1_fixture.vm_ip) router_update_dict = {'admin_state_up': False} - router_rsp = self.quantum_fixture.update_router( + router_rsp = self.quantum_h.update_router( router_dict['id'], router_update_dict) assert router_rsp['router'][ @@ -132,7 +132,7 @@ def test_router_admin_state_up(self): assert vn1_vm1_fixture.ping_with_certainty( vn2_vm1_fixture.vm_ip, expectation=False), 'Routing works with admin_state_up set to False not expected' router_update_dict = {'admin_state_up': True} - router_rsp = self.quantum_fixture.update_router( + router_rsp = self.quantum_h.update_router( router_dict['id'], router_update_dict) assert router_rsp['router'][ @@ -200,7 +200,7 @@ def test_router_with_alloc_pool_and_gateway(self): add_intf_result = self.add_vn_to_router(router_dict['id'], vn1_fixture) assert 'port_id' in add_intf_result.keys(), \ 'Router port not created when allocation-pool is set in Subnet' - router_port_ip = self.quantum_fixture.get_port_ips( + router_port_ip = self.quantum_h.get_port_ips( add_intf_result['port_id'])[0] vn1_gateway_ip = vn1_fixture.vn_subnet_objs[0]['gateway_ip'] assert router_port_ip == vn1_gateway_ip,\ @@ -227,7 +227,7 @@ def test_router_with_alloc_pool_and_gateway(self): add_intf_result = self.add_vn_to_router(router_dict['id'], vn2_fixture) assert 'port_id' in add_intf_result.keys(), \ 'Router port not created when allocation-pool is set in Subnet' - router_port_ip = self.quantum_fixture.get_port_ips( + router_port_ip = self.quantum_h.get_port_ips( add_intf_result['port_id'])[0] vn2_gateway_ip = vn2_fixture.vn_subnet_objs[0]['gateway_ip'] assert router_port_ip == vn2_gateway_ip,\ @@ -290,7 +290,7 @@ def test_basic_snat_behavior_without_external_connectivity(self): router_name = get_random_name('router1') router_dict = self.create_router(router_name) - router_rsp = self.quantum_fixture.router_gateway_set( + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], ext_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) @@ -316,7 +316,7 @@ def test_basic_snat_behavior(self): vm1_fixture.wait_till_vm_is_up() router_name = get_random_name('router1') router_dict = self.create_router(router_name) - router_rsp = self.quantum_fixture.router_gateway_set( + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], self.public_vn_obj.public_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) @@ -340,7 +340,7 @@ def test_basic_snat_behavior_with_fip(self): router_name = get_random_name('router1') router_dict = self.create_router(router_name) - router_rsp = self.quantum_fixture.router_gateway_set( + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], self.public_vn_obj.public_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) @@ -422,16 +422,16 @@ def test_basic_snat_behavior_with_diff_projects(self): vm_name=vm2_name)) vm2_fixture.wait_till_vm_is_up() router_name = get_random_name('router1') - router_dict = self.create_router(router_name, tenant_id=project_fixture_obj1.project_id) - router_rsp = self.quantum_fixture.router_gateway_set( + router_dict = self.create_router(router_name, tenant_id=project_fixture_obj1.uuid) + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], self.public_vn_obj.public_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) assert self.verify_snat(vm1_fixture) router_name = get_random_name('router2') - router_dict = self.create_router(router_name, tenant_id=project_fixture_obj.project_id) - router_rsp = self.quantum_fixture.router_gateway_set( + router_dict = self.create_router(router_name, tenant_id=project_fixture_obj.uuid) + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], self.public_vn_obj.public_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn2_fixture) @@ -523,15 +523,15 @@ def test_basic_snat_behavior_with_fip_and_diff_projects(self): vm3_fixture.wait_till_vm_is_up() router_name = get_random_name('router1') - router_dict = self.create_router(router_name, tenant_id=project_fixture_obj1.project_id) - router_rsp = self.quantum_fixture.router_gateway_set( + router_dict = self.create_router(router_name, tenant_id=project_fixture_obj1.uuid) + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], self.public_vn_obj.public_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) assert self.verify_snat(vm1_fixture) router_name = get_random_name('router2') - router_dict = self.create_router(router_name, tenant_id=project_fixture_obj.project_id) - router_rsp = self.quantum_fixture.router_gateway_set( + router_dict = self.create_router(router_name, tenant_id=project_fixture_obj.uuid) + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], self.public_vn_obj.public_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn2_fixture) @@ -561,7 +561,7 @@ def test_basic_snat_behavior_with_subnet_attach_detach(self): router_name = get_random_name('router1') router_dict = self.create_router(router_name) - router_rsp = self.quantum_fixture.router_gateway_set( + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], self.public_vn_obj.public_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) @@ -611,7 +611,7 @@ def test_basic_snat_behavior_with_different_vns(self): router_name = get_random_name('router1') router_dict = self.create_router(router_name) - router_rsp = self.quantum_fixture.router_gateway_set( + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], self.public_vn_obj.public_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) diff --git a/scripts/neutron/test_sec_group.py b/scripts/neutron/test_sec_group.py index d02989704..2764bd62c 100644 --- a/scripts/neutron/test_sec_group.py +++ b/scripts/neutron/test_sec_group.py @@ -31,7 +31,7 @@ def test_security_group_rename(self): ''' sg1 = self.create_security_group(get_random_name('sg1')) sg_dict = {'name': "test_sec_grp"} - sg_rsp = self.quantum_fixture.update_security_group( + sg_rsp = self.quantum_h.update_security_group( sg1['id'], sg_dict) assert sg_rsp['security_group'][ diff --git a/scripts/neutron/test_subnets.py b/scripts/neutron/test_subnets.py index 04f118481..d2709366d 100644 --- a/scripts/neutron/test_subnets.py +++ b/scripts/neutron/test_subnets.py @@ -267,7 +267,7 @@ def test_enable_dhcp(self): vn1_subnet_dict) vm1_fixture = self.create_vm(vn1_fixture, vn1_vm1_name, image_name='cirros-0.3.0-x86_64-uec') - assert vm1_fixture.wait_till_vm_boots(),\ + assert vm1_fixture.wait_till_vm_up(),\ 'Unable to detect if VM booted up using console log' console_log = vm1_fixture.get_console_output() @@ -348,7 +348,7 @@ def test_subnet_rename(self): vn1_subnets = [{'cidr': vn1_subnet_cidr}] vn1_fixture = self.create_vn(vn1_name, vn1_subnets) subnet_dict = {'name': "test_subnet"} - subnet_rsp = self.quantum_fixture.update_subnet( + subnet_rsp = self.quantum_h.update_subnet( vn1_fixture.vn_subnet_objs[0]['id'], subnet_dict) assert subnet_rsp['subnet'][ diff --git a/scripts/neutron/test_virtual_network.py b/scripts/neutron/test_virtual_network.py index 967b8bfa7..41a294ee0 100644 --- a/scripts/neutron/test_virtual_network.py +++ b/scripts/neutron/test_virtual_network.py @@ -37,7 +37,7 @@ def test_virtual_network_rename(self): vn1_fixture = self.create_vn(vn1_name, vn1_subnets) body = {'name': "test_network"} net_dict = {'network': body} - net_rsp = self.quantum_fixture.update_network( + net_rsp = self.quantum_h.update_network( vn1_fixture.vn_id, net_dict) assert net_rsp['network'][ @@ -67,7 +67,7 @@ def test_virtual_network_admin_state_up(self): assert vn1_vm1_fixture.ping_with_certainty(vn1_vm2_fixture.vm_ip) body = {'admin_state_up': False} net_dict = {'network': body} - net_rsp = self.quantum_fixture.update_network( + net_rsp = self.quantum_h.update_network( vn1_fixture.vn_id, net_dict) assert net_rsp['network'][ @@ -76,7 +76,7 @@ def test_virtual_network_admin_state_up(self): expectation=False) body = {'admin_state_up': True} net_dict = {'network': body} - net_rsp = self.quantum_fixture.update_network( + net_rsp = self.quantum_h.update_network( vn1_fixture.vn_id, net_dict) assert net_rsp['network'][ diff --git a/scripts/performance/sanity.py b/scripts/performance/sanity.py index 3790f6c79..f190f04f2 100644 --- a/scripts/performance/sanity.py +++ b/scripts/performance/sanity.py @@ -19,8 +19,8 @@ def setUp(self): self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) self.agent_inspect = self.connections.agent_inspect - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 diff --git a/scripts/performance/sanity_with_setup.py b/scripts/performance/sanity_with_setup.py index 1e1b1339f..8550e0ec6 100644 --- a/scripts/performance/sanity_with_setup.py +++ b/scripts/performance/sanity_with_setup.py @@ -20,10 +20,10 @@ def __init__(self, *args, **kwargs): self.inputs = self.res.inputs self.connections = self.res.connections self.logger = self.res.logger - self.nova_fixture = self.res.nova_fixture + self.nova_h = self.res.nova_h self.analytics_obj = self.connections.analytics_obj self.vnc_lib = self.connections.vnc_lib - self.quantum_fixture = self.connections.quantum_fixture + self.quantum_h = self.connections.quantum_h self.cn_inspect = self.connections.cn_inspect def __del__(self): diff --git a/scripts/performance/verify.py b/scripts/performance/verify.py index ad56948d9..a6a4e9d63 100644 --- a/scripts/performance/verify.py +++ b/scripts/performance/verify.py @@ -74,7 +74,7 @@ def test_check_netperf_within_vn(self, no_of_vn=1, encap='MPLSoUDP', test_name=' self.vm2_fixture = self.res.get_vn2_vm3_fixture() else: # Making sure VM falls on diffrent compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -85,15 +85,15 @@ def test_check_netperf_within_vn(self, no_of_vn=1, encap='MPLSoUDP', test_name=' assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) else: if getattr(self, 'res', None): self.vm1_fixture = self.res.get_vn1_vm5_fixture() self.vm2_fixture = self.res.get_vn1_vm6_fixture() else: # Making sure VM falls on diffrent compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -104,8 +104,8 @@ def test_check_netperf_within_vn(self, no_of_vn=1, encap='MPLSoUDP', test_name=' assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) results = [] # set the cpu to highest performance in compute nodes before running # the test @@ -198,7 +198,7 @@ def test_ping_latency(self, no_of_vn=1, no_of_pkt=1, count=1): self.vm2_fixture = self.res.get_vn2_vm3_fixture() else: # Making sure VM falls on diffrent compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -209,15 +209,15 @@ def test_ping_latency(self, no_of_vn=1, no_of_pkt=1, count=1): assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - result = self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + result = self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) else: if getattr(self, 'res', None): self.vm1_fixture = self.res.get_vn1_vm5_fixture() self.vm2_fixture = self.res.get_vn1_vm6_fixture() else: # Making sure VM falls on diffrent compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -313,7 +313,7 @@ def test_check_flow_setup_within_vn(self, dst_port_min, dst_port_max, src_port_m self.vm2_fixture= self.res.vn2_vm3_fixture else: # Making sure VM falls on diffrent compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -324,15 +324,15 @@ def test_check_flow_setup_within_vn(self, dst_port_min, dst_port_max, src_port_m assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) else: if getattr(self, 'res', None): self.vm1_fixture= self.res.vn1_vm5_fixture self.vm2_fixture= self.res.vn1_vm6_fixture else: # Making sure VM falls on diffrent compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -343,8 +343,8 @@ def test_check_flow_setup_within_vn(self, dst_port_min, dst_port_max, src_port_m assert self.vm1_fixture.verify_on_setup() assert self.vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(self.vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(self.vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj) vm1_ip = self.vm1_fixture.vm_ip vm2_ip = self.vm2_fixture.vm_ip diff --git a/scripts/policy/base.py b/scripts/policy/base.py index 11d06eda8..06eff9d66 100644 --- a/scripts/policy/base.py +++ b/scripts/policy/base.py @@ -17,8 +17,9 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.orch = cls.connections.orch + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect @@ -32,6 +33,5 @@ def tearDownClass(cls): cls.isolated_creds.delete_tenant() super(BasePolicyTest, cls).tearDownClass() # end tearDownClass - #end BasePolicyTest class diff --git a/scripts/policy/sdn_basic_topology.py b/scripts/policy/sdn_basic_topology.py index e09c72c74..5c6307143 100644 --- a/scripts/policy/sdn_basic_topology.py +++ b/scripts/policy/sdn_basic_topology.py @@ -16,9 +16,21 @@ def __init__(self, domain='default-domain', project='admin', username=None, pass self.vnet_list = ['vnet0', 'vnet1', 'vnet2', 'vnet3'] # # Define network info for each VN: - self.vn_nets = { - 'vnet0': ['10.1.1.0/24', '11.1.1.0/24'], 'vnet1': ['12.1.1.0/24', '13.1.1.0/24'], - 'vnet2': ['14.1.1.0/24', '15.1.1.0/24'], 'vnet3': ['16.1.1.0/24', '17.1.1.0/24']} + if self.project == 'vCenter': + # For vcenter, only one subnet per VN is supported + self.vn_nets = { + 'vnet0': ['10.1.1.0/24'], + 'vnet1': ['12.1.1.0/24'], + 'vnet2': ['14.1.1.0/24'], + 'vnet3': ['16.1.1.0/24'] + } + else: + self.vn_nets = { + 'vnet0': ['10.1.1.0/24', '11.1.1.0/24'], + 'vnet1': ['12.1.1.0/24', '13.1.1.0/24'], + 'vnet2': ['14.1.1.0/24', '15.1.1.0/24'], + 'vnet3': ['16.1.1.0/24', '17.1.1.0/24'] + } # # Define network policies self.policy_list = ['policy0', 'policy1', 'policy2', diff --git a/scripts/policy/sdn_policy_traffic_test_topo.py b/scripts/policy/sdn_policy_traffic_test_topo.py index 5cfd47ba5..3e9a528d9 100755 --- a/scripts/policy/sdn_policy_traffic_test_topo.py +++ b/scripts/policy/sdn_policy_traffic_test_topo.py @@ -104,8 +104,13 @@ def __init__(self, domain='default-domain', project='admin', username=None, pass self.vnet_list = ['vnet0', 'vnet1'] # # Define network info for each VN: - self.vn_nets = {'vnet0': ['10.1.1.0/24', '11.1.1.0/24'], - 'vnet1': ['12.1.1.0/24', '13.1.1.0/24']} + if self.project == 'vCenter': + # For vcenter, only one subnet per VN is supported + self.vn_nets = {'vnet0': ['10.1.1.0/24'], + 'vnet1': ['12.1.1.0/24']} + else: + self.vn_nets = {'vnet0': ['10.1.1.0/24', '11.1.1.0/24'], + 'vnet1': ['12.1.1.0/24', '13.1.1.0/24']} # # Define network policies self.policy_list = ['policy0', 'policy1', 'policy2', 'policy3', 'policy100', diff --git a/scripts/policy/sdn_single_vm_multiple_policy_topology.py b/scripts/policy/sdn_single_vm_multiple_policy_topology.py index 2269286f6..3f69ea8e3 100644 --- a/scripts/policy/sdn_single_vm_multiple_policy_topology.py +++ b/scripts/policy/sdn_single_vm_multiple_policy_topology.py @@ -16,7 +16,11 @@ def __init__(self, domain='default-domain', project='admin', username=None, pass self.vnet_list = ['vnet0'] # # Define network info for each VN: - self.vn_nets = {'vnet0': ['10.1.1.0/24', '11.1.1.0/24']} + if self.project == 'vCenter': + # For vcenter, only one subnet per VN is supported + self.vn_nets = {'vnet0': ['10.1.1.0/24']} + else: + self.vn_nets = {'vnet0': ['10.1.1.0/24', '11.1.1.0/24']} # # Define network policies self.policy_list = ['policy0', 'policy1', 'policy2', 'policy3', diff --git a/scripts/policy/test_policy.py b/scripts/policy/test_policy.py index bf02b8b48..5b492e935 100644 --- a/scripts/policy/test_policy.py +++ b/scripts/policy/test_policy.py @@ -51,7 +51,7 @@ def create_vm( flavor=flavor, node_name=node_name)) - @test.attr(type=['sanity','ci_sanity','quick_sanity']) + @test.attr(type=['sanity','ci_sanity','quick_sanity', 'vcenter']) @preposttest_wrapper def test_policy(self): """ Configure policies based on topology and run policy related verifications. @@ -170,7 +170,7 @@ def test_policy_with_spl_char_in_name(self): return result - @test.attr(type=['sanity','ci_sanity','quick_sanity']) + @test.attr(type=['sanity','ci_sanity','quick_sanity', 'vcenter']) @preposttest_wrapper def test_policy_to_deny(self): ''' Test to validate that with policy having rule to disable icmp within the VN, ping between VMs should fail @@ -317,8 +317,8 @@ def test_policy_with_multi_vn_in_vm(self): project_name=self.inputs.project_name)) assert vm1_fixture.verify_on_setup() assert vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up(vm1_fixture.vm_obj) - self.nova_fixture.wait_till_vm_is_up(vm2_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm1_fixture.vm_obj) + self.nova_h.wait_till_vm_is_up(vm2_fixture.vm_obj) # For multi-vn vm, configure ip address for 2nd interface multivn_vm_ip_list = vm1_fixture.vm_ips intf_conf_cmd = "ifconfig eth1 %s netmask 255.255.255.0" % multivn_vm_ip_list[ @@ -440,9 +440,9 @@ def test_policy_protocol_summary(self): if vn1_fixture.policy_objs: policy_fq_names = [ - self.quantum_fixture.get_policy_fq_name(x) for x in vn1_fixture.policy_objs] + self.quantum_h.get_policy_fq_name(x) for x in vn1_fixture.policy_objs] - policy_fq_name2 = self.quantum_fixture.get_policy_fq_name( + policy_fq_name2 = self.quantum_h.get_policy_fq_name( policy2_fixture.policy_obj) policy_fq_names.append(policy_fq_name2) vn1_fixture.bind_policies(policy_fq_names, vn1_fixture.vn_id) @@ -479,7 +479,7 @@ def setUpClass(cls): def runTest(self): pass - @test.attr(type=['sanity','ci_sanity']) + @test.attr(type=['sanity','ci_sanity', 'vcenter']) @preposttest_wrapper def test_remove_policy_with_ref(self): ''' This tests the following scenarios. @@ -524,55 +524,19 @@ def test_remove_policy_with_ref(self): "Done with setup and verification, moving onto test ..") # try to remove policy which was referenced with VN. policy_removal = True - pol_list = self.quantum_fixture.list_policys() - self.logger.info("policy list for project %s is %s" % - (self.project.project_name, pol_list)) pol_id = None - for policy in pol_list['policys']: - if policy['name'] == policy_name: - pol_id = policy['id'] - policy_removal = self.quantum_fixture.delete_policy( - policy['id']) - break + if self.quantum_h: + policy_removal = self.quantum_h.delete_policy(policy_fixture.get_id()) + else: + try: + self.vnc_lib.network_policy_delete(id=policy_fixture.get_id()) + except Exception as e: + policy_removal = False self.assertFalse( policy_removal, 'Policy removal succeed as not expected since policy is referenced with VN') #assert vn1_fixture.verify_on_setup() # policy_fixture.verify_policy_in_api_server() - - self.logger.info("Done with test, moving onto cleanup ..") - if vn1_fixture.policy_objs: - policy_fq_names = [ - self.quantum_fixture.get_policy_fq_name(x) for x in vn1_fixture.policy_objs] - - # self.assertTrue( - # vn1_fixture.verify_vn_policy_in_vn_uve(), - # "Policy information is not found in VN UVE Analytics after binding policy to VN") - # unbind the policy from VN - vn1_fixture.unbind_policies(vn1_fixture.vn_id, policy_fq_names) - self.assertTrue( - vn1_fixture.verify_vn_policy_not_in_vn_uve(), - "Policy information is not removed from VN UVE Analytics after policy un binded from VN") - # Verify policy ref is removed from VN - vn_pol_found = vn1_fixture.verify_vn_policy_not_in_api_server( - policy_name) - self.assertFalse( - vn_pol_found, - 'policy not removed from VN after policy unbind from VN') - # Wait for 1 secs for db update after unbind operation.. - time.sleep(1) - # remove the policy using quantum API - policy_removal = self.quantum_fixture.delete_policy(pol_id) - if not policy_removal: - self.logger.info("policy delete failed, retry again...") - policy_removal = self.quantum_fixture.delete_policy(pol_id) - self.assertTrue( - policy_removal, - 'Policy removal failure not expected since policy is dereferenced with VN') - pol_found = policy_fixture.verify_policy_not_in_api_server() - self.assertFalse( - pol_found, - 'policy not removed from API server when policy removed from Quantum') return True # end test_remove_policy_with_ref @@ -811,7 +775,7 @@ def setUpClass(cls): def runTest(self): pass - @test.attr(type=['sanity', 'ci_sanity']) + @test.attr(type=['sanity', 'ci_sanity', 'vcenter']) @preposttest_wrapper def test_policy_modify_vn_policy(self): """ Configure policies based on topology; @@ -890,8 +854,7 @@ def test_policy_modify_vn_policy(self): # get new policy_set to be pushed for the vn test_policy_fq_names = [] for policy in new_vn_policy_list: - name = config_topo['policy'][ - policy].policy_obj['policy']['fq_name'] + name = config_topo['policy'][policy].policy_fq_name test_policy_fq_names.append(name) self.logger.info( "adding policy %s to vn %s" % diff --git a/scripts/policy/test_policy_acl.py b/scripts/policy/test_policy_acl.py index b8daef795..164aa9d44 100644 --- a/scripts/policy/test_policy_acl.py +++ b/scripts/policy/test_policy_acl.py @@ -101,7 +101,7 @@ def setup_vm(self): # end setup_vm - @attr(type=['sanity']) + @attr(type=['sanity', 'vcenter']) @tcutils.wrappers.preposttest_wrapper def test_policy_inheritance_src_vn_dst_pol(self): """Test cases to test policy inheritance""" @@ -398,7 +398,7 @@ def test_policy_inheritance_src_any_dst_pol(self): # end test_policy_inheritance_src_any_dst_pol - @attr(type=['sanity']) + @attr(type=['sanity', 'vcenter']) @tcutils.wrappers.preposttest_wrapper def test_policy_inheritance_src_pol_dst_any(self): """Test cases to test policy inheritance""" @@ -625,7 +625,7 @@ def test_policy_cidr_src_policy_dst_cidr(self): # end test_policy_cidr_src_policy_dst_cidr - @attr(type=['sanity']) + @attr(type=['sanity', 'vcenter']) @tcutils.wrappers.preposttest_wrapper def test_policy_cidr_src_vn_dst_cidr(self): """Test cases to test policy CIDR""" @@ -913,7 +913,7 @@ def test_policy_cidr_src_duplicate_vn_dst_cidr(self): # end test_policy_cidr_src_duplicate_vn_dst_cidr - @attr(type=['sanity']) + @attr(type=['sanity', 'vcenter']) @tcutils.wrappers.preposttest_wrapper def test_policy_cidr_src_cidr_dst_any(self): """Test cases to test policy CIDR""" diff --git a/scripts/policy/test_policy_api.py b/scripts/policy/test_policy_api.py index aae17fb39..35ad2442e 100644 --- a/scripts/policy/test_policy_api.py +++ b/scripts/policy/test_policy_api.py @@ -113,7 +113,7 @@ def test_create_api_policy(self): minor=0))) self.vnc_lib.virtual_network_update(vn_blue_obj) - vn_in_quantum = self.quantum_fixture.get_vn_obj_if_present(vb.name) + vn_in_quantum = self.quantum_h.get_vn_obj_if_present(vb.name) if not vn_in_quantum: self.logger.info("VN %s is not present in the quantum server" % vn1_name) @@ -133,7 +133,7 @@ def test_create_api_policy(self): policy_fixt1.policy_obj.name, 'associaton policy data on vn is missing from quantum') - policy_in_quantum = self.quantum_fixture.get_policy_if_present( + policy_in_quantum = self.quantum_h.get_policy_if_present( policy_name=pol.name, project_name=self.inputs.project_name) if not policy_in_quantum: self.logger.info("policy %s is not present in the quantum server" % @@ -359,7 +359,7 @@ def verify_policy_in_api_quantum_server( '''Validate policy information in API-Server. Compare data with quantum based policy fixture data. Check specifically for following: api_server_keys: 1> fq_name, 2> uuid, 3> rules - quantum_fixture_keys: 1> policy_fq_name, 2> id in policy_obj, 3> policy_obj [for rules] + quantum_h_keys: 1> policy_fq_name, 2> id in policy_obj, 3> policy_obj [for rules] ''' me = inspect.getframeinfo(inspect.currentframe())[2] result = True @@ -498,7 +498,7 @@ def test_policy_rules_scaling_with_ping_api(self): for vm_name in vm_names: vn_read = self.vnc_lib.virtual_network_read( id=str(vn_fixture[vn_of_vm[vm_name]]._obj.uuid)) - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present( + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present( vn_read.name) # Launch VM with 'ubuntu-traffic' image which has scapy pkg # remember to call install_pkg after VM bringup @@ -513,7 +513,7 @@ def test_policy_rules_scaling_with_ping_api(self): vm_name=vm_name)) vm_fixture[vm_name].verify_vm_launched() vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm( + self.nova_h.get_nova_host_of_vm( vm_fixture[vm_name].vm_obj)]['host_ip'] self.logger.info("Calling VM verifications... ") time.sleep(5) # wait for 5secs after launching VM's @@ -524,7 +524,7 @@ def test_policy_rules_scaling_with_ping_api(self): err_msg.append(m) return {'result': vm_verify_out, 'msg': err_msg} for vm_name in vm_names: - out = self.nova_fixture.wait_till_vm_is_up( + out = self.nova_h.wait_till_vm_is_up( vm_fixture[vm_name].vm_obj) if not out: return {'result': out, 'msg': "VM failed to come up"} @@ -597,7 +597,7 @@ def verify_policy_in_api_quantum_server( '''Validate policy information in API-Server. Compare data with quantum based policy fixture data. Check specifically for following: api_server_keys: 1> fq_name, 2> uuid, 3> rules - quantum_fixture_keys: 1> policy_fq_name, 2> id in policy_obj, 3> policy_obj [for rules] + quantum_h_keys: 1> policy_fq_name, 2> id in policy_obj, 3> policy_obj [for rules] ''' me = inspect.getframeinfo(inspect.currentframe())[2] result = True diff --git a/scripts/policy/test_policy_detailed.py b/scripts/policy/test_policy_detailed.py index d6d357b1e..226c2089a 100644 --- a/scripts/policy/test_policy_detailed.py +++ b/scripts/policy/test_policy_detailed.py @@ -21,7 +21,7 @@ class TestDetailedPolicy0(BasePolicyTest): def setUpClass(cls): super(TestDetailedPolicy0, cls).setUpClass() - @test.attr(type=['sanity', 'ci_sanity']) + @test.attr(type=['sanity', 'ci_sanity', 'vcenter']) @preposttest_wrapper def test_repeated_policy_modify(self): """ Configure policies based on topology; Replace VN's existing policy [same policy name but with different rule set] multiple times and verify. @@ -76,8 +76,7 @@ def test_repeated_policy_modify(self): for policy in topo.policy_list: # set new policy for test_vn to policy test_policy_fq_names = [] - name = config_topo['policy'][ - policy].policy_obj['policy']['fq_name'] + name = config_topo['policy'][policy].policy_fq_name test_policy_fq_names.append(name) state = "policy for %s updated to %s" % (test_vn, policy) test_vn_fix.bind_policies(test_policy_fq_names, test_vn_id) @@ -126,7 +125,7 @@ def test_single_vn_repeated_policy_update_with_ping(self): topo = topology_class_name() return self.repeated_policy_update_test_with_ping(topo) - @test.attr(type=['sanity', 'ci_sanity_WIP']) + @test.attr(type=['sanity', 'ci_sanity_WIP', 'vcenter']) @preposttest_wrapper def test_multi_vn_repeated_policy_update_with_ping(self): """ Call repeated_policy_update_test_with_ping with multi VN scenario. @@ -177,8 +176,7 @@ def repeated_policy_update_test_with_ping(self, topo): for policy in topo.policy_test_order: # 2. set new policy for test_vn to policy test_policy_fq_names = [] - name = config_topo['policy'][ - policy].policy_obj['policy']['fq_name'] + name = config_topo['policy'][policy].policy_fq_name test_policy_fq_names.append(name) state = "policy for " + test_vn + " updated to " + policy test_vn_fix.bind_policies(test_policy_fq_names, test_vn_id) @@ -219,6 +217,7 @@ def repeated_policy_update_test_with_ping(self, topo): all_policy_verify( self, config_topo, updated_topo, state, fixture_only='yes') assertEqual(result, True, msg) + test_vn_fix.unbind_policies(test_vn_id) return result # end test_repeated_policy_update_with_ping diff --git a/scripts/project/base.py b/scripts/project/base.py index d749447a5..af9140ca1 100644 --- a/scripts/project/base.py +++ b/scripts/project/base.py @@ -15,8 +15,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/scripts/resource_test.py b/scripts/resource_test.py index 6d88cf652..587d27b04 100644 --- a/scripts/resource_test.py +++ b/scripts/resource_test.py @@ -6,8 +6,8 @@ # Set the env variable PARAMS_FILE to point to your ini file. Else it will try to pick params.ini in PWD # import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import unittest import fixtures import testtools @@ -41,8 +41,8 @@ def setUp(self): self.inputs = ContrailTestInit(self.ini_file) self.inputs.setUp() self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 diff --git a/scripts/rt_filter/base.py b/scripts/rt_filter/base.py index 97fa7b9cf..141db57fc 100644 --- a/scripts/rt_filter/base.py +++ b/scripts/rt_filter/base.py @@ -20,8 +20,8 @@ def setUpClass(cls): cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() #cls.connections= ContrailConnections(cls.inputs) - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib # cls.logger= cls.inputs.logger cls.agent_inspect = cls.connections.agent_inspect diff --git a/scripts/scale/config_node/test_scale_config.py b/scripts/scale/config_node/test_scale_config.py index 11d8889bc..2fa46f23b 100644 --- a/scripts/scale/config_node/test_scale_config.py +++ b/scripts/scale/config_node/test_scale_config.py @@ -17,7 +17,7 @@ from security_group import * from common.contrail_test_init import ContrailTestInit from tcutils.wrappers import preposttest_wrapper -from keystoneclient.v2_0 import client as ksclient +from common.openstack_libs import ks_client as ksclient from vnc_api import vnc_api from scale.config_node.base import BaseScaleTest diff --git a/scripts/scale/control-node/vn_oper.py b/scripts/scale/control-node/vn_oper.py index 04e8ce306..c075ed5a0 100755 --- a/scripts/scale/control-node/vn_oper.py +++ b/scripts/scale/control-node/vn_oper.py @@ -16,9 +16,9 @@ import json from pprint import pformat -from neutronclient.neutron import client -from neutronclient.client import HTTPClient -from neutronclient.common import exceptions +from common.openstack_lib import neutron_client as client +from common.openstack_lib import neutron_http_client as HTTPClient +from common.openstack_lib import neutron_exceptions as exceptions class VnCfg(object): diff --git a/scripts/securitygroup/base.py b/scripts/securitygroup/base.py index 05213e69a..70b4e86ff 100644 --- a/scripts/securitygroup/base.py +++ b/scripts/securitygroup/base.py @@ -25,8 +25,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/scripts/securitygroup/sanity_base.py b/scripts/securitygroup/sanity_base.py index 0f8f9df0b..0c0795ca7 100644 --- a/scripts/securitygroup/sanity_base.py +++ b/scripts/securitygroup/sanity_base.py @@ -23,8 +23,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 diff --git a/scripts/securitygroup/setup.py b/scripts/securitygroup/setup.py index b4f984139..8bbc4ca01 100644 --- a/scripts/securitygroup/setup.py +++ b/scripts/securitygroup/setup.py @@ -28,8 +28,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 diff --git a/scripts/securitygroup/test_regression.py b/scripts/securitygroup/test_regression.py index 9ec4c756a..1a7118bad 100644 --- a/scripts/securitygroup/test_regression.py +++ b/scripts/securitygroup/test_regression.py @@ -113,7 +113,7 @@ def test_vm_with_sec_group(self): "Try deleting the security group %s with back ref.", secgrp_name) try: if secgrp.option == 'openstack': - secgrp.quantum_fixture.delete_security_group(secgrp.secgrp_id) + secgrp.quantum_h.delete_security_group(secgrp.secgrp_id) else: secgrp.secgrp_fix.cleanUp() except Exception, msg: @@ -615,7 +615,7 @@ def test_default_sg(self): self.connections, secgrp_fq_name) try: - self.quantum_fixture.delete_security_group(sg_id) + self.quantum_h.delete_security_group(sg_id) except Exception, msg: self.logger.info(msg) self.logger.info( diff --git a/scripts/svc_firewall/base.py b/scripts/svc_firewall/base.py index 7aceb71ad..10f28c17a 100644 --- a/scripts/svc_firewall/base.py +++ b/scripts/svc_firewall/base.py @@ -17,8 +17,8 @@ def setUpClass(cls): cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() #cls.connections= ContrailConnections(cls.inputs) - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib # cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect diff --git a/scripts/svc_firewall/regression.py b/scripts/svc_firewall/regression.py index 42d3e5163..445bf6343 100644 --- a/scripts/svc_firewall/regression.py +++ b/scripts/svc_firewall/regression.py @@ -22,8 +22,8 @@ def setUp(self): self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) self.agent_inspect = self.connections.agent_inspect - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 diff --git a/scripts/svc_firewall/sanity.py b/scripts/svc_firewall/sanity.py index c35cabe48..0ca373a32 100644 --- a/scripts/svc_firewall/sanity.py +++ b/scripts/svc_firewall/sanity.py @@ -20,8 +20,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 diff --git a/scripts/svc_firewall/sanity_with_setup.py b/scripts/svc_firewall/sanity_with_setup.py index 5101b9c5f..4f500deb1 100755 --- a/scripts/svc_firewall/sanity_with_setup.py +++ b/scripts/svc_firewall/sanity_with_setup.py @@ -24,10 +24,10 @@ def __init__(self, *args, **kwargs): self.inputs = self.res.inputs self.connections = self.res.connections self.logger = self.res.logger - self.nova_fixture = self.res.nova_fixture + self.nova_h = self.res.nova_h self.analytics_obj = self.connections.analytics_obj self.vnc_lib = self.connections.vnc_lib - self.quantum_fixture = self.connections.quantum_fixture + self.quantum_h = self.connections.quantum_h def __del__(self): print "Deleting test_with_setup now" diff --git a/scripts/svc_mirror/base.py b/scripts/svc_mirror/base.py index ac8436e8c..343136fdf 100644 --- a/scripts/svc_mirror/base.py +++ b/scripts/svc_mirror/base.py @@ -15,8 +15,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/scripts/svc_mirror/regression.py b/scripts/svc_mirror/regression.py index 600b1a72e..639ef799b 100644 --- a/scripts/svc_mirror/regression.py +++ b/scripts/svc_mirror/regression.py @@ -21,8 +21,8 @@ def setUp(self): self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) self.agent_inspect = self.connections.agent_inspect - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 diff --git a/scripts/svc_mirror/sanity.py b/scripts/svc_mirror/sanity.py index c5e15615c..9d5e6ec27 100644 --- a/scripts/svc_mirror/sanity.py +++ b/scripts/svc_mirror/sanity.py @@ -21,8 +21,8 @@ def setUp(self): self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) self.agent_inspect = self.connections.agent_inspect - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 diff --git a/scripts/svc_mirror/sanity_with_setup.py b/scripts/svc_mirror/sanity_with_setup.py index e896d1d51..8a65ac796 100644 --- a/scripts/svc_mirror/sanity_with_setup.py +++ b/scripts/svc_mirror/sanity_with_setup.py @@ -23,10 +23,10 @@ def __init__(self, *args, **kwargs): self.inputs = self.res.inputs self.connections = self.res.connections self.logger = self.res.logger - self.nova_fixture = self.res.nova_fixture + self.nova_h = self.res.nova_h self.analytics_obj = self.connections.analytics_obj self.vnc_lib = self.connections.vnc_lib - self.quantum_fixture = self.connections.quantum_fixture + self.quantum_h = self.connections.quantum_h self.agent_inspect = self.connections.agent_inspect def setUp(self): diff --git a/scripts/upgrade/upgrade_only.py b/scripts/upgrade/upgrade_only.py index 179fc9c6d..9b62b9645 100644 --- a/scripts/upgrade/upgrade_only.py +++ b/scripts/upgrade/upgrade_only.py @@ -24,8 +24,8 @@ def setUp(self): self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) self.agent_inspect = self.connections.agent_inspect - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 @@ -114,11 +114,11 @@ def test_upgrade_only(self): time.sleep(90) connections.clear() self.logger.info('Will REBOOT the SHUTOFF VMs') - for vm in self.nova_fixture.get_vm_list(): + for vm in self.nova_h.get_vm_list(): if vm.status != 'ACTIVE': self.logger.info('Will Power-On %s' % vm.name) vm.start() - self.nova_fixture.wait_till_vm_is_active(vm) + self.nova_h.wait_till_vm_is_active(vm) run("rm -rf /tmp/temp") run("rm -rf /opt/contrail/utils/fabfile/testbeds/testbed.py") diff --git a/scripts/vdns/base.py b/scripts/vdns/base.py index 9a28d4119..7bc01d790 100644 --- a/scripts/vdns/base.py +++ b/scripts/vdns/base.py @@ -40,8 +40,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect @@ -95,7 +95,7 @@ def verify_dns_record_order(self, record_order, test_type='test_record_order', r VirtualNetworkTestFixtureGen( self.vnc_lib, virtual_network_name=vn_name, network_ipam_ref_infos=vn_nets[vn_name], parent_fixt=proj_fixt, id_perms=IdPermsType(enable=True))) - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present( + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present( vn_name=vn_fixt._name, project_id=proj_fixt._obj._uuid) vm_fixture = self.useFixture( VMFixture(project_name=self.inputs.project_name, @@ -274,7 +274,7 @@ def vdns_with_cn_dns_agent_restart(self, restart_process): # The following code will verify the same. Also, we should be able ping # with VM name. for vm_name in vm_list: - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present( + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present( vn_name=vn_fixt._name, project_id=proj_fixt._obj._uuid) vm_fixture[vm_name] = self.useFixture( VMFixture(project_name=self.inputs.project_name, connections=self.connections, vn_obj=vn_quantum_obj, vm_name=vm_name)) diff --git a/scripts/vdns/test_vdns.py b/scripts/vdns/test_vdns.py index 3e3db89f4..2e7443244 100755 --- a/scripts/vdns/test_vdns.py +++ b/scripts/vdns/test_vdns.py @@ -101,7 +101,7 @@ def test_vdns_ping_same_vn(self): # The following code will verify the same. Also, we should be able ping # with VM name. for vm_name in vm_list: - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present( + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present( vn_name=vn_fixt._name, project_id=proj_fixt._obj._uuid) vm_fixture[vm_name] = self.useFixture( VMFixture(project_name=self.inputs.project_name, connections=self.connections, vn_obj=vn_quantum_obj, vm_name=vm_name)) @@ -226,7 +226,7 @@ def test_vdns_ping_diff_vn(self): vn = vm_vn_list[vm_name] vn_fixt[vm_name] = self.useFixture(VirtualNetworkTestFixtureGen(self.vnc_lib, virtual_network_name=vm_vn_list[ vm_name], network_ipam_ref_infos=vn_nets[vn], parent_fixt=proj_fixt, id_perms=IdPermsType(enable=True), network_policy_ref_infos=policy_ref)) - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present(vn_name=vn, project_id=proj_fixt._obj._uuid) + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present(vn_name=vn, project_id=proj_fixt._obj._uuid) vm_fixture[vm_name] = self.useFixture( VMFixture(project_name=self.inputs.project_name, connections=self.connections, vn_obj=vn_quantum_obj, vm_name=vm_name)) vm_fixture[vm_name].verify_vm_launched() @@ -454,7 +454,7 @@ def test_vdns_with_next_vdns(self): vn = vm_vn_list[vm_name] vn_fixt[vm_name] = self.useFixture(VirtualNetworkTestFixtureGen(self.vnc_lib, virtual_network_name=vm_vn_list[ vm_name], network_ipam_ref_infos=vn_nets[vn], parent_fixt=proj_fixt, id_perms=IdPermsType(enable=True), network_policy_ref_infos=policy_ref)) - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present(vn_name=vn, project_id=proj_fixt._obj._uuid) + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present(vn_name=vn, project_id=proj_fixt._obj._uuid) vm_fixture[vm_name] = self.useFixture( VMFixture(project_name=self.inputs.project_name, connections=self.connections, vn_obj=vn_quantum_obj, vm_name=vm_name)) vm_fixture[vm_name].verify_vm_launched() diff --git a/scripts/vdns/vdns_tests.py b/scripts/vdns/vdns_tests.py index 0229d2f93..57f3db98f 100755 --- a/scripts/vdns/vdns_tests.py +++ b/scripts/vdns/vdns_tests.py @@ -41,8 +41,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 @@ -144,7 +144,7 @@ def test_vdns_ping_same_vn(self): # The following code will verify the same. Also, we should be able ping # with VM name. for vm_name in vm_list: - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present( + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present( vn_fixt._name) vm_fixture[vm_name] = self.useFixture( VMFixture( @@ -325,7 +325,7 @@ def test_vdns_ping_diff_vn(self): id_perms=IdPermsType( enable=True), network_policy_ref_infos=policy_ref)) - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present(vn) + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present(vn) vm_fixture[vm_name] = self.useFixture( VMFixture( project_name=self.inputs.project_name, @@ -632,7 +632,7 @@ def test_vdns_with_next_vdns(self): id_perms=IdPermsType( enable=True), network_policy_ref_infos=policy_ref)) - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present(vn) + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present(vn) vm_fixture[vm_name] = self.useFixture( VMFixture( project_name=self.inputs.project_name, @@ -775,7 +775,7 @@ def vdns_with_cn_dns_agent_restart(self, restart_process): # The following code will verify the same. Also, we should be able ping # with VM name. for vm_name in vm_list: - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present( + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present( vn_fixt._name) vm_fixture[vm_name] = self.useFixture( VMFixture( @@ -993,7 +993,7 @@ def verify_dns_record_order( parent_fixt=proj_fixt, id_perms=IdPermsType( enable=True))) - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present( + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present( vn_fixt._name) vm_fixture = self.useFixture( VMFixture( diff --git a/scripts/vm_regression/base.py b/scripts/vm_regression/base.py index e936328fe..63cfe5486 100644 --- a/scripts/vm_regression/base.py +++ b/scripts/vm_regression/base.py @@ -19,8 +19,8 @@ def setUpClass(cls): cls.inputs = cls.isolated_creds.get_inputs() cls.inputs.set_af('v4') cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/scripts/vm_regression/test_esx.py b/scripts/vm_regression/test_esx.py index 065feb6d2..a97ea72ed 100644 --- a/scripts/vm_regression/test_esx.py +++ b/scripts/vm_regression/test_esx.py @@ -18,10 +18,12 @@ def tearDownClass(cls): super(TestBasicESXKVM, cls).tearDownClass() def is_test_applicable(self): - zones = self.connections.nova_fixture.get_zones() + if not self.inputs.orchestrator == 'openstack': + return (False, 'Skipping Test. Openstack required') + zones = self.connections.nova_h.get_zones() if 'nova' not in zones or 'esx' not in zones: return (False, 'Skipping Test. Both nova and esx zones required') - if not len(self.connections.nova_fixture.get_hosts('nova')) and not len(self.connections.nova_fixture.get_hosts('esx')): + if not len(self.connections.nova_h.get_hosts('nova')) and not len(self.connections.nova_h.get_hosts('esx')): return (False, 'Skipping Test. Either or both nova and esx zones are empty') return (True, None) diff --git a/scripts/vm_regression/test_vm.py b/scripts/vm_regression/test_vm.py index ed310c1ab..3a68ccdb4 100644 --- a/scripts/vm_regression/test_vm.py +++ b/scripts/vm_regression/test_vm.py @@ -110,13 +110,13 @@ def test_broadcast_udp_w_chksum(self): stream=stream, listener=ips, capfilter="udp port 8000", chksum=True) tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm1_fixture.vm_obj)]['host_ip'] + self.orch.get_host_of_vm(vm1_fixture.vm_obj)]['host_ip'] rx1_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm2_fixture.vm_obj)]['host_ip'] + self.orch.get_host_of_vm(vm2_fixture.vm_obj)]['host_ip'] rx2_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm3_fixture.vm_obj)]['host_ip'] + self.orch.get_host_of_vm(vm3_fixture.vm_obj)]['host_ip'] rx3_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm4_fixture.vm_obj)]['host_ip'] + self.orch.get_host_of_vm(vm4_fixture.vm_obj)]['host_ip'] tx_local_host = Host( tx_vm_node_ip, @@ -406,7 +406,7 @@ def test_multiple_metadata_service_scale(self): vm1_name = get_random_name('vm_mine') vn_name = get_random_name('vn222') vn_count_for_test=20 - if (len(self.connections.nova_fixture.get_hosts()) == 1): + if (len(self.connections.orch.get_hosts()) == 1): vn_count_for_test=2 vm_fixture = self.useFixture( create_multiple_vn_and_multiple_vm_fixture( @@ -940,7 +940,7 @@ def test_ping_on_broadcast_multicast(self): return True # end subnet ping - @test.attr(type=['sanity','ci_sanity','quick_sanity']) + @test.attr(type=['sanity','ci_sanity','quick_sanity', 'vcenter']) @preposttest_wrapper def test_ping_within_vn(self): ''' @@ -1143,7 +1143,7 @@ def test_traffic_bw_vms_diff_pkt_size(self): vn_fixture = self.create_vn() assert vn_fixture.verify_on_setup() # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.orch.get_hosts() vm1_fixture = self.create_vm(vn_fixture= vn_fixture, flavor='contrail_flavor_small', image_name='ubuntu-traffic', @@ -1273,7 +1273,7 @@ def test_traffic_bw_vms_diff_pkt_size_w_chksum(self): vn_fixture = self.create_vn() assert vn_fixture.verify_on_setup() # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.orch.get_hosts() vm1_fixture = self.create_vm(vn_fixture= vn_fixture, flavor='contrail_flavor_small', image_name='ubuntu-traffic', @@ -1385,7 +1385,7 @@ def test_traffic_bw_vms_diff_pkt_size_w_chksum(self): return True # end test_traffic_bw_vms_diff_pkt_size_w_chksum - @test.attr(type=['sanity', 'ci_sanity']) + @test.attr(type=['sanity', 'ci_sanity', 'vcenter']) @preposttest_wrapper def test_vm_add_delete(self): ''' @@ -1522,7 +1522,7 @@ def test_vm_arp(self): return True # end test_vm_arp - @test.attr(type=['sanity','quick_sanity','ci_sanity']) + @test.attr(type=['sanity','quick_sanity','ci_sanity', 'vcenter']) @preposttest_wrapper def test_vm_file_trf_scp_tests(self): ''' @@ -1584,7 +1584,7 @@ def test_vm_file_trf_scp_tests(self): return transfer_result # end test_vm_file_trf_scp_tests - @test.attr(type=['sanity']) + @test.attr(type=['sanity', 'vcenter']) #@test.attr(type=['sanity', 'ci_sanity']) @preposttest_wrapper def test_vm_file_trf_tftp_tests(self): @@ -2073,7 +2073,7 @@ def test_vm_vn_block_exhaustion(self): return True # end test_vm_vn_block_exhaustion - @test.attr(type=['sanity','ci_sanity', 'quick_sanity']) + @test.attr(type=['sanity','ci_sanity', 'quick_sanity', 'vcenter']) @preposttest_wrapper def test_vn_add_delete(self): ''' @@ -2274,7 +2274,7 @@ def itest_vn_vm_no_ip_assign(self): vn_name = 'vn_vm_no_ip_assign' vm_name = 'vn_vm_no_ip_assign' vn_fixture = self.create_vn(empty_vn=True, vn_name=vn_name) - vn_obj = self.quantum_fixture.get_vn_obj_if_present(vn_name) + vn_obj = self.orch.get_vn_obj_if_present(vn_name) vn_id = vn_obj['network']['id'] self.logger.info('VN launched with no ip block.Launching VM now.') vm1_fixture = self.useFixture(VMFixture(connections=self.connections, @@ -2285,14 +2285,14 @@ def itest_vn_vm_no_ip_assign(self): vnc_lib_h=self.vnc_lib, project_name=self.inputs.project_name, connections=self.connections)) - vm_obj = self.nova_fixture.get_vm_if_present( - vm_name, self.project_fixture.uuid) + vm_obj = self.orch.get_vm_if_present( + vm_name, project_id=self.project_fixture.uuid) self.logger.info('The VM should not get any IP') assert not vm1_fixture.verify_on_setup() self.logger.info('Now assigning IP block to VN') ipam = vn_fixture.ipam_fq_name vn_fixture.create_subnet_af(af=self.inputs.get_af(), ipam_fq_name=ipam) - vnnow_obj = self.quantum_fixture.get_vn_obj_if_present(vn_name) + vnnow_obj = self.orch.get_vn_obj_if_present(vn_name) subnet_created = list(map(lambda obj: obj['subnet_cidr'], vnnow_obj['network']['contrail:subnet_ipam'])) if set(subnet_created) != set(vn_fixture.get_subnets()): diff --git a/scripts/vpc/base.py b/scripts/vpc/base.py index 66a2f3806..e8d00b955 100644 --- a/scripts/vpc/base.py +++ b/scripts/vpc/base.py @@ -26,8 +26,8 @@ def setUpClass(cls): cls.connections = cls.isolated_creds.get_conections() cls.admin_inputs = cls.isolated_creds.get_admin_inputs() cls.admin_connections = cls.isolated_creds.get_admin_connections() - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect diff --git a/scripts/vpc/sanity.py b/scripts/vpc/sanity.py index 4dc30dd55..ada9750f7 100644 --- a/scripts/vpc/sanity.py +++ b/scripts/vpc/sanity.py @@ -42,7 +42,7 @@ def __init__(self, *args, **kwargs): self.connections = self.res.connections self.vnc_lib = self.res.vnc_lib self.logger = self.res.logger - self.nova_fixture = self.res.nova_fixture + self.nova_h = self.res.nova_h def __del__(self): print "Deleting vpc_test_with_setup now" @@ -56,8 +56,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 # end setUp diff --git a/scripts/vpc/vpc_resource.py b/scripts/vpc/vpc_resource.py index 6a38e6711..0a84f6d89 100644 --- a/scripts/vpc/vpc_resource.py +++ b/scripts/vpc/vpc_resource.py @@ -28,8 +28,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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() diff --git a/serial_scripts/analytics/base.py b/serial_scripts/analytics/base.py index 052a867a2..65722d426 100644 --- a/serial_scripts/analytics/base.py +++ b/serial_scripts/analytics/base.py @@ -21,8 +21,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect @@ -98,7 +98,7 @@ def setup_common_objects(self, inputs , connections): vn_name= self.fip_vn_name)) # Making sure VM falls on diffrent compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: diff --git a/serial_scripts/analytics/test_analytics_resource.py b/serial_scripts/analytics/test_analytics_resource.py index aeb8397ca..8f60c5a2c 100644 --- a/serial_scripts/analytics/test_analytics_resource.py +++ b/serial_scripts/analytics/test_analytics_resource.py @@ -393,7 +393,7 @@ def test_vrouter_uve_vm_on_vm_create(self): assert vm_fixture.verify_on_setup() vm_uuid = vm_fixture.vm_id vm_node_ip = vm_fixture.inputs.host_data[ - vm_fixture.nova_fixture.get_nova_host_of_vm( + vm_fixture.nova_h.get_nova_host_of_vm( vm_fixture.vm_obj)]['host_ip'] vn_of_vm = vm_fixture.vn_fq_name vm_host = vm_fixture.inputs.host_data[vm_node_ip]['name'] @@ -547,7 +547,7 @@ def test_verify_flow_series_table_query_range(self): time.sleep(1) vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[ - self.res. vn1_vm1_fixture.nova_fixture.get_nova_host_of_vm( + self.res. vn1_vm1_fixture.nova_h.get_nova_host_of_vm( self.res.vn1_vm1_fixture.vm_obj)]['host_ip'] vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]['name'] time.sleep(30) @@ -787,7 +787,7 @@ def test_verify_flow_tables(self): assert "sender.sent == receiver.recv", "UDP traffic to ip:%s failed" % self.res.vn2_vm2_fixture.vm_ip # Verifying the vrouter uve for the active flow vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[ - self.res.vn1_vm1_fixture. nova_fixture.get_nova_host_of_vm( + self.res.vn1_vm1_fixture. nova_h.get_nova_host_of_vm( self.res.vn1_vm1_fixture.vm_obj)]['host_ip'] vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]['name'] self.logger.info( @@ -1028,7 +1028,7 @@ def test_verify_flow_series_table(self): print sender.sent, receiver.recv time.sleep(1) vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[ - self.res.vn1_vm1_fixture. nova_fixture.get_nova_host_of_vm( + self.res.vn1_vm1_fixture. nova_h.get_nova_host_of_vm( self.res.vn1_vm1_fixture.vm_obj)]['host_ip'] vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]['name'] time.sleep(300) diff --git a/serial_scripts/discovery_regression/base.py b/serial_scripts/discovery_regression/base.py index 6cf0edae3..826b0ec0b 100644 --- a/serial_scripts/discovery_regression/base.py +++ b/serial_scripts/discovery_regression/base.py @@ -15,8 +15,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/serial_scripts/discovery_regression/test_discovery_serial.py b/serial_scripts/discovery_regression/test_discovery_serial.py index 9771883a7..6545f95c5 100644 --- a/serial_scripts/discovery_regression/test_discovery_serial.py +++ b/serial_scripts/discovery_regression/test_discovery_serial.py @@ -20,7 +20,7 @@ def runTest(self): # end runTest - @test.attr(type=['sanity']) + @test.attr(type=['sanity', 'vcenter']) @preposttest_wrapper def test_control_node_restart_and_validate_status_of_the_service(self): ''' Validate restart of control node services diff --git a/serial_scripts/ecmp/base.py b/serial_scripts/ecmp/base.py index 3470d7a2b..7f58d8f50 100644 --- a/serial_scripts/ecmp/base.py +++ b/serial_scripts/ecmp/base.py @@ -16,8 +16,8 @@ def setUpClass(cls): cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() #cls.connections= ContrailConnections(cls.inputs) - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib # cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect diff --git a/serial_scripts/encap/base.py b/serial_scripts/encap/base.py index 128137921..d97501487 100644 --- a/serial_scripts/encap/base.py +++ b/serial_scripts/encap/base.py @@ -19,8 +19,8 @@ def setUpClass(cls): cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() #cls.connections= ContrailConnections(cls.inputs) - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib # cls.logger= cls.inputs.logger cls.agent_inspect = cls.connections.agent_inspect diff --git a/serial_scripts/encap/test_encap.py b/serial_scripts/encap/test_encap.py index 3c6728be8..a02c0ddb3 100644 --- a/serial_scripts/encap/test_encap.py +++ b/serial_scripts/encap/test_encap.py @@ -40,7 +40,7 @@ def test_encaps_mx_gateway(self): if (('MX_GW_TEST' in os.environ) and ( os.environ.get('MX_GW_TEST') == '1')): - if len(self.connections.nova_fixture.get_hosts()) < 2: + if len(self.connections.nova_h.get_hosts()) < 2: raise self.skipTest( 'Skipping Test. At least 2 compute node required to run the test') self.logger.info("Read the existing encap priority") @@ -188,7 +188,7 @@ def test_apply_policy_fip_on_same_vn_gw_mx(self): if (('MX_GW_TEST' in os.environ) and ( os.environ.get('MX_GW_TEST') == '1')): - if len(self.connections.nova_fixture.get_hosts()) < 2: + if len(self.connections.nova_h.get_hosts()) < 2: self.logger.info( "Skipping Test. At least 2 compute node required to run the test") raise self.skipTest( @@ -246,7 +246,7 @@ def test_apply_policy_fip_on_same_vn_gw_mx(self): self.inputs.project_name, 'default') # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() fvn_fixture = self.useFixture( VNFixture( @@ -424,7 +424,7 @@ def test_apply_policy_fip_vn_with_encaps_change_gw_mx(self): if (('MX_GW_TEST' in os.environ) and ( os.environ.get('MX_GW_TEST') == '1')): - if len(self.connections.nova_fixture.get_hosts()) < 2: + if len(self.connections.nova_h.get_hosts()) < 2: self.logger.info( "Skipping Test. At least 2 compute node required to run the test") raise self.skipTest( @@ -483,7 +483,7 @@ def test_apply_policy_fip_vn_with_encaps_change_gw_mx(self): self.inputs.project_name, 'default') # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() fvn_fixture = self.useFixture( VNFixture( diff --git a/serial_scripts/evpn/base.py b/serial_scripts/evpn/base.py index f532ba516..93fc05ede 100644 --- a/serial_scripts/evpn/base.py +++ b/serial_scripts/evpn/base.py @@ -16,8 +16,8 @@ def setUpClass(cls): cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() #cls.connections= ContrailConnections(cls.inputs) - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib # cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect diff --git a/serial_scripts/evpn/verify.py b/serial_scripts/evpn/verify.py index 1adced9a6..817923049 100644 --- a/serial_scripts/evpn/verify.py +++ b/serial_scripts/evpn/verify.py @@ -27,7 +27,7 @@ def verify_dns_disabled(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] compute_3 = host_list[0] @@ -208,7 +208,7 @@ def verify_ipv6_ping_for_non_ip_communication(self, encap): self.update_encap_priority('udp') elif (encap == 'vxlan'): self.update_encap_priority('vxlan') - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -277,7 +277,7 @@ def verify_ping_to_configured_ipv6_address(self, encap): elif (encap == 'vxlan'): self.update_encap_priority('vxlan') - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -350,7 +350,7 @@ def verify_l2_ipv6_multicast_traffic(self, encap): elif (encap == 'vxlan'): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] compute_3 = host_list[0] @@ -489,7 +489,7 @@ def verify_l2l3_ipv6_multicast_traffic(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] compute_3 = host_list[0] @@ -605,7 +605,7 @@ def verify_change_of_l2_vn_forwarding_mode(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -666,7 +666,7 @@ def verify_change_of_l2_vn_forwarding_mode(self, encap): self.logger.info( "Changing vn1 forwarding mode from l2 only to l2l3 followed by calling verify_on_setup for vms which checks if l3 routes are there or not ") disable_subnet_dhcp = {'enable_dhcp':False} - self.quantum_fixture.update_subnet(self.vn1_fixture.vn_subnet_objs[0]['id'], disable_subnet_dhcp) + self.quantum_h.update_subnet(self.vn1_fixture.vn_subnet_objs[0]['id'], disable_subnet_dhcp) assert self.vn1_fixture.verify_on_setup() assert vn_l2_vm1_fixture.verify_on_setup() assert vn_l2_vm2_fixture.verify_on_setup() @@ -713,7 +713,7 @@ def verify_change_of_l2l3_vn_forwarding_mode(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -773,7 +773,7 @@ def verify_change_of_l2l3_vn_forwarding_mode(self, encap): self.logger.info( "Changing vn1 forwarding mode from l2l3 to l2 only followed by calling verify_on_setup for vms which checks l2 routes and explicity check l3 routes are removed ") enable_subnet_dhcp = {'enable_dhcp':False} - self.quantum_fixture.update_subnet(self.vn1_fixture.vn_subnet_objs[0]['id'], enable_subnet_dhcp) + self.quantum_h.update_subnet(self.vn1_fixture.vn_subnet_objs[0]['id'], enable_subnet_dhcp) assert self.vn1_fixture.verify_on_setup() assert vn_l2_vm1_fixture.verify_on_setup() assert vn_l2_vm2_fixture.verify_on_setup() @@ -815,7 +815,7 @@ def verify_vxlan_mode_with_configured_vxlan_id_l2_vn(self): self.update_encap_priority(encap) result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -969,7 +969,7 @@ def verify_vxlan_mode_with_configured_vxlan_id_l2l3_vn(self): self.update_encap_priority(encap) result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -1110,7 +1110,7 @@ def verify_l2_vm_file_trf_by_scp(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] compute_3 = host_list[0] @@ -1302,7 +1302,7 @@ def verify_l2_vm_file_trf_by_tftp(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] compute_3 = host_list[0] @@ -1492,7 +1492,7 @@ def verify_vlan_tagged_packets_for_l2_vn(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -1654,7 +1654,7 @@ def verify_vlan_qinq_tagged_packets_for_l2_vn(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -1977,7 +1977,7 @@ def verify_epvn_l2_mode_control_node_switchover(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -2153,7 +2153,7 @@ def verify_epvn_with_agent_restart(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -2246,7 +2246,7 @@ def verify_epvn_l2_mode(self, encap): self.update_encap_priority('vxlan') result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -2326,7 +2326,7 @@ def verify_epvn_l2_mode(self, encap): assert vn_l2_vm1_fixture.ping_to_ipv6( vm2_ipv6.split("/")[0].strip(), count='15', other_opt='-I eth1') comp_vm2_ip = vn_l2_vm2_fixture.vm_node_ip - if len(self.connections.nova_fixture.get_hosts()) >= 2: + if len(self.connections.nova_h.get_hosts()) >= 2: self.tcpdump_analyze_on_compute(comp_vm2_ip, encap.upper()) self.tcpdump_stop_on_all_compute() diff --git a/serial_scripts/floatingip/base.py b/serial_scripts/floatingip/base.py index 628bbb339..8c7cb04dd 100644 --- a/serial_scripts/floatingip/base.py +++ b/serial_scripts/floatingip/base.py @@ -22,8 +22,8 @@ def setUpClass(cls): cls.connections = cls.isolated_creds.get_conections() cls.admin_inputs = cls.isolated_creds.get_admin_inputs() cls.admin_connections = cls.isolated_creds.get_admin_connections() - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect diff --git a/serial_scripts/floatingip/test_floatingip.py b/serial_scripts/floatingip/test_floatingip.py index 8658f3415..d56b36497 100644 --- a/serial_scripts/floatingip/test_floatingip.py +++ b/serial_scripts/floatingip/test_floatingip.py @@ -7,8 +7,8 @@ # import re import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import fixtures import testtools import unittest @@ -70,7 +70,7 @@ def test_service_restart_with_fip(self): (self.vn1_vm1_traffic_name) = get_random_name('VN1_VM1_traffic') (self.fvn1_vm1_traffic_name) = get_random_name('FVN1_VM1_traffic') # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -221,7 +221,7 @@ def test_traffic_with_control_node_switchover(self): fip_pool_name2 = get_random_name('some-pool2') # Get all compute host - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: diff --git a/serial_scripts/floatingip/test_mx.py b/serial_scripts/floatingip/test_mx.py index 4b450f68a..7d66d4655 100644 --- a/serial_scripts/floatingip/test_mx.py +++ b/serial_scripts/floatingip/test_mx.py @@ -7,8 +7,8 @@ # Set the env variable MX_GW_TESTto 1 to run the test # import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import unittest import fixtures import testtools @@ -44,7 +44,7 @@ def is_test_applicable(self): return (False, 'Skipping Test. Env variable MX_GW_TEST is not set') return (True, None) - @test.attr(type=['mx_test', 'serial', 'sanity' ]) + @test.attr(type=['mx_test', 'serial', 'sanity', 'vcenter']) @preposttest_wrapper def test_change_of_rt_in_vn(self): ''' diff --git a/serial_scripts/flow_tests/base.py b/serial_scripts/flow_tests/base.py index 3d930c18e..9b36331a2 100644 --- a/serial_scripts/flow_tests/base.py +++ b/serial_scripts/flow_tests/base.py @@ -19,8 +19,8 @@ def setUpClass(cls): cls.connections = cls.isolated_creds.get_conections() cls.admin_inputs = cls.isolated_creds.get_admin_inputs() cls.admin_connections = cls.isolated_creds.get_admin_connections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/serial_scripts/ha/base.py b/serial_scripts/ha/base.py index 66471bac1..10cfb491f 100644 --- a/serial_scripts/ha/base.py +++ b/serial_scripts/ha/base.py @@ -32,7 +32,7 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.nova_fixture = cls.connections.nova_fixture + cls.nova_h = cls.connections.nova_h cls.vnc_lib_fixture = cls.connections.vnc_lib_fixture # cls.logger= cls.inputs.logger cls.ipmi_list = cls.inputs.hosts_ipmi[0] @@ -218,7 +218,7 @@ def ha_start(self): self.send_fip_host = {} self.recv_host = {} self.send_host = {} - self.host_list= self.connections.nova_fixture.get_hosts() + self.host_list= self.connections.nova_h.get_hosts() for i in range(0,self.vm_num): val = random.randint(1,100000) @@ -241,7 +241,7 @@ def ha_start(self): for i in range(0,self.vm_num): assert self.vm_fixture[i].verify_on_setup() for i in range(0,self.vm_num): - out1 = self.nova_fixture.wait_till_vm_is_up( self.vm_fixture[i].vm_obj ) + out1 = self.nova_h.wait_till_vm_is_up( self.vm_fixture[i].vm_obj ) if out1 == False: return {'result':out1, 'msg':"%s failed to come up"%self.vm_fixture[i].vm_name} else: sleep (10); self.logger.info('Will install Traffic package on %s'%self.vm_fixture[i].vm_name); self.vm_fixture[i].install_pkg("Traffic") ''' @@ -344,7 +344,7 @@ def ha_basic_test(self): vms.append(self.useFixture(VMFixture(project_name= self.inputs.project_name, connections= self.connections, vn_objs = [ self.vn1_fixture.obj ], vm_name= "ha_new_vm"+str(random.randint(1,100000)) ,flavor='contrail_flavor_large',image_name='ubuntu-traffic'))) for i in range(0,vm_cnt): assert vms[i].verify_on_setup() - status = self.nova_fixture.wait_till_vm_is_up(vms[i].vm_obj ) + status = self.nova_h.wait_till_vm_is_up(vms[i].vm_obj ) if status == False: self.logger.error("%s failed to come up" % vms[i].vm_name) return False diff --git a/serial_scripts/headless_vrouter/base.py b/serial_scripts/headless_vrouter/base.py index 29fa57cb5..5143d71c9 100644 --- a/serial_scripts/headless_vrouter/base.py +++ b/serial_scripts/headless_vrouter/base.py @@ -17,8 +17,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/serial_scripts/neutron/lbaas/test_lbaas.py b/serial_scripts/neutron/lbaas/test_lbaas.py index ec9d8cca2..6e2de90e5 100644 --- a/serial_scripts/neutron/lbaas/test_lbaas.py +++ b/serial_scripts/neutron/lbaas/test_lbaas.py @@ -8,7 +8,7 @@ from common.connections import ContrailConnections from tcutils.wrappers import preposttest_wrapper from tcutils.util import run_fab_cmd_on_node -from neutronclient.common.exceptions import NeutronClientException +from common.openstack_libs import neutron_exception as NeutronClientException from common.neutron.lbaas.base import BaseTestLbaas import test @@ -283,8 +283,8 @@ def test_lbaas_garbage_collector(self): sleep(5) #Delete VIP while the agent is stopped - self.quantum_fixture.delete_vip(lb_vip['id']) - self.remove_method_from_cleanups((self.quantum_fixture.delete_vip, (lb_vip['id'],), {})) + self.quantum_h.delete_vip(lb_vip['id']) + self.remove_method_from_cleanups((self.quantum_h.delete_vip, (lb_vip['id'],), {})) result, msg = self.verify_vip_delete(lb_vip['id']) assert result, msg diff --git a/serial_scripts/neutron/test_quota.py b/serial_scripts/neutron/test_quota.py index 9a1e6a7df..bf494bd68 100644 --- a/serial_scripts/neutron/test_quota.py +++ b/serial_scripts/neutron/test_quota.py @@ -134,12 +134,12 @@ def test_update_quota_for_admin_tenant(self): 'port': 5, 'security_group': 4, 'security_group_rule': 6} - quota_rsp = self.admin_connections.quantum_fixture.update_quota( + quota_rsp = self.admin_connections.quantum_h.update_quota( self.admin_connections.project_id, quota_dict) - self.addCleanup(self.admin_connections.quantum_fixture.delete_quota, self.admin_connections.project_id) - quota_show_dict = self.connections.quantum_fixture.show_quota( + self.addCleanup(self.admin_connections.quantum_h.delete_quota, self.admin_connections.project_id) + quota_show_dict = self.connections.quantum_h.show_quota( self.admin_connections.project_id) for neutron_obj in quota_rsp['quota']: @@ -197,29 +197,29 @@ def verify_quota_limit(self, inputs, connections, vn_fix, sg_obj): response_dict = {} vn1_name = get_random_name('vn_test_quota') - vn1_obj = connections.quantum_fixture.create_network(vn1_name) + vn1_obj = connections.quantum_h.create_network(vn1_name) if vn1_obj: self.addCleanup( - connections.quantum_fixture.delete_vn, + connections.quantum_h.delete_vn, vn1_obj['network']['id']) response_dict['network'] = vn1_obj subnet_cidr = get_random_cidr() - subnet_rsp = connections.quantum_fixture.create_subnet( + subnet_rsp = connections.quantum_h.create_subnet( {'cidr': subnet_cidr}, vn_fix.vn_id) response_dict['subnet'] = subnet_rsp secgrp_obj = self.create_security_group( get_random_name('sec_grp'), - connections.quantum_fixture) + connections.quantum_h) response_dict['secgrp'] = secgrp_obj router_obj = self.create_router( get_random_name('router'), connections.project_id) response_dict['router'] = router_obj - sg_rule_obj = connections.quantum_fixture.create_security_group_rule( + sg_rule_obj = connections.quantum_h.create_security_group_rule( sg_obj['id'], protocol='tcp') response_dict['sg_rule'] = sg_rule_obj - port_obj = connections.quantum_fixture.create_port( + port_obj = connections.quantum_h.create_port( vn_fix.vn_id) response_dict['port'] = port_obj fip_obj = self.create_multiple_floatingip( @@ -260,7 +260,7 @@ def create_multiple_floatingip( fvn_fixture): body = {'router:external': 'True'} net_dict = {'network': body} - net_rsp = connections.quantum_fixture.update_network( + net_rsp = connections.quantum_h.update_network( fvn_fixture.vn_id, net_dict) assert net_rsp['network'][ @@ -274,7 +274,7 @@ def create_multiple_floatingip( vn_id=fvn_fixture.vn_id, option='neutron')) assert fip_fixture.verify_on_setup() if count == 1: - fip_resp = connections.quantum_fixture.create_floatingip( + fip_resp = connections.quantum_h.create_floatingip( fvn_fixture.vn_id, connections.project_id) if fip_resp: @@ -293,7 +293,7 @@ def create_multiple_secgrp(self, connections, count=1): for i in range(count): secgrp_obj = self.create_security_group( get_random_name('sec_grp'), - connections.quantum_fixture) + connections.quantum_h) secgrp_objs.append(secgrp_obj) return secgrp_objs @@ -302,7 +302,7 @@ def create_multiple_secgrp_rule(self, connections, sg_obj_list, count=1): sg_rule_objs = [] for sg_obj in sg_obj_list: for i in range(count): - sg_rule_obj = connections.quantum_fixture.create_security_group_rule( + sg_rule_obj = connections.quantum_h.create_security_group_rule( sg_obj['id'], protocol=random.choice(proto_list)) sg_rule_objs.append(sg_rule_obj) @@ -313,11 +313,11 @@ def create_multiple_ports(self, connections, vn_fix_list, count=1): port_obj_list = [] for vn_fix in vn_fix_list: for i in range(count): - port_obj = connections.quantum_fixture.create_port( + port_obj = connections.quantum_h.create_port( vn_fix.vn_id) if port_obj: self.addCleanup( - connections.quantum_fixture.delete_port, + connections.quantum_h.delete_port, port_obj['id']) port_obj_list.append(port_obj) return port_obj_list diff --git a/serial_scripts/neutron/test_routers.py b/serial_scripts/neutron/test_routers.py index 6182dbd15..0081c7446 100644 --- a/serial_scripts/neutron/test_routers.py +++ b/serial_scripts/neutron/test_routers.py @@ -51,7 +51,7 @@ def test_basic_snat_behavior_with_config_and_vrouter_restart(self): router_name = get_random_name('router1') router_dict = self.create_router(router_name) - router_rsp = self.quantum_fixture.router_gateway_set( + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], ext_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) @@ -91,7 +91,7 @@ def test_basic_snat_behavior_with_fip_and_config_and_vrouter_restart(self): router_name = get_random_name('router1') router_dict = self.create_router(router_name) - router_rsp = self.quantum_fixture.router_gateway_set( + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], ext_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) @@ -115,14 +115,14 @@ def test_basic_snat_behavior_with_fip_and_config_and_vrouter_restart(self): @preposttest_wrapper def test_snat_active_standby_mode(self): - if len(self.connections.nova_fixture.get_hosts()) < 2: + if len(self.connections.nova_h.get_hosts()) < 2: self.logger.info( "Skipping Test. At least 2 compute node required to run the test") raise self.skipTest( "Skipping Test. At least 2 compute node required to run the test") result = True - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() compute_1 = host_list[0] compute_2 = host_list[0] if len(host_list) > 1: @@ -140,7 +140,7 @@ def test_snat_active_standby_mode(self): vn1_fixture.verify_on_setup() router_name = get_random_name('router1') router_dict = self.create_router(router_name) - router_rsp = self.quantum_fixture.router_gateway_set( + router_rsp = self.quantum_h.router_gateway_set( router_dict['id'], ext_vn_fixture.vn_id) self.add_vn_to_router(router_dict['id'], vn1_fixture) diff --git a/serial_scripts/policy/base.py b/serial_scripts/policy/base.py index 770446fa3..8ea78cf26 100644 --- a/serial_scripts/policy/base.py +++ b/serial_scripts/policy/base.py @@ -17,8 +17,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/serial_scripts/rsyslog/base.py b/serial_scripts/rsyslog/base.py index 6387a3973..05d69c6a3 100644 --- a/serial_scripts/rsyslog/base.py +++ b/serial_scripts/rsyslog/base.py @@ -17,8 +17,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect diff --git a/serial_scripts/system_test/flow_tests/base.py b/serial_scripts/system_test/flow_tests/base.py index 2121deaf7..ca591c24f 100644 --- a/serial_scripts/system_test/flow_tests/base.py +++ b/serial_scripts/system_test/flow_tests/base.py @@ -19,8 +19,8 @@ def setUpClass(cls): cls.connections = cls.isolated_creds.get_conections() cls.admin_inputs = cls.isolated_creds.get_admin_inputs() cls.admin_connections = cls.isolated_creds.get_admin_connections() - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect diff --git a/serial_scripts/upgrade/base.py b/serial_scripts/upgrade/base.py index 80c9fc9c6..6ceff11ae 100644 --- a/serial_scripts/upgrade/base.py +++ b/serial_scripts/upgrade/base.py @@ -26,8 +26,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect @@ -59,7 +59,7 @@ def setUp(self, inputs, connections, logger): self.inputs = inputs self.connections = connections self.logger = logger - self.quantum_fixture = connections.quantum_fixture + self.quantum_h = connections.quantum_h self.vnc_lib = connections.vnc_lib self.setup_common_objects(self.inputs , self.connections) diff --git a/serial_scripts/upgrade/test_upgrade.py b/serial_scripts/upgrade/test_upgrade.py index 45730370f..dba427d87 100755 --- a/serial_scripts/upgrade/test_upgrade.py +++ b/serial_scripts/upgrade/test_upgrade.py @@ -16,8 +16,8 @@ import traceback from vn_test import VNFixture from vm_test import VMFixture -from quantum_test import QuantumFixture -from nova_test import NovaFixture +from quantum_test import QuantumHelper +from nova_test import NovaHelper from floating_ip import FloatingIPFixture from policy_test import PolicyFixture from tcutils.commands import * @@ -462,11 +462,11 @@ def test_to_upgrade(self): time.sleep(90) connections.clear() self.logger.info('Will REBOOT the SHUTOFF VMs') - for vm in self.nova_fixture.get_vm_list(): + for vm in self.nova_h.get_vm_list(): if vm.status != 'ACTIVE': self.logger.info('Will Power-On %s' % vm.name) vm.start() - self.nova_fixture.wait_till_vm_is_active(vm) + self.nova_h.wait_till_vm_is_active(vm) run("rm -rf /tmp/temp") run("rm -rf /opt/contrail/utils/fabfile/testbeds/testbed.py") diff --git a/serial_scripts/vdns/base.py b/serial_scripts/vdns/base.py index f22c15739..0a0be9bfc 100644 --- a/serial_scripts/vdns/base.py +++ b/serial_scripts/vdns/base.py @@ -40,8 +40,8 @@ def setUpClass(cls): cls.isolated_creds.create_and_attach_user_to_tenant() cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect @@ -95,7 +95,7 @@ def verify_dns_record_order(self, record_order, test_type='test_record_order', r VirtualNetworkTestFixtureGen( self.vnc_lib, virtual_network_name=vn_name, network_ipam_ref_infos=vn_nets[vn_name], parent_fixt=proj_fixt, id_perms=IdPermsType(enable=True))) - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present( + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present( vn_name=vn_fixt._name, project_id=proj_fixt._obj._uuid) vm_fixture = self.useFixture( VMFixture(project_name=self.inputs.project_name, @@ -274,7 +274,7 @@ def vdns_with_cn_dns_agent_restart(self, restart_process): # The following code will verify the same. Also, we should be able ping # with VM name. for vm_name in vm_list: - vn_quantum_obj = self.quantum_fixture.get_vn_obj_if_present( + vn_quantum_obj = self.quantum_h.get_vn_obj_if_present( vn_name=vn_fixt._name, project_id=proj_fixt._obj._uuid) vm_fixture[vm_name] = self.useFixture( VMFixture(project_name=self.inputs.project_name, connections=self.connections, vn_obj=vn_quantum_obj, vm_name=vm_name)) diff --git a/serial_scripts/vgw/base.py b/serial_scripts/vgw/base.py index 85dfb5cec..c2c6ca35a 100644 --- a/serial_scripts/vgw/base.py +++ b/serial_scripts/vgw/base.py @@ -18,8 +18,8 @@ def setUpClass(cls): password=cls.inputs.stack_password, logger=cls.logger) #cls.connections= ContrailConnections(cls.inputs) - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib #cls.logger= cls.inputs.logger cls.agent_inspect = cls.connections.agent_inspect diff --git a/serial_scripts/vgw/verify.py b/serial_scripts/vgw/verify.py index bc8bba4f0..32405f81c 100644 --- a/serial_scripts/vgw/verify.py +++ b/serial_scripts/vgw/verify.py @@ -27,7 +27,7 @@ def verify_vgw_with_fip(self, compute_type): assert self.vn_fixture_dict[0].verify_on_setup() # Selection of compute to launch VM and VGW to configure - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() vgw_compute = None vm_compute = None if len(host_list) > 1: @@ -93,7 +93,7 @@ def verify_vgw_with_native_vm(self, compute_type): assert self.vn_fixture_dict[0].verify_on_setup() # Selection of compute to launch VM and VGW to configure - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() vgw_compute = None vm_compute = None if len(host_list) > 1: @@ -223,7 +223,7 @@ def vgw_restart_of_vgw_node(self): assert self.vn_fixture_dict[0].verify_on_setup() # Selection of compute to launch VM and VGW to configure - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() vgw_compute = None vm_compute = None if len(host_list) > 1: @@ -306,7 +306,7 @@ def verify_dynamic_vgw_compute_ping(self): route = '0.0.0.0/0' vgw_fq_name= 'default-domain:admin:vgwvn:vgwvn' vm1_name= "vgw_vm" - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.nova_h.get_hosts() if len(host_list) > 1: vm_compute = self.inputs.host_data[host_list[0]] vgw_compute = self.inputs.host_data[host_list[1]] diff --git a/serial_scripts/vgw/vgw_test_resource.py b/serial_scripts/vgw/vgw_test_resource.py index 4ccf95860..bf44c2669 100755 --- a/serial_scripts/vgw/vgw_test_resource.py +++ b/serial_scripts/vgw/vgw_test_resource.py @@ -25,8 +25,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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() diff --git a/serial_scripts/vgw/vgw_tests.py b/serial_scripts/vgw/vgw_tests.py index d0d06d8dc..806639949 100755 --- a/serial_scripts/vgw/vgw_tests.py +++ b/serial_scripts/vgw/vgw_tests.py @@ -6,8 +6,8 @@ # Set the env variable PARAMS_FILE to point to your ini file. Else it will try to pick params.ini in PWD # import os -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import fixtures import testtools import unittest @@ -40,7 +40,7 @@ def __init__(self, *args, **kwargs): self.inputs = self.res.inputs self.connections = self.res.connections self.logger = self.res.logger - self.nova_fixture = self.res.nova_fixture + self.nova_h = self.res.nova_h self.agent_inspect = self.connections.agent_inspect self.cn_inspect = self.connections.cn_inspect self.analytics_obj = self.connections.analytics_obj diff --git a/serial_scripts/vm_regression/base.py b/serial_scripts/vm_regression/base.py index 75798b12f..1755cf0d3 100644 --- a/serial_scripts/vm_regression/base.py +++ b/serial_scripts/vm_regression/base.py @@ -19,8 +19,8 @@ def setUpClass(cls): cls.inputs = cls.isolated_creds.get_inputs() cls.connections = cls.isolated_creds.get_conections() #cls.connections= ContrailConnections(cls.inputs) - cls.quantum_fixture= cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h= cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib # cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect diff --git a/serial_scripts/vm_regression/test_vm_serial.py b/serial_scripts/vm_regression/test_vm_serial.py index 824796795..47d0ce02e 100644 --- a/serial_scripts/vm_regression/test_vm_serial.py +++ b/serial_scripts/vm_regression/test_vm_serial.py @@ -75,9 +75,9 @@ def test_bring_up_vm_with_control_node_down(self): vm1_fixture.verify_vm_launched() vm2_fixture.verify_vm_launched() vm1_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm1_fixture.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm1_fixture.vm_obj)]['host_ip'] vm2_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm2_fixture.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm2_fixture.vm_obj)]['host_ip'] inspect_h1 = self.agent_inspect[vm1_node_ip] inspect_h2 = self.agent_inspect[vm2_node_ip] self.logger.info( @@ -170,8 +170,8 @@ def test_ipam_persistence_across_restart_reboots(self): assert vm1_fixture.verify_on_setup() assert vm2_fixture.verify_on_setup() - self.nova_fixture.wait_till_vm_is_up( vm1_fixture.vm_obj ) - self.nova_fixture.wait_till_vm_is_up( vm2_fixture.vm_obj ) + self.nova_h.wait_till_vm_is_up( vm1_fixture.vm_obj ) + self.nova_h.wait_till_vm_is_up( vm2_fixture.vm_obj ) assert vm1_fixture.ping_to_ip( vm2_fixture.vm_ip ) self.logger.info('Will restart the services now') for compute_ip in self.inputs.compute_ips: @@ -228,7 +228,7 @@ def test_multistep_vm_add_delete_with_stop_start_service(self): vn_obj=vn_obj, vm_name = get_random_name ('vm2'), project_name=self.inputs.project_name)) vm2_fixture.verify_vm_launched() self.logger.info('Checking if vm2 has booted up') - assert not self.nova_fixture.wait_till_vm_is_up(vm2_fixture.vm_obj) + assert not self.nova_h.wait_till_vm_is_up(vm2_fixture.vm_obj) self.logger.info( 'vm2 has not booted up as expected.Starting vrouter service') for compute_ip in self.inputs.compute_ips: diff --git a/serial_scripts/webui/base.py b/serial_scripts/webui/base.py index 7988af185..3c4e310bd 100644 --- a/serial_scripts/webui/base.py +++ b/serial_scripts/webui/base.py @@ -33,8 +33,8 @@ def setUpClass(cls): logger=cls.logger) cls.inputs = cls.isolated_creds.get_admin_inputs() cls.connections = cls.isolated_creds.get_admin_connections() - cls.quantum_fixture = cls.connections.quantum_fixture - cls.nova_fixture = cls.connections.nova_fixture + cls.quantum_h = cls.connections.quantum_h + cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect diff --git a/tcutils/collector/analytics_performance_tests.py b/tcutils/collector/analytics_performance_tests.py index f17dece75..c13369fc2 100644 --- a/tcutils/collector/analytics_performance_tests.py +++ b/tcutils/collector/analytics_performance_tests.py @@ -35,8 +35,8 @@ def setUp(self): self.ini_file = 'params.ini' self.inputs = self.useFixture(ContrailTestInit(self.ini_file)) self.connections = ContrailConnections(self.inputs) - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + 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 @@ -323,7 +323,7 @@ def test_verify_analytics_scale(self): first_vm = self.setup_fixture.vm_valuelist[0] vm_list = self.setup_fixture.vm_valuelist[1:] self.tx_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(first_vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(first_vm.vm_obj)]['host_ip'] self.start_time = self.analytics_obj.getstarttime(self.tx_vm_node_ip) traffic_threads = [] for vm in vm_list: @@ -384,7 +384,7 @@ def test_verify_analytics_scale(self): for vm in vm_list: dest_vm_node_list = [] dest_vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] + self.nova_h.get_nova_host_of_vm(vm.vm_obj)]['host_ip'] dest_vm_node_list.append(dest_vm_node_ip) self.triggers(preference='agent reboot', ip=dest_vm_node_list) time.sleep(20) diff --git a/tcutils/cores.py b/tcutils/cores.py index b358069c0..84d122836 100644 --- a/tcutils/cores.py +++ b/tcutils/cores.py @@ -20,7 +20,9 @@ def get_node_ips(inputs): """ node_ips = [] nodes = ['cfgm_ips', 'bgp_ips', 'collector_ips', - 'webui_ip', 'compute_ips', 'openstack_ip'] + 'webui_ip', 'compute_ips'] + if inputs.orchestrator == 'openstack': + nodes += ['openstack_ip'] for node in nodes: ip = inputs.__getattribute__(node) if type(ip) is str: diff --git a/tcutils/topo/sdn_topo_setup.py b/tcutils/topo/sdn_topo_setup.py index 88f6085fe..1a806c032 100644 --- a/tcutils/topo/sdn_topo_setup.py +++ b/tcutils/topo/sdn_topo_setup.py @@ -1,7 +1,7 @@ import os import copy -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import fixtures import testtools import topo_steps @@ -31,9 +31,10 @@ def __init__(self, connections, topo): self.ini_file = os.environ.get('TEST_CONFIG_FILE') self.connections = connections self.inputs = self.connections.inputs - self.quantum_fixture = self.connections.quantum_fixture - self.nova_fixture = self.connections.nova_fixture + self.quantum_h = self.connections.quantum_h + self.nova_h = self.connections.nova_h self.vnc_lib = self.connections.vnc_lib + self.orch = self.connections.orch self.logger = self.inputs.logger self.topo = topo if self.inputs.verify_thru_gui(): @@ -65,6 +66,7 @@ def topo_setup(self, config_option='openstack', skip_verify='no', flavor='contra d. VN: Contrail API e. VM: Nova ''' + config_option = 'contrail' if self.inputs.orchestrator == 'vcenter' else config_option self.result = True self.err_msg = [] self.flavor = flavor diff --git a/tcutils/topo/topo_steps.py b/tcutils/topo/topo_steps.py index db1a563c0..4ce4ed007 100644 --- a/tcutils/topo/topo_steps.py +++ b/tcutils/topo/topo_steps.py @@ -1,8 +1,8 @@ ''' This module provides utils for setting up sdn topology given the topo inputs''' import os import copy -from novaclient import client as mynovaclient -from novaclient import exceptions as novaException +from common.openstack_libs import nova_client as mynovaclient +from common.openstack_libs import nova_exception as novaException import fixtures import topo_steps from common.contrail_test_init import ContrailTestInit @@ -141,8 +141,8 @@ def create_sg_contrail(self): def createPolicy(self, option='openstack'): - if option == 'openstack': - createPolicyOpenstack(self) + if option == 'openstack' or self.inputs.orchestrator == 'vcenter': + createPolicyFixtures(self) elif option == 'contrail': createPolicyContrail(self) else: @@ -151,7 +151,7 @@ def createPolicy(self, option='openstack'): # end createPolicy -def createPolicyOpenstack(self, option='openstack'): +def createPolicyFixtures(self, option='openstack'): self.logger.info("Setup step: Creating Policies") self.policy_fixt = {} self.conf_policy_objs = {} @@ -274,8 +274,8 @@ def createVN_Policy(self, option='openstack'): def createVN(self, option='openstack'): - if option == 'openstack': - createVNOpenStack(self) + if option == 'openstack' or self.inputs.orchestrator == 'vcenter': + createVNOrch(self) elif option == 'contrail': createVNContrail(self) else: @@ -284,7 +284,7 @@ def createVN(self, option='openstack'): # end createVN -def createVNOpenStack(self): +def createVNOrch(self): self.logger.info("Setup step: Creating VN's") self.vn_fixture = {} self.vn_of_cn = {} @@ -471,15 +471,15 @@ def createVMNova( VmToNodeMapping=None): self.logger.info("Setup step: Creating VM's") self.vm_fixture = {} - host_list = self.connections.nova_fixture.get_hosts() + host_list = self.connections.orch.get_hosts() vm_image_name = os.environ['ci_image'] if os.environ.has_key('ci_image') else 'ubuntu-traffic' for vm in self.topo.vmc_list: sec_gp = [] if option == 'contrail': vn_read = self.vnc_lib.virtual_network_read( - id=str(self.vn_fixture[self.topo.vn_of_vm[vm]]._obj.uuid)) - vn_obj = self.quantum_fixture.get_vn_obj_if_present( + id=str(self.vn_fixture[self.topo.vn_of_vm[vm]].vn_id)) + vn_obj = self.orch.get_vn_obj_if_present( vn_read.name, project_id=self.project_fixture[ self.topo.project].uuid) @@ -567,7 +567,7 @@ def createVMNova( assert vm_verify_out, self.err_msg vm_node_ip = self.inputs.host_data[ - self.nova_fixture.get_nova_host_of_vm( + self.orch.get_host_of_vm( self.vm_fixture[vm].vm_obj)]['host_ip'] self.vn_of_cn[vm_node_ip].append(self.topo.vn_of_vm[vm])