print "not all tenants are found" sys.exit(1) tenantIds = map(lambda tenant: tenant.id, tenants) 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))
except webob.exc.HTTPNotFound: router = api.get_router(device_id) if router: delete_router(api,tx,router,peer.get_peer_id()) def delete_chain(api,tx,chain): tx.append(DeleteChain(api,chain)) if __name__ == '__main__': tenantIds = map(lambda tenant: tenant.id, list_tenants()) api = MidonetApi('http://127.0.0.1:8080/midonet-api','admin','*') for tenantId in tenantIds: # router and its children (routers and bridges) tx = Transaction() for router in api.get_routers({'tenant_id': tenantId}): delete_router(api,tx,router) tx.rollback() # commit actually # dangling bridge tx = Transaction() for bridge in api.get_bridges({'tenant_id': tenantId}): delete_bridge(api,tx,bridge) tx.rollback() tx = Transaction() for chain in api.get_chains({'tenant_id': tenantId}): delete_chain(api,tx,chain) tx.rollback()
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', '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],
if router: delete_router(api, tx, router, peer.get_peer_id()) def delete_chain(api, tx, chain): tx.append(DeleteChain(api, chain)) if __name__ == '__main__': tenantIds = map(lambda tenant: tenant.id, list_tenants()) api = MidonetApi('http://127.0.0.1:8080/midonet-api', 'admin', '*') for tenantId in tenantIds: # router and its children (routers and bridges) tx = Transaction() for router in api.get_routers({'tenant_id': tenantId}): delete_router(api, tx, router) tx.rollback() # commit actually # dangling bridge tx = Transaction() for bridge in api.get_bridges({'tenant_id': tenantId}): delete_bridge(api, tx, bridge) tx.rollback() tx = Transaction() for chain in api.get_chains({'tenant_id': tenantId}): delete_chain(api, tx, chain) tx.rollback()