当前位置: 首页>>代码示例>>Python>>正文


Python topology.BaseTopology类代码示例

本文整理汇总了Python中topology.BaseTopology的典型用法代码示例。如果您正苦于以下问题:Python BaseTopology类的具体用法?Python BaseTopology怎么用?Python BaseTopology使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BaseTopology类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_topology_defaults

def update_topology_defaults(top_id, data, user=""):
    serializer = TopologyPostDefaultsSerializer(data=data)
    if not serializer.is_valid():
        raise IgniteException(serializer.errors)

    BaseTopology.get_object(top_id, user).update_defaults(serializer.data)
    serializer = TopologySerializer(BaseTopology.get_topology(top_id))
    return serializer.data
开发者ID:datacenter,项目名称:ignite,代码行数:8,代码来源:services.py

示例2: add_topology_link

def add_topology_link(top_id, data, user=""):
    serializer = LinkPostSerializer(data=data)
    if not serializer.is_valid():
        raise IgniteException(serializer.errors)

    BaseTopology.get_object(top_id, user).add_link(serializer.data)
    serializer = TopologySerializer(BaseTopology.get_topology(top_id))
    return serializer.data
开发者ID:datacenter,项目名称:ignite,代码行数:8,代码来源:services.py

示例3: update_topology_switch

def update_topology_switch(top_id, switch_id, data, user=""):
    serializer = TopologySwitchPutSerializer(data=data)
    if not serializer.is_valid():
        raise IgniteException(serializer.errors)

    BaseTopology.get_object(top_id, user).update_switch(switch_id,
                                                        serializer.data)
    serializer = TopologySerializer(BaseTopology.get_topology(top_id))
    return serializer.data
开发者ID:datacenter,项目名称:ignite,代码行数:9,代码来源:services.py

示例4: update_switch

def update_switch(fab_id, switch_id, data, user):
    switch = Switch.objects.get(pk=switch_id)

    # check if switch is already booted
    if switch.boot_detail:
        if any([switch.name != data[NAME], switch.model.id != data[MODEL], switch.serial_num != data[SERIAL_NUM]]):
            raise IgniteException(ERR_NO_NAME_CHANGE)

    # check if switch already exists with new name
    # switch name is searched across all fabrics
    if (switch.name != data[NAME] and
            Switch.objects.filter(topology__is_fabric=True, dummy=False,
                                  name=data[NAME])):
        raise IgniteException(ERR_SW_NAME_IN_USE)

    switch.name = data[NAME]

    # check if switch already exists with new serial num
    # note: serial numbers are unique across fabrics
    if (data[SERIAL_NUM] and switch.serial_num != data[SERIAL_NUM] and
            Switch.objects.filter(dummy=False, serial_num=data[SERIAL_NUM])):
        raise IgniteException(ERR_SERIAL_NUM_IN_USE)
    # check if serial_num exists in discovery rules
    find_dup_serial_discovery([data[SERIAL_NUM]])
    switch.serial_num = data[SERIAL_NUM]

    new_model = get_switch(data[MODEL])

    # is there a change in model?
    change = True if new_model != switch.model else False
    logger.debug("%schange in switch model", "no " if not change else "")

    # save new values
    switch.model = new_model
    switch.image_profile = (image.get_profile(data[IMAGE_PROFILE])
                            if data[IMAGE_PROFILE] else None)
    switch.config_profile = (config.get_profile(data[CONFIG_PROFILE])
                             if data[CONFIG_PROFILE] else None)
    switch.feature_profile = (feature.get_profile(data[FEATURE_PROFILE])
                              if data[FEATURE_PROFILE] else None)
    switch.workflow = (workflow.get_workflow(data[WORKFLOW])
                       if data[WORKFLOW] else None)

    switch.save()

    if change:
        BaseTopology.get_object(fab_id, user).update_model(switch)
    else:
        Fabric.objects.filter(pk=fab_id).update(updated_by=user)
开发者ID:sushantpande,项目名称:ignite,代码行数:49,代码来源:fabric.py

示例5: add_topology

def add_topology(data, user=""):
    serializer = TopologyPostSerializer(data=data)
    if not serializer.is_valid():
        raise IgniteException(serializer.errors)

    top = BaseTopology.create_object(serializer.data[MODEL_NAME])
    serializer = TopologySerializer(top.add_topology(serializer.data, user))
    return serializer.data
