def runTest(self): try: # Basic checks for status of services status_inst = CheckStatusOfServices(self.config_dict) status = CheckStatusOfServices.check(status_inst) if not status: print "Some service/s not running...Unable to run testcase" return resultConstants.RESULT_ABORT # Create project new_project = self.controller.createProject(self.new_tenant) nova = self.controller.get_nova_client(new_project.id, self.new_user, self.new_password) if not nova: raise Exception("Nova client not found") # Create user new_user = self.controller.createUser( new_project, new_username=self.new_user, new_password=self.new_password) # Create 1st network new_network1 = self.controller.createNetwork( self.new_tenant, self.new_network1, self.new_user, self.new_password) print "New Network:", new_network1 # Create subnet new_subnet1 = self.controller.createSubnet( new_network1.get('network').get('id'), self.new_tenant, self.new_user, self.new_password, self.new_subnw1) print "New Subnetwork:", new_subnet1 # Create key-pair key_pair = self.controller.createKeyPair(new_project.id, self.new_user, self.new_password) # Create security groups and rules self.controller.createSecurityGroup(new_project.id, self.new_user, self.new_password) hosts = nova.hosts.list() hosts_list = [h for h in hosts if h.zone == "nova"] # print "Hosts list:", hosts_list # Create an aggregate with availability zone agg1 = self.new_tenant + "_agg_" + \ self.config_dict['computes'][0]['hostname'] zone1 = self.new_tenant + "_az_" + \ self.config_dict['computes'][0]['hostname'] aggregate1 = self.controller.createAggregate( new_project.id, self.new_user, self.new_password, agg_name=agg1, availability_zone=zone1) if hosts_list: aggregate1.add_host(hosts_list[0].host_name) else: raise Exception("No hosts found") agg2 = self.new_tenant + "_agg_" + \ self.config_dict['computes'][1]['hostname'] zone2 = self.new_tenant + "_az_" + \ self.config_dict['computes'][1]['hostname'] aggregate2 = self.controller.createAggregate( new_project.id, self.new_user, self.new_password, agg_name=agg2, availability_zone=zone2) if hosts_list: aggregate2.add_host(hosts_list[1].host_name) else: raise Exception("No hosts found") # Create instance zones = nova.availability_zones.list() for zone in zones: zone_name = str(zone.zoneName) if zone_name == zone1: print "Launching instance in zone: ", zone_name host1 = self.controller.createInstance( new_project.id, self.new_user, self.new_password, new_network1.get('network').get('id'), self.new_inst1, key_name=key_pair, availability_zone=zone_name) print "Host1:", host1 zones = nova.availability_zones.list() for zone in zones: zone_name = str(zone.zoneName) if zone_name == zone2: print "Launching instance in zone: ", zone_name host2 = self.controller.createInstance( new_project.id, self.new_user, self.new_password, new_network1.get('network').get('id'), self.new_inst2, key_name=key_pair, availability_zone=zone_name) print "Host2:", host2 ip_host1 = str((host1[0].networks[self.new_network1])[0]) ip_host2 = str((host2[0].networks[self.new_network1])[0]) # Verify Ping using DHCP namespace pingObj = Ping() result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network1.get('network').get('id'), ip_host2) if not result: raise Exception("Ping failed...Failing test case\n") result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network1.get('network').get('id'), ip_host1) if not result: raise Exception("Ping failed...Failing test case\n") dhcp_ip = self.new_subnw1[:-4] + "2" result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network1.get('network').get('id'), dhcp_ip) if not result: raise Exception("Ping failed...Failing test case\n") except Exception as e: print "Created Exception: ", e self.cleanup() return ReturnValue.FAILURE self.cleanup() return ReturnValue.SUCCESS
def runTest(self, service): print "Service to be restarted is:", service try: # Basic checks for status of services status_inst = CheckStatusOfServices(self.config_dict) status = CheckStatusOfServices.check(status_inst) if not status: print "Some service/s not running...Unable to run testcase" return resultConstants.RESULT_ABORT # Create project & user new_project_user = self.controller.createProjectUser( self.new_tenant, self.new_user, self.new_password) # Create network and subnetwork new_network_inst1 = self.controller.createNetworkSubNetwork( self.new_tenant, self.new_network1, self.new_subnw1, self.new_user, self.new_password) new_network_inst2 = self.controller.createNetworkSubNetwork( self.new_tenant, self.new_network2, self.new_subnw2, self.new_user, self.new_password) # Create key-pair & security groups and rules keypair_secgrp = self.controller.createKeyPairSecurityGroup( new_project_user.tenant.id, self.new_user, self.new_password) hosts_list = self.computeHosts # Create an aggregate with availability zone hosts = [] hosts.append(hosts_list[0]) agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname zone1 = self.new_tenant + "_az_" + hosts_list[0].hostname self.controller.createAggregate(new_project_user.tenant.id, self.new_user, self.new_password, agg_name=agg1, availability_zone=zone1, host_list=hosts) hosts = [] hosts.append(hosts_list[1]) agg2 = self.new_tenant + "_agg_" + hosts_list[1].hostname zone2 = self.new_tenant + "_az_" + hosts_list[1].hostname self.controller.createAggregate(new_project_user.tenant.id, self.new_user, self.new_password, agg_name=agg2, availability_zone=zone2, host_list=hosts) # Create 5 instances on two different computes (total 10 instances) host1 = self.controller.createInstance( new_project_user.tenant.id, self.new_user, self.new_password, new_network_inst1.network.get('network').get('id'), self.new_inst1, key_name=keypair_secgrp.key_pair, availability_zone=zone1, count=self.num_inst) host2 = self.controller.createInstance( new_project_user.tenant.id, self.new_user, self.new_password, new_network_inst2.network.get('network').get('id'), self.new_inst2, key_name=keypair_secgrp.key_pair, availability_zone=zone2, count=self.num_inst) # Verify Ping, ovs flows and uplink & vdptool output using DHCP # namespace on controller (before restart) pingObj = Ping() dhcp_ip1 = self.new_subnw1[:-4] + "2" result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst2.network.get('network').get('id'), dhcp_ip1) if not result: raise Exception("Ping failed...Failing test case\n") dhcp_ip2 = self.new_subnw2[:-4] + "2" result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst1.network.get('network').get('id'), dhcp_ip2) if not result: raise Exception("Ping failed...Failing test case\n") inst_ip_list = [] # Gathering instances information for inst in range(self.num_inst): print "loop:", inst instObj = Instance(ip=str( (host1[inst].networks[self.new_network1])[0]), instname=str(host1[inst].name), hostname=hosts_list[0].hostname) print "InstObj1:", instObj inst_ip_list.append(instObj) print "inst_ip_list1:", inst_ip_list instObj = Instance(ip=str( (host2[inst].networks[self.new_network2])[0]), instname=str(host2[inst].name), hostname=hosts_list[1].hostname) print "InstObj2:", instObj inst_ip_list.append(instObj) print "inst_ip_list2:", inst_ip_list # Verify ping, ovs and vdp results for inst in inst_ip_list: # Verify Ping result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst1.network.get('network').get('id'), inst.ip) print "network_id is:", new_network_inst1.network.get( 'network').get('id') if not result: raise Exception("Ping failed...Failing test case\n") result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst2.network.get('network').get('id'), inst.ip) print "network_id is:", new_network_inst2.network.get( 'network').get('id') if not result: raise Exception("Ping failed...Failing test case\n") OvsFlowsCli().verify_ovs_and_vdp(self.config_dict, self.controller.ip, self.controller.sys_username, self.controller.password, inst.instname, inst.ip, inst.hostname) if not result: raise Exception("Incorrect VDPTool/OVS output") # Restart service if service == "enabler-server": # Restart Enabler server on controller enabler_inst = EnablerService(self.controller.ip, self.controller.sys_username, self.controller.password) result = EnablerService.take_action(enabler_inst, "restart", "server") if not result: raise Exception("Error while restarting enabler server") elif service == "enabler-agent": # Restart Enabler agent on controller enabler_inst = EnablerService(self.controller.ip, self.controller.sys_username, self.controller.password) result = EnablerService.take_action(enabler_inst, "restart", "agent") if not result: raise Exception("Error while restarting enabler agent") elif service == "lldpad": # Restart lldpad on controller lldpad_inst = LldpadService(self.controller.ip, self.controller.sys_username, self.controller.password) result = LldpadService.take_action(lldpad_inst, "restart") if not result: raise Exception("Error while restarting lldpad") # Verify Ping, ovs flows and uplink & vdptool output using DHCP # namespace on controller (after restart) for inst in inst_ip_list: # Verify Ping result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst1.network.get('network').get('id'), inst.ip) print "network_id is:", new_network_inst1.network.get( 'network').get('id') if not result: raise Exception("Ping failed...Failing test case\n") result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst2.network.get('network').get('id'), inst.ip) print "network_id is:", new_network_inst2.network.get( 'network').get('id') if not result: raise Exception("Ping failed...Failing test case\n") OvsFlowsCli().verify_ovs_and_vdp(self.config_dict, self.controller.ip, self.controller.sys_username, self.controller.password, inst.instname, inst.ip, inst.hostname) if not result: raise Exception("Incorrect VDPTool/OVS output") except Exception as e: print "Created Exception: ", e return resultConstants.RESULT_ABORT self.cleanup() return ReturnValue.FAILURE self.cleanup() return ReturnValue.SUCCESS
def runTest(self): agg = [] aggregate = [] zone = [] vm = [] ip_vm = [] try: # Basic checks for status of services status_inst = CheckStatusOfServices(self.config_dict) status = CheckStatusOfServices.check(status_inst) if not status: print "Some service/s not running...Unable to run testcase" return resultConstants.RESULT_ABORT # Create project & user new_project_user = self.controller.createProjectUser( self.new_tenant, self.new_user, self.new_password) # Create network and subnetwork new_network_inst1 = self.controller.createNetworkSubNetwork( self.new_tenant, self.new_network1, self.new_subnw1, self.new_user, self.new_password) # Create key-pair & security groups and rules keypair_secgrp = self.controller.createKeyPairSecurityGroup( new_project_user.tenant.id, self.new_user, self.new_password) hosts_list = self.computeHosts for host in range(self.computeCount): hosts = [] # Create an aggregate with availability zone per compute/host agg.append(self.new_tenant + "_agg_" + hosts_list[host].hostname) zone.append(self.new_tenant + "_az_" + hosts_list[host].hostname) hosts.append(hosts_list[host]) aggregate.append( self.controller.createAggregate( new_project_user.tenant.id, self.new_user, self.new_password, agg_name=agg[host], availability_zone=zone[host], host_list=hosts)) #aggregate[host].add_host(hosts_list[host].hostname) # Create instance vm.append( self.controller.createInstance( new_project_user.tenant.id, self.new_user, self.new_password, new_network_inst1.network.get('network').get('id'), self.new_inst + str(host), key_name=keypair_secgrp.key_pair, availability_zone=zone[host])) print "VM[" + str(host) + "]:", vm[host] ip_vm.append(str((vm[host][0].networks[self.new_network1])[0])) print "IP of VM[" + str(host) + "]:", ip_vm[host] pingObj = Ping() dhcp_ip = self.new_subnw1[:-4] + "2" result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst1.network.get('network').get('id'), dhcp_ip) if not result: raise Exception("Ping failed...Failing test case\n") for host in range(self.computeCount): # Verify Ping using DHCP namespace result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst1.network.get('network').get('id'), ip_vm[host]) if not result: raise Exception("Ping failed...Failing test case\n") except Exception as e: print "Created Exception: ", e self.cleanup() return ReturnValue.FAILURE self.cleanup() return ReturnValue.SUCCESS
def runTest(self): try: # Basic checks for status of services status_inst = CheckStatusOfServices(self.config_dict) status = CheckStatusOfServices.check(status_inst) if not status: print "Some service/s not running...Unable to run testcase" return resultConstants.RESULT_ABORT # Create project & user new_project_user = self.controller.createProjectUser( self.new_tenant, self.new_user, self.new_password) # Create network and subnetwork new_network_inst1 = self.controller.createNetworkSubNetwork( self.new_tenant, self.new_network1, self.new_subnw1, self.new_user, self.new_password) # Create key-pair & security groups and rules keypair_secgrp = self.controller.createKeyPairSecurityGroup( new_project_user.tenant.id, self.new_user, self.new_password) # Create an aggregate with availability zone hosts = [] hosts_list = self.computeHosts hosts.append(hosts_list[0]) agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname zone1 = self.new_tenant + "_az_" + hosts_list[0].hostname self.controller.createAggregate(new_project_user.tenant.id, self.new_user, self.new_password, agg_name=agg1, availability_zone=zone1, host_list=hosts) #Create instance host1 = self.controller.createInstance( new_project_user.tenant.id, self.new_user, self.new_password, new_network_inst1.network.get('network').get('id'), self.new_inst1, key_name=keypair_secgrp.key_pair, availability_zone=zone1) print "Host1:", host1 host2 = self.controller.createInstance( new_project_user.tenant.id, self.new_user, self.new_password, new_network_inst1.network.get('network').get('id'), self.new_inst2, key_name=keypair_secgrp.key_pair, availability_zone=zone1) print "Host2:", host2 ip_host1 = str((host1[0].networks[self.new_network1])[0]) ip_host2 = str((host2[0].networks[self.new_network1])[0]) #Verify Ping using DHCP namespace on controller pingObj = Ping() result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst1.network.get('network').get('id'), ip_host1) if not result: raise Exception("Ping failed...Failing test case\n") result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst1.network.get('network').get('id'), ip_host2) if not result: raise Exception("Ping failed...Failing test case\n") dhcp_ip = self.new_subnw1[:-4] + "2" result = pingObj.verify_ping_qdhcpns( self.controller.ip, self.controller.sys_username, self.controller.password, new_network_inst1.network.get('network').get('id'), dhcp_ip) if not result: raise Exception("Ping failed...Failing test case\n") except Exception as e: print "Created Exception: ", e self.cleanup() return ReturnValue.FAILURE self.cleanup() return ReturnValue.SUCCESS