Exemple #1
0
def _generate_switch_info(switch_type, data):
    switch_info = dict()
    meta = dict()
    slot_list = []

    for role in PORT_ROLES:
        # for each role, create a list of ports belonging to that role
        switch_info[role] = list()
        meta[role] = list()

    for speed in PORT_SPEEDS:
        # number of ports at each speed
        switch_info[speed] = 0

    if switch_type == FIXED:
        _scan_port_groups(switch_info, meta, 1, data[PORT_GROUPS])

        module_id = data.get(MODULE_ID, 0)

        if module_id:
            module = linecard.get_linecard(module_id)
            linecard.update_ref_count(module_id, 1)
            _scan_port_groups(switch_info, meta, 2, module.lc_data[PORT_GROUPS])
    else:
        for slot in data[SLOTS]:
            lc = linecard.get_linecard(slot[LC_ID])
            linecard.update_ref_count(slot[LC_ID], 1)
            slot_list.append(slot[SLOT_NUM])
            _scan_port_groups(switch_info, meta, slot[SLOT_NUM],
                              lc.lc_data[PORT_GROUPS])

        if len(slot_list) != len(set(slot_list)):
            raise IgniteException(ERR_SW_SLOT_IN_USE)

    return switch_info, meta
Exemple #2
0
def _generate_switch_info(switch_type, data):
    switch_info = dict()
    meta = dict()
    slot_list = []

    for role in PORT_ROLES:
        # for each role, create a list of ports belonging to that role
        switch_info[role] = list()
        meta[role] = list()

    for speed in PORT_SPEEDS:
        # number of ports at each speed
        switch_info[speed] = 0

    if switch_type == FIXED:
        _scan_port_groups(switch_info, meta, 1, data[PORT_GROUPS])

        module_id = data.get(MODULE_ID, 0)

        if module_id:
            module = linecard.get_linecard(module_id)
            linecard.update_ref_count(module_id, 1)
            _scan_port_groups(switch_info, meta, 2,
                              module.lc_data[PORT_GROUPS])
    else:
        for slot in data[SLOTS]:
            lc = linecard.get_linecard(slot[LC_ID])
            linecard.update_ref_count(slot[LC_ID], 1)
            slot_list.append(slot[SLOT_NUM])
            _scan_port_groups(switch_info, meta, slot[SLOT_NUM],
                              lc.lc_data[PORT_GROUPS])

        if len(slot_list) != len(set(slot_list)):
            raise IgniteException(ERR_SW_SLOT_IN_USE)

    return switch_info, meta
Exemple #3
0
def get_linecard(id):
    lc = linecard.get_linecard(id)
    serializer = LineCardSerializer(lc)
    return serializer.data