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 = []
        tenant_routers.append(router)

        chains = {
            'in': Chain({
                'name': 'in',
                'tenantId': tenantIds[1]
            }),
    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 = []
        tenant_routers.append(router)

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

        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],
Example #3
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, tx, [(RouterPort({
     'portAddress': '172.16.0.240',
     'networkAddress': '172.16.0.0',
     'networkLength': 24
 }), bridge)])
 provider_router = Router({'name': 'router0', 'tenantId': providerId})
 provider_router.add(api, tx, [((RouterPort({
     'portAddress': '169.254.255.1',
     'networkAddress': '169.254.255.0',
     'networkLength': 30
 }),
                                 RouterPort({
                                     'portAddress': '169.254.255.2',
                                     'networkAddress': '169.254.255.0',
                                     'networkLength': 30
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,
        tx,
        [
            (
                RouterPort({"portAddress": "172.16.0.240", "networkAddress": "172.16.0.0", "networkLength": 24}),
                bridge,
            )
        ],
    )
    provider_router = Router({"name": "router0", "tenantId": providerId})
    provider_router.add(
        api,
        tx,
        [
 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[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,tx,[(RouterPort({'portAddress': '172.16.0.240',
                                     'networkAddress': '172.16.0.0',
                                     'networkLength': 24}),
                         bridge)])
     provider_router = Router({'name':'router0','tenantId':providerId})
     provider_router.add(api,tx,
                         [((RouterPort({'portAddress': '169.254.255.1',
                                        'networkAddress': '169.254.255.0',
                                        'networkLength': 30}),
                            RouterPort({'portAddress': '169.254.255.2',
                                        'networkAddress': '169.254.255.0',
                                        'networkLength': 30})),
                           router)])
 except:
     traceback.print_exc()