Skip to content

Commit

Permalink
Merge "Enable Vcenter test - 4th change set" into R2.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jul 2, 2015
2 parents d770f78 + 4526dc9 commit a85155b
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 79 deletions.
4 changes: 2 additions & 2 deletions common/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, inputs,logger,

self.orch = OpenstackOrchestrator(username=username, password=password,
project_id=self.project_id, project_name=project_name,
inputs=inputs, vnclib=self.vnc_lib)
inputs=inputs, vnclib=self.vnc_lib, logger=logger)
self.nova_h = self.orch.nova_h
self.quantum_h = self.orch.quantum_h
else: # vcenter
Expand All @@ -62,7 +62,7 @@ def __init__(self, inputs,logger,
port=self.inputs.auth_port,
dc_name=self.inputs.vcenter_dc,
vnc=self.vnc_lib,
inputs=self.inputs)
inputs=self.inputs, logger=logger)

self.api_server_inspects = {}
self.dnsagent_inspect = {}
Expand Down
3 changes: 0 additions & 3 deletions common/create_public_vn.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ def __init__(self, user, password, inputs, ini_file = None ,logger = None, mx_rt
self.logger = logger
self.public_vn = self.inputs.public_vn
self.public_tenant = self.inputs.public_tenant
if self.inputs.orchestrator == 'vcenter':
# Not supported yet for vcenter setup
return
self.setUp()
self.create_public_vn(mx_rt)
self.create_floatingip_pool()
Expand Down
37 changes: 11 additions & 26 deletions fixtures/floating_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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.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
Expand Down Expand Up @@ -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]))
Expand All @@ -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_h.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
Expand Down Expand Up @@ -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_h.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

Expand Down Expand Up @@ -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_h.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_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
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_h.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'):
Expand Down
37 changes: 36 additions & 1 deletion fixtures/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
class OpenstackOrchestrator(Orchestrator):

def __init__(self, inputs, username, password, project_name, project_id,
vnclib):
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,
Expand Down Expand Up @@ -103,6 +104,40 @@ def wait_till_vm_status(self, 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):
Expand Down
15 changes: 15 additions & 0 deletions fixtures/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ def wait_till_vm_status(self, vm_obj, status):
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:

Expand Down
42 changes: 36 additions & 6 deletions fixtures/vcenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ def free_vlan(self, vlan):

class VcenterOrchestrator(Orchestrator):

def __init__(self, inputs, host, port, user, pwd, dc_name, vnc):
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)
Expand Down Expand Up @@ -137,12 +138,13 @@ def _get_clusters_hosts(self):
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 self._clusters_hosts.values()
return [host for hosts in self._clusters_hosts.values() for host in hosts]

def get_zones(self):
return self._clusters_hosts.keys()
Expand Down Expand Up @@ -381,6 +383,38 @@ def get_vn_id(self, vnobj):
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
Expand All @@ -392,8 +426,6 @@ def create_in_vcenter(vcenter, name, vlan, prefix):
vn.uuid = None
vn.prefix = IPNetwork(prefix)
ip_list = list(vn.prefix.iter_hosts())
vn.gw_ip = ip_list.pop(-1)
vn.meta_ip = ip_list.pop(-1)

spec = _vim_obj('dvs.ConfigSpec', name=name, type='earlyBinding', numPorts = len(ip_list),
defaultPortConfig=_vim_obj('dvs.PortConfig',
Expand Down Expand Up @@ -425,8 +457,6 @@ def create_from_vnobj(vcenter, vn_obj):
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())
vn.gw_ip = ip_list.pop(-1)
vn.meta_ip = ip_list.pop(-1)
return vn

@retry(tries=30, delay=5)
Expand Down
12 changes: 6 additions & 6 deletions scripts/discovery_regression/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
'''
Expand All @@ -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):
'''
Expand All @@ -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):
Expand Down Expand Up @@ -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):
'''
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/floatingip/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_h.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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/floatingip/test_floatingip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions scripts/floatingip/test_mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@ def tearDownClass(cls):
super(TestSanity_MX, cls).tearDownClass()

def is_test_applicable(self):
ret = super(TestSanity_MX, self).is_test_applicable()
if not ret[0]:
return ret
if os.environ.get('MX_GW_TEST') != '1':
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):
'''
Expand Down
3 changes: 0 additions & 3 deletions scripts/neutron/test_routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ def tearDownClass(cls):


def is_test_applicable(self):
ret = super(TestRouterSNAT, self).is_test_applicable()
if not ret[0]:
return ret
if os.environ.get('MX_GW_TEST') != '1':
return (False, 'Skipping Test. Env variable MX_GW_TEST is not set')
return (True, None)
Expand Down
5 changes: 2 additions & 3 deletions scripts/vm_regression/test_esx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ def tearDownClass(cls):
super(TestBasicESXKVM, cls).tearDownClass()

def is_test_applicable(self):
ret = super(TestBasicESXKVM, self).is_test_applicable()
if not ret[0]:
return ret
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')
Expand Down

0 comments on commit a85155b

Please sign in to comment.