def restart_server(ibmc):
    """
    Function:
        Restart the server.
    Args:
        ibmc : Class that contains basic information about iBMC
    Returns:
        ret : Task result
            "result": True or False
            "msg": description for success or failure
    Raises:
         None
    Date: 2021/2/22 21:13
    """
    ret = {'result': True, 'msg': ''}
    ibmc.log_info(
        "Restart the server immediately for the configuration to take effect.")

    command = "forcerestart"
    restart_result = manage_power(ibmc, command)
    if not restart_result.get('result'):
        return restart_result

    # get power status
    for _ in range(100):
        time.sleep(2)
        pow_ret = get_power_status(ibmc)
        if "on" in pow_ret.get("msg").lower():
            log_msg = "Server restart successfully"
            set_result(ibmc.log_info, log_msg, True, ret)
            break
    else:
        log_error = "Server restart timed out. Please check the server status later."
        set_result(ibmc.log_error, log_error, False, ret)
    return ret
def check_status(ibmc):
    """
    Function:
        check ibmc version, power status and sp status
    Args:
        ibmc : Class that contains basic information about iBMC
    Returns:
        ret : Task result
            "result": True or False
            "msg": description for success or failure
    Raises:
        None
    Date: 2019/10/12 17:21
    """
    rets = {'result': True, 'msg': ''}
    r = ibmc.check_ibmc_version(BMC_EXPECT_VERSION)
    if r is False:
        log_msg = "ibmc version must be %s or above" % BMC_EXPECT_VERSION
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets

    ret = manage_power(ibmc, "PowerOff")
    if ret['result'] is True:
        ibmc.log_info("ForceOff system successfully!")
    else:
        log_msg = "ForceOff  system failed!"
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets
    time.sleep(5)
    for cnt_times in range(WAIT_POWEROFF):
        time.sleep(1)
        ret = get_power_status(ibmc)
        if "off" in ret['msg'].lower():
            break
        if cnt_times == WAIT_POWEROFF - 1:
            ibmc.log_error("power state is still on after 120 s")
    for cnt_times in range(WAIT_POWEROFF):
        time.sleep(1)
        try:
            ret = sp_api_get_status(ibmc)
            if ret is None:
                ibmc.log_error("get sp status return None ")
        except Exception as e:
            ibmc.log_error("get sp status exception exception is :%s" % str(e))
            continue
        if SP_STATUS_POWEROFF in ret:
            break
        if cnt_times == WAIT_POWEROFF - 1:
            ibmc.log_info("sp state is still on after 120 s")
    return rets
def prepare_update(ibmc):
    """
    Function:
        set sp and power for update
    Args:
        ibmc : Class that contains basic information about iBMC
    Returns:
        ret : Task result
            "result": True or False
            "msg": description for success or failure
    Raises:
         None
    Date: 2019/10/12 17:21
    """
    rets = {'result': True, 'msg': ''}
    # start sp to upgrade
    ret = sp_api_set_sp_service(ibmc, sp_enable=True)
    if ret['result'] is True:
        ibmc.log_info("set sp_service successfully!")
    else:
        time.sleep(CHECK_INTERVAL)
        ret = sp_api_set_sp_service(ibmc, sp_enable=True)
        if ret['result'] is True:
            ibmc.log_info("set sp service again successfully!")
        else:
            log_msg = "set sp service again failed!"
            set_result(ibmc.log_error, log_msg, False, rets)
            return rets
    # power on
    ret = manage_power(ibmc, "PowerOn")
    if ret['result'] is True:
        ibmc.log_info("power on system successfully!")
    else:
        log_msg = "power on  system failed!"
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets

    ret = wait_sp_start(ibmc)
    if ret['result'] is False:
        return ret
    return rets
Example #4
0
def ibmc_power_mannager_module(module):
    """
    Function:

    Args:
              ansible_module       (class):

    Returns:
        "result": False
        "msg": 'not run set power yet'
    Raises:
        Exception
    Examples:

    Author: xwh
    Date: 2019/10/9 20:30
    """
    with IbmcBaseConnect(module.params, log, report) as ibmc:
        ret = is_support_server(ibmc, SERVERTYPE)
        if ret['result']:
            ret = manage_power(ibmc, module.params["power_cmd"])
    return ret
