def setUpClass(cls): cls.apiclient = super(TestDeployVmWithVariedPlanners, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient, cls.services) cls.zone = get_zone(cls.apiclient, cls.services) cls.template = get_template( cls.apiclient, cls.zone.id, cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["template"] = cls.template.id cls.services["zoneid"] = cls.zone.id cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls.hosts = Host.list(cls.apiclient, type='Routing') cls.clusters = Cluster.list(cls.apiclient) cls.cleanup = [ cls.account ]
def AddCluster(self, cluster_size): #Create clusters with Hypervisor type XEN/KVM/VWare for k, v in self.services["clusters"].items(): v["clustername"] = str(uuid.uuid1()) cluster = Cluster.create( self.apiclient, v, zoneid=self.zone.id, podid=self.pod.id ) self.debug( "Created Cluster for hypervisor type %s & ID: %s" %( v["hypervisor"], cluster.id )) self.assertEqual( cluster.allocationstate, 'Enabled', "Check whether allocation state of cluster is enabled" ) hypervisor_type = str(cluster.hypervisortype.lower()) i = 1 while i < cluster_size: i+=1 host_services = self.services["hosts"][hypervisor_type] host_services["url"] = "http://sim/" + str(uuid.uuid1()) + "/" host = Host.create( self.apiclient, cluster, host_services, zoneid=self.zone.id, podid=self.pod.id ) self.debug( "Created host (ID: %s) in cluster ID %s" %( host.id, cluster.id )) storage_services = { "url": "nfs://nfsstor:/export/home/sandbox/" + str(uuid.uuid1()) + "/", "name": str(uuid.uuid1()) } storage = StoragePool.create(self.apiclient, storage_services, clusterid=cluster.id, zoneid=self.zone.id, podid=self.pod.id ) return
def setUpClass(cls): cls.apiclient = super(TestDeployVmWithVariedPlanners, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient, cls.services) cls.zone = get_zone(cls.apiclient, cls.services) cls.template = get_template(cls.apiclient, cls.zone.id, cls.services["ostype"]) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["template"] = cls.template.id cls.services["zoneid"] = cls.zone.id cls.account = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.services["account"] = cls.account.name cls.hosts = Host.list(cls.apiclient, type='Routing') cls.clusters = Cluster.list(cls.apiclient) cls.cleanup = [cls.account]
def setUp(self): self.testdata = TestData().testdata self.apiclient = self.testClient.getApiClient() # Get Zone, Domain and Default Built-in template self.domain = get_domain(self.apiclient, self.testdata) self.zone = get_zone(self.apiclient, self.testdata) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) self.hosts = [] suitablecluster = None clusters = Cluster.list(self.apiclient) self.assertTrue(isinstance(clusters, list) and len(clusters) > 0, msg = "No clusters found") for cluster in clusters: self.hosts = Host.list(self.apiclient, clusterid=cluster.id, type='Routing') if isinstance(self.hosts, list) and len(self.hosts) >= 2: suitablecluster = cluster break self.assertTrue(isinstance(self.hosts, list) and len(self.hosts) >= 2, msg = "Atleast 2 hosts required in cluster for VM HA test") #update host tags for host in self.hosts: Host.update(self.apiclient, id=host.id, hosttags=self.testdata["service_offering"]["hasmall"]["hosttags"]) #create a user account self.account = Account.create( self.apiclient, self.testdata["account"], domainid=self.domain.id ) #create a service offering self.service_offering = ServiceOffering.create( self.apiclient, self.testdata["service_offering"]["hasmall"] ) #deploy ha vm self.virtual_machine = VirtualMachine.create( self.apiclient, self.testdata["virtual_machine"], accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, templateid=self.template.id ) list_vms = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id) self.debug( "Verify listVirtualMachines response for virtual machine: %s"\ % self.virtual_machine.id ) self.assertTrue(isinstance(list_vms, list) and len(list_vms) == 1, msg = "List VM response was empty") self.virtual_machine = list_vms[0] self.mock_checkhealth = SimulatorMock.create( apiclient=self.apiclient, command="CheckHealthCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, clusterid=suitablecluster.id, hostid=self.virtual_machine.hostid, value="result:fail") self.mock_ping = SimulatorMock.create( apiclient=self.apiclient, command="PingCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, clusterid=suitablecluster.id, hostid=self.virtual_machine.hostid, value="result:fail") self.mock_checkvirtualmachine = SimulatorMock.create( apiclient=self.apiclient, command="CheckVirtualMachineCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, clusterid=suitablecluster.id, hostid=self.virtual_machine.hostid, value="result:fail") self.mock_pingtest = SimulatorMock.create( apiclient=self.apiclient, command="PingTestCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, value="result:fail") self.mock_checkonhost_list = [] for host in self.hosts: if host.id != self.virtual_machine.hostid: self.mock_checkonhost_list.append(SimulatorMock.create( apiclient=self.apiclient, command="CheckOnHostCommand", zoneid=suitablecluster.zoneid, podid=suitablecluster.podid, clusterid=suitablecluster.id, hostid=host.id, value="result:fail")) #build cleanup list self.cleanup = [ self.service_offering, self.account, self.mock_checkhealth, self.mock_ping, self.mock_checkvirtualmachine, self.mock_pingtest ] self.cleanup = self.cleanup + self.mock_checkonhost_list