additional review cleanup
This commit is contained in:
9 changed files with 37 additions and 27 deletions
2
.mailmap
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>
@@ -22,11 +22,15 @@ import socket
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 @@ class JSONSerializer(object):
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):
@@ -65,8 +65,9 @@ class FakeQuantumClientConnection(object):
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 @@ class FakeQuantumClientConnection(object):
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):
@@ -86,7 +86,7 @@ class QuantumManager(manager.FlatManager):
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):
@@ -35,7 +35,9 @@ flags.DEFINE_string('melange_port',
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):
@@ -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 @@ class QuantumMelangeIPAMLib(object):
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,
@@ -154,7 +154,7 @@ class QuantumNovaIPAMLib(object):
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
@@ -80,8 +80,8 @@ class QuantumClientConnection(object):
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 @@ class QuantumClientConnection(object):
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)
@@ -189,29 +189,29 @@ class QuantumTestCaseBase(object):
# 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 @@ class QuantumNovaIPAMTestCase(QuantumTestCaseBase, test.TestCase):
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():
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.