예제 #1
0
def add_discovered_switches(fab_id, tiers, switch_with_ip):
    from bootstrap import bootstrap
    logger.debug("Adding discovered switches in fabric")
    switch_id_details = dict()
    switch_id_details[SPINE] = dict()
    switch_id_details[LEAF] = dict()
    switch_id_details[CORE] = dict()
    switch_id_details[BORDER] = dict()
    for spine_switch in tiers[SPINE]:
        logger.debug("Adding spine switch:%s in fabric", spine_switch[0])
        switch = Switch()
        switch.tier = SPINE
        switch.name = spine_switch[0]
        switch.dummy = False
        switch.serial_num = spine_switch[1]
        find_duplicate([spine_switch[1]])
        switch.topology_id = fab_id
        switch.mgmt_ip = switch_with_ip[spine_switch[0]]
        switch.model = SwitchModel.objects.get(id=1)
        switch.save()
        bootstrap.update_boot_detail(switch,
                                     match_type=DISCOVERY,
                                     discovery_rule=None,
                                     boot_time=timezone.now(),
                                     boot_status=BOOT_SUCCESS,
                                     model_type='')
        logger.debug("Spine added")
        switch_id_details[SPINE][spine_switch[0]] = switch.id
    for leaf_switch in tiers[LEAF]:
        logger.debug("Adding leaf switch:%s to fabric", leaf_switch[0])
        switch = Switch()
        switch.tier = LEAF
        switch.name = leaf_switch[0]
        switch.serial_num = leaf_switch[1]
        find_duplicate([leaf_switch[1]])
        switch.topology_id = fab_id
        switch.mgmt_ip = switch_with_ip[leaf_switch[0]]
        switch.model = SwitchModel.objects.get(id=1)
        switch.save()
        bootstrap.update_boot_detail(switch,
                                     match_type=DISCOVERY,
                                     discovery_rule=None,
                                     boot_time=timezone.now(),
                                     boot_status=BOOT_SUCCESS,
                                     model_type='')
        logger.debug("Leaf added")
        switch_id_details[LEAF][leaf_switch[0]] = switch.id
    for core_switch in tiers[CORE]:
        logger.debug("Adding core switch:%s in fabric", core_switch)
        switch = Switch()
        switch.tier = CORE
        switch.name = core_switch
        switch.dummy = False
        switch.topology_id = fab_id
        switch.model = SwitchModel.objects.get(id=1)
        switch.save()
        bootstrap.update_boot_detail(switch,
                                     match_type=DISCOVERY,
                                     discovery_rule=None,
                                     boot_time=timezone.now(),
                                     boot_status=BOOT_SUCCESS,
                                     model_type='')
        logger.debug("core added")
        switch_id_details[CORE][core_switch] = switch.id
    for border_switch in tiers[BORDER]:
        logger.debug("Adding border switch:%s in fabric", border_switch)
        switch = Switch()
        switch.tier = BORDER
        switch.name = border_switch
        switch.dummy = False
        switch.topology_id = fab_id
        switch.model = SwitchModel.objects.get(id=1)
        switch.save()
        bootstrap.update_boot_detail(switch,
                                     match_type=DISCOVERY,
                                     discovery_rule=None,
                                     boot_time=timezone.now(),
                                     boot_status=BOOT_SUCCESS,
                                     model_type='')
        logger.debug("Border added")
        switch_id_details[BORDER][border_switch] = switch.id

    return switch_id_details
예제 #2
0
파일: fabric.py 프로젝트: datacenter/ignite
def add_discovered_switches(fab_id, tiers, switch_with_ip):
    from bootstrap import bootstrap
    logger.debug("Adding discovered switches in fabric")
    switch_id_details = dict()
    switch_id_details[SPINE] = dict()
    switch_id_details[LEAF] = dict()
    switch_id_details[CORE] = dict()
    switch_id_details[BORDER] = dict()
    for spine_switch in tiers[SPINE]:
        logger.debug("Adding spine switch:%s in fabric", spine_switch[0])
        switch = Switch()
        switch.tier = SPINE
        switch.name = spine_switch[0]
        switch.dummy = False
        switch.serial_num = spine_switch[1]
        find_duplicate([spine_switch[1]])
        switch.topology_id = fab_id
        switch.mgmt_ip = switch_with_ip[spine_switch[0]]
        switch.model = SwitchModel.objects.get(id=1)
        switch.save()
        bootstrap.update_boot_detail(switch,
                                      match_type=DISCOVERY,
                                      discovery_rule=None,
                                      boot_time=timezone.now(),
                                      boot_status=BOOT_SUCCESS,
                                      model_type='')
        logger.debug("Spine added")
        switch_id_details[SPINE][spine_switch[0]] = switch.id
    for leaf_switch in tiers[LEAF]:
        logger.debug("Adding leaf switch:%s to fabric", leaf_switch[0])
        switch = Switch()
        switch.tier = LEAF
        switch.name = leaf_switch[0]
        switch.serial_num = leaf_switch[1]
        find_duplicate([leaf_switch[1]])
        switch.topology_id = fab_id
        switch.mgmt_ip = switch_with_ip[leaf_switch[0]]
        switch.model = SwitchModel.objects.get(id=1)
        switch.save()
        bootstrap.update_boot_detail(switch,
                                      match_type=DISCOVERY,
                                      discovery_rule=None,
                                      boot_time=timezone.now(),
                                      boot_status=BOOT_SUCCESS,
                                      model_type='')
        logger.debug("Leaf added")
        switch_id_details[LEAF][leaf_switch[0]] = switch.id
    for core_switch in tiers[CORE]:
        logger.debug("Adding core switch:%s in fabric", core_switch)
        switch = Switch()
        switch.tier = CORE
        switch.name = core_switch
        switch.dummy = False
        switch.topology_id = fab_id
        switch.model = SwitchModel.objects.get(id=1)
        switch.save()
        bootstrap.update_boot_detail(switch,
                                      match_type=DISCOVERY,
                                      discovery_rule=None,
                                      boot_time=timezone.now(),
                                      boot_status=BOOT_SUCCESS,
                                      model_type='')
        logger.debug("core added")
        switch_id_details[CORE][core_switch] = switch.id
    for border_switch in tiers[BORDER]:
        logger.debug("Adding border switch:%s in fabric", border_switch)
        switch = Switch()
        switch.tier = BORDER
        switch.name = border_switch
        switch.dummy = False
        switch.topology_id = fab_id
        switch.model = SwitchModel.objects.get(id=1)
        switch.save()
        bootstrap.update_boot_detail(switch,
                                      match_type=DISCOVERY,
                                      discovery_rule=None,
                                      boot_time=timezone.now(),
                                      boot_status=BOOT_SUCCESS,
                                      model_type='')
        logger.debug("Border added")
        switch_id_details[BORDER][border_switch] = switch.id

    return switch_id_details