Example #5
0
def deploy_os_by_sp_process(ibmc, os_img, os_config):
    """
    Function:
       deploy os by sp
    Args:
        ibmc:   IbmcBaseConnect Object
        os_img (str):os image path
        os_config(dict):os config dict
    Returns:
      ret {}
    Raises:
       Exception
    Examples:
       None
    Author:
    Date: 10/26/2019
    """
    # Check the BMC version
    r = ibmc.check_ibmc_version(BMC_EXPECT_VERSION)
    if r is False:
        rets = {}
        log_msg = "ibmc version must be %s or above" % BMC_EXPECT_VERSION
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets

        # Check the SP version
    r = ibmc.check_sp_version(SP_EXPECT_VERSION)
    if r is False:
        rets = {}
        log_msg = "sp version must be %s or above" % SP_EXPECT_VERSION
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets

        # get vmm is connected
    rets = vmm_is_connected(ibmc)
    ibmc.log_info("vmm connect stat is :" + str(rets))
    # if is connected,disconnect first
    if rets is True:
        ibmc.log_info("vmm is connected before,unmount ! ")
        un_mount_file(ibmc)
        time.sleep(CHECK_INTERVAL)

    # Power off the X86 system to make sure the SP is not running
    rets = manage_power(ibmc, "PowerOff")
    if rets['result'] is True:
        ibmc.log_info("Power off x86 System successfully!")
    else:
        log_msg = "Power off x86 System failed!"
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets

    time.sleep(10)

    # Set SP Finished, in order to avoid the impact of last result
    rets = set_sp_finished(ibmc)
    if rets['result'] is False:
        log_msg = "set sp result finished failed!please try it again! "
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets

    # parse ini file and get image config file
    rets = config_os(ibmc, os_config)
    if rets['result'] is False:
        manage_power(ibmc, "PowerOff")
        time.sleep(15)
        rets = config_os(ibmc, os_config)
        if rets['result'] is False:
            return rets

    # Set SP enabled
    rets = sp_api_set_sp_service(ibmc, sp_enable=True)
    if rets['result'] is True:
        ibmc.log_info("set sp_service  successfully!")
    else:
        time.sleep(CHECK_INTERVAL)
        rets = sp_api_set_sp_service(ibmc, sp_enable=True)
        if rets['result'] is True:
            ibmc.log_info("set sp service again successfully!")
        else:
            log_msg = "set sp service again failed!"
            set_result(ibmc.log_error, log_msg, False, rets)
            return rets

    # mount OS iso image
    r = mount_file(ibmc, os_img)
    if r is False:
        un_mount_file(ibmc)
        log_msg = "install OS failed! please check the OS image is exist or not!"
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets

    # Start the X86 system to make the os config task avaliable and install the OS.
    rets = manage_power(ibmc, "PowerOn")
    if rets['result'] is True:
        ibmc.log_info("power on the X86 system successfully!")
    else:
        un_mount_file(ibmc)
        log_msg = "install os failed! power on x86 System failed!"
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets
    # wait sp start  30 min time out
    for cnt in range(WAIT_SP_START_TIME):
        ret = sp_api_get_status(ibmc)
        if SP_STATUS_WORKING == ret:
            break
        if cnt >= WAIT_SP_START_TIME - 1:
            un_mount_file(ibmc)
            log_msg = "deploy failed , wait sp start timeout"
            set_result(ibmc.log_error, log_msg, False, rets)
            return rets
        time.sleep(CHECK_INTERVAL)
    # check the OS install result-
    try:
        loopInstall = 0
        while 1:
            loopInstall += 1
            status = check_deploy_os_result(ibmc)
            sp_status = status[u'sp_status']
            os_status = status[u'os_status']
            os_progress = status[u'os_progress']
            os_step = status[u'os_step']
            os_error_info = status[u'os_error_info']
            ibmc.log_info(
                "loopInstall: %s sp_status:%s, os_progress:%s, os_status:%s, os_step:%s, os_error_info:%s \n" % (
                    loopInstall, sp_status, os_progress, os_status, os_step, os_error_info))
            if sp_status == "Init":
                ibmc.log_info("SP is initial, please wait!")
                time.sleep(60)
            elif sp_status == "Finished" and os_status == "Successful" and os_progress == "100":
                log_msg = "os install successfully"
                set_result(ibmc.log_info, log_msg, True, rets)
                return rets
            elif sp_status == "Timeout" or sp_status == "Idle" or os_status == "Failed":
                log_msg = "os install failed ,Error info is: %s" % os_error_info
                set_result(ibmc.log_error, log_msg, False, rets)
                return rets
            else:
                time.sleep(60)
            if loopInstall >= 60:
                log_msg = "too many times loop, install OS has time out,please try it again!"
                set_result(ibmc.log_error, log_msg, False, rets)
                return rets
    except Exception as e:
        log_msg = "install OS failed! exception error info:%s" % str(e)
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets
    finally:
        un_mount_file(ibmc)
