Merge "Enforce log hints in neutron.plugins.sriovnicagent"
This commit is contained in:
commit
38ccf39873
@ -93,7 +93,7 @@ def _directory_to_check_translation(filename):
|
||||
#"neutron/plugins/opencontrail",
|
||||
"neutron/plugins/openvswitch",
|
||||
#"neutron/plugins/plumgrid",
|
||||
#"neutron/plugins/sriovnicagent",
|
||||
"neutron/plugins/sriovnicagent",
|
||||
"neutron/plugins/vmware"]
|
||||
return any([dir in filename for dir in dirs])
|
||||
|
||||
|
@ -17,6 +17,7 @@ import glob
|
||||
import os
|
||||
import re
|
||||
|
||||
from neutron.i18n import _LE, _LW
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.sriovnicagent.common import exceptions as exc
|
||||
from neutron.plugins.sriovnicagent import pci_lib
|
||||
@ -43,7 +44,7 @@ class PciOsWrapper(object):
|
||||
vf_list = []
|
||||
dev_path = cls.DEVICE_PATH % dev_name
|
||||
if not os.path.isdir(dev_path):
|
||||
LOG.error(_("Failed to get devices for %s"), dev_name)
|
||||
LOG.error(_LE("Failed to get devices for %s"), dev_name)
|
||||
raise exc.InvalidDeviceError(dev_name=dev_name,
|
||||
reason=_("Device not found"))
|
||||
file_list = os.listdir(dev_path)
|
||||
@ -144,7 +145,7 @@ class EmbSwitch(object):
|
||||
"""
|
||||
vf_index = self.pci_slot_map.get(pci_slot)
|
||||
if vf_index is None:
|
||||
LOG.warning(_("Cannot find vf index for pci slot %s"),
|
||||
LOG.warning(_LW("Cannot find vf index for pci slot %s"),
|
||||
pci_slot)
|
||||
raise exc.InvalidPciSlotError(pci_slot=pci_slot)
|
||||
return self.pci_dev_wrapper.get_vf_state(vf_index)
|
||||
@ -157,7 +158,7 @@ class EmbSwitch(object):
|
||||
"""
|
||||
vf_index = self.pci_slot_map.get(pci_slot)
|
||||
if vf_index is None:
|
||||
LOG.warning(_("Cannot find vf index for pci slot %s"),
|
||||
LOG.warning(_LW("Cannot find vf index for pci slot %s"),
|
||||
pci_slot)
|
||||
raise exc.InvalidPciSlotError(pci_slot=pci_slot)
|
||||
return self.pci_dev_wrapper.set_vf_state(vf_index, state)
|
||||
@ -282,8 +283,8 @@ class ESwitchManager(object):
|
||||
if embedded_switch:
|
||||
used_device_mac = embedded_switch.get_pci_device(pci_slot)
|
||||
if used_device_mac != device_mac:
|
||||
LOG.warning(_("device pci mismatch: %(device_mac)s "
|
||||
"- %(pci_slot)s"), {"device_mac": device_mac,
|
||||
"pci_slot": pci_slot})
|
||||
LOG.warning(_LW("device pci mismatch: %(device_mac)s "
|
||||
"- %(pci_slot)s"),
|
||||
{"device_mac": device_mac, "pci_slot": pci_slot})
|
||||
embedded_switch = None
|
||||
return embedded_switch
|
||||
|
@ -16,6 +16,7 @@
|
||||
import re
|
||||
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.i18n import _LE, _LW
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.sriovnicagent.common import exceptions as exc
|
||||
|
||||
@ -53,7 +54,7 @@ class PciDeviceIPWrapper(ip_lib.IPWrapper):
|
||||
out = self._execute('', "link", ("show", self.dev_name),
|
||||
self.root_helper)
|
||||
except Exception as e:
|
||||
LOG.exception(_("Failed executing ip command"))
|
||||
LOG.exception(_LE("Failed executing ip command"))
|
||||
raise exc.IpCommandError(dev_name=self.dev_name,
|
||||
reason=str(e))
|
||||
vf_lines = self._get_vf_link_show(vf_list, out)
|
||||
@ -75,7 +76,7 @@ class PciDeviceIPWrapper(ip_lib.IPWrapper):
|
||||
out = self._execute('', "link", ("show", self.dev_name),
|
||||
self.root_helper)
|
||||
except Exception as e:
|
||||
LOG.exception(_("Failed executing ip command"))
|
||||
LOG.exception(_LE("Failed executing ip command"))
|
||||
raise exc.IpCommandError(dev_name=self.dev_name,
|
||||
reason=str(e))
|
||||
vf_lines = self._get_vf_link_show([vf_index], out)
|
||||
@ -102,7 +103,7 @@ class PciDeviceIPWrapper(ip_lib.IPWrapper):
|
||||
str(vf_index), "state", status_str),
|
||||
self.root_helper)
|
||||
except Exception as e:
|
||||
LOG.exception(_("Failed executing ip command"))
|
||||
LOG.exception(_LE("Failed executing ip command"))
|
||||
raise exc.IpCommandError(dev_name=self.dev_name,
|
||||
reason=str(e))
|
||||
|
||||
@ -123,7 +124,7 @@ class PciDeviceIPWrapper(ip_lib.IPWrapper):
|
||||
if index in vf_list:
|
||||
vf_lines.append(line)
|
||||
if not vf_lines:
|
||||
LOG.warning(_("Cannot find vfs %(vfs)s in device %(dev_name)s"),
|
||||
LOG.warning(_LW("Cannot find vfs %(vfs)s in device %(dev_name)s"),
|
||||
{'vfs': vf_list, 'dev_name': self.dev_name})
|
||||
return vf_lines
|
||||
|
||||
@ -139,7 +140,7 @@ class PciDeviceIPWrapper(ip_lib.IPWrapper):
|
||||
vf_details["MAC"] = pattern_match.group("mac")
|
||||
vf_details["link-state"] = pattern_match.group("state")
|
||||
else:
|
||||
LOG.warning(_("failed to parse vf link show line %(line)s: "
|
||||
"for %(device)s"), {'line': vf_line,
|
||||
'device': self.dev_name})
|
||||
LOG.warning(_LW("failed to parse vf link show line %(line)s: "
|
||||
"for %(device)s"),
|
||||
{'line': vf_line, 'device': self.dev_name})
|
||||
return vf_details
|
||||
|
@ -31,6 +31,7 @@ from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils as q_utils
|
||||
from neutron import context
|
||||
from neutron.i18n import _LE, _LI
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common import loopingcall
|
||||
from neutron.plugins.sriovnicagent.common import config # noqa
|
||||
@ -63,7 +64,7 @@ class SriovNicSwitchRpcCallbacks(n_rpc.RpcCallback,
|
||||
# notifications there is no guarantee the notifications are
|
||||
# processed in the same order as the relevant API requests.
|
||||
self.agent.updated_devices.add(port['mac_address'])
|
||||
LOG.debug(_("port_update RPC received for port: %s"), port['id'])
|
||||
LOG.debug("port_update RPC received for port: %s", port['id'])
|
||||
|
||||
|
||||
class SriovNicSwitchPluginApi(agent_rpc.PluginApi,
|
||||
@ -97,7 +98,7 @@ class SriovNicSwitchAgent(sg_rpc.SecurityGroupAgentRpcMixin):
|
||||
|
||||
def _setup_rpc(self):
|
||||
self.agent_id = 'nic-switch-agent.%s' % socket.gethostname()
|
||||
LOG.info(_("RPC agent_id: %s"), self.agent_id)
|
||||
LOG.info(_LI("RPC agent_id: %s"), self.agent_id)
|
||||
|
||||
self.topic = topics.AGENT
|
||||
self.plugin_rpc = SriovNicSwitchPluginApi(topics.PLUGIN)
|
||||
@ -128,7 +129,7 @@ class SriovNicSwitchAgent(sg_rpc.SecurityGroupAgentRpcMixin):
|
||||
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_eswitch_mgr(self, device_mappings, exclude_devices={}):
|
||||
self.eswitch_mgr = esm.ESwitchManager(device_mappings,
|
||||
@ -178,7 +179,7 @@ class SriovNicSwitchAgent(sg_rpc.SecurityGroupAgentRpcMixin):
|
||||
self.eswitch_mgr.set_device_state(device, pci_slot,
|
||||
admin_state_up)
|
||||
except exc.SriovNicError:
|
||||
LOG.exception(_("Failed to set device %s state"), device)
|
||||
LOG.exception(_LE("Failed to set device %s state"), device)
|
||||
return
|
||||
if admin_state_up:
|
||||
# update plugin about port status
|
||||
@ -192,7 +193,7 @@ class SriovNicSwitchAgent(sg_rpc.SecurityGroupAgentRpcMixin):
|
||||
self.agent_id,
|
||||
cfg.CONF.host)
|
||||
else:
|
||||
LOG.info(_("No device with MAC %s defined on agent."), device)
|
||||
LOG.info(_LI("No device with MAC %s defined on agent."), device)
|
||||
|
||||
def treat_devices_added_updated(self, devices):
|
||||
try:
|
||||
@ -210,48 +211,49 @@ class SriovNicSwitchAgent(sg_rpc.SecurityGroupAgentRpcMixin):
|
||||
LOG.debug("Port with MAC address %s is added", device)
|
||||
|
||||
if 'port_id' in device_details:
|
||||
LOG.info(_("Port %(device)s updated. Details: %(details)s"),
|
||||
LOG.info(_LI("Port %(device)s updated. Details: %(details)s"),
|
||||
{'device': device, 'details': device_details})
|
||||
profile = device_details['profile']
|
||||
self.treat_device(device_details['device'],
|
||||
profile.get('pci_slot'),
|
||||
device_details['admin_state_up'])
|
||||
else:
|
||||
LOG.info(_("Device with MAC %s not defined on plugin"), device)
|
||||
LOG.info(_LI("Device with MAC %s not defined on plugin"),
|
||||
device)
|
||||
return False
|
||||
|
||||
def treat_devices_removed(self, devices):
|
||||
resync = False
|
||||
for device in devices:
|
||||
LOG.info(_("Removing device with mac_address %s"), device)
|
||||
LOG.info(_LI("Removing device with mac_address %s"), device)
|
||||
try:
|
||||
dev_details = self.plugin_rpc.update_device_down(self.context,
|
||||
device,
|
||||
self.agent_id,
|
||||
cfg.CONF.host)
|
||||
except Exception as e:
|
||||
LOG.debug(_("Removing port failed for device %(device)s "
|
||||
"due to %(exc)s"), {'device': device, 'exc': e})
|
||||
LOG.debug("Removing port failed for device %(device)s "
|
||||
"due to %(exc)s", {'device': device, 'exc': e})
|
||||
resync = True
|
||||
continue
|
||||
if dev_details['exists']:
|
||||
LOG.info(_("Port %s updated."), device)
|
||||
LOG.info(_LI("Port %s updated."), device)
|
||||
else:
|
||||
LOG.debug(_("Device %s not defined on plugin"), device)
|
||||
LOG.debug("Device %s not defined on plugin", device)
|
||||
return resync
|
||||
|
||||
def daemon_loop(self):
|
||||
sync = True
|
||||
devices = set()
|
||||
|
||||
LOG.info(_("SRIOV NIC Agent RPC Daemon Started!"))
|
||||
LOG.info(_LI("SRIOV NIC Agent RPC Daemon Started!"))
|
||||
|
||||
while True:
|
||||
start = time.time()
|
||||
LOG.debug("Agent rpc_loop - iteration:%d started",
|
||||
self.iter_num)
|
||||
if sync:
|
||||
LOG.info(_("Agent out of sync with plugin!"))
|
||||
LOG.info(_LI("Agent out of sync with plugin!"))
|
||||
devices.clear()
|
||||
sync = False
|
||||
device_info = {}
|
||||
@ -264,13 +266,13 @@ class SriovNicSwitchAgent(sg_rpc.SecurityGroupAgentRpcMixin):
|
||||
try:
|
||||
device_info = self.scan_devices(devices, updated_devices_copy)
|
||||
if self._device_info_has_changes(device_info):
|
||||
LOG.debug(_("Agent loop found changes! %s"), device_info)
|
||||
LOG.debug("Agent loop found changes! %s", device_info)
|
||||
# If treat devices fails - indicates must resync with
|
||||
# plugin
|
||||
sync = self.process_network_devices(device_info)
|
||||
devices = device_info['current']
|
||||
except Exception:
|
||||
LOG.exception(_("Error in agent loop. Devices info: %s"),
|
||||
LOG.exception(_LE("Error in agent loop. Devices info: %s"),
|
||||
device_info)
|
||||
sync = True
|
||||
# Restore devices that were removed from this set earlier
|
||||
@ -282,8 +284,8 @@ class SriovNicSwitchAgent(sg_rpc.SecurityGroupAgentRpcMixin):
|
||||
if (elapsed < self.polling_interval):
|
||||
time.sleep(self.polling_interval - elapsed)
|
||||
else:
|
||||
LOG.debug(_("Loop iteration exceeded interval "
|
||||
"(%(polling_interval)s vs. %(elapsed)s)!"),
|
||||
LOG.debug("Loop iteration exceeded interval "
|
||||
"(%(polling_interval)s vs. %(elapsed)s)!",
|
||||
{'polling_interval': self.polling_interval,
|
||||
'elapsed': elapsed})
|
||||
self.iter_num = self.iter_num + 1
|
||||
@ -329,12 +331,12 @@ def main():
|
||||
device_mappings = config_parser.device_mappings
|
||||
exclude_devices = config_parser.exclude_devices
|
||||
|
||||
except ValueError as e:
|
||||
LOG.error(_("Failed on Agent configuration parse : %s."
|
||||
" Agent terminated!"), e)
|
||||
except ValueError:
|
||||
LOG.exception(_LE("Failed on Agent configuration parse. "
|
||||
"Agent terminated!"))
|
||||
raise SystemExit(1)
|
||||
LOG.info(_("Physical Devices mappings: %s"), device_mappings)
|
||||
LOG.info(_("Exclude Devices: %s"), exclude_devices)
|
||||
LOG.info(_LI("Physical Devices mappings: %s"), device_mappings)
|
||||
LOG.info(_LI("Exclude Devices: %s"), exclude_devices)
|
||||
|
||||
polling_interval = cfg.CONF.AGENT.polling_interval
|
||||
root_helper = cfg.CONF.AGENT.root_helper
|
||||
@ -344,10 +346,10 @@ def main():
|
||||
polling_interval,
|
||||
root_helper)
|
||||
except exc.SriovNicError:
|
||||
LOG.exception(_("Agent Initialization Failed"))
|
||||
LOG.exception(_LE("Agent Initialization Failed"))
|
||||
raise SystemExit(1)
|
||||
# Start everything.
|
||||
LOG.info(_("Agent initialized successfully, now running... "))
|
||||
LOG.info(_LI("Agent initialized successfully, now running... "))
|
||||
agent.daemon_loop()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user