Beispiel #1
0
    def wait_until_erasure_pool_deleted(self, *args, **kwargs):
        banner("PCC.Ceph Wait Until Erasure Pool Deleted")

        self._load_kwargs(kwargs)

        if self.id == None:
            # pool doesn't exist, nothing to wait for
            return "OK"
        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e

        Id_found_in_list_of_pools = True
        timeout = time.time() + PCCSERVER_TIMEOUT

        while Id_found_in_list_of_pools == True:
            Id_found_in_list_of_pools = False
            response = pcc.get_erasure_ceph_pools(conn)
            for pool in get_response_data(response):
                if str(pool['id']) == str(self.id):
                    name = pool["name"]
                    Id_found_in_list_of_pools = True
            if time.time() > timeout:
                raise Exception(
                    "[PCC.Wait Until Erasure Pool Deleted] Timeout")
            if Id_found_in_list_of_pools:
                trace(
                    "Waiting until node: %s is deleted. Timeout in %.1f seconds."
                    % (name, timeout - time.time()))
                time.sleep(5)
            else:
                trace("Erasure Pool deleted!")
        return "OK"
Beispiel #2
0
    def wait_until_erasure_pool_ready(self, *args, **kwargs):
        banner("PCC.Ceph Wait Until Erasure Pool Ready")
        self._load_kwargs(kwargs)

        if self.name == None:
            return None
        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e

        pool_ready = False
        timeout = time.time() + PCCSERVER_TIMEOUT

        while pool_ready == False:
            response = pcc.get_erasure_ceph_pools(conn)

            for data in get_response_data(response):
                print("Data to look into: {}".format(data))
                print("Name to look: {}".format(self.name))
                print("Name found in data: {}".format(str(data['name'])))
                if str(data['name']).lower() == str(self.name).lower():
                    print(str(data))
                    if data['deploy_status'] == "completed":
                        pool_ready = True
                    if data['deploy_status'] == "failed":
                        return "Error"

            if time.time() > timeout:
                raise Exception(
                    "[PCC.Ceph Wait Until Erasure Pool Ready] Timeout")
            trace("  Waiting until erasure pool : %s is Ready, currently: %s" %
                  (data['name'], data['progressPercentage']))
            time.sleep(5)
        return "OK"
Beispiel #3
0
    def get_multiple_erasure_pool_details_for_fs(self, *args, **kwargs):
        self._load_kwargs(kwargs)
        banner("PCC.Ceph Get Erasure Pool Details For FS")

        temp = dict()
        temp_list = []

        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e

        response = pcc.get_erasure_ceph_pools(conn)['Result']['Data']
        for val in eval(str(self.name)):
            for data in response:
                if str(data['name']) == str(val):
                    temp["id"] = data["id"]
                    temp["name"] = data["name"]
                    temp["size"] = data["size"]
                    temp["tags"] = ["tags"]
                    temp["ceph_cluster_id"] = data["ceph_cluster_id"]
                    temp["pool_type"] = data["pool_type"]
                    temp["quota"] = data["quota"]
                    temp["quota_unit"] = data["quota_unit"]
            if len(temp) != 0:
                temp_list.append(temp)
        return temp_list
Beispiel #4
0
    def get_erasure_ceph_all_pools_data(self, *args, **kwargs):
        self._load_kwargs(kwargs)
        pool_id = None
        banner("PCC.Ceph Get All Erasure Pools Data")

        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e

        response = get_response_data(pcc.get_erasure_ceph_pools(conn))
        return response
Beispiel #5
0
    def delete_all_erasure_pools(self, *args, **kwargs):
        self._load_kwargs(kwargs)
        banner("PCC.Ceph Delete All Erasure Pool")

        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e

        response = pcc.get_erasure_ceph_pools(conn)
        for data in get_response_data(response):
            response = pcc.delete_erasure_ceph_pool_by_id(
                conn, str(data['id']))
            status = self.wait_until_erasure_pool_deleted(id=data['id'])
            if status != "OK":
                print("{} deletion failed".format(data['name']))
                return "Error"
        return "OK"
Beispiel #6
0
def get_erasure_ceph_pool_id_by_name(conn: dict, Name: str) -> int:
    """
    Get Id of Ceph Pool with matching Name from PCC
    [Args]
        (dict) conn: Connection dictionary obtained after logging in
        (str) Name: Name of Ceph Pool
    [Returns]
        (int) Id: Id of the matchining tenant, or
            None: if no match found, or
        (dict) Error response: If Exception occured
    """
    try:
        list_of_erasure_ceph_pools = pcc.get_erasure_ceph_pools(
            conn)['Result']['Data']
        for ceph_pool in list_of_erasure_ceph_pools:
            if str(ceph_pool['name']) == str(Name):
                return ceph_pool['id']
        return None
    except Exception as e:
        return {"Error": str(e)}
Beispiel #7
0
    def get_erasure_pool_details_for_fs(self, *args, **kwargs):
        self._load_kwargs(kwargs)
        banner("PCC.Ceph Get Erasure Pool Details For FS")

        temp = dict()

        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e

        response = pcc.get_erasure_ceph_pools(conn)['Result']['Data']
        print("Response:-" + str(response))
        for data in response:
            if str(data['name']) == str(self.name):
                temp["id"] = data["id"]
                temp["name"] = data["name"]
                temp["size"] = data["size"]
                temp["tags"] = []
                temp["ceph_cluster_id"] = data["ceph_cluster_id"]
                temp["pool_type"] = data["pool_type"]
                temp["quota"] = data["quota"]
                temp["quota_unit"] = data["quota_unit"]
        return temp