示例#1
0
def start_imc_iod_snapshot(handle, iso_share_ip, iso_share, iso_share_type, username, password, timeout, remote_share_ip, remote_share_path, remote_share_file, remote_share_type, remote_share_username, remote_share_password, admin_state="trigger", dump_xml=None):
    """ This method starts the IOD Snapshot."""
    #dn = "sys/iod/snapshotStart"
    #dn = ImcUtils.make_dn([ManagedObject(NamingId.TOP_SYSTEM).make_rn(), ManagedObject(NamingId.IOD_CONTROLLER).make_rn(), ManagedObject(NamingId.IOD_SNAPSHOT_START).make_rn()])
    dn = CoreUtils.make_dn([CoreUtils.make_rn(NamingId.TOP_SYSTEM), CoreUtils.make_rn(NamingId.IOD_CONTROLLER), CoreUtils.make_rn(NamingId.IOD_SNAPSHOT_START)])
    iod_snapshot = ManagedObject(NamingId.IOD_SNAPSHOT_START)
    iod_snapshot.dn = dn
    #iod_snapshot.AdminState = iod_snapshot.CONST_ADMIN_STATE_TRIGGER
    iod_snapshot.AdminState = admin_state
    iod_snapshot.IsoShare = iso_share
    iod_snapshot.IsoShareIp = iso_share_ip
    iod_snapshot.IsoShareType = iso_share_type
    iod_snapshot.Username = username
    iod_snapshot.Password = password
    iod_snapshot.TimeOut = timeout
    iod_snapshot.RemoteShareIp = remote_share_ip
    iod_snapshot.RemoteSharePath = remote_share_path
    iod_snapshot.RemoteShareFile = remote_share_file
    iod_snapshot.RemoteShareType = remote_share_type
    iod_snapshot.RemoteShareUsername = remote_share_username
    iod_snapshot.RemoteSharePassword = remote_share_password

    in_config = ConfigConfig()
    in_config.add_child(iod_snapshot)
    ccm = handle.config_conf_mo(dn=dn, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
    if ccm.error_code != 0:
        raise ImcException(ccm.error_code, ccm.error_descr)

    return ccm.OutConfig.child
示例#2
0
def update_imc_firmware(handle, in_mo, admin_state, protocol, share_type, remote_server, remote_path, username, password, secure_boot=None, dump_xml=None):
    """
    Uploads the Firmware image to IMC Server.

    - in_mo            specifies the respective Managed Object to upload image.
    - remoteserver        specifies the IP address of host containing firmware image.
    - username        specifies the Username login credential of host containing firmware image.
    - password        specifies the Password login credential of host containing firmware image.
    - remotepath        specifies the path of firmware image on remoteserver.
    - protocol            specifies the protocol used for transferring the file to remotehost.
    - sharetype            specifies the share type.
    - admin_state        specifies the admin state.
    """
    from ImcMos import FirmwareUpdatable
    dn = None

    if in_mo != None:
        if str(ImcUtils.word_u(in_mo.class_id)) == "FirmwareUpdatable":
            dn = in_mo.get_attr("Dn")
        elif str(ImcUtils.word_u(in_mo.class_id)) == "BiosUnit":
            dn = CoreUtils.make_dn([in_mo.get_attr("Dn"), CoreUtils.make_rn("FirmwareUpdatable")])
        elif str(ImcUtils.word_u(in_mo.class_id)) == "MgmtController":
            dn = CoreUtils.make_dn([in_mo.get_attr("Dn"), CoreUtils.make_rn("FirmwareUpdatable")])
        else:
            raise ImcValidationException("Please provide correct Managed Object. Valid MOs <FirmwareUpdatable or BiosUnit or MgmtController")
    else:
        raise ImcValidationException("Please provide correct Managed Object. Valid MOs <FirmwareUpdatable or BiosUnit or MgmtController")

#        if updatetype == FirmwareUpdatable.CONST_TYPE_BLADE_CONTROLLER:
#            dn = "sys/rack-unit-1/mgmt/fw-updatable"
#        if updatetype == FirmwareUpdatable.CONST_TYPE_BLADE_BIOS:
#            dn = "sys/rack-unit-1/bios/fw-updatable"
#        if updatetype == FirmwareUpdatable.CONST_TYPE_ADAPTOR:
#            dn = "sys/rack-unit-1/adaptor-1/mgmt/fw-updatable"

    firmware_updater = ManagedObject(NamingId.FIRMWARE_UPDATABLE)
    firmware_updater.dn = dn
    firmware_updater.Status = Status.MODIFIED
    #firmware_updater.AdminState = FirmwareUpdatable.CONST_ADMIN_STATE_TRIGGER
    firmware_updater.AdminState = admin_state
    firmware_updater.Protocol = protocol
    firmware_updater.RemoteServer = remote_server
    firmware_updater.RemotePath = remote_path
    firmware_updater.User = username
    firmware_updater.Pwd = password
    firmware_updater.Type = share_type
    firmware_updater.SecureBoot = secure_boot

    in_config = ConfigConfig()
    in_config.add_child(firmware_updater)

    ccm = handle.config_conf_mo(dn=dn, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)

    if ccm.error_code != 0:
        raise ImcException(ccm.error_code, ccm.error_descr)

    return ccm.OutConfig.child
示例#3
0
def import_imc_backup(handle, remotehost, remotefile, protocol, username, password, passphrase=None, dump_xml=None):
    """
    Imports backUp.
    This operation will upload the IMC backup taken earlier via GUI or backup_imc operation.
    User can perform an import while the system is up and running.

    - remotehost    specifies the host where username need to download the backup.
    - remotefile    specifies the path on remotehost where username need to download the backup.
    - protocol        specifies the protocol used for transferring the file to remotehost.
    - username        specifies the username credential to login to remotehost.
    - password        specifies the password credential to login to remotehost.
    """
    from ImcMos import MgmtImporter

    dn = CoreUtils.make_dn([CoreUtils.make_rn(NamingId.TOP_SYSTEM), CoreUtils.make_rn(NamingId.MGMT_IMPORTER)])
    mgmt_importer = ManagedObject(NamingId.MGMT_IMPORTER)
    mgmt_importer.dn = dn
    mgmt_importer.AdminState = MgmtImporter.CONST_ADMIN_STATE_ENABLED
    mgmt_importer.Hostname = remotehost
    mgmt_importer.User = username
    mgmt_importer.Pwd = password
    mgmt_importer.RemoteFile = remotefile
    mgmt_importer.Proto = protocol
    mgmt_importer.AdminState = MgmtImporter.CONST_ADMIN_STATE_ENABLED
    mgmt_importer.Status = Status.MODIFIED
    mgmt_importer.Passphrase = passphrase
    
    in_config = ConfigConfig()
    in_config.add_child(mgmt_importer)
    ccm = handle.config_conf_mo(dn=dn, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
    if ccm.error_code != 0:
        raise ImcException(ccm.error_code, ccm.error_descr)

    time.sleep(10) #Wait for 10 seconds before start checking.
    status = False
    while True:
        cr_dn = handle.config_resolve_dn(dn, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
        if cr_dn.error_code == 0:
            if cr_dn.OutConfig.get_child_count() > 0:
                for cimc_backup in cr_dn.OutConfig.child:
                    if cimc_backup.AdminState == MgmtImporter.CONST_ADMIN_STATE_DISABLED:
                        if cimc_backup.FsmStageDescr == "Completed successfully":
                            status = True
                        if cimc_backup.FsmStageDescr == "Error":
                            raise ImcValidationException("Failed to import the CIMC configuration file." + "Error Code: " + cimc_backup.FsmRmtInvErrCode + " Error Description: " + cimc_backup.FsmRmtInvErrDescr)
            else:
                raise ImcValidationException("Failed to  import the CIMC configuration file.")
        else:
            raise ImcException(cr_dn.error_code, cr_dn.error_descr)
        if status:
            break

    return ccm.OutConfig.child
示例#4
0
def stop_imc_iod_snapshot(handle, timeout, admin_state="trigger", dump_xml=None):
    """ This method stops the IOD Snapshot."""
    #dn = "sys/iod/snapshotStart"
    #dn = ImcUtils.make_dn([ManagedObject(NamingId.TOP_SYSTEM).make_rn(), ManagedObject(NamingId.IOD_CONTROLLER).make_rn(), ManagedObject(NamingId.IOD_SNAPSHOT_CANCEL).make_rn()])
    dn = CoreUtils.make_dn([CoreUtils.make_rn(NamingId.TOP_SYSTEM), CoreUtils.make_rn(NamingId.IOD_CONTROLLER), CoreUtils.make_rn(NamingId.IOD_SNAPSHOT_CANCEL)])
    iod_snapshot = ManagedObject(NamingId.IOD_SNAPSHOT_CANCEL)
    iod_snapshot.dn = dn
    #iod_snapshot.AdminState = iod_snapshot.CONST_ADMIN_STATE_TRIGGER
    iod_snapshot.AdminState = admin_state
    iod_snapshot.TimeOut = timeout

    in_config = ConfigConfig()
    in_config.add_child(iod_snapshot)
    ccm = handle.config_conf_mo(dn=dn, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)

    if ccm.error_code != 0:
        raise ImcException(ccm.error_code, ccm.error_descr)

    return ccm.OutConfig.child
示例#5
0
def update_imc_firmware_huu(handle, remote_share, share_type, remote_ip, username, password, update_component, stop_on_error=None, timeout=None, verify_update=None, cimc_secure_boot=None, dump_xml=None):
    """
    Uploads the HUU Firmware image to IMC Server.

    - remoteip        specifies the IP address of host containing firmware image.
    - username        specifies the Username login credential of host containing firmware image.
    - password        specifies the Password login credential of host containing firmware image.
    - remoteshare        specifies the path of firmware image on remoteip server.
    - sharetype        specifies the share type.
    - update_component    specifies the respective component to update or "all".
    - stop_on_error        specifies the action on error. "yes" or "no".
    - timeout        specifies the timeout in minute to exit the operation.
    - verify_update        speifies if IMC verify after update. "yes" or "no".
    """
    from ImcMos import HuuFirmwareUpdater

    dn = CoreUtils.make_dn([CoreUtils.make_rn(NamingId.TOP_SYSTEM), CoreUtils.make_rn(NamingId.HUU_CONTROLLER), CoreUtils.make_rn(NamingId.HUU_FIRMWARE_UPDATER)])
    huu_firmware_updater = ManagedObject(NamingId.HUU_FIRMWARE_UPDATER)
    huu_firmware_updater.dn = dn
    huu_firmware_updater.RemoteShare = remote_share
    huu_firmware_updater.MapType = share_type
    huu_firmware_updater.RemoteIp = remote_ip
    huu_firmware_updater.Username = username
    huu_firmware_updater.Password = password
    huu_firmware_updater.UpdateComponent = update_component
    huu_firmware_updater.AdminState = HuuFirmwareUpdater.CONST_ADMIN_STATE_TRIGGER
    huu_firmware_updater.StopOnError = stop_on_error
    huu_firmware_updater.TimeOut = timeout
    huu_firmware_updater.VerifyUpdate = verify_update
    huu_firmware_updater.CimcSecureBoot = cimc_secure_boot

    in_config = ConfigConfig()
    in_config.add_child(huu_firmware_updater)
    ccm = handle.config_conf_mo(dn=dn, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
    if ccm.error_code != 0:
        raise ImcException(ccm.error_code, ccm.error_descr)

    return ccm.OutConfig.child
示例#6
0
    def remove_imc_managedobject(self,
                                 in_mo=None,
                                 class_id=None,
                                 params=None,
                                 dump_xml=None):
        """
        Removes Managed Object in IMC.

        - in_mo, if provided, it acts as the target object for the present operation.
          It should be None unless a username wants to provide an in_mo.
          It can be a single MO or a list containing multiple managed objects.
        - class_id of the managed object/s to be removed.
        - params contains semicolon (;) separated list of key/value pairs(key=value),
          that are used as filters for selecting specific managed objects.
          The key should be a valid property of the managed object to be modified.
        """

        if params != None:
            keys = params.keys()
        else:
            keys = []

        config_map = ConfigMap()
        if in_mo != None and isinstance(in_mo, list) and len(in_mo) > 0:
            for mo in in_mo:
                pair = Pair()
                pair.set_attr("Key", mo.get_attr("Dn"))
                obj = ManagedObject(mo.class_id)
                obj.set_attr("Status", Status().DELETED)
                pair.add_child(obj)

                config_map.add_child(pair)

        elif class_id != None:
            pair = Pair()
            meta_class_id = CoreUtils.find_class_id_in_mo_meta_ignore_case(
                class_id)
            if meta_class_id != None:
                class_id = meta_class_id
            for prop in keys:
                if prop.lower() == "dn":
                    pair.set_attr("Key", params[prop])
            if pair.get_attr("Key") == None:
                raise ImcValidationException(
                    '[Error]: remove_imc_managedobject [Description]: dn missing in propertyMap'
                )

            obj = ManagedObject(class_id)
            obj.set_attr("Status", Status().DELETED)
            pair.add_child(obj)
            config_map.add_child(pair)

        if config_map.get_child_count() == 0:
            raise ImcValidationException(
                '[Error]: remove_imc_managedobject [Description]: (inMO) or (ClassId and dn) missing'
            )

        for pair in config_map.child:
            in_config = ConfigConfig()
            for mo in pair.child:
                in_config.add_child(mo)

            ccm = self.config_conf_mo(dn=pair.Key,
                                      in_config=in_config,
                                      in_hierarchical=YesOrNo.FALSE,
                                      dump_xml=dump_xml)

            if ccm.error_code == 0:
                molist = []
                for child in ccm.OutConfig.child:
                    if isinstance(child, Pair) == True:
                        for mo in child.child:
                            molist.append(mo)
                    elif isinstance(child, ManagedObject) == True:
                        molist.append(child)
            else:
                raise ImcException(ccm.error_code, ccm.error_descr)

        return molist
示例#7
0
    def set_imc_managedobject(self,
                              in_mo,
                              class_id=None,
                              params=None,
                              dump_xml=None):
        """
        Modifies Managed Object in IMC.

        - in_mo, if provided, it acts as the target object for the present operation.
          It should be None unless a username wants to provide an in_mo.
          It can be a single MO or a list containing multiple managed objects.
        - class_id of the managed object/s to be removed.
        - params contains semicolon (;) separated list of key/value pairs(key=value),
          that are used as filters for selecting specific managed objects.
          The key should be a valid property of the managed object to be modified.
        """

        #unknown_mo = False
        dn = None
        obj = None
        config_map = None
        dn_param_set = False

        if params != None:
            keys = params.keys()
        else:
            keys = []

        for key in keys:
            if key.lower() == "dn":
                # ClassId And dn Specified - No Parent Necessary
                dn_param_set = True
                dn = params[key]

        if in_mo == None or not isinstance(in_mo, list) or len(in_mo) == 0:
            if not dn_param_set:
                if class_id == None or class_id == "":
                    raise ImcValidationException(
                        '[Error]: set_imc_managedobject [Description]: in_mo and ClassId are both not specified'
                    )
                else:
                    raise ImcValidationException(
                        '[Error]: set_imc_managedobject [Description]: in_mo and dn are both not specified'
                    )
            else:
                if class_id == None or class_id == "":
                    raise ImcValidationException(
                        '[Error]: set_imc_managedobject [Description]: in_mo and ClassId are both not specified'
                    )
                else:
                    meta_class_id = CoreUtils.find_class_id_in_mo_meta_ignore_case(
                        class_id)
                    if meta_class_id != None:
                        class_id = meta_class_id
                    #    mo_meta = CoreUtils.get_mo_property_meta(class_id, "Meta")
                    #else:
                    #    unknown_mo = True

                    obj = ManagedObject(class_id)
                    for prop in keys:
                        prop_mo_meta = CoreUtils.is_property_in_meta_ignore_case(
                            class_id, prop)
                        if prop_mo_meta != None:
                            if prop.lower() == "rn" or prop.lower() == "dn":
                                pass
                            elif prop_mo_meta.access == MoPropertyMeta.READ_ONLY:
                                ImcUtils.write_imc_warning(
                                    "[Warning]: SetManagedObject [Description] Attempt to set non-writable property %s in Class %s"
                                    % (prop, class_id))

                            obj.set_attr(prop_mo_meta.name, str(params[prop]))
                        else:
                            #Sets the unknown property/value as Xtra_property in obj
                            obj.set_attr(ImcUtils.word_l(prop),
                                         str(params[prop]))

                    obj.set_attr("Dn", dn)
                    obj.set_attr("Status", Status().MODIFIED)
                    pair = Pair()
                    pair.set_attr("Key", obj.get_attr("Dn"))
                    pair.add_child(obj)
                    config_map = ConfigMap()
                    config_map.add_child(pair)

        else:
            if class_id != None and class_id != "":
                ImcUtils.write_imc_warning(
                    "[Warning]: SetManagedObject [Description] ClassId <%s> is ignored with InMo input"
                    % (class_id))

            config_map = ConfigMap()
            for mo in in_mo:
                obj = ManagedObject(mo.prop_mo_meta.name)
                dn = mo.get_attr("Dn")
                class_id = mo.prop_mo_meta.name

                for prop in keys:
                    prop_mo_meta = CoreUtils.is_property_in_meta_ignore_case(
                        class_id, prop)
                    if prop_mo_meta != None:
                        if prop.lower() == "rn" or prop.lower() == "dn":
                            pass
                        elif prop_mo_meta.access == MoPropertyMeta.READ_ONLY:
                            ImcUtils.write_imc_warning(
                                "[Warning]: SetManagedObject [Description] Attempt to set non-writeable property %s in Class %s"
                                % (prop, class_id))

                        obj.set_attr(prop_mo_meta.name, str(params[prop]))
                    else:
                        #Sets the unknown property/value as Xtra_property in obj
                        obj.set_attr(ImcUtils.word_l(prop), str(params[prop]))

                obj.set_attr("Dn", dn)
                obj.set_attr("Status", Status.MODIFIED)
                pair = Pair()
                pair.set_attr("Key", obj.get_attr("Dn"))
                pair.add_child(obj)
                config_map.add_child(pair)

        output_molist = []
        for pair in config_map.child:
            in_config = ConfigConfig()
            for mo in pair.child:
                in_config.add_child(mo)

            ccm = self.config_conf_mo(dn=pair.Key,
                                      in_config=in_config,
                                      in_hierarchical=YesOrNo.FALSE,
                                      dump_xml=dump_xml)

            if ccm.error_code == 0:
                molist = []
                for child in ccm.OutConfig.child:
                    if isinstance(child, Pair) == True:
                        for mo in child.child:
                            molist.append(mo)
                    elif isinstance(child, ManagedObject) == True:
                        molist.append(child)
                output_molist.extend(molist)
            else:
                raise ImcException(ccm.error_code, ccm.error_descr)

        return output_molist
示例#8
0
    def add_imc_managedobject(self,
                              in_mo=None,
                              class_id=None,
                              params=None,
                              dump_xml=None):
        """
        Adds a Managed Object to IMC.

        - in_mo, if provided, it acts as a parent for the present operation.
          It should be None unless a username wants to define a parent scope.
          It can be a single MO or a list containing multiple managed objects.
        - class_id of the managed object/s to be added.
        - params contains semicolon (;) separated list of key/value pairs(key=value),
          that are used as filters for selecting specific managed objects.
          The key should be a valid property of the managed object to be added.
        """

        unknown_mo = False
        if class_id == None or class_id == "":
            raise ImcValidationException(
                '[Error]: add_imc_managedobject [Description]: class_id is Null'
            )

        meta_class_id = CoreUtils.find_class_id_in_mo_meta_ignore_case(
            class_id)
        if meta_class_id != None:
            class_id = meta_class_id
            mo_meta = CoreUtils.get_mo_property_meta(class_id, "Meta")
        else:
            unknown_mo = True

        config_map = ConfigMap()
        rn = None
        dn = None
        #mo_meta = CoreUtils.get_mo_property_meta(class_id, "Meta")
        if params != None:
            keys = params.keys()
        else:
            keys = []

        if not unknown_mo:
            rn = mo_meta.rn
            for prop in CoreUtils.get_property_list(class_id):
                prop_meta = CoreUtils.get_mo_property_meta(class_id, prop)
                if prop_meta.access != MoPropertyMeta.NAMING:
                    continue
                naming_prop_found = False
                for key in keys:
                    if key.lower() == prop.lower():
                        rn = re.sub(r'\[%s\]' % prop, '%s' % params[key], rn)
                        naming_prop_found = True
                        break

                if naming_prop_found == False:
                    ImcUtils.write_imc_warning(
                        "[Warning]: add_imc_managedobject [Description]:Expected NAMING Property %s for ClassId %s not found"
                        % (prop, class_id))
                    rn = re.sub(r'\[%s\]' % prop, '%s' % "", rn)

        obj = ManagedObject(class_id)

        for prop in keys:
            if not unknown_mo:
                prop_mo_meta = CoreUtils.is_property_in_meta_ignore_case(
                    class_id, prop)
                if prop_mo_meta != None:
                    if prop.lower() == "rn" or prop.lower() == "dn":
                        pass
                    elif prop_mo_meta.access == MoPropertyMeta.READ_ONLY:
                        ImcUtils.write_imc_warning(
                            "[Warning]: AddManagedObject [Description]:Attempt to add non-writeable property %s in Class %s"
                            % (prop, class_id))

                    if prop.lower() == "rn":
                        if in_mo == None or not isinstance(
                                in_mo, list) or len(in_mo) == 0:
                            ImcUtils.write_imc_warning(
                                "[Warning]: AddManagedObject [Description]:Ignoring Rn since no parent provided"
                            )
                        if rn != params[prop]:
                            ImcUtils.write_imc_warning(
                                "[Warning]: AddManagedObject [Description]:Rn Mismatch. Provided %s Computed %s. Ignoring Computed Rn"
                                % (params[prop], rn))
                            rn = params[
                                prop]  #bug fix. if Rn and Name are both provided by username then Rn will get preference.

                    if prop.lower() == "dn":
                        dn = params[prop]

                    obj.set_attr(prop_mo_meta.name, str(params[prop]))
                else:
                    #Known MO - Unknown Property
                    obj.set_attr(ImcUtils.word_l(prop), str(params[prop]))
            else:
                #Unknown MO
                if prop.lower() == "dn":
                    dn = params[prop]

                if prop.lower() == "rn":
                    rn = params[prop]
                if rn == None:
                    rn = ""

                obj.set_attr(ImcUtils.word_l(prop), str(params[prop]))

        obj.set_attr("Status", Status().CREATED)

        if dn != None and dn != "":
            obj.set_attr("Dn", dn)
            pair = Pair()
            #pair.set_attr("Key", obj.dn)
            pair.set_attr("Key", obj.get_attr("Dn"))
            pair.add_child(obj)
            config_map.add_child(pair)
        elif in_mo != None and isinstance(in_mo, list) and len(in_mo) > 0:
            for mo in in_mo:
                pdn = mo.get_attr("Dn")
                if pdn != None:
                    obj.set_attr("Dn", pdn + '/' + rn)
                    pair = Pair()
                    #pair.set_attr("Key", obj.dn)
                    pair.set_attr("Key", obj.get_attr("Dn"))
                    pair.add_child(obj.clone())
                    config_map.add_child(pair)

        if config_map.get_child_count() == 0:
            ImcUtils.write_imc_warning(
                '[Warning]: AddManagedObject [Description]: Nothing to Add')
            return None

        output_molist = []
        for pair in config_map.child:
            in_config = ConfigConfig()
            for mo in pair.child:
                in_config.add_child(mo)
            ccm = self.config_conf_mo(dn=pair.Key,
                                      in_config=in_config,
                                      in_hierarchical=YesOrNo.FALSE,
                                      dump_xml=dump_xml)
            if ccm.error_code == 0:
                molist = []
                for child in ccm.OutConfig.child:
                    if isinstance(child, Pair) == True:
                        for mo in child.child:
                            molist.append(mo)
                    elif isinstance(child, ManagedObject) == True:
                        molist.append(child)
                output_molist.extend(molist)
            else:
                raise ImcException(ccm.error_code, ccm.error_descr)

        return output_molist
示例#9
0
    def remove_imc_managedobject(self, in_mo=None, class_id=None, params=None, dump_xml=None):
        """
        Removes Managed Object in IMC.

        - in_mo, if provided, it acts as the target object for the present operation.
          It should be None unless a username wants to provide an in_mo.
          It can be a single MO or a list containing multiple managed objects.
        - class_id of the managed object/s to be removed.
        - params contains semicolon (;) separated list of key/value pairs(key=value),
          that are used as filters for selecting specific managed objects.
          The key should be a valid property of the managed object to be modified.
        """

        if params != None:
            keys = params.keys()
        else:
            keys = []

        config_map = ConfigMap()
        if in_mo != None and isinstance(in_mo, list) and len(in_mo) > 0:
            for mo in in_mo:
                pair = Pair()
                pair.set_attr("Key", mo.get_attr("Dn"))
                obj = ManagedObject(mo.class_id)
                obj.set_attr("Status", Status().DELETED)
                pair.add_child(obj)

                config_map.add_child(pair)

        elif class_id != None:
            pair = Pair()
            meta_class_id = CoreUtils.find_class_id_in_mo_meta_ignore_case(class_id)
            if meta_class_id != None:
                class_id = meta_class_id
            for prop in keys:
                if prop.lower() == "dn":
                    pair.set_attr("Key", params[prop])
            if pair.get_attr("Key") == None:
                raise ImcValidationException('[Error]: remove_imc_managedobject [Description]: dn missing in propertyMap')

            obj = ManagedObject(class_id)
            obj.set_attr("Status", Status().DELETED)
            pair.add_child(obj)
            config_map.add_child(pair)

        if config_map.get_child_count() == 0:
            raise ImcValidationException('[Error]: remove_imc_managedobject [Description]: (inMO) or (ClassId and dn) missing')

        for pair in config_map.child:
            in_config = ConfigConfig()
            for mo in pair.child:
                in_config.add_child(mo)

            ccm = self.config_conf_mo(dn=pair.Key, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)

            if ccm.error_code == 0:
                molist = []
                for child in ccm.OutConfig.child:
                    if isinstance(child, Pair) == True:
                        for mo in child.child:
                            molist.append(mo)
                    elif isinstance(child, ManagedObject) == True:
                        molist.append(child)
            else:
                raise ImcException(ccm.error_code, ccm.error_descr)

        return molist
示例#10
0
    def set_imc_managedobject(self, in_mo, class_id=None, params=None, dump_xml=None):
        """
        Modifies Managed Object in IMC.

        - in_mo, if provided, it acts as the target object for the present operation.
          It should be None unless a username wants to provide an in_mo.
          It can be a single MO or a list containing multiple managed objects.
        - class_id of the managed object/s to be removed.
        - params contains semicolon (;) separated list of key/value pairs(key=value),
          that are used as filters for selecting specific managed objects.
          The key should be a valid property of the managed object to be modified.
        """

        #unknown_mo = False
        dn = None
        obj = None
        config_map = None
        dn_param_set = False

        if params != None:
            keys = params.keys()
        else:
            keys = []

        for key in keys:
            if key.lower() == "dn":
                # ClassId And dn Specified - No Parent Necessary
                dn_param_set = True
                dn = params[key]

        if in_mo == None or not isinstance(in_mo, list) or len(in_mo) == 0:
            if not dn_param_set:
                if class_id == None or class_id == "":
                    raise ImcValidationException('[Error]: set_imc_managedobject [Description]: in_mo and ClassId are both not specified')
                else:
                    raise ImcValidationException('[Error]: set_imc_managedobject [Description]: in_mo and dn are both not specified')
            else:
                if class_id == None or class_id == "":
                    raise ImcValidationException('[Error]: set_imc_managedobject [Description]: in_mo and ClassId are both not specified')
                else:
                    meta_class_id = CoreUtils.find_class_id_in_mo_meta_ignore_case(class_id)
                    if meta_class_id != None:
                        class_id = meta_class_id
                    #    mo_meta = CoreUtils.get_mo_property_meta(class_id, "Meta")
                    #else:
                    #    unknown_mo = True

                    obj = ManagedObject(class_id)
                    for prop in keys:
                        prop_mo_meta = CoreUtils.is_property_in_meta_ignore_case(class_id, prop)
                        if prop_mo_meta != None:
                            if prop.lower() == "rn" or prop.lower() == "dn":
                                pass
                            elif prop_mo_meta.access == MoPropertyMeta.READ_ONLY:
                                ImcUtils.write_imc_warning("[Warning]: SetManagedObject [Description] Attempt to set non-writable property %s in Class %s" %(prop, class_id))

                            obj.set_attr(prop_mo_meta.name, str(params[prop]))
                        else:
                            #Sets the unknown property/value as Xtra_property in obj
                            obj.set_attr(ImcUtils.word_l(prop), str(params[prop]))

                    obj.set_attr("Dn", dn)
                    obj.set_attr("Status", Status().MODIFIED)
                    pair = Pair()
                    pair.set_attr("Key", obj.get_attr("Dn"))
                    pair.add_child(obj)
                    config_map = ConfigMap()
                    config_map.add_child(pair)

        else:
            if class_id != None and class_id != "":
                ImcUtils.write_imc_warning("[Warning]: SetManagedObject [Description] ClassId <%s> is ignored with InMo input" %(class_id))

            config_map = ConfigMap()
            for mo in in_mo:
                obj = ManagedObject(mo.prop_mo_meta.name)
                dn = mo.get_attr("Dn")
                class_id = mo.prop_mo_meta.name

                for prop in keys:
                    prop_mo_meta = CoreUtils.is_property_in_meta_ignore_case(class_id, prop)
                    if prop_mo_meta != None:
                        if prop.lower() == "rn" or prop.lower() == "dn":
                            pass
                        elif prop_mo_meta.access == MoPropertyMeta.READ_ONLY:
                            ImcUtils.write_imc_warning("[Warning]: SetManagedObject [Description] Attempt to set non-writeable property %s in Class %s" %(prop, class_id))

                        obj.set_attr(prop_mo_meta.name, str(params[prop]))
                    else:
                        #Sets the unknown property/value as Xtra_property in obj
                        obj.set_attr(ImcUtils.word_l(prop), str(params[prop]))

                obj.set_attr("Dn", dn)
                obj.set_attr("Status", Status.MODIFIED)
                pair = Pair()
                pair.set_attr("Key", obj.get_attr("Dn"))
                pair.add_child(obj)
                config_map.add_child(pair)

        output_molist = []
        for pair in config_map.child:
            in_config = ConfigConfig()
            for mo in pair.child:
                in_config.add_child(mo)

            ccm = self.config_conf_mo(dn=pair.Key, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)

            if ccm.error_code == 0:
                molist = []
                for child in ccm.OutConfig.child:
                    if isinstance(child, Pair) == True:
                        for mo in child.child:
                            molist.append(mo)
                    elif isinstance(child, ManagedObject) == True:
                        molist.append(child)
                output_molist.extend(molist)
            else:
                raise ImcException(ccm.error_code, ccm.error_descr)

        return output_molist
示例#11
0
    def add_imc_managedobject(self, in_mo=None, class_id=None, params=None, dump_xml=None):
        """
        Adds a Managed Object to IMC.

        - in_mo, if provided, it acts as a parent for the present operation.
          It should be None unless a username wants to define a parent scope.
          It can be a single MO or a list containing multiple managed objects.
        - class_id of the managed object/s to be added.
        - params contains semicolon (;) separated list of key/value pairs(key=value),
          that are used as filters for selecting specific managed objects.
          The key should be a valid property of the managed object to be added.
        """

        unknown_mo = False
        if class_id == None or class_id == "":
            raise ImcValidationException('[Error]: add_imc_managedobject [Description]: class_id is Null')

        meta_class_id = CoreUtils.find_class_id_in_mo_meta_ignore_case(class_id)
        if meta_class_id != None:
            class_id = meta_class_id
            mo_meta = CoreUtils.get_mo_property_meta(class_id, "Meta")
        else:
            unknown_mo = True

        config_map = ConfigMap()
        rn = None
        dn = None
        #mo_meta = CoreUtils.get_mo_property_meta(class_id, "Meta")
        if params != None:
            keys = params.keys()
        else:
            keys = []

        if not unknown_mo:
            rn = mo_meta.rn
            for prop in CoreUtils.get_property_list(class_id):
                prop_meta = CoreUtils.get_mo_property_meta(class_id, prop)
                if prop_meta.access != MoPropertyMeta.NAMING:
                    continue
                naming_prop_found = False
                for key in keys:
                    if key.lower() == prop.lower():
                        rn = re.sub(r'\[%s\]' % prop, '%s' % params[key], rn)
                        naming_prop_found = True
                        break

                if naming_prop_found == False:
                    ImcUtils.write_imc_warning("[Warning]: add_imc_managedobject [Description]:Expected NAMING Property %s for ClassId %s not found" %(prop, class_id))
                    rn = re.sub(r'\[%s\]' % prop, '%s' % "", rn)

        obj = ManagedObject(class_id)

        for prop in keys:
            if not unknown_mo:
                prop_mo_meta = CoreUtils.is_property_in_meta_ignore_case(class_id, prop)
                if prop_mo_meta != None:
                    if prop.lower() == "rn" or prop.lower() == "dn":
                        pass
                    elif prop_mo_meta.access == MoPropertyMeta.READ_ONLY:
                        ImcUtils.write_imc_warning("[Warning]: AddManagedObject [Description]:Attempt to add non-writeable property %s in Class %s" %(prop, class_id))

                    if prop.lower() == "rn":
                        if in_mo == None or not isinstance(in_mo, list) or len(in_mo) == 0:
                            ImcUtils.write_imc_warning("[Warning]: AddManagedObject [Description]:Ignoring Rn since no parent provided")
                        if rn != params[prop]:
                            ImcUtils.write_imc_warning("[Warning]: AddManagedObject [Description]:Rn Mismatch. Provided %s Computed %s. Ignoring Computed Rn" %(params[prop], rn))
                            rn = params[prop]#bug fix. if Rn and Name are both provided by username then Rn will get preference.

                    if prop.lower() == "dn":
                        dn = params[prop]

                    obj.set_attr(prop_mo_meta.name, str(params[prop]))
                else:
                    #Known MO - Unknown Property
                    obj.set_attr(ImcUtils.word_l(prop), str(params[prop]))
            else:
                #Unknown MO
                if prop.lower() == "dn":
                    dn = params[prop]

                if prop.lower() == "rn":
                    rn = params[prop]
                if rn == None:
                    rn = ""

                obj.set_attr(ImcUtils.word_l(prop), str(params[prop]))

        obj.set_attr("Status", Status().CREATED)

        if dn != None and dn != "":
            obj.set_attr("Dn", dn)
            pair = Pair()
            #pair.set_attr("Key", obj.dn)
            pair.set_attr("Key", obj.get_attr("Dn"))
            pair.add_child(obj)
            config_map.add_child(pair)
        elif in_mo != None and isinstance(in_mo, list) and len(in_mo) > 0:
            for mo in in_mo:
                pdn = mo.get_attr("Dn")
                if pdn != None:
                    obj.set_attr("Dn", pdn + '/' +rn)
                    pair = Pair()
                    #pair.set_attr("Key", obj.dn)
                    pair.set_attr("Key", obj.get_attr("Dn"))
                    pair.add_child(obj.clone())
                    config_map.add_child(pair)

        if config_map.get_child_count() == 0:
            ImcUtils.write_imc_warning('[Warning]: AddManagedObject [Description]: Nothing to Add')
            return None

        output_molist = []
        for pair in config_map.child:
            in_config = ConfigConfig()
            for mo in pair.child:
                in_config.add_child(mo)
            ccm = self.config_conf_mo(dn=pair.Key, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
            if ccm.error_code == 0:
                molist = []
                for child in ccm.OutConfig.child:
                    if isinstance(child, Pair) == True:
                        for mo in child.child:
                            molist.append(mo)
                    elif isinstance(child, ManagedObject) == True:
                        molist.append(child)
                output_molist.extend(molist)
            else:
                raise ImcException(ccm.error_code, ccm.error_descr)

        return output_molist
示例#12
0
def sync_imc_managedobject(handle, difference, delete_not_present=False, no_version_filter=True, dump_xml=None):
    """
    Syncs Managed Object.

    Method takes the difference object (output of compare_imc_managedobject) and applies the differences
    on reference Managed Object.
    - difference specifies the Difference object (output of compare_imc_managedobject) which has
      differences of the properties of two or more Managed Objects.
    - delete_not_present, if set as True, any missing MOs in reference Managed Object set will be deleted.
    - no_version_filter, If set as True, minversion for Mos or properties to be added in reference
      Managed Object will not be checked.
    """
    from ImcUtilityCore import _ImcMoDiff

    if difference == None or (isinstance(difference, list) and len(difference) == 0):
        raise ImcValidationException("[Error]: sync_imc_managedobject: Difference Object can not be Null")

    config_map = ConfigMap()

    for mo_diff in difference:
        mo = mo_diff.input_object
        class_id = mo.class_id
        gmo_diff = None
        meta_class_id = CoreUtils.find_class_id_in_mo_meta_ignore_case(class_id)
        if meta_class_id == None:
            ImcUtils.write_imc_warning("Ignoring [%s]. Unknown ClassId [%s]." %(mo_diff.input_object.get_attr("dn"), class_id))
            continue

        #Removes Difference Object.
        if mo_diff.side_indicator == _ImcMoDiff.REMOVE and delete_not_present:
            gmo_diff = ManagedObject(class_id)
            gmo_diff.set_attr("dn", mo.get_attr("dn"))
            gmo_diff.set_attr("Status", Status().DELETED)
            gmo_diff = GenericMO(gmo_diff, WriteXmlOption.ALL_CONFIG)#gmo_diff should be generic object

        if mo_diff.side_indicator == _ImcMoDiff.ADD_MODIFY:
            gmo_diff = ManagedObject(class_id)
            add_exists = False
            mo_meta = CoreUtils.is_property_in_meta_ignore_case(class_id, "Meta")

            if mo_meta != None and 'Add' in mo_meta.verbs:
                add_exists = True

            #Add Difference Object.
            if add_exists and (mo_diff.diff_property == None or len(mo_diff.diff_property) == 0):
                for prop in mo.__dict__:
                    prop_mo_meta = CoreUtils.is_property_in_meta_ignore_case(class_id, prop)
                    if prop_mo_meta != None:
                        if prop.lower() == "rn" or prop.lower() == "dn" or prop_mo_meta.access == MoPropertyMeta.READ_ONLY:
                            continue
                        gmo_diff.set_attr(prop_mo_meta.name, mo.get_attr(prop))

                gmo_diff.set_attr("Dn", mo.get_attr("Dn"))
                gmo_diff.set_attr("Status", Status().CREATED)

                gmo_diff = GenericMO(gmo_diff, WriteXmlOption.ALL_CONFIG)#gmo_diff should be generic object
                if not no_version_filter:
                    h_reference = mo.get_handle()
                    if h_reference != None and h_reference.version != None:
                        gmo_diff.filter_version(h_reference.version)

            #Modify the Managed Object
            else:
                if mo_diff.diff_property == None or len(mo_diff.diff_property) == 0:
                    ImcUtils.write_imc_warning('Add not supported for class_id ' + class_id +'. Reverting to modify.')
                    continue

                final_diff_props = mo_diff.diff_property
                gmo_diff = ManagedObject(class_id)
                for prop in final_diff_props:
                    prop_mo_meta = CoreUtils.is_property_in_meta_ignore_case(class_id, prop)
                    if prop_mo_meta != None:
                        #if (prop.lower() == "rn" or prop.lower() == "dn" or prop_mo_meta.access == MoPropertyMeta.ReadOnly):
                        if prop.lower() == "rn" or prop.lower() == "dn":
                            continue
                        gmo_diff.set_attr(prop_mo_meta.name, mo.get_attr(prop))

                gmo_diff.set_attr("Dn", mo.get_attr("Dn"))
                gmo_diff.set_attr("Status", Status().MODIFIED)
                gmo_diff = GenericMO(gmo_diff, WriteXmlOption.ALL_CONFIG)#gmo_diff should be generic object to apply filter_version on it.

        #TODO: NoversionFilter functionality discussion.

        if gmo_diff != None and not no_version_filter:
            gmo_meta = CoreUtils.get_mo_property_meta(gmo_diff.class_id, "Meta")
            if gmo_meta != None and handle.version != None:
                if handle.version < gmo_meta.version:
                    ImcUtils.write_imc_warning('Ignoring unsupported class_id %s for dn %s.'  %(gmo_diff.class_id, gmo_diff.get_attr("dn")))
                    gmo_diff = None

                if gmo_diff != None and handle.version != None:
                    gmo_diff.filter_version(h_reference.version)

            if gmo_diff.__dict__.has_key("_exclude_prop_list"):
                for prop in gmo_diff.excludePropList:
                    if prop == "Xtra_property":
                        gmo_diff.__dict__[prop] = {}
                        continue
                    gmo_diff.__dict__[prop] = None

        if gmo_diff != None:
            pair = Pair()
            pair.set_attr("Key", gmo_diff.get_attr("Dn"))
            pair.add_child(gmo_diff)
            config_map.add_child(pair)

    if config_map.get_child_count() == 0:
        return None

    output_molist = []
    for pair in config_map.child:
        in_config = ConfigConfig()
        for mo in pair.child:
            in_config.add_child(mo)

        ccm = handle.config_conf_mo(dn=pair.Key, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
        if ccm.error_code == 0:
            molist = []
            for child in ccm.OutConfig.child:
                if isinstance(child, Pair) == True:
                    for mo in child.child:
                        molist.append(mo)
                elif isinstance(child, ManagedObject) == True:
                    molist.append(child)
            output_molist.extend(molist)
        else:
            raise ImcException(ccm.error_code, ccm.error_descr)

    return output_molist
示例#13
0
def get_imc_techsupport(handle, remotehost, remotefile, protocol, username, password, timeout_sec=ImcConstant.TIME_OUT_IN_SEC, dump_xml=None):
    """
    Creates and downloads the technical support data of IMC server.

    - remotehost    specifies the host where username need to download the technical support data.
    - remotefile    specifies the path on remotehost where username need to download the technical support data.
    - protocol        specifies the protocol used for transferring the file to remotehost.
    - username        specifies the username credential to login to remotehost.
    - password        specifies the password credential to login to remotehost.
    - timeout_sec     specifies the time in seconds for which method waits for the technical support data file
            to generate else exit.Default is 600 Seconds.
    """
    from ImcMos import MgmtImporter

    if timeout_sec == None or timeout_sec == "" or timeout_sec < 1:
        timeout_sec = ImcConstant.TIME_OUT_IN_SEC
        ImcUtils.write_imc_warning('[Warning]: Inappropriate <timeoutsec>. Chosen default value is 600 Seconds')

    #dn = "sys/rack-unit-1/tech-support"
    dn = CoreUtils.make_dn([CoreUtils.make_rn(NamingId.TOP_SYSTEM), CoreUtils.make_rn(NamingId.COMPUTE_RACK_UNIT, ServerId="1"), CoreUtils.make_rn(NamingId.SYSDEBUG_TECH_SUPPORT_EXPORT)])
    sysdebug_techsupport = ManagedObject(NamingId.SYSDEBUG_TECH_SUPPORT_EXPORT)
    sysdebug_techsupport.DN = dn
    sysdebug_techsupport.AdminState = MgmtImporter.CONST_ADMIN_STATE_ENABLED
    sysdebug_techsupport.RemoteFile = remotefile
    sysdebug_techsupport.Protocol = protocol
    sysdebug_techsupport.Status = Status.MODIFIED
    sysdebug_techsupport.Hostname = remotehost
    sysdebug_techsupport.User = username
    sysdebug_techsupport.Pwd = password

    in_config = ConfigConfig()
    in_config.add_child(sysdebug_techsupport)
    ccm = handle.config_conf_mo(dn=dn, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
    time.sleep(10) #Wait for 10 seconds before start checking.

    #TODO: CHECK THE FIELD fsmStageDescr
    duration = timeout_sec
    poll_interval = ImcConstant.POLL_INTERVAL_IN_SEC
    crd = None
    if ccm.error_code == 0:
        ImcUtils.write_imc_warning('Waiting for the Tech Support file to become available (this may take several minutes).')
        status = False
        while True:
            crd = handle.config_resolve_dn(dn, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
            if crd.error_code == 0:
                if crd.OutConfig.get_child_count() > 0:
                    for tech_support in crd.OutConfig.child:
                        if tech_support.AdminState == MgmtImporter.CONST_ADMIN_STATE_DISABLED: #TODO: replace the hard-coded string after schema change
                            if tech_support.FsmStatus == "success":
                                status = True
                            else:
                                raise ImcValidationException('Failed to create the TechSupport file.' + tech_support.FsmStatus)
                else:
                    raise ImcValidationException('Failed to create the TechSupport file.')
            else:
                raise ImcException(crd.error_code, crd.error_descr)
            if status:
                break
            time.sleep(min(duration, poll_interval))
            duration = max(0, (duration-poll_interval))
            if duration == 0:
                raise ImcValidationException('TechSupport generation in progress but get_imc_techsupport process timed out. Exiting Method get_imc_techsupport')
    else:
        raise ImcException(ccm.error_code, ccm.error_descr)

    return crd.OutConfig.child
示例#14
0
def backup_imc(handle, remotehost, remotefile, protocol, username, password, passphrase=None, timeout_sec=ImcConstant.TIME_OUT_IN_SEC, dump_xml=None):
    """
    Creates and downloads the backup of IMC.

    - remotehost    specifies the host where username need to download the backup.
    - remotefile    specifies the path on remotehost where username need to download the backup.
    - protocol        specifies the protocol used for transferring the file to remotehost.
    - username        specifies the username credential to login to remotehost.
    - password        specifies the password credential to login to remotehost.
    - timeout_sec     specifies the time in seconds for which method waits for the backUp file
                    to generate else exit. Default is 600 Seconds.
    """
    from ImcMos import MgmtBackup

    if timeout_sec == None or timeout_sec == "" or timeout_sec < 1:
        timeout_sec = ImcConstant.TIME_OUT_IN_SEC
        ImcUtils.write_imc_warning('[Warning]: Inappropriate <timeoutsec>. Chosen default value is 600 Seconds')

    #dn = "sys/export-config"
    #dn = ImcUtils.make_dn([ManagedObject(NamingId.TOP_SYSTEM).make_rn(),ManagedObject(NamingId.MGMT_BACKUP).make_rn()])
    dn = CoreUtils.make_dn([CoreUtils.make_rn(NamingId.TOP_SYSTEM), CoreUtils.make_rn(NamingId.MGMT_BACKUP)])

    mgmt_backup = ManagedObject(NamingId.MGMT_BACKUP)

    mgmt_backup.Hostname = remotehost
    mgmt_backup.User = username
    mgmt_backup.Pwd = password
    mgmt_backup.Proto = protocol
    mgmt_backup.RemoteFile = remotefile
    mgmt_backup.dn = dn
    mgmt_backup.AdminState = MgmtBackup.CONST_ADMIN_STATE_ENABLED
    mgmt_backup.Status = Status.MODIFIED
    mgmt_backup.Passphrase = passphrase

    in_config = ConfigConfig()
    in_config.add_child(mgmt_backup)
    response = handle.config_conf_mo(dn, in_config=in_config, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
    if response.error_code != 0:
        raise ImcException(response.error_code, response.error_descr)
        #raise Exception('[Error]: backup_imc [Code]:' + ccm.error_code + ' [Description]:' + ccm.error_descr)

    time.sleep(10) #Wait for 10 seconds before start checking.

    duration = timeout_sec
    poll_interval = ImcConstant.POLL_INTERVAL_IN_SEC

    cr_dn = None
    status = False

    while True:
        cr_dn = handle.config_resolve_dn(dn, in_hierarchical=YesOrNo.FALSE, dump_xml=dump_xml)
        if cr_dn.error_code == 0:
            for each_mgmt_dn in cr_dn.OutConfig.child:
                if each_mgmt_dn.AdminState == MgmtBackup.CONST_ADMIN_STATE_DISABLED:
                    if each_mgmt_dn.FsmStageDescr == "Completed successfully":
                        status = True
                    if each_mgmt_dn.FsmStageDescr == "Error":
                        raise ImcValidationException("Failed to export the CIMC configuration file." + "Error Code: " + each_mgmt_dn.FsmRmtInvErrCode + " Error Description: " + each_mgmt_dn.FsmRmtInvErrDescr)

        else:
            raise ImcException(cr_dn.error_code, cr_dn.error_descr)

        if status:
            break

        time.sleep(min(duration, poll_interval))
        duration = max(0, (duration-poll_interval))

        if duration == 0:
            raise ImcValidationException('Backup operation in progress but utility backup_imc timed out. Exiting Method backup_imc')

    return cr_dn.OutConfig.child