ucscsdk/utils/ucscbackup.py
def import_config_domain(handle, to_domain_ip, from_domain_ip, config_file,
                         merge=True,
                         to_domain_name=None, from_domain_name=None,
                         timeout=120):
    """
    This operation imports UcsCentral Domain's config created earlier via
    schedule backup of the same or other Domains.
    Note: Only config-all backup on UcsCentral are available for import, local
    or remote import is not supported for domain

    Args:
        handle (UcscHandle): connection handle
        to_domain_ip(str): IP of domain To which you want to import
                           set 'None' if domain_name is valid
        from_domain_ip(str): IP of domain From which you want to import
                             set 'None' if domain_name is valid
        config_file(str): From domain's config file which you want to import
        merge (boolean): True/False, specifies whether to merge the backup
                         config with the existing domain configuration
        to_domain_name(str): to domain name, valid only if to_domain_ip is None
        from_domain_name(str): from domain name, valid only if
                               from_domain_ip is None
        timeout (number) : time in seconds for which method waits for
                           import operation success before timing out

    Example:
        import_config_domain(handle, to_domain_ip="10.10.10.100",
                             from_domain_ip="192.168.1.1",
                             config_file="all-cfg.1.tgz")\n

    """

    from ..mometa.mgmt.MgmtImporter import MgmtImporter, MgmtImporterConsts
    from .ucscdomain import get_domain, _is_domain_available

    to_domain = get_domain(handle, to_domain_ip, to_domain_name)

    if not _is_domain_available(handle, to_domain.id):
        raise UcscOperationError("Import config domain",
                                 "Domain with IP %s or name %s not "
                                 "registered or lost visibility "
                                 "with UcsCentral" %
                                 (to_domain_ip, to_domain_name))

    from_domain = get_domain(handle, from_domain_ip, from_domain_name)

    if not _is_domain_available(handle, from_domain.id):
        raise UcscOperationError("Import config domain",
                                 "Domain with IP %s or name %s not "
                                 "registered or lost visibility "
                                 "with UcsCentral" %
                                 (from_domain_ip, from_domain_name))

    if not _is_backup_file_on_server(handle, from_domain.address, config_file):
        raise UcscOperationError("Import config domain",
                                 "Backup File '%s' not found "
                                 "on UcsCentral" % config_file)

    filter_str = '(connector_id, %s, type="eq")' % to_domain.id

    consumer_inst = handle.query_classid(
        class_id='ConsumerInst', filter_str=filter_str)

    if (len(consumer_inst) <= 0):
        raise UcscOperationError("Import config domain",
                                 "Unable to get Domain instance"
                                 "with IP %s for import " %
                                 to_domain.address)

    consumer_dn = consumer_inst[0].dn
    top_system = handle.query_dn("sys")

    mgmt_importer = MgmtImporter(
        parent_mo_or_dn=consumer_dn,
        hostname=top_system.address,
        remote_file='/' + from_domain.address + '/cfg-backups/' + config_file,
        proto=MgmtImporterConsts.PROTO_TFTP,
        admin_state=MgmtImporterConsts.ADMIN_STATE_ENABLED)

    if merge:
        mgmt_importer.action = MgmtImporterConsts.ACTION_MERGE
    else:
        mgmt_importer.action = MgmtImporterConsts.ACTION_REPLACE

    handle.add_mo(mgmt_importer, modify_present=True)
    handle.commit(dme="operation-mgr")

    duration = timeout
    poll_interval = 2
    log.debug("Importing domain config")
    while True:
        mgmt_importer = handle.query_dn(
                dn=mgmt_importer.dn,
                dme="operation-mgr")
        admin_state = mgmt_importer.admin_state

        # Break condition:- if state id disabled then break
        if admin_state == MgmtImporterConsts.ADMIN_STATE_DISABLED:
            break

        time.sleep(min(duration, poll_interval))
        duration = max(0, (duration - poll_interval))
        if duration == 0:
            raise UcscOperationError(
                  "Import config", "operation timed out")

    if mgmt_importer.op_status != \
            MgmtImporterConsts.OP_STATUS_ALL_SUCCESS:
            raise UcscOperationError(
                  "Import config",
                  ("operational status %s " % mgmt_importer.op_status))

    log.debug("Import config to domain was successfull")
    return mgmt_importer

    This operation imports UcsCentral Domain's config created earlier via
    schedule backup of the same or other Domains.
    Note: Only config-all backup on UcsCentral are available for import, local
    or remote import is not supported for domain

    Args:
        handle (UcscHandle): connection handle
        to_domain_ip(str): IP of domain To which you want to import
                           set 'None' if domain_name is valid
        from_domain_ip(str): IP of domain From which you want to import
                             set 'None' if domain_name is valid
        config_file(str): From domain's config file which you want to import
        merge (boolean): True/False, specifies whether to merge the backup
                         config with the existing domain configuration
        to_domain_name(str): to domain name, valid only if to_domain_ip is None
        from_domain_name(str): from domain name, valid only if
                               from_domain_ip is None
        timeout (number) : time in seconds for which method waits for
                           import operation success before timing out

    Example:
        import_config_domain(handle, to_domain_ip="10.10.10.100",
                             from_domain_ip="192.168.1.1",
                             config_file="all-cfg.1.tgz")\n

    
