hosts = ['00000000-0000-0000-0000-000000000001',
             '00000000-0000-0000-0000-000000000002',
             '00000000-0000-0000-0000-000000000003']
    addresses = ['10.0.0.8','10.0.0.9','10.0.0.10']
    if not all(hosts):
        print "host uuid file(s) is not found"
        sys.exit(1)

    api = MidonetApi('http://127.0.0.1:8080/midonet-api','admin','*')
    tx = Transaction()
    try:
        zone = TunnelZone({'name': 'zone0', 'type': 'gre'})
        zone.add(api,tx,map(lambda h,a:
                                TunnelZoneHost({'hostId': h,'ipAddress': a}),
                            hosts,addresses))
        bridge = Bridge({'name':'bridge0','tenantId':tenantIds[0]})
        bridge.add(api,tx,map(lambda h:
                                  HostInterface({'hostId': h,'name':'veth0'}),
                              hosts))

        chains = {'in': Chain({'name':'in','tenantId':tenantIds[0]}),
                  'out': Chain({'name':'out','tenantId':tenantIds[0]})}
        map(lambda key: chains[key].add(api,tx),chains)

        router = Router({'name': 'router0','tenantId': tenantIds[0],
                         'chains': chains})
        router.add(api,tx,[(RouterPort({'portAddress': '172.16.0.240',
                                        'networkAddress': '172.16.0.0',
                                        'networkLength': 24}),
                            bridge)])
        tenant_routers = []
    addresses = ['10.0.0.8', '10.0.0.9', '10.0.0.10']
    if not all(hosts):
        print "host uuid file(s) is not found"
        sys.exit(1)

    api = MidonetApi('http://127.0.0.1:8080/midonet-api', 'admin', '*')
    tx = Transaction()
    try:
        zone = TunnelZone({'name': 'zone0', 'type': 'gre'})
        zone.add(
            api, tx,
            map(lambda h, a: TunnelZoneHost({
                'hostId': h,
                'ipAddress': a
            }), hosts, addresses))
        bridge = Bridge({'name': 'bridge0', 'tenantId': tenantIds[0]})
        bridge.add(
            api, tx,
            map(lambda h: HostInterface({
                'hostId': h,
                'name': 'veth0'
            }), hosts))

        chains = {
            'in': Chain({
                'name': 'in',
                'tenantId': tenantIds[0]
            }),
            'out': Chain({
                'name': 'out',
                'tenantId': tenantIds[0]
Esempio n. 3
0
    tenants = map(get_tenant, tenantNames)
    if not all(tenants):
        print "not all tenants are found"
        sys.exit(1)
    tenantIds = map(lambda tenant: tenant.id, tenants)

    hosts = ["00000000-0000-0000-0000-000000000001"]
    addresses = ["10.0.0.8"]
    if not all(hosts):
        print "host uuid file(s) is not found"
        sys.exit(1)

    api = MidonetApi("http://127.0.0.1:8080/midonet-api", "admin", "*")
    tx = Transaction()
    try:
        bridge = Bridge({"name": "bridge0", "tenantId": tenantIds[0]})
        bridge.add(
            api,
            tx,
            [
                HostInterface({"hostId": hosts[0], "name": "veth0"}),
                HostInterface({"hostId": hosts[0], "name": "veth1"}),
                HostInterface({"hostId": hosts[0], "name": "veth2"}),
                HostInterface({"hostId": hosts[0], "name": "veth3"}),
                HostInterface({"hostId": hosts[0], "name": "veth4"}),
                HostInterface({"hostId": hosts[0], "name": "veth5"}),
            ],
        )
        router = Router({"name": "router0", "tenantId": tenantIds[0]})
        router.add(
            api,
Esempio n. 4
0
    hosts = ['00000000-0000-0000-0000-000000000001',
             '00000000-0000-0000-0000-000000000002',
             '00000000-0000-0000-0000-000000000003']
    addresses = ['10.0.0.8','10.0.0.9','10.0.0.10']
    if not all(hosts):
        print "host uuid file(s) is not found"
        sys.exit(1)

    api = MidonetApi('http://127.0.0.1:8080/midonet-api','admin','*')
    tx = Transaction()
    try:
        zone = TunnelZone({'name': 'zone0', 'type': 'gre'})
        zone.add(api,tx,map(lambda h,a:
                                TunnelZoneHost({'hostId': h,'ipAddress': a}),
                            hosts,addresses))
        bridge = Bridge({'name':'bridge0','tenantId':providerId})
        bridge.add(api,tx,map(lambda h:
                                  HostInterface({'hostId': h,'name':'veth0'}),
                              hosts))
        router = Router({'name':'router0','tenantId':providerId})
        router.add(api,tx,[(RouterPort({'portAddress': '172.16.0.240',
                                        'networkAddress': '172.16.0.0',
                                        'networkLength': 24}),
                            bridge)])
    except:
        traceback.print_exc()
        tx.rollback()

    # import pdb; pdb.set_trace()
    # tx.rollback()
Esempio n. 5
0
    tenants = map(get_tenant, tenantNames)
    if not all(tenants):
        print "not all tenants are found"
        sys.exit(1)
    tenantIds = map(lambda tenant: tenant.id, tenants)

    hosts = ['00000000-0000-0000-0000-000000000001']
    addresses = ['10.0.0.8']
    if not all(hosts):
        print "host uuid file(s) is not found"
        sys.exit(1)

    api = MidonetApi('http://127.0.0.1:8080/midonet-api', 'admin', '*')
    tx = Transaction()
    try:
        bridge = Bridge({'name': 'bridge0', 'tenantId': tenantIds[0]})
        bridge.add(api, tx, [
            HostInterface({
                'hostId': hosts[0],
                'name': 'veth0'
            }),
            HostInterface({
                'hostId': hosts[0],
                'name': 'veth1'
            }),
            HostInterface({
                'hostId': hosts[0],
                'name': 'veth2'
            }),
            HostInterface({
                'hostId': hosts[0],
             '00000000-0000-0000-0000-000000000002',
             '00000000-0000-0000-0000-000000000003']
    addresses = ['10.0.0.8','10.0.0.9','10.0.0.10']
    if not all(hosts):
        print "host uuid file(s) is not found"
        sys.exit(1)

    api = MidonetApi('http://127.0.0.1:8080/midonet-api','admin','*')
    tx = Transaction()
    try:
        zone = TunnelZone({'name': 'zone0', 'type': 'gre'})
        zone.add(api,tx,map(lambda h,a:
                                TunnelZoneHost({'hostId': h,'ipAddress': a}),
                            hosts,addresses))

        bridge = Bridge({'name':'bridge0','tenantId':tenantIds[0]})
        bridge.add(api,tx,[HostInterface({'hostId': hosts[0],'name':'veth0'}),
                           HostInterface({'hostId': hosts[1],'name':'veth0'}),
                           HostInterface({'hostId': hosts[2],'name':'veth0'})])
        router = Router({'name':'router0','tenantId':tenantIds[0]})
        router.add(api,tx,[(RouterPort({'portAddress': '172.16.0.240',
                                        'networkAddress': '172.16.0.0',
                                        'networkLength': 24}),
                            bridge)])
        tenant_routers = []
        tenant_routers.append(router)

        bridge = Bridge({'name':'bridge0','tenantId':tenantIds[1]})
        bridge.add(api,tx,[HostInterface({'hostId': hosts[1],'name':'veth1'}),
                           HostInterface({'hostId': hosts[1],'name':'veth2'})])
        router = Router({'name':'router0','tenantId':tenantIds[1]})
Esempio n. 7
0
    hosts = ['00000000-0000-0000-0000-000000000001',
             '00000000-0000-0000-0000-000000000002',
             '00000000-0000-0000-0000-000000000003']
    addresses = ['10.0.0.8','10.0.0.9','10.0.0.10']
    if not all(hosts):
        print "host uuid file(s) is not found"
        sys.exit(1)

    api = MidonetApi('http://127.0.0.1:8080/midonet-api','admin','*')
    tx = Transaction()
    try:
        zone = TunnelZone({'name': 'zone0', 'type': 'gre'})
        zone.add(api,tx,map(lambda h,a:
                                TunnelZoneHost({'hostId': h,'ipAddress': a}),
                            hosts,addresses))
        bridge1 = Bridge({'name':'bridge1','tenantId':tenantIds[0],'vlanId':"1"})
        bridge1.add(api,tx,[HostInterface({'hostId': hosts[0],'name':'veth0'}),
                            HostInterface({'hostId': hosts[1],'name':'veth0'})])
        bridge2 = Bridge({'name':'bridge2','tenantId':tenantIds[1],'vlanId':"2"})
        bridge2.add(api,tx,[HostInterface({'hostId': hosts[1],'name':'veth1'}),
                            HostInterface({'hostId': hosts[1],'name':'veth2'})])
        trunk_bridge = Bridge({'name':'bridge0','tenantId':providerId})
        trunk_bridge.add(api,tx,
                         [HostInterface({'hostId': hosts[0],'name':'eth2'}),
                          HostInterface({'hostId': hosts[1],'name':'eth2'}),
                          bridge1,
                          bridge2])
    except:
        traceback.print_exc()
        tx.rollback()