本文整理汇总了Python中topology.BaseTopology.get_object方法的典型用法代码示例。如果您正苦于以下问题:Python BaseTopology.get_object方法的具体用法?Python BaseTopology.get_object怎么用?Python BaseTopology.get_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类topology.BaseTopology
的用法示例。
在下文中一共展示了BaseTopology.get_object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_topology_link
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
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
示例2: update_topology_defaults
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
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
示例3: update_topology_switch
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
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
示例4: update_switch
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
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)
示例5: get_instance_value
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
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))
示例6: get_all_switches
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
def get_all_switches(fab_id, build=True):
return BaseTopology.get_object(fab_id).get_all_switches(build)
示例7: update_defaults
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
def update_defaults(fab_id, data, user):
BaseTopology.get_object(fab_id, user).update_defaults(data)
示例8: delete_link
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
def delete_link(fab_id, link_id, user):
BaseTopology.get_object(fab_id, user).delete_link(link_id, True)
示例9: update_link
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
def update_link(fab_id, link_id, data, user):
BaseTopology.get_object(fab_id, user).update_link(link_id, data)
示例10: add_link
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
def add_link(fab_id, data, user):
BaseTopology.get_object(fab_id, user).add_link(data)
示例11: decommission_switch
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
def decommission_switch(fab_id, switch_id, user):
BaseTopology.get_object(fab_id, user).decommission_switch(switch_id)
示例12: delete_switch
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
def delete_switch(fab_id, switch_id, user):
BaseTopology.get_object(fab_id, user).delete_switch(switch_id)
示例13: add_switches
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
def add_switches(fab_id, data, user):
BaseTopology.get_object(fab_id, user).add_switches(data)
示例14: delete_topology_link
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
def delete_topology_link(top_id, link_id, user=""):
BaseTopology.get_object(top_id, user).delete_link(link_id)
serializer = TopologySerializer(BaseTopology.get_topology(top_id))
return serializer.data
示例15: delete_topology_switch
# 需要导入模块: from topology import BaseTopology [as 别名]
# 或者: from topology.BaseTopology import get_object [as 别名]
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