def test_vag_per_host_5(self):
        hosts = list_hosts(self.apiClient, clusterid=self.cluster.id)

        self.assertTrue(
            len(hosts) >= 2, "There needs to be at least two hosts.")

        unique_vag_ids = self._get_unique_vag_ids(hosts)

        self.assertTrue(
            len(hosts) == len(unique_vag_ids),
            "To run this test, each host should be in its own VAG.")

        primarystorage = self.testdata[TestData.primaryStorage]

        primary_storage = StoragePool.create(
            self.apiClient,
            primarystorage,
            scope=primarystorage[TestData.scope],
            zoneid=self.zone.id,
            provider=primarystorage[TestData.provider],
            tags=primarystorage[TestData.tags],
            capacityiops=primarystorage[TestData.capacityIops],
            capacitybytes=primarystorage[TestData.capacityBytes],
            hypervisor=primarystorage[TestData.hypervisor])

        self.cleanup.append(primary_storage)

        self.virtual_machine = VirtualMachine.create(
            self.apiClient,
            self.testdata[TestData.virtualMachine],
            accountid=self.account.name,
            zoneid=self.zone.id,
            serviceofferingid=self.compute_offering.id,
            templateid=self.template.id,
            domainid=self.domain.id,
            startvm=True)

        root_volume = self._get_root_volume(self.virtual_machine)

        sf_account_id = sf_util.get_sf_account_id(
            self.cs_api, self.account.id, primary_storage.id, self,
            TestAddRemoveHosts._sf_account_id_should_be_non_zero_int_err_msg)

        sf_volumes = sf_util.get_active_sf_volumes(self.sfe, sf_account_id)

        sf_volume = sf_util.check_and_get_sf_volume(sf_volumes,
                                                    root_volume.name, self)

        sf_vag_ids = sf_util.get_vag_ids(self.cs_api, self.cluster.id,
                                         primary_storage.id, self)

        sf_util.check_vags(sf_volume, sf_vag_ids, self)

        host = Host(hosts[0].__dict__)

        host_iqn = self._get_host_iqn(host)

        all_vags = sf_util.get_all_vags(self.sfe)

        host_vag = self._get_host_vag(host_iqn, all_vags)

        self.assertTrue(host_vag != None, "The host should be in a VAG.")

        host.delete(self.apiClient)

        sf_volumes = sf_util.get_active_sf_volumes(self.sfe, sf_account_id)

        sf_volume = sf_util.check_and_get_sf_volume(sf_volumes,
                                                    root_volume.name, self)

        sf_util.check_vags(sf_volume, sf_vag_ids, self)

        all_vags = sf_util.get_all_vags(self.sfe)

        host_vag = self._get_host_vag(host_iqn, all_vags)

        self.assertTrue(host_vag == None, "The host should not be in a VAG.")

        details = {
            TestData.username: "******",
            TestData.password: "******",
            TestData.url: "http://" + host.ipaddress,
            TestData.podId: host.podid,
            TestData.zoneId: host.zoneid
        }

        host = Host.create(self.apiClient,
                           self.cluster,
                           details,
                           hypervisor=host.hypervisor)

        self.assertTrue(isinstance(host, Host), "'host' is not a 'Host'.")

        hosts = list_hosts(self.apiClient, clusterid=self.cluster.id)

        unique_vag_ids = self._get_unique_vag_ids(hosts)

        self.assertTrue(
            len(hosts) == len(unique_vag_ids) + 1,
            "There should be one more host than unique VAG.")
Esempio n. 2
0
      for host in hosts:
        print "host name={}, id={}".format(host.name, host.id)
        if host.type == 'Routing':
          if host.resourcestate == 'PrepareForMaintenance' \
              or host.resourcestate == 'Maintenance':
            print "delete host"
            cmd = deleteHost.deleteHostCmd()
            cmd.id = host.id
#            cmd.forced = 'True'
            apiClient.deleteHost(cmd)
          else:
            print "Delete host"
            h = Host(tmp_dict)