Example #6
0
def deploy_os_process(ibmc, config_dic):
    """
     Function:

     Args:
               ibmc       (class):
               config_dic    (dic): config dic

     Returns:
        "result": False
        "msg": 'not run server profile yet'
     Raises:
         None
     Examples:

     Author: xwh
     Date: 2019/10/9 20:30
    """
    log_msg = None
    rets = {"result": False, "msg": "failed"}
    if config_dic.get("os_img"):
        os_img = config_dic.get("os_img")
    else:
        raise Exception(" param os_img can not be None or empty")

    if config_dic.get("os_type"):
        os_type = config_dic.get("os_type")
    else:
        raise Exception(" param os_type can not be None or empty")

    if config_dic.get("service_cd_img"):
        service_img = config_dic.get("service_cd_img")
    else:
        raise Exception(" param service_img can not be None or empty")

    xml_start = '''<?xml version="1.0" encoding="UTF-8"?>
<osInstallInfo>'''
    xml_end = "</osInstallInfo>"
    xml_body = []
    xml_body.append(xml_start)
    if "Win" in os_type:
        if config_dic.get("win_os_name"):
            xml_body.append("   <ostype>%s</ostype>" %
                            config_dic.get("win_os_name"))
        else:
            log_msg = "param win_os_name can not be None or empty,when you install windows os"
            set_result(ibmc.log_error, log_msg, False, rets)
            return rets
    else:
        xml_body.append("   <ostype>%s</ostype>" % os_type)

    if config_dic.get("cd_key"):
        xml_body.append("   <cdkey>%s</cdkey>" % config_dic.get("cd_key"))
    else:
        xml_body.append("   <cdkey></cdkey>")

    if config_dic.get("password"):
        xml_body.append("   <password>%s</password>" %
                        config_dic.get("password"))
    else:
        xml_body.append("   <password></password>")

    if config_dic.get("hostname"):
        xml_body.append("   <hostname>%s</hostname>" %
                        config_dic.get("hostname"))
    else:
        xml_body.append("   <hostname></hostname>")

    if config_dic.get("language"):
        xml_body.append("   <language>%s</language>" %
                        config_dic.get("language"))
    else:
        if "Win" in os_type:
            log_msg = "param language can not be None or empty"
            set_result(ibmc.log_error, log_msg, False, rets)
            return rets
        xml_body.append("   <language></language>")

    if config_dic.get("org_name"):
        xml_body.append("   <orgname>%s</orgname>" %
                        config_dic.get("org_name"))
    else:
        xml_body.append("   <orgname></orgname>")

    if config_dic.get("position"):
        xml_body.append("   <position>%s</position>" %
                        config_dic.get("position"))
    else:
        xml_body.append("   <position></position>")

    partitions = config_dic.get("partitions")
    if partitions:
        xml_body.append("   <partitions>")
        for partition in partitions:
            if partition.get("partition"):
                xml_body.append("   <partition>%s</partition>" %
                                partition.get("partition"))
        xml_body.append("   </partitions>")
    else:
        xml_body.append("   <partitions></partitions>")

    if config_dic.get("timezone"):
        xml_body.append("   <timezone>%s</timezone>" %
                        config_dic.get("timezone"))
    else:
        xml_body.append("   <timezone></timezone>")

    if config_dic.get("mode"):
        xml_body.append("   <mode>%s</mode>" % config_dic.get("mode"))
    else:
        xml_body.append("   <mode></mode>")

    rpms = config_dic.get("rpms")
    if rpms:
        xml_body.append("   <rpms>")
        for rpm in rpms:
            if rpm.get("rpm"):
                xml_body.append("   <rpm>%s</rpm>" % rpm.get("rpm"))
        xml_body.append("   </rpms>")
    else:
        xml_body.append("   <rpms></rpms>")

    if config_dic.get("script"):
        xml_body.append("   <script>%s</script>" % config_dic.get("script"))
    else:
        xml_body.append("   <script></script>")

    if config_dic.get("software"):
        xml_body.append("   <software>%s</software>" %
                        config_dic.get("software"))
    else:
        xml_body.append("   <software></software>")

    xml_body.append(xml_end)

    config_file = "\n".join(xml_body)
    encode_cfg_str = base64.b64encode(config_file)

    # clear bmc info
    ret = clear_bmc_info_by_redfish(ibmc)
    if ret is not True:
        log_msg = " clear ibmc info file!"
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets

    # write operator and os_type to ibmc
    ret = write_bmc_info_by_redfish(ibmc, "operator:eSight;osType:" + os_type)
    if ret is not True:
        log_msg = "write operator and os_type to ibmc file!"
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets
    ret = read_bmc_info_by_redfish(ibmc)
    ibmc.log_info("read for bmc info:%s" % str(ret))

    # get vmm is connected
    ret = vmm_is_connected(ibmc)
    ibmc.log_info("vmm connect status:" + str(ret))

    # if is connected,disconnect first
    if ret is True:
        ibmc.log_info(" vmm is connect before,unmount ! ")
        un_mount_file(ibmc)
        time.sleep(5)

    # set CD as boot device
    ibmc.log_info("set boot device to CD! ")
    set_boot_dict = {
        'boot_target': "Cd",
        'boot_enabled': "Once",
        'boot_mode': "UEFI"
    }
    set_boot_device(ibmc, set_boot_dict)

    # make sure boot device is Cd
    get_boot_device(ibmc)

    # mount service iso
    r = mount_file(ibmc, service_img)
    if r is False:
        un_mount_file(ibmc)
        log_msg = "mount file failed ,please check the service image is exist or not!"
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets
    ret = get_power_status(ibmc)
    if "off" in ret["msg"].lower():
        ret = manage_power(ibmc, "powerOn")
    else:
        ret = manage_power(ibmc, "ForceRestart")
    if ret['result'] is True:
        ibmc.log_info("reboot system successfully!")
    else:
        log_msg = "install os failed! reboot system failed!"
        set_result(ibmc.log_error, log_msg, False, rets)
        un_mount_file(ibmc)
        return rets

    loop = 0
    loop_count = 0
    # make sure serviceCD is received operator and os_type, write successful info to BMC
    while 1:
        loop += 1
        time.sleep(20)

        if loop > MAX_LOOP_CNT:
            loop_count += 1
            if loop_count > MAX_RETRY_CNT:
                log_msg = "%s; step1 failed!" % log_msg
                set_result(ibmc.log_error, log_msg, False, rets)
                un_mount_file(ibmc)
                return rets
            # clear bmc info
            try:
                ret = clear_bmc_info_by_redfish(ibmc)
                if ret is not True:
                    log_msg = "clear Bmc Info failed ,step1 failed!"
                    set_result(ibmc.log_error, log_msg, False, rets)
                    un_mount_file(ibmc)
                    return rets
                # write operator and os_type to ibmc
                ret = write_bmc_info_by_redfish(
                    ibmc, "operator:eSight;osType:" + os_type)
                if ret is not True:
                    log_msg = "write Bmc Info failed ,step1 failed!"
                    set_result(ibmc.log_error, log_msg, False, rets)
                    un_mount_file(ibmc)
                    return rets
                set_boot_dict = {
                    'boot_target': "Cd",
                    'boot_enabled': "Once",
                    'boot_mode': "Legacy"
                }
                set_boot_device(ibmc, set_boot_dict)
            except Exception as e:
                ibmc.log_Info("write bmc info exception %s" % str(e))
                time.sleep(100)
                continue
            try:
                ret = get_power_status(ibmc)
                if "off" in ret["msg"].lower():
                    ret = manage_power(ibmc, "powerOn")
                else:
                    ret = manage_power(ibmc, "ForceRestart")
            except Exception as e:
                ibmc.log_info("manger power exception ,exception is : %s" %
                              str(e))
                continue
            ibmc.log_info("reboot system again %s " % str(ret))
            loop = 0
        try:
            log_msg = ""
            ret = read_bmc_info_by_redfish(ibmc)
            ibmc.log_info(" loop: %s ret:%s" % (str(loop), str(ret)))
            if ret.find("progress:step1;result:successful") >= 0:
                ibmc.log_info("progress:step1;result:successful")
                break
            if ret.find("result:failed") >= 0:
                ibmc.log_info("progress:step1;result:failed")
                info_group = re.match(r".*result:failed;errorCode:(\d+).*",
                                      ret)
                if info_group:
                    if SERVER_CD_ERROR_CODE.get(str(info_group.group(1))):
                        log_msg = SERVER_CD_ERROR_CODE.get(
                            str(info_group.group(1)))
                    else:
                        log_msg = "unknow error, error code: %s " % info_group.group(
                            1)
                else:
                    log_msg = "unknow error; ret:%s" % str(ret)
                loop_count = MAX_RETRY_CNT
                loop = MAX_LOOP_CNT
        except Exception as e:
            ibmc.log_info(" read_bmc_info_by_redfish exception :%s" % str(e))
            continue

            # start cp config file info to BMC
    ibmc.log_info("start cp config file")
    ret = clear_bmc_info_by_redfish(ibmc)
    if ret is not True:
        log_msg = "clear Bmc Info failed ,step1 failed!"
        set_result(ibmc.log_error, log_msg, False, rets)
        un_mount_file(ibmc)
        return rets
    ret = write_bmc_info_by_redfish(ibmc, "oscfg:start")
    if ret is not True:
        log_msg = "write Bmc Info failed ,step1 failed!"
        set_result(ibmc.log_error, log_msg, False, rets)
        un_mount_file(ibmc)
        return rets

    try:
        loop_write_file = 0
        while 1:
            loop_write_file += 1
            ibmc.log_info("loop_write_file: %s" % str(loop_write_file))
            loop_next = 0
            while 1:
                loop_next += 1
                ibmc.log_info("loop_next: %s" % str(loop_next))
                try:
                    ret = read_bmc_info_by_redfish(ibmc)
                except Exception as e:
                    ibmc.log_info("Exception: %s" % str(e))
                    ret = ""
                if ret.find("oscfg:next") >= 0:
                    ibmc.log_info("find oscfg:next!!!")
                    break
                if loop_next >= 20:
                    log_msg = " write os config too long,failed! "
                    set_result(ibmc.log_error, log_msg, False, rets)
                    un_mount_file(ibmc)
                    return rets
                time.sleep(10)
            if len(encode_cfg_str) > EACH_SEND_MSG_LEN:
                new_str = encode_cfg_str[0:EACH_SEND_MSG_LEN]
                encode_cfg_str = encode_cfg_str[EACH_SEND_MSG_LEN:]
            else:
                new_str = encode_cfg_str
                encode_cfg_str = ''
            if len(new_str) == EACH_SEND_MSG_LEN:
                ibmc.log_info("equal EACH_SEND_MSG_LEN")
                ret = clear_bmc_info_by_redfish(ibmc)
                if ret is not True:
                    rets['result'] = False
                    rets['msg'] = ret
                    un_mount_file(ibmc)
                    return rets
                ret = write_bmc_info_by_redfish(ibmc, "oscfg:" + new_str)
                if ret is not True:
                    rets['result'] = False
                    rets['msg'] = ret
                    un_mount_file(ibmc)
                    return rets
            else:
                ibmc.log_info("not equal EACH_SEND_MSG_LEN")
                ret = clear_bmc_info_by_redfish(ibmc)
                if ret is not True:
                    rets['result'] = False
                    rets['msg'] = ret
                    un_mount_file(ibmc)
                    return rets
                ret = write_bmc_info_by_redfish(ibmc, "oscfg:%s:end" % new_str)
                if ret is not True:
                    rets['result'] = False
                    rets['msg'] = ret
                    un_mount_file(ibmc)
                    return rets
                break
            if loop_write_file >= 50:
                log_msg = " write os config too long,failed! "
                set_result(ibmc.log_error, log_msg, False, rets)
                un_mount_file(ibmc)
                return rets
    except Exception as e:
        log_msg = "  write config failed! error info: %s " % str(e)
        set_result(ibmc.log_error, log_msg, False, rets)
        un_mount_file(ibmc)
        return rets

    loop_step2 = 0
    while 1:
        loop_step2 += 1
        time.sleep(5)
        if loop_step2 > MAX_LOOP_CNT:
            log_msg = "progress:setp2 failed!"
            set_result(ibmc.log_error, log_msg, False, rets)
            un_mount_file(ibmc)
            return rets
        try:
            ret = read_bmc_info_by_redfish(ibmc)
        except Exception as e:
            ibmc.log_info("step2  exception: %s" % str(e))
            continue
        if ret.find("progress:step2;result:successful;errorCode:0") >= 0:
            ibmc.log_info("progress:step2;result:successful;")
            break
        elif ret.find("result:failed") != -1:
            info_group = re.match(r".*result:failed;errorCode:(\d+).*", ret)
            if info_group:
                if SERVER_CD_ERROR_CODE.get(str(info_group.group(1))):
                    log_msg = SERVER_CD_ERROR_CODE.get(str(
                        info_group.group(1)))
                else:
                    log_msg = "unknow error,error code: %s" % info_group.group(
                        1)
            else:
                log_msg = "unknow error; ret:%s" % str(ret)
            log_msg = "%s; install OS %s  failed! " % (log_msg, os_type)
            set_result(ibmc.log_error, log_msg, False, rets)
            return rets
        else:
            ibmc.log_info("loop_step2:%s ret:%s" % (str(loop_step2), str(ret)))

    # make sure the service ISO is disconnect!
    time.sleep(15)
    ret = vmm_is_connected(ibmc)
    ibmc.log_info("os is connected:%s" % str(ret))
    if ret is True:
        un_mount_file(ibmc)
    # make sure OS image is mounted!!!!
    r = mount_file(ibmc, os_img)
    if r is False:
        un_mount_file(ibmc)
        log_msg = "install OS %s  failed! please check the OS image is exist or not!" % os_type
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets

    ibmc.log_info("mount os image result: %s" % str(ret))
    time.sleep(20)

    ret = clear_bmc_info_by_redfish(ibmc)
    if ret is not True:
        set_result(ibmc.log_error, str(ret), False, rets)
        un_mount_file(ibmc)
        return rets
    ret = write_bmc_info_by_redfish(ibmc, "osinstall:start")
    if ret is not True:
        set_result(ibmc.log_error, str(ret), False, rets)
        un_mount_file(ibmc)
        return rets
    ibmc.log_info("start install os")

    try:
        loop_install = 0
        while 1:
            loop_install += 1
            time.sleep(100)
            if loop_install >= MAX_LOOP_CNT:
                log_msg = "time out; install OS %s  failed! " % os_type
                set_result(ibmc.log_error, log_msg, False, rets)
                return rets
            try:
                log_msg = ""
                ret = read_bmc_info_by_redfish(ibmc)
            except Exception as e:
                ibmc.log_info("read bmc info exception ! exception  is:%s" %
                              str(e))
                continue
            ibmc.log_info("loop_install: %s install os: %s" %
                          (str(loop_install), str(ret)))

            if ret.find("result:5") != -1:
                log_msg = "install OS %s  successfully! " % os_type
                set_result(ibmc.log_info, log_msg, True, rets)
                return rets
            elif ret.find("result:failed") != -1:
                info_group = re.match(r".*result:failed;errorCode:(\d+).*",
                                      ret)
                if info_group:
                    if SERVER_CD_ERROR_CODE.get(str(info_group.group(1))):
                        log_msg = SERVER_CD_ERROR_CODE.get(
                            str(info_group.group(1)))
                    else:
                        log_msg = "unknow error error code: %s " % info_group.group(
                            1)
                else:
                    log_msg = "unknow error; ret:%s" % str(ret)
                log_msg = "%s; install OS %s  failed! " % (log_msg, os_type)
                set_result(ibmc.log_error, log_msg, False, rets)
                return rets
            else:
                continue
    except Exception as e:
        log_msg = "install OS %s  failed! error info: %s  " % (os_type, str(e))
        set_result(ibmc.log_error, log_msg, False, rets)
        return rets
    finally:
        un_mount_file(ibmc)