This operation imports UcsCentral Domain's config created earlier via
schedule backup of the same or other Domains.
Note: Only config-all backup on UcsCentral are available for import, local
or remote import is not supported for domain
This operation imports UcsCentral Domain ' s config created earlier via schedule backup of the same or other Domains . Note : Only config - all backup on UcsCentral are available for import local or remote import is not supported for domain
def import_config_domain(handle, to_domain_ip, from_domain_ip, config_file,
                         merge=True,
                         to_domain_name=None, from_domain_name=None,
                         timeout=120):
    from ..mometa.mgmt.MgmtImporter import MgmtImporter, MgmtImporterConsts
    from .ucscdomain import get_domain, _is_domain_available
    to_domain = get_domain(handle, to_domain_ip, to_domain_name)
    if not _is_domain_available(handle, to_domain.id):
        raise UcscOperationError("Import config domain",
                                 "Domain with IP %s or name %s not "
                                 "registered or lost visibility "
                                 "with UcsCentral" %
                                 (to_domain_ip, to_domain_name))
    from_domain = get_domain(handle, from_domain_ip, from_domain_name)
    if not _is_domain_available(handle, from_domain.id):
        raise UcscOperationError("Import config domain",
                                 "Domain with IP %s or name %s not "
                                 "registered or lost visibility "
                                 "with UcsCentral" %
                                 (from_domain_ip, from_domain_name))
    if not _is_backup_file_on_server(handle, from_domain.address, config_file):
        raise UcscOperationError("Import config domain",
                                 "Backup File '%s' not found "
                                 "on UcsCentral" % config_file)
    filter_str = '(connector_id, %s, type="eq")' % to_domain.id
    consumer_inst = handle.query_classid(
        class_id='ConsumerInst', filter_str=filter_str)
    if (len(consumer_inst) <= 0):
        raise UcscOperationError("Import config domain",
                                 "Unable to get Domain instance"
                                 "with IP %s for import " %
                                 to_domain.address)
    consumer_dn = consumer_inst[0].dn
    top_system = handle.query_dn("sys")
    mgmt_importer = MgmtImporter(
        parent_mo_or_dn=consumer_dn,
        hostname=top_system.address,
        remote_file='/' + from_domain.address + '/cfg-backups/' + config_file,
        proto=MgmtImporterConsts.PROTO_TFTP,
        admin_state=MgmtImporterConsts.ADMIN_STATE_ENABLED)
    if merge:
        mgmt_importer.action = MgmtImporterConsts.ACTION_MERGE
    else:
        mgmt_importer.action = MgmtImporterConsts.ACTION_REPLACE
    handle.add_mo(mgmt_importer, modify_present=True)
    handle.commit(dme="operation-mgr")
    duration = timeout
    poll_interval = 2
    log.debug("Importing domain config")
    while True:
        mgmt_importer = handle.query_dn(
                dn=mgmt_importer.dn,
                dme="operation-mgr")
        admin_state = mgmt_importer.admin_state
        if admin_state == MgmtImporterConsts.ADMIN_STATE_DISABLED:
            break
        time.sleep(min(duration, poll_interval))
        duration = max(0, (duration - poll_interval))
        if duration == 0:
            raise UcscOperationError(
                  "Import config", "operation timed out")
    if mgmt_importer.op_status != \
            MgmtImporterConsts.OP_STATUS_ALL_SUCCESS:
            raise UcscOperationError(
                  "Import config",
                  ("operational status %s " % mgmt_importer.op_status))
    log.debug("Import config to domain was successfull")
    return mgmt_importer
