Add i18n for logging, changed create_bridge/vlan to should_create_bridge/vlan, changed unfilter_instance's keyword param to positional, and added Dan's alternate ID to .mailmap

This commit is contained in:
Ryu Ishimoto
2011-07-23 05:11:39 +09:00
parent d06908783c
commit 348dcb39f8
11 changed files with 31 additions and 41 deletions
+1
View File
@@ -14,6 +14,7 @@
<code@term.ie> <github@anarkystic.com> <code@term.ie> <github@anarkystic.com>
<code@term.ie> <termie@preciousroy.local> <code@term.ie> <termie@preciousroy.local>
<corywright@gmail.com> <cory.wright@rackspace.com> <corywright@gmail.com> <cory.wright@rackspace.com>
<dan@nicira.com> <danwent@dan-xs3-cs>
<devin.carlen@gmail.com> <devcamcar@illian.local> <devin.carlen@gmail.com> <devcamcar@illian.local>
<ewan.mellor@citrix.com> <emellor@silver> <ewan.mellor@citrix.com> <emellor@silver>
<itoumsn@nttdata.co.jp> <itoumsn@shayol> <itoumsn@nttdata.co.jp> <itoumsn@shayol>
+1 -1
View File
@@ -1316,7 +1316,7 @@ class ComputeManager(manager.SchedulerDependentManager):
network_info = self._get_instance_nw_info(ctxt, instance_ref) network_info = self._get_instance_nw_info(ctxt, instance_ref)
# Releasing security group ingress rule. # Releasing security group ingress rule.
self.driver.unfilter_instance(instance_ref, network_info=network_info) self.driver.unfilter_instance(instance_ref, network_info)
# Database updating. # Database updating.
i_name = instance_ref.name i_name = instance_ref.name
+15 -27
View File
@@ -300,6 +300,14 @@ class NetworkManager(manager.SchedulerDependentManager):
The one at a time part is to flatten the layout to help scale The one at a time part is to flatten the layout to help scale
""" """
"""Constant to indicate whether this manager requires VIF to create a
bridge."""
SHOULD_CREATE_BRIDGE = False
"""Constant to indicate whether this manager requires VIF to create a
VLAN tag."""
SHOULD_CREATE_VLAN = False
timeout_fixed_ips = True timeout_fixed_ips = True
def __init__(self, network_driver=None, *args, **kwargs): def __init__(self, network_driver=None, *args, **kwargs):
@@ -483,8 +491,8 @@ class NetworkManager(manager.SchedulerDependentManager):
'rxtx_cap': flavor['rxtx_cap'], 'rxtx_cap': flavor['rxtx_cap'],
'dns': [network['dns']], 'dns': [network['dns']],
'ips': [ip_dict(ip) for ip in network_IPs], 'ips': [ip_dict(ip) for ip in network_IPs],
'create_bridge': self._create_bridge, 'should_create_bridge': self.SHOULD_CREATE_BRIDGE,
'create_vlan': self._create_vlan} 'should_create_vlan': self.SHOULD_CREATE_VLAN}
if network['cidr_v6']: if network['cidr_v6']:
info['ip6s'] = [ip6_dict()] info['ip6s'] = [ip6_dict()]
# TODO(tr3buchet): handle ip6 routes here as well # TODO(tr3buchet): handle ip6 routes here as well
@@ -702,16 +710,6 @@ class NetworkManager(manager.SchedulerDependentManager):
"""Sets up network on this host.""" """Sets up network on this host."""
raise NotImplementedError() raise NotImplementedError()
@property
def _create_bridge(self):
"""Indicate whether this manager requires VIF to create a bridge."""
return False
@property
def _create_vlan(self):
"""Indicate whether this manager requires VIF to create a VLAN tag."""
return False
class FlatManager(NetworkManager): class FlatManager(NetworkManager):
"""Basic network where no vlans are used. """Basic network where no vlans are used.
@@ -772,6 +770,8 @@ class FlatDHCPManager(FloatingIP, RPCAllocateFixedIP, NetworkManager):
""" """
SHOULD_CREATE_BRIDGE = True
def init_host(self): def init_host(self):
"""Do any initialization that needs to be run if this is a """Do any initialization that needs to be run if this is a
standalone service. standalone service.
@@ -798,11 +798,6 @@ class FlatDHCPManager(FloatingIP, RPCAllocateFixedIP, NetworkManager):
self.db.network_update(context, network_ref['id'], self.db.network_update(context, network_ref['id'],
{'gateway_v6': gateway}) {'gateway_v6': gateway})
@property
def _create_bridge(self):
"""Indicate whether this manager requires VIF to create a bridge."""
return True
class VlanManager(RPCAllocateFixedIP, FloatingIP, NetworkManager): class VlanManager(RPCAllocateFixedIP, FloatingIP, NetworkManager):
"""Vlan network with dhcp. """Vlan network with dhcp.
@@ -819,6 +814,9 @@ class VlanManager(RPCAllocateFixedIP, FloatingIP, NetworkManager):
""" """
SHOULD_CREATE_BRIDGE = True
SHOULD_CREATE_VLAN = True
def init_host(self): def init_host(self):
"""Do any initialization that needs to be run if this is a """Do any initialization that needs to be run if this is a
standalone service. standalone service.
@@ -919,13 +917,3 @@ class VlanManager(RPCAllocateFixedIP, FloatingIP, NetworkManager):
"""Number of reserved ips at the top of the range.""" """Number of reserved ips at the top of the range."""
parent_reserved = super(VlanManager, self)._top_reserved_ips parent_reserved = super(VlanManager, self)._top_reserved_ips
return parent_reserved + FLAGS.cnt_vpn_clients return parent_reserved + FLAGS.cnt_vpn_clients
@property
def _create_bridge(self):
"""Indicate whether this manager requires VIF to create a bridge."""
return True
@property
def _create_vlan(self):
"""Indicate whether this manager requires VIF to create a VLAN tag."""
return True
+1 -1
View File
@@ -828,7 +828,7 @@ class ComputeTestCase(test.TestCase):
for v in i_ref['volumes']: for v in i_ref['volumes']:
self.compute.volume_manager.remove_compute_volume(c, v['id']) self.compute.volume_manager.remove_compute_volume(c, v['id'])
self.mox.StubOutWithMock(self.compute.driver, 'unfilter_instance') self.mox.StubOutWithMock(self.compute.driver, 'unfilter_instance')
self.compute.driver.unfilter_instance(i_ref, network_info=[]) self.compute.driver.unfilter_instance(i_ref, [])
# executing # executing
self.mox.ReplayAll() self.mox.ReplayAll()
+2 -2
View File
@@ -164,8 +164,8 @@ class FlatNetworkTestCase(test.TestCase):
'label': 'test%s' % i, 'label': 'test%s' % i,
'mac': 'DE:AD:BE:EF:00:0%s' % i, 'mac': 'DE:AD:BE:EF:00:0%s' % i,
'rxtx_cap': 'DONTCARE', 'rxtx_cap': 'DONTCARE',
'create_vlan': False, 'should_create_vlan': False,
'create_bridge': False} 'should_create_bridge': False}
self.assertDictMatch(nw[1], check) self.assertDictMatch(nw[1], check)
check = [{'enabled': 'DONTCARE', check = [{'enabled': 'DONTCARE',
+1 -1
View File
@@ -224,7 +224,7 @@ class ComputeDriver(object):
""" """
raise NotImplementedError() raise NotImplementedError()
def unfilter_instance(self, instance, network_info=None): def unfilter_instance(self, instance, network_info):
"""Stop filtering instance""" """Stop filtering instance"""
raise NotImplementedError() raise NotImplementedError()
+3 -3
View File
@@ -315,8 +315,8 @@ class LibvirtConnection(driver.ComputeDriver):
for (network, mapping) in network_info: for (network, mapping) in network_info:
self.vif_driver.unplug(instance, network, mapping) self.vif_driver.unplug(instance, network, mapping)
except: except:
LOG.warning("Failed while unplugging vif of instance '%s'" % \ LOG.warning(_("Failed while unplugging vif of instance '%s'"),
instance['name']) instance['name'])
raise raise
def _wait_for_destroy(): def _wait_for_destroy():
@@ -1570,7 +1570,7 @@ class LibvirtConnection(driver.ComputeDriver):
timer.f = wait_for_live_migration timer.f = wait_for_live_migration
timer.start(interval=0.5, now=True) timer.start(interval=0.5, now=True)
def unfilter_instance(self, instance_ref, network_info=None): def unfilter_instance(self, instance_ref, network_info):
"""See comments of same method in firewall_driver.""" """See comments of same method in firewall_driver."""
self.firewall_driver.unfilter_instance(instance_ref, self.firewall_driver.unfilter_instance(instance_ref,
network_info=network_info) network_info=network_info)
+3 -2
View File
@@ -72,8 +72,9 @@ class LibvirtBridgeDriver(VIFDriver):
def plug(self, instance, network, mapping): def plug(self, instance, network, mapping):
"""Ensure that the bridge exists, and add VIF to it.""" """Ensure that the bridge exists, and add VIF to it."""
if not network.get('multi_host') and mapping.get('create_bridge'): if (not network.get('multi_host') and
if mapping.get('create_vlan'): mapping.get('should_create_bridge')):
if mapping.get('should_create_vlan'):
LOG.debug(_('Ensuring vlan %(vlan)s and bridge %(bridge)s'), LOG.debug(_('Ensuring vlan %(vlan)s and bridge %(bridge)s'),
{'vlan': network['vlan'], {'vlan': network['vlan'],
'bridge': network['bridge']}) 'bridge': network['bridge']})
+1 -1
View File
@@ -36,7 +36,7 @@ class XenAPIBridgeDriver(VIFDriver):
def plug(self, xenapi_session, vm_ref, instance, device, network, def plug(self, xenapi_session, vm_ref, instance, device, network,
network_mapping): network_mapping):
if network_mapping.get('create_vlan'): if network_mapping.get('should_create_vlan'):
network_ref = self.ensure_vlan_bridge(xenapi_session, network) network_ref = self.ensure_vlan_bridge(xenapi_session, network)
else: else:
network_ref = NetworkHelper.find_network_with_bridge( network_ref = NetworkHelper.find_network_with_bridge(
+2 -2
View File
@@ -880,8 +880,8 @@ class VMOps(object):
for (network, mapping) in network_info: for (network, mapping) in network_info:
self.vif_driver.unplug(instance, network, mapping) self.vif_driver.unplug(instance, network, mapping)
except: except:
LOG.warning("Failed while unplugging vif of instance '%s'" % \ LOG.warning(_("Failed while unplugging vif of instance '%s'"),
instance['name']) instance['name'])
raise raise
def _wait_with_callback(self, instance_id, task, callback): def _wait_with_callback(self, instance_id, task, callback):
+1 -1
View File
@@ -325,7 +325,7 @@ class XenAPIConnection(driver.ComputeDriver):
"""This method is supported only by libvirt.""" """This method is supported only by libvirt."""
return return
def unfilter_instance(self, instance_ref, network_info=None): def unfilter_instance(self, instance_ref, network_info):
"""This method is supported only by libvirt.""" """This method is supported only by libvirt."""
raise NotImplementedError('This method is supported only by libvirt.') raise NotImplementedError('This method is supported only by libvirt.')