本文整理汇总了Python中neutron.common.utils.parse_mappings函数的典型用法代码示例。如果您正苦于以下问题:Python parse_mappings函数的具体用法?Python parse_mappings怎么用?Python parse_mappings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_mappings函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_empty_bridges
def remove_empty_bridges():
try:
interface_mappings = n_utils.parse_mappings(
cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
except ValueError as e:
LOG.error(_LE("Parsing physical_interface_mappings failed: %s."), e)
sys.exit(1)
LOG.info(_LI("Interface mappings: %s."), interface_mappings)
try:
bridge_mappings = n_utils.parse_mappings(
cfg.CONF.LINUX_BRIDGE.bridge_mappings)
except ValueError as e:
LOG.error(_LE("Parsing bridge_mappings failed: %s."), e)
sys.exit(1)
LOG.info(_LI("Bridge mappings: %s."), bridge_mappings)
lb_manager = linuxbridge_neutron_agent.LinuxBridgeManager(
bridge_mappings, interface_mappings)
# NOTE(mgagne) Don't remove pre-existing user-defined bridges
bridge_names = set(lb_manager.get_all_neutron_bridges())
bridge_names -= set(bridge_mappings.values())
for bridge_name in bridge_names:
if lb_manager.get_tap_devices_count(bridge_name):
continue
try:
lb_manager.delete_bridge(bridge_name)
LOG.info(_LI("Linux bridge %s deleted"), bridge_name)
except RuntimeError:
LOG.exception(_LE("Linux bridge %s delete failed"), bridge_name)
LOG.info(_LI("Linux bridge cleanup completed successfully"))
示例2: main
def main():
common_config.init(sys.argv[1:])
common_config.setup_logging()
try:
interface_mappings = n_utils.parse_mappings(
cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
except ValueError as e:
LOG.error(_LE("Parsing physical_interface_mappings failed: %s. "
"Agent terminated!"), e)
sys.exit(1)
LOG.info(_LI("Interface mappings: %s"), interface_mappings)
try:
bridge_mappings = n_utils.parse_mappings(
cfg.CONF.LINUX_BRIDGE.bridge_mappings)
except ValueError as e:
LOG.error(_LE("Parsing bridge_mappings failed: %s. "
"Agent terminated!"), e)
sys.exit(1)
LOG.info(_LI("Bridge mappings: %s"), bridge_mappings)
manager = LinuxBridgeManager(bridge_mappings, interface_mappings)
polling_interval = cfg.CONF.AGENT.polling_interval
quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout
agent = ca.CommonAgentLoop(manager, polling_interval, quitting_rpc_timeout,
constants.AGENT_TYPE_LINUXBRIDGE,
LB_AGENT_BINARY)
LOG.info(_LI("Agent initialized successfully, now running... "))
launcher = service.launch(cfg.CONF, agent)
launcher.wait()
示例3: create_agent_config_map
def create_agent_config_map(config):
"""Create a map of agent config parameters.
:param config: an instance of cfg.CONF
:returns: a map of agent configuration parameters
"""
try:
bridge_mappings = n_utils.parse_mappings(config.OVS.bridge_mappings)
except ValueError as e:
raise ValueError(_("Parsing bridge_mappings failed: %s.") % e)
try:
interface_mappings = n_utils.parse_mappings(config.AGENT.physical_interface_mappings)
except ValueError as e:
raise ValueError(_("Parsing physical_interface_mappings failed: %s.") % e)
kwargs = dict(
integ_br=config.OVS.integration_bridge,
local_ip=config.OVS.local_ip,
interface_mappings=interface_mappings,
bridge_mappings=bridge_mappings,
polling_interval=config.AGENT.polling_interval,
tunnel_types=config.AGENT.tunnel_types,
)
# Verify the tunnel_types specified are valid
for tun in kwargs["tunnel_types"]:
if tun not in constants.TUNNEL_NETWORK_TYPES:
msg = _("Invalid tunnel type specificed: %s"), tun
raise ValueError(msg)
if not kwargs["local_ip"]:
msg = _("Tunneling cannot be enabled without a valid local_ip.")
raise ValueError(msg)
return kwargs
示例4: test_device_mappings
def test_device_mappings(self):
cfg.CONF.set_override('physical_device_mappings',
self.DEVICE_MAPPING_LIST,
'SRIOV_NIC')
device_mappings = q_utils.parse_mappings(
cfg.CONF.SRIOV_NIC.physical_device_mappings)
self.assertEqual(device_mappings, self.DEVICE_MAPPING)
示例5: test_device_mappings_with_spaces
def test_device_mappings_with_spaces(self):
cfg.CONF.set_override('physical_device_mappings',
self.DEVICE_MAPPING_WITH_SPACES_LIST,
'SRIOV_NIC')
device_mappings = n_utils.parse_mappings(
cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
self.assertEqual(self.DEVICE_MAPPING, device_mappings)
示例6: __init__
def __init__(self):
try:
self.physnet_mtus = utils.parse_mappings(
cfg.CONF.ml2.physical_network_mtus
)
except Exception:
self.physnet_mtus = []
示例7: main
def main():
eventlet.monkey_patch()
cfg.CONF(project='neutron')
# fix-neutron-agent-for-mtu-config hack
cfg.CONF.register_opts(interface.OPTS)
logging_config.setup_logging(cfg.CONF)
LOG.info(_("network_device_mtu: %s"), str(cfg.CONF.network_device_mtu))
try:
interface_mappings = q_utils.parse_mappings(
cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
except ValueError as e:
LOG.error(_("Parsing physical_interface_mappings failed: %s."
" Agent terminated!"), e)
sys.exit(1)
LOG.info(_("Interface mappings: %s"), interface_mappings)
polling_interval = cfg.CONF.AGENT.polling_interval
root_helper = cfg.CONF.AGENT.root_helper
agent = LinuxBridgeNeutronAgentRPC(interface_mappings,
polling_interval,
root_helper)
LOG.info(_("Agent initialized successfully, now running... "))
agent.daemon_loop()
sys.exit(0)
示例8: create_agent_config_map
def create_agent_config_map(config):
"""Create a map of agent config parameters.
:param config: an instance of cfg.CONF
:returns: a map of agent configuration parameters
"""
try:
bridge_mappings = q_utils.parse_mappings(config.OVS.bridge_mappings)
except ValueError as e:
raise ValueError(_("Parsing bridge_mappings failed: %s.") % e)
kwargs = dict(
integ_br=config.OVS.integration_bridge,
tun_br=config.OVS.tunnel_bridge,
local_ip=config.OVS.local_ip,
bridge_mappings=bridge_mappings,
root_helper=config.AGENT.root_helper,
polling_interval=config.AGENT.polling_interval,
tunnel_types=config.AGENT.tunnel_types,
)
# If enable_tunneling is TRUE, set tunnel_type to default to GRE
if config.OVS.enable_tunneling and not kwargs['tunnel_types']:
kwargs['tunnel_types'] = [constants.TYPE_GRE]
# Verify the tunnel_types specified are valid
for tun in kwargs['tunnel_types']:
if tun not in constants.TUNNEL_NETWORK_TYPES:
msg = _('Invalid tunnel type specificed: %s'), tun
raise ValueError(msg)
if not kwargs['local_ip']:
msg = _('Tunneling cannot be enabled without a valid local_ip.')
raise ValueError(msg)
return kwargs
示例9: __init__
def __init__(self):
LOG.debug(_('L2HighNeutronAgent init is STARTING'))
self.conf = cfg.CONF
try:
self.bridge_mappings = common_utils.parse_mappings(self.conf.bridge_mappings)
except ValueError as e:
raise ValueError(_("Parsing bridge_mappings failed: %s.") % e)
self.context = context.get_admin_context_without_session()
self.agent_id = 'ovs-agent-%s' % self.conf.host
self.l2_plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
self.l2_state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
self._set_l2_rpc_consumers()
self.use_call = True
self.local_vlan_map = {}
self.tunnel_types = [p_const.TYPE_VXLAN]
self.l2_pop = self.conf.l2_population
self.local_ip = self.conf.local_ip
self.arp_responder_enabled = self.conf.arp_responder and self.l2_pop
self.l2pop_network_types = self.conf.l2pop_network_types or self.tunnel_types
self.l2_agent_state = {
'binary': 'neutron-openvswitch-agent',
'host': self.conf.host,
'topic': l3_constants.L2_AGENT_TOPIC,
'configurations': {
'bridge_mappings': self.bridge_mappings,
'tunnel_types': self.tunnel_types,
'tunneling_ip': self.local_ip.split('/')[0],
'l2_population': self.l2_pop,
'l2pop_network_types': self.l2pop_network_types,
'arp_responder_enabled':self.arp_responder_enabled,
'enable_distributed_routing': True
},
'agent_type': l3_constants.AGENT_TYPE_OVS,
'start_flag': True}
LOG.debug(_('RPC l2_state_report heartbeat start'))
示例10: get_chassis_hostname_and_physnets
def get_chassis_hostname_and_physnets(self):
chassis_info_dict = {}
for ch in self.idl.tables['Chassis'].rows.values():
bridge_mappings = ch.external_ids.get('ovn-bridge-mappings', '')
mapping_dict = n_utils.parse_mappings(bridge_mappings.split(','))
chassis_info_dict[ch.hostname] = mapping_dict.keys()
return chassis_info_dict
示例11: main
def main():
common_config.init(sys.argv[1:])
common_config.setup_logging()
try:
interface_mappings = utils.parse_mappings(
cfg.CONF.ESWITCH.physical_interface_mappings)
except ValueError as e:
LOG.error(_LE("Parsing physical_interface_mappings failed: %s. "
"Agent terminated!"), e)
sys.exit(1)
LOG.info(_LI("Interface mappings: %s"), interface_mappings)
try:
agent = mlnx_eswitch_neutron_agent.MlnxEswitchNeutronAgent(
interface_mappings)
except Exception as e:
LOG.error(_LE("Failed on Agent initialisation : %s. "
"Agent terminated!"), e)
sys.exit(1)
# Start everything.
LOG.info(_LI("Agent initialised successfully, now running... "))
agent.run()
sys.exit(0)
示例12: _parse_physical_network_types
def _parse_physical_network_types(self):
"""Parse physical network types configuration.
Verify default physical network type is valid.
Parse physical network mappings.
"""
self.physical_net_type = cfg.CONF.MLNX.physical_network_type
if self.physical_net_type not in (constants.TYPE_ETH,
constants.TYPE_IB):
LOG.error(_("Invalid physical network type %(type)s."
"Server terminated!"), {'type': self.physical_net_type})
raise SystemExit(1)
try:
self.phys_network_type_maps = utils.parse_mappings(
cfg.CONF.MLNX.physical_network_type_mappings)
except ValueError as e:
LOG.error(_("Parsing physical_network_type failed: %s."
" Server terminated!"), e)
raise SystemExit(1)
for network, type in self.phys_network_type_maps.iteritems():
if type not in (constants.TYPE_ETH, constants.TYPE_IB):
LOG.error(_("Invalid physical network type %(type)s "
" for network %(net)s. Server terminated!"),
{'net': network, 'type': type})
raise SystemExit(1)
LOG.info(_("Physical Network type mappings: %s"),
self.phys_network_type_maps)
示例13: main
def main():
eventlet.monkey_patch()
cfg.CONF(project='neutron')
logging_config.setup_logging(cfg.CONF)
try:
interface_mappings = q_utils.parse_mappings(
cfg.CONF.ESWITCH.physical_interface_mappings)
except ValueError as e:
LOG.error(_("Parsing physical_interface_mappings failed: %s."
" Agent terminated!"), e)
sys.exit(1)
LOG.info(_("Interface mappings: %s"), interface_mappings)
try:
agent = MlnxEswitchNeutronAgent(interface_mappings)
except Exception as e:
LOG.error(_("Failed on Agent initialisation : %s."
" Agent terminated!"), e)
sys.exit(1)
# Start everything.
LOG.info(_("Agent initialised successfully, now running... "))
agent.daemon_loop()
sys.exit(0)
示例14: parse
def parse(self):
"""Parses device_mappings and exclude_devices.
Parse and validate the consistency in both mappings
"""
self.device_mappings = n_utils.parse_mappings(cfg.CONF.SRIOV_NIC.physical_device_mappings)
self.exclude_devices = config.parse_exclude_devices(cfg.CONF.SRIOV_NIC.exclude_devices)
self._validate()
示例15: __init__
def __init__(self):
try:
self.physnet_mtus = utils.parse_mappings(
cfg.CONF.ml2.physical_network_mtus, unique_values=False
)
except Exception as e:
LOG.error(_LE("Failed to parse physical_network_mtus: %s"), e)
self.physnet_mtus = []