def tearDownClass(cls):
     try:
         zoneList = Zone.list(cls.apiclient, id=cls.zone.id)
         if zoneList[0].allocationstate.lower() == DISABLED.lower():
             cmd = updateZone.updateZoneCmd()
             cmd.id = zoneList[0].id
             cmd.allocationstate = ENABLED
             cls.apiclient.updateZone(cmd)
         cleanup_resources(cls.apiclient, cls._cleanup)
     except Exception as e:
         raise Exception("Warning: Exception during cleanup : %s" % e)
 def tearDownClass(cls):
     try:
         for hostid in cls.disabledHosts:
             hosts = Host.list(cls.apiclient, id=hostid)
             assert (
                 validateList(hosts)[0] == PASS
             ), "hosts\
                     list validation failed"
             if hosts[0].resourcestate.lower() == DISABLED.lower():
                 cmd = updateHost.updateHostCmd()
                 cmd.id = hostid
                 cmd.resourcestate = ENABLED
                 cmd.allocationstate = ENABLE
                 cls.apiclient.updateHost(cmd)
         cleanup_resources(cls.apiclient, cls._cleanup)
     except Exception as e:
         raise Exception("Warning: Exception during cleanup : %s" % e)
    def tearDownClass(cls):
        try:
            clusterList = Cluster.list(cls.apiclient, id=cls.cluster.id)
            if clusterList[0].allocationstate.lower() == DISABLED.lower():
                cmd = updateCluster.updateClusterCmd()
                cmd.id = clusterList[0].id
                cmd.allocationstate = ENABLED
                cls.apiclient.updateCluster(cmd)

            if clusterList[0].managedstate.lower() == "unmanaged":
                cmd = updateCluster.updateClusterCmd()
                cmd.id = clusterList[0].id
                cmd.managedstate = "Managed"
                cls.apiclient.updateCluster(cmd)

            cleanup_resources(cls.apiclient, cls._cleanup)
        except Exception as e:
            raise Exception("Warning: Exception during cleanup : %s" % e)