ucscsdk/utils/ucscdomain.py
def domain_register(handle, domain_name_or_ip,
                    username, password,
                    timeout=2 * 60):
    """
    This method registers Ucs domain to Ucs Central.

    Args:
        handle (UcscHandle): UcsCentral Connection handle
        domain_name_or_ip (str): Domain name or IP
        username(str): User name of the domain
        password(str): Password of the domain

    Returns:
        PolicyControlEpOp object

    Example:
        domain_register(handle, domain_name_or_ip="192.168.1.1",
                        username="admin",password="password")
    """

    from distutils.version import LooseVersion as VERSION
    from ucscsdk.mometa.policy.PolicyControlEpOp import\
        PolicyControlEpOp, PolicyControlEpOpConsts

    if VERSION(handle.get_firmware_version()) < VERSION("1.5"):
        raise UcscOperationError(
                "Domain register",
                "Operation only supported from version 1.5 onwards")

    if is_domain_registered(handle, domain_name_or_ip):
        domain_dn = "holder/domain-ep/control-ep-" + domain_name_or_ip
        domain_register = handle.query_dn(domain_dn)
        log.debug("Domain already registered with Ucs Central")
        return domain_register

    parent_dn = "holder/domain-ep"

    domain_register = PolicyControlEpOp(parent_mo_or_dn=parent_dn,
                                        host_name_or_ip=domain_name_or_ip,
                                        name=username,
                                        password=password)
    domain_register.action_event = \
        PolicyControlEpOpConsts.ACTION_EVENT_REGISTER
    handle.add_mo(domain_register)
    handle.commit()

    start = datetime.datetime.now()
    while not domain_register.registration_state == \
            PolicyControlEpOpConsts.REGISTRATION_STATE_REGISTERED:
        domain_register = handle.query_dn(domain_register.dn)
        if domain_register.registration_state == \
                PolicyControlEpOpConsts.REGISTRATION_STATE_FAILED:
            raise UcscOperationError(
                    "Registration of '%s'" %
                    domain_name_or_ip, "%s" %
                    domain_register.fsm_rmt_inv_err_descr)
        if (datetime.datetime.now() - start).total_seconds() > timeout:
            raise UcscOperationError(
                    "Registration of '%s' " %
                    domain_name_or_ip, "timeout error %s" %
                    domain_register.fsm_rmt_inv_err_descr)

    log.debug("Domain got successfully registered with Ucs Central")
    return domain_register

    This method registers Ucs domain to Ucs Central.

    Args:
        handle (UcscHandle): UcsCentral Connection handle
        domain_name_or_ip (str): Domain name or IP
        username(str): User name of the domain
        password(str): Password of the domain

    Returns:
        PolicyControlEpOp object

    Example:
        domain_register(handle, domain_name_or_ip="192.168.1.1",
                        username="admin",password="password")
    
This method registers Ucs domain to Ucs Central.
This method registers Ucs domain to Ucs Central .
def domain_register(handle, domain_name_or_ip,
                    username, password,
                    timeout=2 * 60):
    from distutils.version import LooseVersion as VERSION
    from ucscsdk.mometa.policy.PolicyControlEpOp import\
        PolicyControlEpOp, PolicyControlEpOpConsts
    if VERSION(handle.get_firmware_version()) < VERSION("1.5"):
        raise UcscOperationError(
                "Domain register",
                "Operation only supported from version 1.5 onwards")
    if is_domain_registered(handle, domain_name_or_ip):
        domain_dn = "holder/domain-ep/control-ep-" + domain_name_or_ip
        domain_register = handle.query_dn(domain_dn)
        log.debug("Domain already registered with Ucs Central")
        return domain_register
    parent_dn = "holder/domain-ep"
    domain_register = PolicyControlEpOp(parent_mo_or_dn=parent_dn,
                                        host_name_or_ip=domain_name_or_ip,
                                        name=username,
                                        password=password)
    domain_register.action_event = \
        PolicyControlEpOpConsts.ACTION_EVENT_REGISTER
    handle.add_mo(domain_register)
    handle.commit()
    start = datetime.datetime.now()
    while not domain_register.registration_state == \
            PolicyControlEpOpConsts.REGISTRATION_STATE_REGISTERED:
        domain_register = handle.query_dn(domain_register.dn)
        if domain_register.registration_state == \
                PolicyControlEpOpConsts.REGISTRATION_STATE_FAILED:
            raise UcscOperationError(
                    "Registration of '%s'" %
                    domain_name_or_ip, "%s" %
                    domain_register.fsm_rmt_inv_err_descr)
        if (datetime.datetime.now() - start).total_seconds() > timeout:
            raise UcscOperationError(
                    "Registration of '%s' " %
                    domain_name_or_ip, "timeout error %s" %
                    domain_register.fsm_rmt_inv_err_descr)
    log.debug("Domain got successfully registered with Ucs Central")
    return domain_register
def domain_register ( handle , domain_name_or_ip , username , password , timeout = 2 * 60 ) : from distutils . version import LooseVersion as VERSION from ucscsdk . mometa . policy . PolicyControlEpOp import PolicyControlEpOp , PolicyControlEpOpConsts if VERSION ( handle . get_firmware_version ( ) ) < VERSION ( "1.5" ) : raise UcscOperationError ( "Domain register" , "Operation only supported from version 1.5 onwards" ) if is_domain_registered ( handle , domain_name_or_ip ) : domain_dn = "holder/domain-ep/control-ep-" + domain_name_or_ip domain_register = handle . query_dn ( domain_dn ) log . debug ( "Domain already registered with Ucs Central" ) return domain_register parent_dn = "holder/domain-ep" domain_register = PolicyControlEpOp ( parent_mo_or_dn = parent_dn , host_name_or_ip = domain_name_or_ip , name = username , password = password ) domain_register . action_event = PolicyControlEpOpConsts . ACTION_EVENT_REGISTER handle . add_mo ( domain_register ) handle . commit ( ) start = datetime . datetime . now ( ) while not domain_register . registration_state == PolicyControlEpOpConsts . REGISTRATION_STATE_REGISTERED : domain_register = handle . query_dn ( domain_register . dn ) if domain_register . registration_state == PolicyControlEpOpConsts . REGISTRATION_STATE_FAILED : raise UcscOperationError ( "Registration of '%s'" % domain_name_or_ip , "%s" % domain_register . fsm_rmt_inv_err_descr ) if ( datetime . datetime . now ( ) - start ) . total_seconds ( ) > timeout : raise UcscOperationError ( "Registration of '%s' " % domain_name_or_ip , "timeout error %s" % domain_register . fsm_rmt_inv_err_descr ) log . debug ( "Domain got successfully registered with Ucs Central" ) return domain_register
This method registers Ucs domain to Ucs Central.
This method registers Ucs domain to Ucs Central .
"""
    This method registers Ucs domain to Ucs Central.

    Args:
        handle (UcscHandle): UcsCentral Connection handle
        domain_name_or_ip (str): Domain name or IP
        username(str): User name of the domain
        password(str): Password of the domain

    Returns:
        PolicyControlEpOp object

    Example:
        domain_register(handle, domain_name_or_ip="192.168.1.1",
                        username="admin",password="password")
    """
None
handle
UcsCentral Connection handle
UcsCentral Connection handle
domain_name_or_ip
Domain name or IP
Domain name or IP
username
User name of the domain
User name of the domain
password
Password of the domain
Password of the domain
timeout
examples
domain_register(handle, domain_name_or_ip="192.168.1.1",
username="admin",password="password")
domain_register ( handle domain_name_or_ip = " 192 . 168 . 1 . 1 " username = " admin " password = " password " )