Example #1
0
    def ceph_rgw_verify_be_creation(self, **kwargs):
        banner("PCC.Ceph Rgw Verify BE Creation")
        self._load_kwargs(kwargs)

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

        ceph_be_cmd = "sudo ceph -s"
        wait_time = 400

        for i in range(4):
            time.sleep(100)
            wait_time -= 100
            print("wait time left for RGW backend check {}s".format(wait_time))
            trace("wait time left for RGW backend check {}s".format(wait_time))
            failed_chk = []
            success_chk = []
            for ip in eval(str(self.targetNodeIp)):
                host_name = easy.get_host_name_by_ip(conn, ip)
                cmd_rgw = "sudo systemctl status ceph-radosgw@rgw.{}.rgw0".format(
                    host_name)
                ceph_check = cli_run(ip, self.user, self.password, ceph_be_cmd)
                rgw_check = cli_run(ip, self.user, self.password, cmd_rgw)
                print("=========== ceph_check output is: {} \n==============".
                      format(str(ceph_check)))
                print("=========== rgw_check output is: {} \n==============".
                      format(str(rgw_check)))
                if re.search("rgw", str(ceph_check)) and re.search(
                        "running", str(rgw_check)):
                    success_chk.append(ip)

                else:
                    failed_chk.append(ip)

                if len(success_chk) == len(eval(str(self.targetNodeIp))):
                    print("Backend verification successfuly done for : {}".
                          format(success_chk))
                    return "OK"
        if wait_time <= 0:
            print("Rgw Check: " + str(rgw_check))
            print("Ceph Rgw Check: " + str(ceph_check))

        if failed_chk:
            print("Rgw service are down for {}".format(failed_chk))
            return "Error"
        else:
            return "OK"
    def operation_to_perform_on_all_ceph_daemons(self, *args, **kwargs):
        banner("PCC.Operation to perform on all CEPH daemons")
        self._load_kwargs(kwargs)
        print("Kwargs are: {}".format(kwargs))
        try:
            try:
                conn = BuiltIn().get_variable_value("${PCC_CONN}")
            except Exception as e:
                raise e
            host_name = easy.get_host_name_by_ip(conn, self.hostip)
            if "operation_to_perform" not in kwargs:
                self.operation_to_perform = None

            if self.operation_to_perform:
                cmd_list = [
                    "sudo systemctl {} ceph-mon@{}",
                    "sudo systemctl {} ceph-mds@{}",
                    "sudo systemctl {} ceph-mgr@{}"
                ]
                cmd_with_host_name = [
                    x.format(self.operation_to_perform.lower(), host_name)
                    for x in cmd_list
                ]
            else:
                return "Please provide a valid operation to perform. Choose from 'Start', 'Stop', 'Status'"
            for cmd_run in cmd_with_host_name:
                print("Command is: {}".format(cmd_run))
                status = cli_run(cmd=cmd_run,
                                 host_ip=self.hostip,
                                 linux_user=self.user,
                                 linux_password=self.password)
                print("status: {}".format(status))
                time.sleep(2)
                trace("Command: {} executed successfully".format(cmd_run))

            return "OK"

        except Exception as e:
            trace(
                "Error in Operation to perform on_all_ceph_daemons: {}".format(
                    e))