from neutron.common import constants as n_const
from neutron.common import topics
from neutron.common import utils as n_utils
+from neutron.i18n import _LE, _LI
from neutron import context
from neutron.openstack.common import log as logging
from neutron.openstack.common import loopingcall
self.agent_state)
self.agent_state.pop('start_flag', None)
except Exception:
- LOG.exception(_("Failed reporting state!"))
+ LOG.exception(_LE("Failed reporting state!"))
def setup_rpc(self):
if self.int_br:
# Plugin calls the agents through the following
def info_update(self, context, **kwargs):
- LOG.debug(_("info_update received"))
+ LOG.debug("info_update received")
info = kwargs.get('info', {})
new_controller = info.get('new_controller')
out_of_band = info.get('out_of_band')
if self.int_br and new_controller:
- LOG.debug(_("info_update received. New controller"
- "is to be set to: %s"), new_controller)
+ LOG.debug("info_update received. New controller"
+ "is to be set to: %s", new_controller)
self.int_br.run_vsctl(["set-controller",
self.int_bridge_name,
"tcp:" + new_controller])
if out_of_band:
- LOG.debug(_("info_update received. New controller"
- "is set to be out of band"))
+ LOG.debug("info_update received. New controller"
+ "is set to be out of band")
self.int_br.set_db_attribute("controller",
self.int_bridge_name,
"connection-mode",
'''
for physical_network, interface in interface_mappings.iteritems():
- LOG.info(_("Mapping physical network %(physical_network)s to "
- "interface %(interface)s"),
+ LOG.info(_LI("Mapping physical network %(physical_network)s to "
+ "interface %(interface)s"),
{'physical_network': physical_network,
'interface': interface})
# Connect the physical interface to the bridge
if not ip_lib.device_exists(interface, self.root_helper):
- LOG.error(_("Interface %(interface)s for physical network "
- "%(physical_network)s does not exist. Agent "
- "terminated!"),
+ LOG.error(_LE("Interface %(interface)s for physical network "
+ "%(physical_network)s does not exist. Agent "
+ "terminated!"),
{'physical_network': physical_network,
'interface': interface})
raise SystemExit(1)
while True:
start = time.time()
- LOG.debug(_("Agent in the rpc loop."))
+ LOG.debug("Agent in the rpc loop.")
# sleep till end of polling interval
elapsed = (time.time() - start)
if (elapsed < self.polling_interval):
time.sleep(self.polling_interval - elapsed)
else:
- LOG.info(_("Loop iteration exceeded interval "
- "(%(polling_interval)s vs. %(elapsed)s)!"),
+ LOG.info(_LI("Loop iteration exceeded interval "
+ "(%(polling_interval)s vs. %(elapsed)s)!"),
{'polling_interval': self.polling_interval,
'elapsed': elapsed})
config.SDNVE.interface_mappings)
controller_ips = config.SDNVE.controller_ips
- LOG.info(_("Controller IPs: %s"), controller_ips)
+ LOG.info(_LI("Controller IPs: %s"), controller_ips)
controller_ip = controller_ips[0]
return {
try:
agent_config = create_agent_config_map(cfg.CONF)
except ValueError as e:
- LOG.exception(_("%s Agent terminated!"), e)
+ LOG.exception(_LE("%s Agent terminated!"), e)
raise SystemExit(1)
plugin = SdnveNeutronAgent(**agent_config)
# Start everything.
- LOG.info(_("Agent initialized successfully, now running... "))
+ LOG.info(_LI("Agent initialized successfully, now running... "))
plugin.daemon_loop()
from oslo.config import cfg
from neutron.api.v2 import attributes
+from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
from neutron.plugins.ibm.common import config # noqa
from neutron.plugins.ibm.common import constants
self.base_url = base_url or cfg.CONF.SDNVE.base_url
self.controller_ips = controller_ips or cfg.CONF.SDNVE.controller_ips
- LOG.info(_("The IP addr of available SDN-VE controllers: %s"),
+ LOG.info(_LI("The IP addr of available SDN-VE controllers: %s"),
self.controller_ips)
self.controller_ip = self.controller_ips[0]
- LOG.info(_("The SDN-VE controller IP address: %s"),
+ LOG.info(_LI("The SDN-VE controller IP address: %s"),
self.controller_ip)
self.new_controller = False
myurl += '?' + urllib.urlencode(params, doseq=1)
try:
- LOG.debug(_("Sending request to SDN-VE. url: "
- "%(myurl)s method: %(method)s body: "
- "%(body)s header: %(header)s "),
+ LOG.debug("Sending request to SDN-VE. url: "
+ "%(myurl)s method: %(method)s body: "
+ "%(body)s header: %(header)s ",
{'myurl': myurl, 'method': method,
'body': body, 'header': self.headers})
resp, replybody = self.httpclient.request(
status_code = resp.status
except Exception as e:
- LOG.error(_("Error: Could not reach server: %(url)s "
- "Exception: %(excp)s."),
+ LOG.error(_LE("Error: Could not reach server: %(url)s "
+ "Exception: %(excp)s."),
{'url': myurl, 'excp': e})
self.cookie = None
continue
if status_code not in constants.HTTP_ACCEPTABLE:
- LOG.debug(_("Error message: %(reply)s -- Status: %(status)s"),
+ LOG.debug("Error message: %(reply)s -- Status: %(status)s",
{'reply': replybody, 'status': status_code})
else:
- LOG.debug(_("Received response status: %s"), status_code)
+ LOG.debug("Received response status: %s", status_code)
if resp.get('set-cookie'):
self.cookie = resp['set-cookie']
replybody_deserialized = self.deserialize(
replybody,
status_code)
- LOG.debug(_("Deserialized body: %s"), replybody_deserialized)
+ LOG.debug("Deserialized body: %s", replybody_deserialized)
if controller_ip != self.controller_ip:
# bcast the change of controller
self.new_controller = True
res = self.resource_path.get(resource, None)
if not res:
- LOG.info(_("Bad resource for forming a list request"))
+ LOG.info(_LI("Bad resource for forming a list request"))
return 0, ''
return self.get(res, params=params)
res = self.resource_path.get(resource, None)
if not res:
- LOG.info(_("Bad resource for forming a show request"))
+ LOG.info(_LI("Bad resource for forming a show request"))
return 0, ''
return self.get(res + specific, params=params)
res = self.resource_path.get(resource, None)
if not res:
- LOG.info(_("Bad resource for forming a create request"))
+ LOG.info(_LI("Bad resource for forming a create request"))
return 0, ''
body = self.process_request(body)
res = self.resource_path.get(resource, None)
if not res:
- LOG.info(_("Bad resource for forming a update request"))
+ LOG.info(_LI("Bad resource for forming a update request"))
return 0, ''
body = self.process_request(body)
res = self.resource_path.get(resource, None)
if not res:
- LOG.info(_("Bad resource for forming a delete request"))
+ LOG.info(_LI("Bad resource for forming a delete request"))
return 0, ''
return self.delete(res + specific)
if not network_type:
return tenant_id
if tenant_type != network_type:
- LOG.info(_("Non matching tenant and network types: "
+ LOG.info(_LI("Non matching tenant and network types: "
"%(ttype)s %(ntype)s"),
{'ttype': tenant_type, 'ntype': network_type})
return
try:
return self.client.tenants.get(id)
except Exception:
- LOG.exception(_("Did not find tenant: %r"), id)
+ LOG.exception(_LE("Did not find tenant: %r"), id)
def get_tenant_type(self, id):
from neutron.db import portbindings_db
from neutron.db import quota_db # noqa
from neutron.extensions import portbindings
+from neutron.i18n import _LE, _LI, _LW
from neutron.openstack.common import log as logging
from neutron.plugins.ibm.common import config # noqa
from neutron.plugins.ibm.common import constants
portbindings.VIF_TYPE] = portbindings.VIF_TYPE_OVS
def set_controller(self, context):
- LOG.info(_("Set a new controller if needed."))
+ LOG.info(_LI("Set a new controller if needed."))
new_controller = self.sdnve_client.sdnve_get_controller()
if new_controller:
self.notifier.info_update(
context,
{'new_controller': new_controller})
- LOG.info(_("Set the controller to a new controller: %s"),
+ LOG.info(_LI("Set the controller to a new controller: %s"),
new_controller)
def _process_request(self, request, current):
@_ha
def create_network(self, context, network):
- LOG.debug(_("Create network in progress: %r"), network)
+ LOG.debug("Create network in progress: %r", network)
session = context.session
tenant_id = self._get_tenant_id_for_create(context, network['network'])
raise sdnve_exc.SdnveException(
msg=(_('Create net failed in SDN-VE: %s') % res))
- LOG.debug(_("Created network: %s"), net['id'])
+ LOG.debug("Created network: %s", net['id'])
return net
@_ha
def update_network(self, context, id, network):
- LOG.debug(_("Update network in progress: %r"), network)
+ LOG.debug("Update network in progress: %r", network)
session = context.session
processed_request = {}
@_ha
def delete_network(self, context, id):
- LOG.debug(_("Delete network in progress: %s"), id)
+ LOG.debug("Delete network in progress: %s", id)
session = context.session
with session.begin(subtransactions=True):
(res, data) = self.sdnve_client.sdnve_delete('network', id)
if res not in constants.HTTP_ACCEPTABLE:
LOG.error(
- _("Delete net failed after deleting the network in DB: %s"),
+ _LE("Delete net failed after deleting the network in DB: %s"),
res)
@_ha
def get_network(self, context, id, fields=None):
- LOG.debug(_("Get network in progress: %s"), id)
+ LOG.debug("Get network in progress: %s", id)
return super(SdnvePluginV2, self).get_network(context, id, fields)
@_ha
def get_networks(self, context, filters=None, fields=None, sorts=None,
limit=None, marker=None, page_reverse=False):
- LOG.debug(_("Get networks in progress"))
+ LOG.debug("Get networks in progress")
return super(SdnvePluginV2, self).get_networks(
context, filters, fields, sorts, limit, marker, page_reverse)
@_ha
def create_port(self, context, port):
- LOG.debug(_("Create port in progress: %r"), port)
+ LOG.debug("Create port in progress: %r", port)
session = context.session
# Set port status as 'ACTIVE' to avoid needing the agent
# requires a tenant id
tenant_id = port.get('tenant_id')
if not tenant_id:
- LOG.debug(_("Create port does not have tenant id info"))
+ LOG.debug("Create port does not have tenant id info")
original_network = super(SdnvePluginV2, self).get_network(
context, port['network_id'])
original_tenant_id = original_network['tenant_id']
port['tenant_id'] = original_tenant_id
LOG.debug(
- _("Create port does not have tenant id info; "
- "obtained is: %s"),
+ "Create port does not have tenant id info; "
+ "obtained is: %s",
port['tenant_id'])
os_tenant_id = tenant_id
raise sdnve_exc.SdnveException(
msg=(_('Create port failed in SDN-VE: %s') % res))
- LOG.debug(_("Created port: %s"), port.get('id', 'id not found'))
+ LOG.debug("Created port: %s", port.get('id', 'id not found'))
return port
@_ha
def update_port(self, context, id, port):
- LOG.debug(_("Update port in progress: %r"), port)
+ LOG.debug("Update port in progress: %r", port)
session = context.session
processed_request = {}
@_ha
def delete_port(self, context, id, l3_port_check=True):
- LOG.debug(_("Delete port in progress: %s"), id)
+ LOG.debug("Delete port in progress: %s", id)
# if needed, check to see if this is a port owned by
# an l3-router. If so, we should prevent deletion.
(res, data) = self.sdnve_client.sdnve_delete('port', id)
if res not in constants.HTTP_ACCEPTABLE:
LOG.error(
- _("Delete port operation failed in SDN-VE "
- "after deleting the port from DB: %s"), res)
+ _LE("Delete port operation failed in SDN-VE "
+ "after deleting the port from DB: %s"), res)
#
# Subnet
@_ha
def create_subnet(self, context, subnet):
- LOG.debug(_("Create subnet in progress: %r"), subnet)
+ LOG.debug("Create subnet in progress: %r", subnet)
new_subnet = super(SdnvePluginV2, self).create_subnet(context, subnet)
# Note(mb): Use of null string currently required by controller
raise sdnve_exc.SdnveException(
msg=(_('Create subnet failed in SDN-VE: %s') % res))
- LOG.debug(_("Subnet created: %s"), new_subnet['id'])
+ LOG.debug("Subnet created: %s", new_subnet['id'])
return new_subnet
@_ha
def update_subnet(self, context, id, subnet):
- LOG.debug(_("Update subnet in progress: %r"), subnet)
+ LOG.debug("Update subnet in progress: %r", subnet)
session = context.session
processed_request = {}
@_ha
def delete_subnet(self, context, id):
- LOG.debug(_("Delete subnet in progress: %s"), id)
+ LOG.debug("Delete subnet in progress: %s", id)
super(SdnvePluginV2, self).delete_subnet(context, id)
(res, data) = self.sdnve_client.sdnve_delete('subnet', id)
if res not in constants.HTTP_ACCEPTABLE:
- LOG.error(_("Delete subnet operation failed in SDN-VE after "
- "deleting the subnet from DB: %s"), res)
+ LOG.error(_LE("Delete subnet operation failed in SDN-VE after "
+ "deleting the subnet from DB: %s"), res)
#
# Router
@_ha
def create_router(self, context, router):
- LOG.debug(_("Create router in progress: %r"), router)
+ LOG.debug("Create router in progress: %r", router)
if router['router']['admin_state_up'] is False:
- LOG.warning(_('Ignoring admin_state_up=False for router=%r. '
- 'Overriding with True'), router)
+ LOG.warning(_LW('Ignoring admin_state_up=False for router=%r. '
+ 'Overriding with True'), router)
router['router']['admin_state_up'] = True
tenant_id = self._get_tenant_id_for_create(context, router['router'])
raise sdnve_exc.SdnveException(
msg=(_('Create router failed in SDN-VE: %s') % res))
- LOG.debug(_("Router created: %r"), new_router)
+ LOG.debug("Router created: %r", new_router)
return new_router
@_ha
def update_router(self, context, id, router):
- LOG.debug(_("Update router in progress: id=%(id)s "
- "router=%(router)r"),
+ LOG.debug("Update router in progress: id=%(id)s "
+ "router=%(router)r",
{'id': id, 'router': router})
session = context.session
@_ha
def delete_router(self, context, id):
- LOG.debug(_("Delete router in progress: %s"), id)
+ LOG.debug("Delete router in progress: %s", id)
super(SdnvePluginV2, self).delete_router(context, id)
(res, data) = self.sdnve_client.sdnve_delete('router', id)
if res not in constants.HTTP_ACCEPTABLE:
LOG.error(
- _("Delete router operation failed in SDN-VE after "
- "deleting the router in DB: %s"), res)
+ _LE("Delete router operation failed in SDN-VE after "
+ "deleting the router in DB: %s"), res)
@_ha
def add_router_interface(self, context, router_id, interface_info):
- LOG.debug(_("Add router interface in progress: "
- "router_id=%(router_id)s "
- "interface_info=%(interface_info)r"),
+ LOG.debug("Add router interface in progress: "
+ "router_id=%(router_id)s "
+ "interface_info=%(interface_info)r",
{'router_id': router_id, 'interface_info': interface_info})
new_interface = super(SdnvePluginV2, self).add_router_interface(
context, router_id, interface_info)
LOG.debug(
- _("SdnvePluginV2.add_router_interface called. Port info: %s"),
+ "SdnvePluginV2.add_router_interface called. Port info: %s",
new_interface)
request_info = interface_info.copy()
request_info['port_id'] = new_interface['port_id']
msg=(_('Update router-add-interface failed in SDN-VE: %s') %
res))
- LOG.debug(_("Added router interface: %r"), new_interface)
+ LOG.debug("Added router interface: %r", new_interface)
return new_interface
def _add_router_interface_only(self, context, router_id, interface_info):
- LOG.debug(_("Add router interface only called: "
- "router_id=%(router_id)s "
- "interface_info=%(interface_info)r"),
+ LOG.debug("Add router interface only called: "
+ "router_id=%(router_id)s "
+ "interface_info=%(interface_info)r",
{'router_id': router_id, 'interface_info': interface_info})
port_id = interface_info.get('port_id')
(res, data) = self.sdnve_client.sdnve_update(
'router', router_id + '/add_router_interface', interface_info)
if res not in constants.HTTP_ACCEPTABLE:
- LOG.error(_("SdnvePluginV2._add_router_interface_only: "
- "failed to add the interface in the roll back."
- " of a remove_router_interface operation"))
+ LOG.error(_LE("SdnvePluginV2._add_router_interface_only: "
+ "failed to add the interface in the roll back."
+ " of a remove_router_interface operation"))
@_ha
def remove_router_interface(self, context, router_id, interface_info):
- LOG.debug(_("Remove router interface in progress: "
- "router_id=%(router_id)s "
- "interface_info=%(interface_info)r"),
+ LOG.debug("Remove router interface in progress: "
+ "router_id=%(router_id)s "
+ "interface_info=%(interface_info)r",
{'router_id': router_id, 'interface_info': interface_info})
subnet_id = interface_info.get('subnet_id')
if not port_id:
raise sdnve_exc.BadInputException(msg=_('No port ID'))
myport = super(SdnvePluginV2, self).get_port(context, port_id)
- LOG.debug(_("SdnvePluginV2.remove_router_interface port: %s"),
+ LOG.debug("SdnvePluginV2.remove_router_interface port: %s",
myport)
myfixed_ips = myport.get('fixed_ips')
if not myfixed_ips:
if subnet_id:
interface_info['subnet_id'] = subnet_id
LOG.debug(
- _("SdnvePluginV2.remove_router_interface subnet_id: %s"),
+ "SdnvePluginV2.remove_router_interface subnet_id: %s",
subnet_id)
else:
if not port_id:
@_ha
def create_floatingip(self, context, floatingip):
- LOG.debug(_("Create floatingip in progress: %r"),
+ LOG.debug("Create floatingip in progress: %r",
floatingip)
new_floatingip = super(SdnvePluginV2, self).create_floatingip(
context, floatingip)
msg=(_('Creating floating ip operation failed '
'in SDN-VE controller: %s') % res))
- LOG.debug(_("Created floatingip : %r"), new_floatingip)
+ LOG.debug("Created floatingip : %r", new_floatingip)
return new_floatingip
@_ha
def update_floatingip(self, context, id, floatingip):
- LOG.debug(_("Update floatingip in progress: %r"), floatingip)
+ LOG.debug("Update floatingip in progress: %r", floatingip)
session = context.session
processed_request = {}
@_ha
def delete_floatingip(self, context, id):
- LOG.debug(_("Delete floatingip in progress: %s"), id)
+ LOG.debug("Delete floatingip in progress: %s", id)
super(SdnvePluginV2, self).delete_floatingip(context, id)
(res, data) = self.sdnve_client.sdnve_delete('floatingip', id)
if res not in constants.HTTP_ACCEPTABLE:
- LOG.error(_("Delete floatingip failed in SDN-VE: %s"), res)
+ LOG.error(_LE("Delete floatingip failed in SDN-VE: %s"), res)