How to use the imcsdk.imcexception.ImcOperationError function in imcsdk

To help you get started, we’ve selected a few imcsdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CiscoUcs / imcsdk / imcsdk / apis / admin / ldap.py View on Github external
def _prepare_ldap_servers(ldap_servers):
    if len(ldap_servers) > len(_LDAP_SERVERS):
        raise ImcOperationError("Configure LDAP", "Cannot configure more than"
                                "%d servers" % len(_LDAP_SERVERS))
    servers = {}
    ports = {}
    for server in ldap_servers:
        if 'id' not in server:
            raise ImcOperationError("Enable LDAP",
                                    "Provide 'id'.")
        id = server['id']
        if id == 0 or id > 6:
            raise ImcOperationError("Enable LDAP",
                                    "Provide valid 'id' (1-6).")
        id = str(id)
        if 'ip' in server:
            servers['ldap_server' + id] = server['ip']
        if 'port' in server:
            ports['ldap_server_port' + id] = str(server['port'])
github CiscoUcs / imcsdk / imcsdk / apis / v2 / server / serveractions.py View on Github external
Returns:
        bool
    """
    # Verify desired state is valid
    if state not in ("on", "off"):
        raise ValueError("ERROR invalid state: {0}".format(state))

    # Verify interval not set to zero
    if interval < 1 or type(interval) is not int:
        raise ValueError("ERROR: interval must be positive integer")

    wait_time = 0
    while server_power_state_get(handle, server_id) != state:
        # Raise error if we've reached timeout
        if wait_time > timeout:
            raise ImcOperationError(
                'Power State Change',
                '{%s}: ERROR - Power {%s} did not complete within '
                '{%s} sec' % (handle.ip, state, timeout)
            )
        # Wait interval sec between checks
        time.sleep(interval)
        wait_time += interval
github CiscoUcs / imcsdk / imcsdk / apis / v2 / server / vic.py View on Github external
def _vic_get(handle, adaptor_slot, name, vic_type, server_id=1):
    """
    Internal method to get vnic and vhba
    """
    from imcsdk.imccoreutils import load_class

    parent_mo = adaptor_unit_get(handle, adaptor_slot, server_id)
    if parent_mo is None:
        raise ImcOperationError("Cannot create %s." % vic_type,
                                "Adaptor unit %s is missing" % adaptor_slot)

    vic_mo_name = vic_map[vic_type]
    vic_mo_class = load_class(vic_mo_name)
    vic_mo = vic_mo_class(parent_mo_or_dn=parent_mo, name=name)
    return handle.query_dn(vic_mo.dn)
github CiscoUcs / imcsdk / imcsdk / apis / v2 / storage / vd.py View on Github external
def _raid_max_size_get(raid_level, total_size, min_size, span_depth):
    size = {0: total_size,
            1: total_size/2,
            5: total_size - (span_depth * 1 * min_size),
            6: total_size - (span_depth * 2 * min_size),
            10: total_size/2,
            50: total_size - (span_depth * 1 * min_size),
            60: total_size - (span_depth * 2 * min_size)}

    if raid_level not in size:
        raise ImcOperationError("Create Virtual Drive",
                                "Unsupported Raid level <%d>" % raid_level)
    return size[raid_level]
github CiscoUcs / imcsdk / imcsdk / apis / v2 / admin / syslog.py View on Github external
handle (ImcHandle)
        caller (string): name of the calling function

    Returns:
        CommSyslog: Managed object

    Raises:
        ImcOperationError

    Example:
        mo = syslog_remote_get(handle, name="primary", caller="myfunc")
    """
    dn = SYSLOG_DN + "/client-" + name
    mo = handle.query_dn(dn=dn)
    if mo is None:
        raise ImcOperationError(caller,
                                "syslog remote client '%s' does not exist" %
                                dn)
    return mo
github CiscoUcs / imcsdk / imcsdk / apis / admin / ldap.py View on Github external
def _get_free_ldap_role_group_id(handle):
    mos = handle.query_classid('AaaLdapRoleGroup')
    for mo in mos:
        if not mo.name and not mo.domain:
            return mo.id

    raise ImcOperationError("LDAP role group create", "No free role group available")
github CiscoUcs / imcsdk / imcsdk / apis / v2 / admin / ldap.py View on Github external
def _get_free_ldap_role_group_id(handle):
    mos = handle.query_classid('AaaLdapRoleGroup')
    for mo in mos:
        if not mo.name and not mo.domain:
            return mo.id

    raise ImcOperationError("LDAP role group create",
                            "No free role group available")
github CiscoUcs / imcsdk / imcsdk / apis / v2 / storage / sdcard.py View on Github external
def flexutil_controller_get(handle):
    controller = handle.query_classid(
        class_id=NamingId.STORAGE_FLEX_UTIL_CONTROLLER)
    if not controller:
        raise ImcOperationError("Get Flex Util Controller",
                                "FlexUtil Controller not found")
    return controller[0]
github CiscoUcs / imcsdk / imcsdk / apis / v2 / server / vic.py View on Github external
def _get_vnic_order(vnic):
    api_error_msg = VicConst.VNIC_ERROR_MSG
    children = vnic._child
    for ch in children:
        if ch.get_class_id() == "AdaptorEthGenProfile":
            return int(ch.order)
    raise ImcOperationError(api_error_msg,
                            "Order is missing.")