"neutron/plugins/cisco",
"neutron/plugins/common",
#"neutron/plugins/embrane",
- #"neutron/plugins/hyperv",
+ "neutron/plugins/hyperv",
#"neutron/plugins/ibm",
"neutron/plugins/linuxbridge",
#"neutron/plugins/metaplugin",
from neutron.common import rpc as n_rpc
from neutron.common import topics
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.common import constants as p_const
self.state_rpc.report_state(self.context,
self.agent_state)
self.agent_state.pop('start_flag', None)
- except Exception as ex:
- LOG.exception(_("Failed reporting state! %s"), ex)
+ except Exception:
+ LOG.exception(_LE("Failed reporting state!"))
def _setup_rpc(self):
self.agent_id = 'hyperv_%s' % platform.node()
for mapping in CONF.AGENT.physical_network_vswitch_mappings:
parts = mapping.split(':')
if len(parts) != 2:
- LOG.debug(_('Invalid physical network mapping: %s'), mapping)
+ LOG.debug('Invalid physical network mapping: %s', mapping)
else:
pattern = re.escape(parts[0].strip()).replace('\\*', '.*')
vswitch = parts[1].strip()
return (network_id, map)
def network_delete(self, context, network_id=None):
- LOG.debug(_("network_delete received. "
- "Deleting network %s"), network_id)
+ LOG.debug("network_delete received. "
+ "Deleting network %s", network_id)
# The network may not be defined on this agent
if network_id in self._network_vswitch_map:
self._reclaim_local_network(network_id)
else:
- LOG.debug(_("Network %s not defined on agent."), network_id)
+ LOG.debug("Network %s not defined on agent.", network_id)
def port_delete(self, context, port_id=None):
- LOG.debug(_("port_delete received"))
+ LOG.debug("port_delete received")
self._port_unbound(port_id)
def port_update(self, context, port=None, network_type=None,
segmentation_id=None, physical_network=None):
- LOG.debug(_("port_update received"))
+ LOG.debug("port_update received")
if CONF.SECURITYGROUP.enable_security_group:
if 'security_groups' in port:
self.sec_groups_agent.refresh_firewall()
net_uuid, network_type,
physical_network,
segmentation_id):
- LOG.info(_("Provisioning network %s"), net_uuid)
+ LOG.info(_LI("Provisioning network %s"), net_uuid)
vswitch_name = self._get_vswitch_name(network_type, physical_network)
self._network_vswitch_map[net_uuid] = map
def _reclaim_local_network(self, net_uuid):
- LOG.info(_("Reclaiming local network %s"), net_uuid)
+ LOG.info(_LI("Reclaiming local network %s"), net_uuid)
del self._network_vswitch_map[net_uuid]
def _port_bound(self, port_id,
network_type,
physical_network,
segmentation_id):
- LOG.debug(_("Binding port %s"), port_id)
+ LOG.debug("Binding port %s", port_id)
if net_uuid not in self._network_vswitch_map:
self._provision_network(
self._utils.connect_vnic_to_vswitch(map['vswitch_name'], port_id)
if network_type == p_const.TYPE_VLAN:
- LOG.info(_('Binding VLAN ID %(segmentation_id)s '
- 'to switch port %(port_id)s'),
+ LOG.info(_LI('Binding VLAN ID %(segmentation_id)s '
+ 'to switch port %(port_id)s'),
dict(segmentation_id=segmentation_id, port_id=port_id))
self._utils.set_vswitch_port_vlan_id(
segmentation_id,
#Nothing to do
pass
else:
- LOG.error(_('Unsupported network type %s'), network_type)
+ LOG.error(_LE('Unsupported network type %s'), network_type)
if CONF.AGENT.enable_metrics_collection:
self._utils.enable_port_metrics_collection(port_id)
def _port_unbound(self, port_id):
(net_uuid, map) = self._get_network_vswitch_map_by_port_id(port_id)
if net_uuid not in self._network_vswitch_map:
- LOG.info(_('Network %s is not avalailable on this agent'),
+ LOG.info(_LI('Network %s is not avalailable on this agent'),
net_uuid)
return
- LOG.debug(_("Unbinding port %s"), port_id)
+ LOG.debug("Unbinding port %s", port_id)
self._utils.disconnect_switch_port(map['vswitch_name'], port_id, True)
if not map['ports']:
for port_id in self._port_metric_retries.keys():
if self._utils.can_enable_control_metrics(port_id):
self._utils.enable_control_metrics(port_id)
- LOG.info(_('Port metrics enabled for port: %s'), port_id)
+ LOG.info(_LI('Port metrics enabled for port: %s'), port_id)
del self._port_metric_retries[port_id]
elif self._port_metric_retries[port_id] < 1:
self._utils.enable_control_metrics(port_id)
- LOG.error(_('Port metrics raw enabling for port: %s'), port_id)
+ LOG.error(_LE('Port metrics raw enabling for port: %s'),
+ port_id)
del self._port_metric_retries[port_id]
else:
self._port_metric_retries[port_id] -= 1
else:
self._port_unbound(port_id)
else:
- LOG.debug(_("No port %s defined on agent."), port_id)
+ LOG.debug("No port %s defined on agent.", port_id)
def _treat_devices_added(self, devices):
try:
for device_details in devices_details_list:
device = device_details['device']
- LOG.info(_("Adding port %s"), device)
+ LOG.info(_LI("Adding port %s"), device)
if 'port_id' in device_details:
- LOG.info(
- _("Port %(device)s updated. Details: %(device_details)s"),
- {'device': device, 'device_details': device_details})
+ LOG.info(_LI("Port %(device)s updated. Details: "
+ "%(device_details)s"),
+ {'device': device, 'device_details': device_details})
self._treat_vif_port(
device_details['port_id'],
device_details['network_id'],
def _treat_devices_removed(self, devices):
resync = False
for device in devices:
- LOG.info(_("Removing port %s"), device)
+ LOG.info(_LI("Removing port %s"), device)
try:
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: %(e)s"),
- dict(device=device, e=e))
+ LOG.debug("Removing port failed for device %(device)s: %(e)s",
+ dict(device=device, e=e))
resync = True
continue
self._port_unbound(device)
try:
start = time.time()
if sync:
- LOG.info(_("Agent out of sync with plugin!"))
+ LOG.info(_LI("Agent out of sync with plugin!"))
ports.clear()
sync = False
# notify plugin about port deltas
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
sync = self._process_network_ports(port_info)
ports = port_info['current']
self._port_enable_control_metrics()
- except Exception as e:
- LOG.exception(_("Error in agent event loop: %s"), e)
+ except Exception:
+ LOG.exception(_LE("Error in agent event loop"))
sync = True
# sleep till end of polling interval
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})
plugin = HyperVNeutronAgent()
# Start everything.
- LOG.info(_("Agent initialized successfully, now running... "))
+ LOG.info(_LI("Agent initialized successfully, now running... "))
plugin.daemon_loop()
# under the License.
from neutron.agent import firewall
+from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
from neutron.plugins.hyperv.agent import utilsfactory
from neutron.plugins.hyperv.agent import utilsv2
self._security_ports = {}
def prepare_port_filter(self, port):
- LOG.debug('Creating port %s rules' % len(port['security_group_rules']))
+ LOG.debug('Creating port %s rules', len(port['security_group_rules']))
# newly created port, add default rules.
if port['device'] not in self._security_ports:
try:
self._utils.create_security_rule(port_id, **param_map)
except Exception as ex:
- LOG.error(_('Hyper-V Exception: %(hyperv_exeption)s while '
- 'adding rule: %(rule)s'),
+ LOG.error(_LE('Hyper-V Exception: %(hyperv_exeption)s while '
+ 'adding rule: %(rule)s'),
dict(hyperv_exeption=ex, rule=rule))
def _remove_port_rules(self, port_id, rules):
try:
self._utils.remove_security_rule(port_id, **param_map)
except Exception as ex:
- LOG.error(_('Hyper-V Exception: %(hyperv_exeption)s while '
- 'removing rule: %(rule)s'),
+ LOG.error(_LE('Hyper-V Exception: %(hyperv_exeption)s while '
+ 'removing rule: %(rule)s'),
dict(hyperv_exeption=ex, rule=rule))
def _create_param_map(self, rule):
}
def apply_port_filter(self, port):
- LOG.info(_('Aplying port filter.'))
+ LOG.info(_LI('Aplying port filter.'))
def update_port_filter(self, port):
- LOG.info(_('Updating port rules.'))
+ LOG.info(_LI('Updating port rules.'))
if port['device'] not in self._security_ports:
self.prepare_port_filter(port)
new_rules = [r for r in param_port_rules if r not in rules]
remove_rules = [r for r in rules if r not in param_port_rules]
- LOG.info(_("Creating %(new)s new rules, removing %(old)s "
- "old rules."),
- {'new': len(new_rules),
- 'old': len(remove_rules)})
+ LOG.info(_LI("Creating %(new)s new rules, removing %(old)s "
+ "old rules."),
+ {'new': len(new_rules), 'old': len(remove_rules)})
self._remove_port_rules(old_port['id'], remove_rules)
self._create_port_rules(port['id'], new_rules)
self._security_ports[port['device']] = port
def remove_port_filter(self, port):
- LOG.info(_('Removing port filter'))
+ LOG.info(_LI('Removing port filter'))
self._security_ports.pop(port['device'], None)
@property
desc = job.Description
elap = job.ElapsedTime
- LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s"),
+ LOG.debug("WMI job succeeded: %(desc)s, Elapsed=%(elap)s",
{'desc': desc, 'elap': elap})
def _create_switch_port(self, vswitch_name, switch_port_name):
from oslo.config import cfg
+from neutron.i18n import _LW
from neutron.openstack.common import log as logging
from neutron.plugins.hyperv.agent import utils
from neutron.plugins.hyperv.agent import utilsv2
force_v1_flag = CONF.hyperv.force_hyperv_utils_v1
if _check_min_windows_version(6, 3):
if force_v1_flag:
- LOG.warning(_('V1 virtualization namespace no longer supported on '
- 'Windows Server / Hyper-V Server 2012 R2 or above.'))
+ LOG.warning(_LW('V1 virtualization namespace no longer supported '
+ 'on Windows Server / Hyper-V Server 2012 R2 or '
+ 'above.'))
cls = utilsv2.HyperVUtilsV2R2
elif not force_v1_flag and _check_min_windows_version(6, 2):
cls = utilsv2.HyperVUtilsV2
else:
cls = utils.HyperVUtils
- LOG.debug(_("Loading class: %(module_name)s.%(class_name)s"),
+ LOG.debug("Loading class: %(module_name)s.%(class_name)s",
{'module_name': cls.__module__, 'class_name': cls.__name__})
return cls()
from neutron.common import rpc as n_rpc
from neutron.common import topics
-from neutron.openstack.common import log as logging
from neutron.plugins.hyperv.common import constants
-LOG = logging.getLogger(__name__)
-
class AgentNotifierApi(object):
'''Agent side of the openvswitch rpc API.
from neutron.common import exceptions as n_exc
import neutron.db.api as db_api
from neutron.db import models_v2
+from neutron.i18n import _LW
from neutron.openstack.common import log as logging
from neutron.plugins.hyperv.common import constants
from neutron.plugins.hyperv import model as hyperv_model
alloc_q = alloc_q.filter_by(allocated=False)
alloc = alloc_q.first()
if alloc:
- LOG.debug(_("Reserving vlan %(vlan_id)s on physical network "
- "%(physical_network)s from pool"),
+ LOG.debug("Reserving vlan %(vlan_id)s on physical network "
+ "%(physical_network)s from pool",
{'vlan_id': alloc.vlan_id,
'physical_network': alloc.physical_network})
alloc.allocated = True
vlan_id=constants.FLAT_VLAN_ID)
alloc = alloc_q.first()
if alloc:
- LOG.debug(_("Reserving flat physical network "
- "%(physical_network)s from pool"),
+ LOG.debug("Reserving flat physical network "
+ "%(physical_network)s from pool",
{'physical_network': alloc.physical_network})
alloc.allocated = True
return alloc.physical_network
raise n_exc.VlanIdInUse(
vlan_id=vlan_id,
physical_network=physical_network)
- LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
- "network %(physical_network)s from pool"),
+ LOG.debug("Reserving specific vlan %(vlan_id)s on physical "
+ "network %(physical_network)s from pool",
{'vlan_id': vlan_id,
'physical_network': physical_network})
alloc.allocated = True
alloc = alloc_q.one()
alloc.allocated = False
#session.delete(alloc)
- LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
- "%(physical_network)s"),
+ LOG.debug("Releasing vlan %(vlan_id)s on physical network "
+ "%(physical_network)s",
{'vlan_id': vlan_id,
'physical_network': physical_network})
except exc.NoResultFound:
- LOG.warning(_("vlan_id %(vlan_id)s on physical network "
- "%(physical_network)s not found"),
+ LOG.warning(_LW("vlan_id %(vlan_id)s on physical network "
+ "%(physical_network)s not found"),
{'vlan_id': vlan_id,
'physical_network': physical_network})
# it's not allocatable, so check if its allocated
if not alloc.allocated:
# it's not, so remove it from table
- LOG.debug(_(
- "Removing vlan %(vlan_id)s on "
- "physical network "
- "%(physical_network)s from pool"),
+ LOG.debug(
+ "Removing vlan %(vlan_id)s on physical network "
+ "%(physical_network)s from pool",
{'vlan_id': alloc.vlan_id,
'physical_network': physical_network})
session.delete(alloc)
for allocs in allocations.itervalues():
for alloc in allocs:
if not alloc.allocated:
- LOG.debug(_("Removing vlan %(vlan_id)s on physical "
- "network %(physical_network)s from pool"),
+ LOG.debug("Removing vlan %(vlan_id)s on physical "
+ "network %(physical_network)s from pool",
{'vlan_id': alloc.vlan_id,
'physical_network': alloc.physical_network})
session.delete(alloc)
from neutron.db import quota_db # noqa
from neutron.extensions import portbindings
from neutron.extensions import providernet as provider
+from neutron.i18n import _LI
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as svc_constants
from neutron.plugins.common import utils as plugin_utils
def _parse_network_vlan_ranges(self):
self._network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(
cfg.CONF.HYPERV.network_vlan_ranges)
- LOG.info(_("Network VLAN ranges: %s"), self._network_vlan_ranges)
+ LOG.info(_LI("Network VLAN ranges: %s"), self._network_vlan_ranges)
def _check_vlan_id_in_range(self, physical_network, vlan_id):
for r in self._network_vlan_ranges[physical_network]:
self._process_l3_create(context, net, network['network'])
self._extend_network_dict_provider(context, net)
- LOG.debug(_("Created network: %s"), net['id'])
+ LOG.debug("Created network: %s", net['id'])
return net
def _extend_network_dict_provider(self, context, network):
"""Agent requests device details."""
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
- LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
+ LOG.debug("Device %(device)s details requested from %(agent_id)s",
{'device': device, 'agent_id': agent_id})
port = self._db.get_port(device)
if port:
self._db.set_port_status(port['id'], q_const.PORT_STATUS_ACTIVE)
else:
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
def get_devices_details_list(self, rpc_context, **kwargs):
# TODO(garyk) - live migration and port status
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
- LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
+ LOG.debug("Device %(device)s no longer exists on %(agent_id)s",
{'device': device, 'agent_id': agent_id})
port = self._db.get_port(device)
if port:
else:
entry = {'device': device,
'exists': False}
- LOG.debug(_("%s can not be found in database"), device)
+ LOG.debug("%s can not be found in database", device)
return entry
def tunnel_sync(self, rpc_context, **kwargs):