本文整理汇总了Python中orc.Orc.get_topology方法的典型用法代码示例。如果您正苦于以下问题:Python Orc.get_topology方法的具体用法?Python Orc.get_topology怎么用?Python Orc.get_topology使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orc.Orc
的用法示例。
在下文中一共展示了Orc.get_topology方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_ovs_swarm
# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import get_topology [as 别名]
def setup_ovs_swarm(topology=None, nodes=None, contr_addr="10.12.1.20:6633"):
"""
Setup ovs over each host in the topology
Parameters:
topology: dict of interconections
nodes: list/dict of nodes and their properties
e.g. IP address
contr_addr: ["X.X.X.X"|None] if None, configures switches
in stanalone mode
"""
if not topology:
#NOTE: This may potentially cause a circular dependency
orc = Orc()
topology = orc.topology
if not nodes:
if not orc:
orc = Orc()
nodes = orc.get_topology()
if type(nodes) == list:
#transform nodes into nodename mapped dict
node_dict = {}
for node in nodes:
ut.is_prefix(config.instance_prefix, node['name'])
node_name = node['name'][len(config.instance_prefix): ]
node_dict[node_name] = node
nodes = node_dict
def _get_connections(remote):
"""remote_node obj -> {'vni':#, 'remote_ip': remote_node IP}"""
#NOTE: all nodes share the VNI
return {'vni':1, 'remote_ip': nodes[remote]['addr']}
for node_name, node in nodes.items():
connections = map(_get_connections, topology[node_name])
setup_host(contr_addr=contr_addr,
connections=connections,
int_ip = ut.overlay_ip(node['addr']),
ip = node['addr'])
示例2: server
# 需要导入模块: from orc import Orc [as 别名]
# 或者: from orc.Orc import get_topology [as 别名]
help="provide info on the queryied server(s)")
parser.add_argument('-d', '--delete', nargs='?', const="ALL",
help="delete the server(s) with matching prefix")
parser.add_argument('-m', '--mesh', action='store_true',
help="create a mesh topology. Must be used with --create")
args = parser.parse_args()
if args.mesh and not args.create:
parser.error( "--[m]esh must be used with --[c]reate")
orc = Orc(mesh=args.mesh)
if args.create:
#Create topology
orc.create_topology()
#Print output
map(ut.format_and_print, orc.get_topology())
if args.info:
if args.info == "ALL":
map(ut.format_and_print, orc.get_topology())
else:
orc.get_topology() #args.info
if args.delete:
orc.delete_topology()
if not(args.create or args.info or args.delete):
parser.print_help()