Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update get_* for new client.

Signed-off-by: Tomoe Sugihara <tomoe@midokura.com>
  • Loading branch information...
commit 8b8a573fc1f9d0efa93d697e04acd67c8fbe2199 1 parent 6aba2e0
@tomoe tomoe authored
Showing with 31 additions and 36 deletions.
  1. +31 −36 src/midolman/quantum/plugin.py
View
67 src/midolman/quantum/plugin.py
@@ -17,9 +17,6 @@
import logging
import ConfigParser
-from midonet.client.mgmt import MidonetMgmt
-from midonet.client.web_resource import WebResource
-from midonet.auth.keystone import KeystoneAuth
from quantum.db import db_base_plugin_v2
from quantum.db import l3_db
from quantum.db import api as db
@@ -28,6 +25,13 @@
from quantum.common.utils import find_config_file
from quantum.common import exceptions as q_exc
+from midonet.client.mgmt import MidonetMgmt
+from midonet.client.web_resource import WebResource
+from midonet.auth.keystone import KeystoneAuth
+from webob import exc as w_exc
+
+
+
LOG = logging.getLogger('MidonetPluginV2')
LOG.setLevel(logging.DEBUG)
@@ -94,9 +98,8 @@ def create_subnet(self, context, subnet):
subnet)
try:
- bridge = self.mido_mgmt.get_bridge(sn_entry['tenant_id'],
- sn_entry['network_id'])
- except LookupError as e:
+ bridge = self.mido_mgmt.get_bridge(sn_entry['network_id'])
+ except HTTPError as e:
raise q_exc.NetworkNotFound(net_id=subnet['network_id'])
gateway_ip = subnet['subnet']['gateway_ip']
@@ -117,7 +120,7 @@ def get_subnet(self, context, id, fields=None):
try:
bridge = self.mido_mgmt.get_bridge(subnet['tenant_id'],
subnet['network_id'])
- except LookupError as e:
+ except w_exc.HTTPNotFound as e:
raise Exception("Databases are out of Sync.")
# get dhcp subnet data from MidoNet bridge.
@@ -140,9 +143,8 @@ def get_subnets(self, context, filters=None, fields=None):
for sn in subnets:
try:
- bridge = self.mido_mgmt.get_bridge(sn['tenant_id'],
- sn['network_id'])
- except LookupError as e:
+ bridge = self.mido_mgmt.get_bridge(sn['network_id'])
+ except w_exc.HTTPNotFound as e:
raise Exception("Databases are out of Sync.")
# TODO: dedupe this part.
@@ -167,9 +169,8 @@ def delete_subnet(self, context, id):
subnet = super(MidonetPluginV2, self).get_subnet(context, id,
fields=None)
try:
- bridge = self.mido_mgmt.get_bridge(subnet['tenant_id'],
- subnet['network_id'])
- except LookupError as e:
+ bridge = self.mido_mgmt.get_bridge(subnet['network_id'])
+ except w_exc.HTTPNotFound as e:
raise Exception("Databases are out of Sync.")
dhcp = bridge.get_dhcp_subnets()
@@ -217,8 +218,8 @@ def update_network(self, context, id, network):
net = super(MidonetPluginV2, self).update_network(
context, id, network)
try:
- bridge = self.mido_mgmt.get_bridge(context.tenant_id, id)
- except LookupError as e:
+ bridge = self.mido_mgmt.get_bridge(id)
+ except w_exc.HTTPNotFound as e:
raise q_exc.NetworkNotFound(net_id=id)
bridge.name(net['name']).update()
return net
@@ -233,8 +234,8 @@ def get_network(self, context, id, fields=None):
net = super(MidonetPluginV2, self).get_network(context, id, fields)
try:
- bridge = self.mido_mgmt.get_bridge(context.tenant_id, id)
- except LookupError as e:
+ bridge = self.mido_mgmt.get_bridge(id)
+ except w_exc.HTTPNotFound as e:
raise q_exc.NetworkNotFound(net_id=id)
return net
@@ -249,8 +250,8 @@ def get_networks(self, context, filters=None, fields=None):
bridges = self.mido_mgmt.get_bridges({'tenant_id':context.tenant_id})
for n in net:
try:
- bridge = self.mido_mgmt.get_bridge(context.tenant_id, n['id'])
- except LookupError as e:
+ bridge = self.mido_mgmt.get_bridge(n['id'])
+ except w_exc.HTTPNotFound as e:
raise Exception("Databases are out of Syc.")
return net
@@ -262,7 +263,7 @@ def delete_network(self, context, id):
session = context.session
with session.begin(subtransactions=True):
- self.mido_mgmt.get_bridge(context.tenant_id, id).delete()
+ self.mido_mgmt.get_bridge(id).delete()
super(MidonetPluginV2, self).delete_network(context, id)
def create_port(self, context, port):
@@ -275,9 +276,8 @@ def create_port(self, context, port):
with session.begin(subtransactions=True):
# get the bridge and create a port on it.
try:
- bridge = self.mido_mgmt.get_bridge(port['port']['tenant_id'],
- port['port']['network_id'])
- except LookupError as e:
+ bridge = self.mido_mgmt.get_bridge(port['port']['network_id'])
+ except w_exc.HTTPNotFound as e:
raise q_exc.NetworkNotFound(net_id=port['port']['network_id'])
bridge_port = bridge.add_materialized_port().create()
@@ -318,10 +318,8 @@ def get_port(self, context, id, fields=None):
# verify that corresponding port exists in MidoNet.
try:
LOG.debug('qport=%r', qport)
- bridge = self.mido_mgmt.get_bridge(qport['tenant_id'],
- qport['network_id'])
- #bridge_port = bridge.get_port(id)
- except LookupError as e:
+ bridge_port = self.mido_mgmt.get_port(id)
+ except w_exc.HTTPNotFound as e:
raise Exception("Databases are out of Sync.")
return qport
@@ -340,11 +338,9 @@ def get_ports(self, context, filters=None, fields=None):
# we need to chenge the validation below.
if len(qports) > 0:
try:
- bridge = self.mido_mgmt.get_bridge(context.tenant_id,
- qports[0]['network_id'])
for port in qports:
- bridge.get_port(port['id'])
- except LookupError as e:
+ self.mido_mgmt.get_port(port['id'])
+ except w_exc.HTTPNotFound as e:
raise Exception("Databases are out of Sync.")
return qports
@@ -360,8 +356,7 @@ def delete_port(self, context, id, l3_port_check=True):
session = context.session
with session.begin(subtransactions=True):
qport = super(MidonetPluginV2, self).get_port(context, id, None)
- bridge = self.mido_mgmt.get_bridge(context.tenant_id,
- qport['network_id'])
+ bridge = self.mido_mgmt.get_bridge(qport['network_id'])
# get ip and mac from DB record.
fixed_ip = qport['fixed_ips'][0]['ip_address']
mac = qport['mac_address']
@@ -374,7 +369,7 @@ def delete_port(self, context, id, l3_port_check=True):
dh.get_ip_addr() == fixed_ip:
dh.delete()
- bridge.get_port(id).delete()
+ self.mido_mgmt.get_port(id).delete()
qport = super(MidonetPluginV2, self).delete_port(context, id)
return qport
@@ -439,7 +434,7 @@ def get_router(self, context, id, fields=None):
try:
self.mido_mgmt.get_router(context.tenant_id, id)
- except LookupError as e:
+ except w_exc.HTTPNotFound as e:
raise Exception("Databases are out of Syc.")
return super(MidonetPluginV2, self).get_router(context, id, fields)
@@ -453,7 +448,7 @@ def get_routers(self, context, filters=None, fields=None):
for qr in qrouters:
try:
self.mido_mgmt.get_router(context.tenant_id, qr['id'])
- except LookupError as e:
+ except w_exc.HTTPNotFound as e:
raise Exception("Databases are out of Syc.")
return qrouters
Please sign in to comment.
Something went wrong with that request. Please try again.