开发者ID:datacenter,项目名称:ignite,代码行数:8,代码来源:services.py

示例6: get_instance_value

def get_instance_value(instance_value, switch, switch_name):
    logger.debug("Get Instance value for %s" % instance_value)

    if instance_value == HOST_NAME:
        if switch:
            return switch.name
        return switch_name

    if instance_value == VPC_PEER_SRC:

        if not switch.mgmt_ip:
            raise IgniteException("%s- %s"
                                  % (ERR_MGMT_IP_NOT_DETERMINED,
                                     switch.name))

        return switch.mgmt_ip

    if not switch.topology:
        raise IgniteException("%s- %s"
                              % (ERR_SWITCH_FABRIC_NOT_DETERMINED,
                                 switch.name))

    topo = BaseTopology.get_object(switch.topology.id)

    if instance_value == VPC_PEER_DST:
        peer_switch = topo.get_vpc_peer_switch(switch)

        if not peer_switch.mgmt_ip:

            if not switch.mgmt_ip:
                raise IgniteException("%s- %s"
                                      % (ERR_MGMT_IP_NOT_DETERMINED,
                                         switch.name))

            return get_peer_mgmt_ip(switch, peer_switch)
        else:

            if not peer_switch.mgmt_ip:
                raise IgniteException("%s- %s"
                                      % (ERR_PEER_MGMT_IP_NOT_DETERMINED,
                                         switch.name))
            return peer_switch.mgmt_ip

    if instance_value == VPC_PEER_PORTS:
        return (topo.get_vpc_peer_ports(switch))

    if instance_value == UPLINK_PORTS:
        return (topo.get_uplink_ports(switch))

    if instance_value == DOWNLINK_PORTS:
        return (topo.get_downlink_ports(switch))

    raise IgniteException("%s- %s Instance %s"
                          % (ERR_FAILED_TO_GET_INSTANCE_PARAM_VALUE,
                             switch.name, instance_value))
开发者ID:datacenter,项目名称:ignite,代码行数:55,代码来源:build.py

示例7: delete_switch

def delete_switch(fab_id, switch_id, user):
    BaseTopology.get_object(fab_id, user).delete_switch(switch_id)
开发者ID:hasebrand,项目名称:ignite,代码行数:2,代码来源:fabric.py

示例8: add_switches

def add_switches(fab_id, data, user):
    BaseTopology.get_object(fab_id, user).add_switches(data)
开发者ID:hasebrand,项目名称:ignite,代码行数:2,代码来源:fabric.py

示例9: delete_fabric

def delete_fabric(fab_id):
    BaseTopology.delete_topology(fab_id)
开发者ID:hasebrand,项目名称:ignite,代码行数:2,代码来源:fabric.py

示例10: get_fabric

def get_fabric(fab_id):
    # get topology info, then add fabric info
    top = BaseTopology.get_topology(fab_id)
    top.site = top.fabric.site
    return top
开发者ID:hasebrand,项目名称:ignite,代码行数:5,代码来源:fabric.py

示例11: get_all_topologies

def get_all_topologies(submit):
    top_list = BaseTopology.get_all_topologies(submit)
    serializer = TopologyBriefSerializer(top_list, many=True)
    return serializer.data
开发者ID:datacenter,项目名称:ignite,代码行数:4,代码来源:services.py

示例12: set_submit

def set_submit(fab_id, data, user):
    BaseTopology.set_submit(fab_id, data, user)
开发者ID:hasebrand,项目名称:ignite,代码行数:2,代码来源:fabric.py

示例13: update_link

def update_link(fab_id, link_id, data, user):
    BaseTopology.get_object(fab_id, user).update_link(link_id, data)
开发者ID:hasebrand,项目名称:ignite,代码行数:2,代码来源:fabric.py

示例14: delete_topology_switch

def delete_topology_switch(top_id, switch_id, user=""):
    BaseTopology.get_object(top_id, user).delete_switch(switch_id)
    serializer = TopologySerializer(BaseTopology.get_topology(top_id))
    return serializer.data
开发者ID:datacenter,项目名称:ignite,代码行数:4,代码来源:services.py

示例15: delete_topology

def delete_topology(top_id):
    BaseTopology.delete_topology(top_id)
开发者ID:datacenter,项目名称:ignite,代码行数:2,代码来源:services.py


注:本文中的topology.BaseTopology类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。