Skip to content
Browse files

additional review cleanup

  • Loading branch information...
1 parent 76a60bf commit 5b3b3d1b357c085c2088df7d76df8392118fb82e @danwent danwent committed Sep 1, 2011
View
2 .mailmap
@@ -37,7 +37,7 @@
<nirmal.ranganathan@rackspace.com> <nirmal.ranganathan@rackspace.coom>
<paul@openstack.org> <paul.voccio@rackspace.com>
<paul@openstack.org> <pvoccio@castor.local>
-<rconradharris@gmail.com> <rick.harris@rackspace.com>
+<rconradharris@gmail.com> <rick.harris@rackspace.com>
<rlane@wikimedia.org> <laner@controller>
<sleepsonthefloor@gmail.com> <root@tonbuntu>
<soren.hansen@rackspace.com> <soren@linux2go.dk>
View
12 nova/network/quantum/client.py
@@ -22,11 +22,15 @@
import urllib
+#FIXME(danwent): All content in this file should be removed once the
+# packaging work for the quantum client libraries is complete.
+# At that point, we will be able to just install the libraries as a
+# dependency and import from quantum.client.* and quantum.common.*
+# Until then, we have simplified versions of these classes in this file.
+
class JSONSerializer(object):
- """
- This is a simple json-only serializer to use until we can just grab
+ """ This is a simple json-only serializer to use until we can just grab
the standard serializer from the quantum library.
- TODO(danwent): replace serializer with quantum implementation
"""
def serialize(self, data, content_type):
try:
@@ -39,7 +43,7 @@ def deserialize(self, data, content_type):
return json.loads(data)
-# FIXME: (danwent) the full client lib will expose more
+# The full client lib will expose more
# granular exceptions, for now, just try to distinguish
# between the cases we care about.
class QuantumNotFoundException(Exception):
View
10 nova/network/quantum/fake.py
@@ -65,8 +65,9 @@ def _confirm_not_attached(self, interface_id):
def create_and_attach_port(self, tenant_id, net_id, interface_id):
if not self.network_exists(tenant_id, net_id):
- raise Exception(_("network %s does not exist for tenant %s" %
- (net_id, tenant_id)))
+ raise Exception(
+ _("network %(net_id)s does not exist for tenant %(tenant_id)"
+ % locals()))
self._confirm_not_attached(interface_id)
uuid = str(utils.gen_uuid())
@@ -76,8 +77,9 @@ def create_and_attach_port(self, tenant_id, net_id, interface_id):
def detach_and_delete_port(self, tenant_id, net_id, port_id):
if not self.network_exists(tenant_id, net_id):
- raise Exception(_("network %s does not exist for tenant %s" %\
- (net_id, tenant_id)))
+ raise exception.NotFound(
+ _("network %s does not exist for tenant %s" %
+ (net_id, tenant_id)))
del self.nets[net_id]['ports'][port_id]
def get_port_by_attachment(self, tenant_id, attachment_id):
View
2 nova/network/quantum/manager.py
@@ -86,7 +86,7 @@ def create_networks(self, context, label, cidr, multi_host, num_networks,
if num_networks != 1:
raise Exception(_("QuantumManager requires that only one"
" network is created per call"))
- q_tenant_id = kwargs["project_id"] or FLAGS.quantum_default_tenant_id
+ q_tenant_id = kwargs.get("project_id", FLAGS.quantum_default_tenant_id)
quantum_net_id = uuid
if quantum_net_id:
if not self.q_conn.network_exists(q_tenant_id, quantum_net_id):
View
4 nova/network/quantum/melange_connection.py
@@ -35,7 +35,9 @@
json_content_type = {'Content-type': "application/json"}
-
+#FIXME(danwent): talk to the Melange folks about creating a
+# client lib that we can import as a library, instead of
+# have to have all of the client code in here.
class MelangeConnection(object):
def __init__(self, host=None, port=None, use_ssl=False):
View
3 nova/network/quantum/melange_ipam_lib.py
@@ -17,6 +17,7 @@
from netaddr import IPNetwork
+from nova import exception
from nova import flags
from nova import log as logging
from nova.network.quantum import melange_connection
@@ -85,7 +86,7 @@ def get_network_id_by_cidr(self, context, cidr, project_id):
for b in all_blocks['ip_blocks']:
if b['cidr'] == cidr:
return b['network_id']
- raise Exception(_("No network found for cidr %s" % cidr))
+ raise exception.NotFound(_("No network found for cidr %s" % cidr))
def delete_subnets_by_net_id(self, context, net_id, project_id):
""" Find Melange block associated with the Quantum UUID,
View
2 nova/network/quantum/nova_ipam_lib.py
@@ -154,7 +154,7 @@ def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
fixed_ips = db.fixed_ip_get_by_virtual_interface(context,
vif_rec['id'])
- return [f['address'] for f in fixed_ips]
+ return [fixed_ip['address'] for fixed_ip in fixed_ips]
def get_v6_ips_by_interface(self, context, net_id, vif_id, project_id):
""" Returns a list containing a single IPv6 address strings
View
8 nova/network/quantum/quantum_connection.py
@@ -80,8 +80,8 @@ def create_and_attach_port(self, tenant_id, net_id, interface_id):
status to ACTIVE to enable traffic, and attaches the
vNIC with the specified interface-id.
"""
- LOG.debug(_("Connecting interface %s to net %s for %s" %
- (interface_id, net_id, tenant_id)))
+ LOG.debug(_("Connecting interface %(interface_id)s to "
+ "net %(net_id)s for %(tenant_id)s" % locals()))
port_data = {'port': {'state': 'ACTIVE'}}
resdict = self.client.create_port(net_id, port_data, tenant=tenant_id)
port_id = resdict["port"]["id"]
@@ -92,8 +92,8 @@ def create_and_attach_port(self, tenant_id, net_id, interface_id):
def detach_and_delete_port(self, tenant_id, net_id, port_id):
""" Detach and delete the specified Quantum port. """
- LOG.debug("Deleting port %s on net %s for %s" % \
- (port_id, net_id, tenant_id))
+ LOG.debug(_("Deleting port %(port_id)s on net %(net_id)s"
+ " for %(tenant_id)s" % locals()))
self.client.detach_resource(net_id, port_id, tenant=tenant_id)
self.client.delete_port(net_id, port_id, tenant=tenant_id)
View
21 nova/tests/test_quantum.py
@@ -189,29 +189,29 @@ def test_allocate_and_deallocate_instance_dynamic(self):
# we don't know which order the NICs will be in until we
# introduce the notion of priority
# v4 cidr
- self.assertTrue(nw_info[0][0]['cidr'].startswith("9.") or \
+ self.assertTrue(nw_info[0][0]['cidr'].startswith("9.") or
nw_info[1][0]['cidr'].startswith("9."))
- self.assertTrue(nw_info[0][0]['cidr'].startswith("192.") or \
+ self.assertTrue(nw_info[0][0]['cidr'].startswith("192.") or
nw_info[1][0]['cidr'].startswith("192."))
# v4 address
- self.assertTrue(nw_info[0][1]['ips'][0]['ip'].startswith("9.") or \
+ self.assertTrue(nw_info[0][1]['ips'][0]['ip'].startswith("9.") or
nw_info[1][1]['ips'][0]['ip'].startswith("9."))
- self.assertTrue(nw_info[0][1]['ips'][0]['ip'].startswith("192.") or \
+ self.assertTrue(nw_info[0][1]['ips'][0]['ip'].startswith("192.") or
nw_info[1][1]['ips'][0]['ip'].startswith("192."))
# v6 cidr
- self.assertTrue(nw_info[0][0]['cidr_v6'].startswith("2001:1dbb:") or \
+ self.assertTrue(nw_info[0][0]['cidr_v6'].startswith("2001:1dbb:") or
nw_info[1][0]['cidr_v6'].startswith("2001:1dbb:"))
- self.assertTrue(nw_info[0][0]['cidr_v6'].startswith("2001:1db9:") or \
+ self.assertTrue(nw_info[0][0]['cidr_v6'].startswith("2001:1db9:") or
nw_info[1][0]['cidr_v6'].startswith("2001:1db9:"))
# v6 address
self.assertTrue(\
- nw_info[0][1]['ip6s'][0]['ip'].startswith("2001:1dbb:") or \
+ nw_info[0][1]['ip6s'][0]['ip'].startswith("2001:1dbb:") or
nw_info[1][1]['ip6s'][0]['ip'].startswith("2001:1dbb:"))
self.assertTrue(\
- nw_info[0][1]['ip6s'][0]['ip'].startswith("2001:1db9:") or \
+ nw_info[0][1]['ip6s'][0]['ip'].startswith("2001:1db9:") or
nw_info[1][1]['ip6s'][0]['ip'].startswith("2001:1db9:"))
self.net_man.deallocate_for_instance(ctx,
@@ -240,9 +240,10 @@ def setUp(self):
for n in db.network_get_all(ctx):
db.network_delete_safe(ctx, n['id'])
- # NOTE(danwent): I've found that other unit tests have a nasty
+ # Other unit tests (e.g., test_compute.py) have a nasty
# habit of of creating fixed IPs and not cleaning up, which
- # can confuse these tests, so we clean them all.
+ # can confuse these tests, so we remove all existing fixed
+ # ips before starting.
session = get_session()
result = session.query(models.FixedIp).all()
with session.begin():

0 comments on commit 5b3b3d1

Please sign in to comment.
Something went wrong with that request. Please try again.