#            h.forced = 'True'
            h.id = host.id
            h.delete(apiClient)

    clusters = Cluster.list(apiClient)
    if clusters:
      for cluster in clusters:
        print "cluster name={}, id={}".format(cluster.name, cluster.id)
        if cluster.allocationstate == 'Enabled':
          print "Delete Cluster"
          c = Cluster(tmp_dict)
          c.id = cluster.id
          c.delete(apiClient)

    ipranges = PublicIpRange.list(apiClient)
    if ipranges:
      for iprange in ipranges:
        print "ip range name={}, id={}".format(iprange.name, iprange.id)
Esempio n. 3
0
    def test_vag_per_host_5(self):
        hosts = list_hosts(self.apiClient, clusterid=self.cluster.id)

        self.assertTrue(
            len(hosts) >= 2,
            "There needs to be at least two hosts."
        )

        unique_vag_ids = self._get_unique_vag_ids(hosts)

        self.assertTrue(len(hosts) == len(unique_vag_ids), "To run this test, each host should be in its own VAG.")

        primarystorage = self.testdata[TestData.primaryStorage]

        primary_storage = StoragePool.create(
            self.apiClient,
            primarystorage,
            scope=primarystorage[TestData.scope],
            zoneid=self.zone.id,
            provider=primarystorage[TestData.provider],
            tags=primarystorage[TestData.tags],
            capacityiops=primarystorage[TestData.capacityIops],
            capacitybytes=primarystorage[TestData.capacityBytes],
            hypervisor=primarystorage[TestData.hypervisor]
        )

        self.cleanup.append(primary_storage)

        self.virtual_machine = VirtualMachine.create(
            self.apiClient,
            self.testdata[TestData.virtualMachine],
            accountid=self.account.name,
            zoneid=self.zone.id,
            serviceofferingid=self.compute_offering.id,
            templateid=self.template.id,
            domainid=self.domain.id,
            startvm=True
        )

        root_volume = self._get_root_volume(self.virtual_machine)

        sf_account_id = sf_util.get_sf_account_id(self.cs_api, self.account.id, primary_storage.id, self, TestAddRemoveHosts._sf_account_id_should_be_non_zero_int_err_msg)

        sf_volumes = sf_util.get_active_sf_volumes(self.sfe, sf_account_id)

        sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, root_volume.name, self)

        sf_vag_ids = sf_util.get_vag_ids(self.cs_api, self.cluster.id, primary_storage.id, self)

        sf_util.check_vags(sf_volume, sf_vag_ids, self)

        host = Host(hosts[0].__dict__)

        host_iqn = self._get_host_iqn(host)

        all_vags = sf_util.get_all_vags(self.sfe)

        host_vag = self._get_host_vag(host_iqn, all_vags)

        self.assertTrue(host_vag != None, "The host should be in a VAG.")

        host.delete(self.apiClient)

        sf_volumes = sf_util.get_active_sf_volumes(self.sfe, sf_account_id)

        sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, root_volume.name, self)

        sf_util.check_vags(sf_volume, sf_vag_ids, self)

        all_vags = sf_util.get_all_vags(self.sfe)

        host_vag = self._get_host_vag(host_iqn, all_vags)

        self.assertTrue(host_vag == None, "The host should not be in a VAG.")

        details = {
            TestData.username: "******",
            TestData.password: "******",
            TestData.url: "http://" + host.ipaddress,
            TestData.podId : host.podid,
            TestData.zoneId: host.zoneid
        }

        host = Host.create(
            self.apiClient,
            self.cluster,
            details,
            hypervisor=host.hypervisor
        )

        self.assertTrue(
            isinstance(host, Host),
            "'host' is not a 'Host'."
        )

        hosts = list_hosts(self.apiClient, clusterid=self.cluster.id)

        unique_vag_ids = self._get_unique_vag_ids(hosts)

        self.assertTrue(len(hosts) == len(unique_vag_ids) + 1, "There should be one more host than unique VAG.")