def import_config_domain ( handle , to_domain_ip , from_domain_ip , config_file , merge = True , to_domain_name = None , from_domain_name = None , timeout = 120 ) : from . . mometa . mgmt . MgmtImporter import MgmtImporter , MgmtImporterConsts from . ucscdomain import get_domain , _is_domain_available to_domain = get_domain ( handle , to_domain_ip , to_domain_name ) if not _is_domain_available ( handle , to_domain . id ) : raise UcscOperationError ( "Import config domain" , "Domain with IP %s or name %s not " "registered or lost visibility " "with UcsCentral" % ( to_domain_ip , to_domain_name ) ) from_domain = get_domain ( handle , from_domain_ip , from_domain_name ) if not _is_domain_available ( handle , from_domain . id ) : raise UcscOperationError ( "Import config domain" , "Domain with IP %s or name %s not " "registered or lost visibility " "with UcsCentral" % ( from_domain_ip , from_domain_name ) ) if not _is_backup_file_on_server ( handle , from_domain . address , config_file ) : raise UcscOperationError ( "Import config domain" , "Backup File '%s' not found " "on UcsCentral" % config_file ) filter_str = '(connector_id, %s, type="eq")' % to_domain . id consumer_inst = handle . query_classid ( class_id = 'ConsumerInst' , filter_str = filter_str ) if ( len ( consumer_inst ) <= 0 ) : raise UcscOperationError ( "Import config domain" , "Unable to get Domain instance" "with IP %s for import " % to_domain . address ) consumer_dn = consumer_inst [ 0 ] . dn top_system = handle . query_dn ( "sys" ) mgmt_importer = MgmtImporter ( parent_mo_or_dn = consumer_dn , hostname = top_system . address , remote_file = '/' + from_domain . address + '/cfg-backups/' + config_file , proto = MgmtImporterConsts . PROTO_TFTP , admin_state = MgmtImporterConsts . ADMIN_STATE_ENABLED ) if merge : mgmt_importer . action = MgmtImporterConsts . ACTION_MERGE else : mgmt_importer . action = MgmtImporterConsts . ACTION_REPLACE handle . add_mo ( mgmt_importer , modify_present = True ) handle . commit ( dme = "operation-mgr" ) duration = timeout poll_interval = 2 log . debug ( "Importing domain config" ) while True : mgmt_importer = handle . query_dn ( dn = mgmt_importer . dn , dme = "operation-mgr" ) admin_state = mgmt_importer . admin_state if admin_state == MgmtImporterConsts . ADMIN_STATE_DISABLED : break time . sleep ( min ( duration , poll_interval ) ) duration = max ( 0 , ( duration - poll_interval ) ) if duration == 0 : raise UcscOperationError ( "Import config" , "operation timed out" ) if mgmt_importer . op_status != MgmtImporterConsts . OP_STATUS_ALL_SUCCESS : raise UcscOperationError ( "Import config" , ( "operational status %s " % mgmt_importer . op_status ) ) log . debug ( "Import config to domain was successfull" ) return mgmt_importer
This operation imports UcsCentral Domain's config created earlier via
schedule backup of the same or other Domains.
This operation imports UcsCentral Domain ' s config created earlier via schedule backup of the same or other Domains .
"""
    This operation imports UcsCentral Domain's config created earlier via
    schedule backup of the same or other Domains.
    Note: Only config-all backup on UcsCentral are available for import, local
    or remote import is not supported for domain

    Args:
        handle (UcscHandle): connection handle
        to_domain_ip(str): IP of domain To which you want to import
                           set 'None' if domain_name is valid
        from_domain_ip(str): IP of domain From which you want to import
                             set 'None' if domain_name is valid
        config_file(str): From domain's config file which you want to import
        merge (boolean): True/False, specifies whether to merge the backup
                         config with the existing domain configuration
        to_domain_name(str): to domain name, valid only if to_domain_ip is None
        from_domain_name(str): from domain name, valid only if
                               from_domain_ip is None
        timeout (number) : time in seconds for which method waits for
                           import operation success before timing out

    Example:
        import_config_domain(handle, to_domain_ip="10.10.10.100",
                             from_domain_ip="192.168.1.1",
                             config_file="all-cfg.1.tgz")\n

    """ # Break condition:- if state id disabled then break
handle
None
to_domain_ip
IP of domain To which you want to import
set 'None' if domain_name is valid
IP of domain To which you want to import set ' None ' if domain_name is valid
from_domain_ip
IP of domain From which you want to import
set 'None' if domain_name is valid
IP of domain From which you want to import set ' None ' if domain_name is valid
config_file
From domain's config file which you want to import
From domain ' s config file which you want to import
merge
True/False, specifies whether to merge the backup
config with the existing domain configuration
True / False specifies whether to merge the backup config with the existing domain configuration
to_domain_name
to domain name, valid only if to_domain_ip is None
to domain name valid only if to_domain_ip is None
from_domain_name
from domain name, valid only if
from_domain_ip is None
from domain name valid only if from_domain_ip is None
timeout
time in seconds for which method waits for
import operation success before timing out
time in seconds for which method waits for import operation success before timing out
examples
None