Correct i18n message for ovs plugin

Part of bp make-string-localizable

Change-Id: I891d0128fd9e24805cef2c1db99cf8e716c7b4a0
This commit is contained in:
He Jie Xu 2012-11-22 22:23:28 +08:00
parent a14a03f4c5
commit 1aa64efc7e
3 changed files with 126 additions and 92 deletions

View File

@ -186,18 +186,18 @@ class OVSQuantumAgent(object):
return network_id return network_id
def network_delete(self, context, **kwargs): def network_delete(self, context, **kwargs):
LOG.debug("network_delete received") LOG.debug(_("network_delete received"))
network_id = kwargs.get('network_id') network_id = kwargs.get('network_id')
LOG.debug("Delete %s", network_id) LOG.debug(_("Delete %s"), network_id)
# The network may not be defined on this agent # The network may not be defined on this agent
lvm = self.local_vlan_map.get(network_id) lvm = self.local_vlan_map.get(network_id)
if lvm: if lvm:
self.reclaim_local_vlan(network_id, lvm) self.reclaim_local_vlan(network_id, lvm)
else: else:
LOG.debug("Network %s not used on agent.", network_id) LOG.debug(_("Network %s not used on agent."), network_id)
def port_update(self, context, **kwargs): def port_update(self, context, **kwargs):
LOG.debug("port_update received") LOG.debug(_("port_update received"))
port = kwargs.get('port') port = kwargs.get('port')
network_type = kwargs.get('network_type') network_type = kwargs.get('network_type')
segmentation_id = kwargs.get('segmentation_id') segmentation_id = kwargs.get('segmentation_id')
@ -208,7 +208,7 @@ class OVSQuantumAgent(object):
segmentation_id, port['admin_state_up']) segmentation_id, port['admin_state_up'])
def tunnel_update(self, context, **kwargs): def tunnel_update(self, context, **kwargs):
LOG.debug("tunnel_update received") LOG.debug(_("tunnel_update received"))
if not self.enable_tunneling: if not self.enable_tunneling:
return return
tunnel_ip = kwargs.get('tunnel_ip') tunnel_ip = kwargs.get('tunnel_ip')
@ -237,10 +237,12 @@ class OVSQuantumAgent(object):
''' '''
if not self.available_local_vlans: if not self.available_local_vlans:
LOG.error("No local VLAN available for net-id=%s", net_uuid) LOG.error(_("No local VLAN available for net-id=%s"), net_uuid)
return return
lvid = self.available_local_vlans.pop() lvid = self.available_local_vlans.pop()
LOG.info("Assigning %s as local vlan for net-id=%s", lvid, net_uuid) LOG.info(_("Assigning %(vlan_id)s as local vlan for "
"net-id=%(net_uuid)s"),
{'vlan_id': lvid, 'net_uuid': net_uuid})
self.local_vlan_map[net_uuid] = LocalVLANMapping(lvid, network_type, self.local_vlan_map[net_uuid] = LocalVLANMapping(lvid, network_type,
physical_network, physical_network,
segmentation_id) segmentation_id)
@ -260,8 +262,8 @@ class OVSQuantumAgent(object):
actions="mod_vlan_vid:%s,output:%s" % actions="mod_vlan_vid:%s,output:%s" %
(lvid, self.patch_int_ofport)) (lvid, self.patch_int_ofport))
else: else:
LOG.error("Cannot provision GRE network for net-id=%s " LOG.error(_("Cannot provision GRE network for net-id=%s "
"- tunneling disabled", net_uuid) "- tunneling disabled"), net_uuid)
elif network_type == constants.TYPE_FLAT: elif network_type == constants.TYPE_FLAT:
if physical_network in self.phys_brs: if physical_network in self.phys_brs:
# outbound # outbound
@ -277,9 +279,10 @@ class OVSQuantumAgent(object):
dl_vlan=0xffff, dl_vlan=0xffff,
actions="mod_vlan_vid:%s,normal" % lvid) actions="mod_vlan_vid:%s,normal" % lvid)
else: else:
LOG.error("Cannot provision flat network for net-id=%s " LOG.error(_("Cannot provision flat network for "
"- no bridge for physical_network %s", net_uuid, "net-id=%(net_uuid)s - no bridge for "
physical_network) "physical_network %(physical_network)s"),
locals())
elif network_type == constants.TYPE_VLAN: elif network_type == constants.TYPE_VLAN:
if physical_network in self.phys_brs: if physical_network in self.phys_brs:
# outbound # outbound
@ -295,15 +298,17 @@ class OVSQuantumAgent(object):
dl_vlan=segmentation_id, dl_vlan=segmentation_id,
actions="mod_vlan_vid:%s,normal" % lvid) actions="mod_vlan_vid:%s,normal" % lvid)
else: else:
LOG.error("Cannot provision VLAN network for net-id=%s " LOG.error(_("Cannot provision VLAN network for "
"- no bridge for physical_network %s", net_uuid, "net-id=%(net_uuid)s - no bridge for "
physical_network) "physical_network %(physical_network)s"),
locals())
elif network_type == constants.TYPE_LOCAL: elif network_type == constants.TYPE_LOCAL:
# no flows needed for local networks # no flows needed for local networks
pass pass
else: else:
LOG.error("Cannot provision unknown network type %s for " LOG.error(_("Cannot provision unknown network type "
"net-id=%s", network_type, net_uuid) "%(network_type)s for net-id=%(net_uuid)s"),
locals())
def reclaim_local_vlan(self, net_uuid, lvm): def reclaim_local_vlan(self, net_uuid, lvm):
'''Reclaim a local VLAN. '''Reclaim a local VLAN.
@ -311,7 +316,9 @@ class OVSQuantumAgent(object):
:param net_uuid: the network uuid associated with this vlan. :param net_uuid: the network uuid associated with this vlan.
:param lvm: a LocalVLANMapping object that tracks (vlan, lsw_id, :param lvm: a LocalVLANMapping object that tracks (vlan, lsw_id,
vif_ids) mapping.''' vif_ids) mapping.'''
LOG.info("Reclaiming vlan = %s from net-id = %s", lvm.vlan, net_uuid) LOG.info(_("Reclaiming vlan = %(vlan_id)s from net-id = %(net_uuid)s"),
{'vlan_id': lvm.vlan,
'net_uuid': net_uuid})
if lvm.network_type == constants.TYPE_GRE: if lvm.network_type == constants.TYPE_GRE:
if self.enable_tunneling: if self.enable_tunneling:
@ -343,8 +350,10 @@ class OVSQuantumAgent(object):
# no flows needed for local networks # no flows needed for local networks
pass pass
else: else:
LOG.error("Cannot reclaim unknown network type %s for net-id=%s", LOG.error(_("Cannot reclaim unknown network type "
lvm.network_type, net_uuid) "%(network_type)s for net-id=%(net_uuid)s"),
{'network_type': lvm.network_type,
'net_uuid': net_uuid})
del self.local_vlan_map[net_uuid] del self.local_vlan_map[net_uuid]
self.available_local_vlans.add(lvm.vlan) self.available_local_vlans.add(lvm.vlan)
@ -446,10 +455,10 @@ class OVSQuantumAgent(object):
self.patch_int_ofport = self.tun_br.add_patch_port("patch-int", self.patch_int_ofport = self.tun_br.add_patch_port("patch-int",
"patch-tun") "patch-tun")
if int(self.patch_tun_ofport) < 0 or int(self.patch_int_ofport) < 0: if int(self.patch_tun_ofport) < 0 or int(self.patch_int_ofport) < 0:
LOG.error("Failed to create OVS patch port. Cannot have tunneling " LOG.error(_("Failed to create OVS patch port. Cannot have "
"enabled on this agent, since this version of OVS does " "tunneling enabled on this agent, since this version "
"not support tunnels or patch ports. " "of OVS does not support tunnels or patch ports. "
"Agent terminated!") "Agent terminated!"))
exit(1) exit(1)
self.tun_br.remove_all_flows() self.tun_br.remove_all_flows()
self.tun_br.add_flow(priority=1, actions="drop") self.tun_br.add_flow(priority=1, actions="drop")
@ -466,13 +475,15 @@ class OVSQuantumAgent(object):
self.phys_ofports = {} self.phys_ofports = {}
ip_wrapper = ip_lib.IPWrapper(self.root_helper) ip_wrapper = ip_lib.IPWrapper(self.root_helper)
for physical_network, bridge in bridge_mappings.iteritems(): for physical_network, bridge in bridge_mappings.iteritems():
LOG.info("Mapping physical network %s to bridge %s", LOG.info(_("Mapping physical network %(physical_network)s to "
physical_network, bridge) "bridge %(bridge)s"),
locals())
# setup physical bridge # setup physical bridge
if not ip_lib.device_exists(bridge, self.root_helper): if not ip_lib.device_exists(bridge, self.root_helper):
LOG.error("Bridge %s for physical network %s does not exist. " LOG.error(_("Bridge %(bridge)s for physical network "
"Agent terminated!", "%(physical_network)s does not exist. Agent "
bridge, physical_network) "terminated!"),
locals())
sys.exit(1) sys.exit(1)
br = ovs_lib.OVSBridge(bridge, self.root_helper) br = ovs_lib.OVSBridge(bridge, self.root_helper)
br.remove_all_flows() br.remove_all_flows()
@ -522,23 +533,25 @@ class OVSQuantumAgent(object):
else: else:
self.port_dead(vif_port) self.port_dead(vif_port)
else: else:
LOG.debug("No VIF port for port %s defined on agent.", port_id) LOG.debug(_("No VIF port for port %s defined on agent."), port_id)
def treat_devices_added(self, devices): def treat_devices_added(self, devices):
resync = False resync = False
for device in devices: for device in devices:
LOG.info("Port %s added", device) LOG.info(_("Port %s added"), device)
try: try:
details = self.plugin_rpc.get_device_details(self.context, details = self.plugin_rpc.get_device_details(self.context,
device, device,
self.agent_id) self.agent_id)
except Exception as e: except Exception as e:
LOG.debug("Unable to get port details for %s: %s", device, e) LOG.debug(_("Unable to get port details for "
"%(device)s: %(e)s"), locals())
resync = True resync = True
continue continue
port = self.int_br.get_vif_port_by_id(details['device']) port = self.int_br.get_vif_port_by_id(details['device'])
if 'port_id' in details: if 'port_id' in details:
LOG.info("Port %s updated. Details: %s", device, details) LOG.info(_("Port %(device)s updated. Details: %(details)s"),
locals())
self.treat_vif_port(port, details['port_id'], self.treat_vif_port(port, details['port_id'],
details['network_id'], details['network_id'],
details['network_type'], details['network_type'],
@ -546,7 +559,7 @@ class OVSQuantumAgent(object):
details['segmentation_id'], details['segmentation_id'],
details['admin_state_up']) details['admin_state_up'])
else: else:
LOG.debug("Device %s not defined on plugin", device) LOG.debug(_("Device %s not defined on plugin"), device)
if (port and int(port.ofport) != -1): if (port and int(port.ofport) != -1):
self.port_dead(port) self.port_dead(port)
return resync return resync
@ -554,20 +567,21 @@ class OVSQuantumAgent(object):
def treat_devices_removed(self, devices): def treat_devices_removed(self, devices):
resync = False resync = False
for device in devices: for device in devices:
LOG.info("Attachment %s removed", device) LOG.info(_("Attachment %s removed"), device)
try: try:
details = self.plugin_rpc.update_device_down(self.context, details = self.plugin_rpc.update_device_down(self.context,
device, device,
self.agent_id) self.agent_id)
except Exception as e: except Exception as e:
LOG.debug("port_removed failed for %s: %s", device, e) LOG.debug(_("port_removed failed for %(device)s: %(e)s"),
locals())
resync = True resync = True
continue continue
if details['exists']: if details['exists']:
LOG.info("Port %s updated.", device) LOG.info(_("Port %s updated."), device)
# Nothing to do regarding local networking # Nothing to do regarding local networking
else: else:
LOG.debug("Device %s not defined on plugin", device) LOG.debug(_("Device %s not defined on plugin"), device)
self.port_unbound(device) self.port_unbound(device)
return resync return resync
@ -591,7 +605,8 @@ class OVSQuantumAgent(object):
tun_name = 'gre-%s' % tunnel['id'] tun_name = 'gre-%s' % tunnel['id']
self.tun_br.add_tunnel_port(tun_name, tunnel['ip_address']) self.tun_br.add_tunnel_port(tun_name, tunnel['ip_address'])
except Exception as e: except Exception as e:
LOG.debug("Unable to sync tunnel IP %s: %s", self.local_ip, e) LOG.debug(_("Unable to sync tunnel IP %(local_ip)s: %(e)s"),
{'local_ip': self.local_ip, 'e': e})
resync = True resync = True
return resync return resync
@ -604,26 +619,26 @@ class OVSQuantumAgent(object):
try: try:
start = time.time() start = time.time()
if sync: if sync:
LOG.info("Agent out of sync with plugin!") LOG.info(_("Agent out of sync with plugin!"))
ports.clear() ports.clear()
sync = False sync = False
# Notify the plugin of tunnel IP # Notify the plugin of tunnel IP
if self.enable_tunneling and tunnel_sync: if self.enable_tunneling and tunnel_sync:
LOG.info("Agent tunnel out of sync with plugin!") LOG.info(_("Agent tunnel out of sync with plugin!"))
tunnel_sync = self.tunnel_sync() tunnel_sync = self.tunnel_sync()
port_info = self.update_ports(ports) port_info = self.update_ports(ports)
# notify plugin about port deltas # notify plugin about port deltas
if port_info: if port_info:
LOG.debug("Agent loop has new devices!") LOG.debug(_("Agent loop has new devices!"))
# If treat devices fails - must resync with plugin # If treat devices fails - must resync with plugin
sync = self.process_network_ports(port_info) sync = self.process_network_ports(port_info)
ports = port_info['current'] ports = port_info['current']
except: except:
LOG.exception("Error in agent event loop") LOG.exception(_("Error in agent event loop"))
sync = True sync = True
tunnel_sync = True tunnel_sync = True
@ -632,8 +647,10 @@ class OVSQuantumAgent(object):
if (elapsed < self.polling_interval): if (elapsed < self.polling_interval):
time.sleep(self.polling_interval - elapsed) time.sleep(self.polling_interval - elapsed)
else: else:
LOG.debug("Loop iteration exceeded interval (%s vs. %s)!", LOG.debug(_("Loop iteration exceeded interval "
self.polling_interval, elapsed) "(%(polling_interval)s vs. %(elapsed)s)!"),
{'polling_interval': self.polling_interval,
'elapsed': elapsed})
def daemon_loop(self): def daemon_loop(self):
self.rpc_loop() self.rpc_loop()
@ -675,13 +692,13 @@ def main():
try: try:
agent_config = create_agent_config_map(cfg.CONF) agent_config = create_agent_config_map(cfg.CONF)
except ValueError as e: except ValueError as e:
LOG.error('%s Agent terminated!', e) LOG.error(_('%s Agent terminated!'), e)
sys.exit(1) sys.exit(1)
plugin = OVSQuantumAgent(**agent_config) plugin = OVSQuantumAgent(**agent_config)
# Start everything. # Start everything.
LOG.info("Agent initialized successfully, now running... ") LOG.info(_("Agent initialized successfully, now running... "))
plugin.daemon_loop() plugin.daemon_loop()
sys.exit(0) sys.exit(0)

View File

@ -90,9 +90,11 @@ def sync_vlan_allocations(network_vlan_ranges):
# it's not allocatable, so check if its allocated # it's not allocatable, so check if its allocated
if not alloc.allocated: if not alloc.allocated:
# it's not, so remove it from table # it's not, so remove it from table
LOG.debug("removing vlan %s on physical network " LOG.debug(_("Removing vlan %(vlan_id)s on "
"%s from pool" % "physical network "
(alloc.vlan_id, physical_network)) "%(physical_network)s from pool"),
{'vlan_id': alloc.vlan_id,
'physical_network': physical_network})
session.delete(alloc) session.delete(alloc)
del allocations[physical_network] del allocations[physical_network]
@ -106,9 +108,10 @@ def sync_vlan_allocations(network_vlan_ranges):
for allocs in allocations.itervalues(): for allocs in allocations.itervalues():
for alloc in allocs: for alloc in allocs:
if not alloc.allocated: if not alloc.allocated:
LOG.debug("removing vlan %s on physical network %s" LOG.debug(_("Removing vlan %(vlan_id)s on physical "
" from pool" % "network %(physical_network)s from pool"),
(alloc.vlan_id, physical_network)) {'vlan_id': alloc.vlan_id,
'physical_network': physical_network})
session.delete(alloc) session.delete(alloc)
@ -130,8 +133,10 @@ def reserve_vlan(session):
filter_by(allocated=False). filter_by(allocated=False).
first()) first())
if alloc: if alloc:
LOG.debug("reserving vlan %s on physical network %s from pool" % LOG.debug(_("Reserving vlan %(vlan_id)s on physical network "
(alloc.vlan_id, alloc.physical_network)) "%(physical_network)s from pool"),
{'vlan_id': alloc.vlan_id,
'physical_network': alloc.physical_network})
alloc.allocated = True alloc.allocated = True
return (alloc.physical_network, alloc.vlan_id) return (alloc.physical_network, alloc.vlan_id)
raise q_exc.NoNetworkAvailable() raise q_exc.NoNetworkAvailable()
@ -151,12 +156,13 @@ def reserve_specific_vlan(session, physical_network, vlan_id):
else: else:
raise q_exc.VlanIdInUse(vlan_id=vlan_id, raise q_exc.VlanIdInUse(vlan_id=vlan_id,
physical_network=physical_network) physical_network=physical_network)
LOG.debug("reserving specific vlan %s on physical network %s " LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"from pool" % (vlan_id, physical_network)) "network %(physical_network)s from pool"), locals())
alloc.allocated = True alloc.allocated = True
except exc.NoResultFound: except exc.NoResultFound:
LOG.debug("reserving specific vlan %s on physical network %s " LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"outside pool" % (vlan_id, physical_network)) "network %(physical_network)s outside pool"),
locals())
alloc = ovs_models_v2.VlanAllocation(physical_network, vlan_id) alloc = ovs_models_v2.VlanAllocation(physical_network, vlan_id)
alloc.allocated = True alloc.allocated = True
session.add(alloc) session.add(alloc)
@ -177,12 +183,17 @@ def release_vlan(session, physical_network, vlan_id, network_vlan_ranges):
break break
if not inside: if not inside:
session.delete(alloc) session.delete(alloc)
LOG.debug("releasing vlan %s on physical network %s %s pool" % LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
(vlan_id, physical_network, "%(physical_network)s outside pool"),
inside and "to" or "outside")) locals())
else:
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s to pool"),
locals())
except exc.NoResultFound: except exc.NoResultFound:
LOG.warning("vlan_id %s on physical network %s not found" % LOG.warning(_("vlan_id %(vlan_id)s on physical network "
(vlan_id, physical_network)) "%(physical_network)s not found"),
locals())
def sync_tunnel_allocations(tunnel_id_ranges): def sync_tunnel_allocations(tunnel_id_ranges):
@ -193,8 +204,9 @@ def sync_tunnel_allocations(tunnel_id_ranges):
for tunnel_id_range in tunnel_id_ranges: for tunnel_id_range in tunnel_id_ranges:
tun_min, tun_max = tunnel_id_range tun_min, tun_max = tunnel_id_range
if tun_max + 1 - tun_min > 1000000: if tun_max + 1 - tun_min > 1000000:
LOG.error("Skipping unreasonable tunnel ID range %s:%s" % LOG.error(_("Skipping unreasonable tunnel ID range "
tunnel_id_range) "%(tun_min)s:%(tun_max)s"),
locals())
else: else:
tunnel_ids |= set(xrange(tun_min, tun_max + 1)) tunnel_ids |= set(xrange(tun_min, tun_max + 1))
@ -211,7 +223,7 @@ def sync_tunnel_allocations(tunnel_id_ranges):
# it's not allocatable, so check if its allocated # it's not allocatable, so check if its allocated
if not alloc.allocated: if not alloc.allocated:
# it's not, so remove it from table # it's not, so remove it from table
LOG.debug("removing tunnel %s from pool" % LOG.debug(_("Removing tunnel %s from pool"),
alloc.tunnel_id) alloc.tunnel_id)
session.delete(alloc) session.delete(alloc)
@ -238,7 +250,7 @@ def reserve_tunnel(session):
filter_by(allocated=False). filter_by(allocated=False).
first()) first())
if alloc: if alloc:
LOG.debug("reserving tunnel %s from pool" % alloc.tunnel_id) LOG.debug(_("Reserving tunnel %s from pool"), alloc.tunnel_id)
alloc.allocated = True alloc.allocated = True
return alloc.tunnel_id return alloc.tunnel_id
raise q_exc.NoNetworkAvailable() raise q_exc.NoNetworkAvailable()
@ -252,10 +264,11 @@ def reserve_specific_tunnel(session, tunnel_id):
one()) one())
if alloc.allocated: if alloc.allocated:
raise q_exc.TunnelIdInUse(tunnel_id=tunnel_id) raise q_exc.TunnelIdInUse(tunnel_id=tunnel_id)
LOG.debug("reserving specific tunnel %s from pool" % tunnel_id) LOG.debug(_("Reserving specific tunnel %s from pool"), tunnel_id)
alloc.allocated = True alloc.allocated = True
except exc.NoResultFound: except exc.NoResultFound:
LOG.debug("reserving specific tunnel %s outside pool" % tunnel_id) LOG.debug(_("Reserving specific tunnel %s outside pool"),
tunnel_id)
alloc = ovs_models_v2.TunnelAllocation(tunnel_id) alloc = ovs_models_v2.TunnelAllocation(tunnel_id)
alloc.allocated = True alloc.allocated = True
session.add(alloc) session.add(alloc)
@ -276,10 +289,11 @@ def release_tunnel(session, tunnel_id, tunnel_id_ranges):
break break
if not inside: if not inside:
session.delete(alloc) session.delete(alloc)
LOG.debug("releasing tunnel %s %s pool" % LOG.debug(_("Releasing tunnel %s outside pool"), tunnel_id)
(tunnel_id, inside and "to" or "outside")) else:
LOG.debug(_("Releasing tunnel %s to pool"), tunnel_id)
except exc.NoResultFound: except exc.NoResultFound:
LOG.warning("tunnel_id %s not found" % tunnel_id) LOG.warning(_("tunnel_id %s not found"), tunnel_id)
def get_port(port_id): def get_port(port_id):

