Пример #1
0
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
0
                    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()