View File

@ -64,7 +64,8 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
"""Agent requests device details""" """Agent requests device details"""
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug("Device %s details requested from %s", device, agent_id) LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
locals())
port = ovs_db_v2.get_port(device) port = ovs_db_v2.get_port(device)
if port: if port:
binding = ovs_db_v2.get_network_binding(None, port['network_id']) binding = ovs_db_v2.get_network_binding(None, port['network_id'])
@ -79,7 +80,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
ovs_db_v2.set_port_status(port['id'], q_const.PORT_STATUS_ACTIVE) ovs_db_v2.set_port_status(port['id'], q_const.PORT_STATUS_ACTIVE)
else: else:
entry = {'device': device} entry = {'device': device}
LOG.debug("%s can not be found in database", device) LOG.debug(_("%s can not be found in database"), device)
return entry return entry
def update_device_down(self, rpc_context, **kwargs): def update_device_down(self, rpc_context, **kwargs):
@ -87,7 +88,8 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
# (TODO) garyk - live migration and port status # (TODO) garyk - live migration and port status
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug("Device %s no longer exists on %s", device, agent_id) LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
locals())
port = ovs_db_v2.get_port(device) port = ovs_db_v2.get_port(device)
if port: if port:
entry = {'device': device, entry = {'device': device,
@ -97,7 +99,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
else: else:
entry = {'device': device, entry = {'device': device,
'exists': False} 'exists': False}
LOG.debug("%s can not be found in database", device) LOG.debug(_("%s can not be found in database"), device)
return entry return entry
def tunnel_sync(self, rpc_context, **kwargs): def tunnel_sync(self, rpc_context, **kwargs):
@ -197,8 +199,8 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
constants.TYPE_VLAN, constants.TYPE_VLAN,
constants.TYPE_GRE, constants.TYPE_GRE,
constants.TYPE_NONE]: constants.TYPE_NONE]:
LOG.error("Invalid tenant_network_type: %s. " LOG.error(_("Invalid tenant_network_type: %s. "
"Agent terminated!", "Agent terminated!"),
self.tenant_network_type) self.tenant_network_type)
sys.exit(1) sys.exit(1)
self.enable_tunneling = cfg.CONF.OVS.enable_tunneling self.enable_tunneling = cfg.CONF.OVS.enable_tunneling
@ -207,8 +209,8 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
self._parse_tunnel_id_ranges() self._parse_tunnel_id_ranges()
ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges) ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges)
elif self.tenant_network_type == constants.TYPE_GRE: elif self.tenant_network_type == constants.TYPE_GRE:
LOG.error("Tunneling disabled but tenant_network_type is 'gre'. " LOG.error(_("Tunneling disabled but tenant_network_type is 'gre'. "
"Agent terminated!") "Agent terminated!"))
sys.exit(1) sys.exit(1)
self.setup_rpc() self.setup_rpc()
@ -235,13 +237,13 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
int(vlan_min), int(vlan_min),
int(vlan_max)) int(vlan_max))
except ValueError as ex: except ValueError as ex:
LOG.error("Invalid network VLAN range: '%s' - %s. " LOG.error(_("Invalid network VLAN range: "
"Agent terminated!", "'%(range)s' - %(e)s. Agent terminated!"),
entry, ex) {'range': entry, 'e': ex})
sys.exit(1) sys.exit(1)
else: else:
self._add_network(entry) self._add_network(entry)
LOG.info("Network VLAN ranges: %s", self.network_vlan_ranges) LOG.info(_("Network VLAN ranges: %s"), self.network_vlan_ranges)
def _add_network_vlan_range(self, physical_network, vlan_min, vlan_max): def _add_network_vlan_range(self, physical_network, vlan_min, vlan_max):
self._add_network(physical_network) self._add_network(physical_network)
@ -258,10 +260,11 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
tun_min, tun_max = entry.split(':') tun_min, tun_max = entry.split(':')
self.tunnel_id_ranges.append((int(tun_min), int(tun_max))) self.tunnel_id_ranges.append((int(tun_min), int(tun_max)))
except ValueError as ex: except ValueError as ex:
LOG.error("Invalid tunnel ID range: '%s' - %s. " LOG.error(_("Invalid tunnel ID range: "
"Agent terminated!", entry, ex) "'%(range)s' - %(e)s. Agent terminated!"),
{'range': entry, 'e': ex})
sys.exit(1) sys.exit(1)
LOG.info("Tunnel ID ranges: %s", self.tunnel_id_ranges) LOG.info(_("Tunnel ID ranges: %s"), self.tunnel_id_ranges)
# TODO(rkukura) Use core mechanism for attribute authorization # TODO(rkukura) Use core mechanism for attribute authorization
# when available. # when available.
@ -354,14 +357,14 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
else: else:
segmentation_id = None segmentation_id = None
else: else:
msg = _("provider:network_type %s not supported" % network_type) msg = _("provider:network_type %s not supported") % network_type
raise q_exc.InvalidInput(error_message=msg) raise q_exc.InvalidInput(error_message=msg)
if network_type in [constants.TYPE_VLAN, constants.TYPE_FLAT]: if network_type in [constants.TYPE_VLAN, constants.TYPE_FLAT]:
if physical_network_set: if physical_network_set:
if physical_network not in self.network_vlan_ranges: if physical_network not in self.network_vlan_ranges:
msg = _("unknown provider:physical_network %s" % msg = _("Unknown provider:physical_network "
physical_network) "%s") % physical_network
raise q_exc.InvalidInput(error_message=msg) raise q_exc.InvalidInput(error_message=msg)
elif 'default' in self.network_vlan_ranges: elif 'default' in self.network_vlan_ranges:
physical_network = 'default' physical_network = 'default'
@ -425,7 +428,7 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
self._extend_network_dict_provider(context, net) self._extend_network_dict_provider(context, net)
self._extend_network_dict_l3(context, net) self._extend_network_dict_l3(context, net)
# note - exception will rollback entire transaction # note - exception will rollback entire transaction
LOG.debug("Created network: %s", net['id']) LOG.debug(_("Created network: %s"), net['id'])
return net return net
def update_network(self, context, id, network): def update_network(self, context, id, network):