本文整理汇总了Python中neutron.i18n._LI函数的典型用法代码示例。如果您正苦于以下问题:Python _LI函数的具体用法?Python _LI怎么用?Python _LI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_LI函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_foreign_keys
def check_foreign_keys(metadata):
# This methods checks foreign keys that tables contain in models with
# foreign keys that are in db.
added_fks = []
dropped_fks = []
bind = op.get_bind()
insp = sqlalchemy.engine.reflection.Inspector.from_engine(bind)
# Get all tables from db
db_tables = insp.get_table_names()
# Get all tables from models
model_tables = metadata.tables
for table in db_tables:
if table not in model_tables:
continue
# Get all necessary information about key of current table from db
fk_db = dict((_get_fk_info_db(i), i['name']) for i in
insp.get_foreign_keys(table))
fk_db_set = set(fk_db.keys())
# Get all necessary information about key of current table from models
fk_models = dict((_get_fk_info_from_model(fk), fk) for fk in
model_tables[table].foreign_keys)
fk_models_set = set(fk_models.keys())
for key in (fk_db_set - fk_models_set):
dropped_fks.append(('drop_key', fk_db[key], table))
LOG.info(_LI("Detected removed foreign key %(fk)r on "
"table %(table)r"),
{'fk': fk_db[key], 'table': table})
for key in (fk_models_set - fk_db_set):
added_fks.append(('add_key', fk_models[key]))
LOG.info(_LI("Detected added foreign key for column %(fk)r on "
"table %(table)r"),
{'fk': fk_models[key].column.name,
'table': table})
return (added_fks, dropped_fks)
示例2: main
def main():
common_config.init(sys.argv[1:])
common_config.setup_logging()
try:
config_parser = SriovNicAgentConfigParser()
config_parser.parse()
device_mappings = config_parser.device_mappings
exclude_devices = config_parser.exclude_devices
except ValueError:
LOG.exception(_LE("Failed on Agent configuration parse. "
"Agent terminated!"))
raise SystemExit(1)
LOG.info(_LI("Physical Devices mappings: %s"), device_mappings)
LOG.info(_LI("Exclude Devices: %s"), exclude_devices)
polling_interval = cfg.CONF.AGENT.polling_interval
try:
agent = SriovNicSwitchAgent(device_mappings,
exclude_devices,
polling_interval)
except exc.SriovNicError:
LOG.exception(_LE("Agent Initialization Failed"))
raise SystemExit(1)
# Start everything.
LOG.info(_LI("Agent initialized successfully, now running... "))
agent.daemon_loop()
示例3: _schedule_network
def _schedule_network(self, context, network_id, dhcp_notifier):
LOG.info(_LI("Scheduling unhosted network %s"), network_id)
try:
# TODO(enikanorov): have to issue redundant db query
# to satisfy scheduling interface
network = self.get_network(context, network_id)
agents = self.schedule_network(context, network)
if not agents:
LOG.info(_LI("Failed to schedule network %s, "
"no eligible agents or it might be "
"already scheduled by another server"),
network_id)
return
if not dhcp_notifier:
return
for agent in agents:
LOG.info(_LI("Adding network %(net)s to agent "
"%(agent)s on host %(host)s"),
{'net': network_id,
'agent': agent.id,
'host': agent.host})
dhcp_notifier.network_added_to_agent(
context, network_id, agent.host)
except Exception:
# catching any exception during scheduling
# so if _schedule_network is invoked in the loop it could
# continue in any case
LOG.exception(_LE("Failed to schedule network %s"), network_id)
示例4: _run_openstack_l3_cmds
def _run_openstack_l3_cmds(self, commands, server):
"""Execute/sends a CAPI (Command API) command to EOS.
In this method, list of commands is appended with prefix and
postfix commands - to make is understandble by EOS.
:param commands : List of command to be executed on EOS.
:param server: Server endpoint on the Arista switch to be configured
"""
command_start = ['enable', 'configure']
command_end = ['exit']
full_command = command_start + commands + command_end
LOG.info(_LI('Executing command on Arista EOS: %s'), full_command)
try:
# this returns array of return values for every command in
# full_command list
ret = server.runCmds(version=1, cmds=full_command)
LOG.info(_LI('Results of execution on Arista EOS: %s'), ret)
except Exception:
msg = (_LE("Error occurred while trying to execute "
"commands %(cmd)s on EOS %(host)s"),
{'cmd': full_command, 'host': server})
LOG.exception(msg)
raise arista_exc.AristaServicePluginRpcError(msg=msg)
示例5: refresh_firewall
def refresh_firewall(self, device_ids=None):
LOG.info(_LI("Refresh firewall rules"))
if not device_ids:
device_ids = self.firewall.ports.keys()
if not device_ids:
LOG.info(_LI("No ports here to refresh firewall"))
return
if self.use_enhanced_rpc:
devices_info = self.plugin_rpc.security_group_info_for_devices(
self.context, device_ids)
devices = devices_info['devices']
security_groups = devices_info['security_groups']
security_group_member_ips = devices_info['sg_member_ips']
else:
devices = self.plugin_rpc.security_group_rules_for_devices(
self.context, device_ids)
with self.firewall.defer_apply():
for device in devices.values():
LOG.debug("Update port filter for %s", device['device'])
self.set_local_zone(device)
self.firewall.update_port_filter(device)
if self.use_enhanced_rpc:
LOG.debug("Update security group information for ports %s",
devices.keys())
self._update_security_group_info(
security_groups, security_group_member_ips)
示例6: main
def main():
"""Main method for cleaning up OVS bridges.
The utility cleans up the integration bridges used by Neutron.
"""
conf = setup_conf()
conf()
config.setup_logging()
configuration_bridges = set([conf.ovs_integration_bridge,
conf.external_network_bridge])
ovs = ovs_lib.BaseOVS()
ovs_bridges = set(ovs.get_bridges())
available_configuration_bridges = configuration_bridges & ovs_bridges
if conf.ovs_all_ports:
bridges = ovs_bridges
else:
bridges = available_configuration_bridges
# Collect existing ports created by Neutron on configuration bridges.
# After deleting ports from OVS bridges, we cannot determine which
# ports were created by Neutron, so port information is collected now.
ports = collect_neutron_ports(available_configuration_bridges)
for bridge in bridges:
LOG.info(_LI("Cleaning bridge: %s"), bridge)
ovs = ovs_lib.OVSBridge(bridge)
ovs.delete_ports(all_ports=conf.ovs_all_ports)
# Remove remaining ports created by Neutron (usually veth pair)
delete_neutron_ports(ports)
LOG.info(_LI("OVS cleanup completed successfully"))
示例7: dfa_uplink_restart
def dfa_uplink_restart(self, uplink_dict):
LOG.info(_LI("Obtained uplink after restart %s "), uplink_dict)
# This shouldn't happen
if self.phy_uplink is not None:
LOG.error(_LE("Uplink detection already done %s"), self.phy_uplink)
return
uplink = uplink_dict.get('uplink')
veth_intf = uplink_dict.get('veth_intf')
# Logic is as follows:
# If DB didn't have any uplink it means it's not yet detected or down
# if DB has uplink and veth, then no need to scan all ports we can
# start with this veth.
# If uplink has been removed or modified during restart, then a
# down will be returned by uplink detection code and it will be
# removed then.
# If DB has uplink, but no veth, it's an error condition and in
# which case remove the uplink port from bridge and start fresh
if uplink is None or len(uplink) == 0:
LOG.info(_LI("uplink not discovered yet"))
self.restart_uplink_called = True
return
if veth_intf is not None and len(veth_intf) != 0:
LOG.info(_LI("veth interface is already added, %(ul)s %(veth)s"),
{'ul': uplink, 'veth': veth_intf})
self.phy_uplink = uplink
self.veth_intf = veth_intf
self.restart_uplink_called = True
return
LOG.info(_LI("Error case removing the uplink %s from bridge"), uplink)
ovs_vdp.delete_uplink_and_flows(self.root_helper, self.br_ex, uplink)
self.restart_uplink_called = True
示例8: 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)
示例9: _get_dp
def _get_dp(self):
"""Get (dp, ofp, ofpp) tuple for the switch.
A convenient method for openflow message composers.
"""
while True:
dpid_int = self._cached_dpid
if dpid_int is None:
dpid_str = self.get_datapath_id()
LOG.info(_LI("Bridge %(br_name)s has datapath-ID %(dpid)s"),
{"br_name": self.br_name, "dpid": dpid_str})
dpid_int = int(dpid_str, 16)
try:
dp = self._get_dp_by_dpid(dpid_int)
except RuntimeError:
with excutils.save_and_reraise_exception() as ctx:
self._cached_dpid = None
# Retry if dpid has been changed.
# NOTE(yamamoto): Open vSwitch change its dpid on
# some events.
# REVISIT(yamamoto): Consider to set dpid statically.
new_dpid_str = self.get_datapath_id()
if new_dpid_str != dpid_str:
LOG.info(_LI("Bridge %(br_name)s changed its "
"datapath-ID from %(old)s to %(new)s"), {
"br_name": self.br_name,
"old": dpid_str,
"new": new_dpid_str,
})
ctx.reraise = False
else:
self._cached_dpid = dpid_int
return dp, dp.ofproto, dp.ofproto_parser
示例10: logical_port_updated
def logical_port_updated(self, lport):
if self.db_store.get_port(lport.get_id()) is not None:
# TODO(gsagie) support updating port
return
if lport.get_chassis() is None:
return
chassis_to_ofport, lport_to_ofport = (
self.vswitch_api.get_local_ports_to_ofport_mapping())
network = self.get_network_id(lport.get_lswitch_id())
lport.set_external_value('local_network_id', network)
if lport.get_chassis() == self.chassis_name:
ofport = lport_to_ofport.get(lport.get_id(), 0)
if ofport != 0:
lport.set_external_value('ofport', ofport)
lport.set_external_value('is_local', True)
LOG.info(_LI("Adding new local Logical Port"))
LOG.info(lport.__str__())
self.dispatcher.dispatch('add_local_port', lport=lport)
self.db_store.set_port(lport.get_id(), lport, True)
else:
raise RuntimeError("ofport is 0")
else:
ofport = chassis_to_ofport.get(lport.get_chassis(), 0)
if ofport != 0:
lport.set_external_value('ofport', ofport)
lport.set_external_value('is_local', False)
LOG.info(_LI("Adding new remote Logical Port"))
LOG.info(lport.__str__())
self.dispatcher.dispatch('add_remote_port', lport=lport)
self.db_store.set_port(lport.get_id(), lport, False)
else:
raise RuntimeError("ofport is 0")
示例11: treat_devices_added_updated
def treat_devices_added_updated(self, devices_info):
try:
macs_list = set([device_info[0] for device_info in devices_info])
devices_details_list = self.plugin_rpc.get_devices_details_list(
self.context, macs_list, self.agent_id)
except Exception as e:
LOG.debug("Unable to get port details for devices "
"with MAC addresses %(devices)s: %(e)s",
{'devices': macs_list, 'e': e})
# resync is needed
return True
for device_details in devices_details_list:
device = device_details['device']
LOG.debug("Port with MAC address %s is added", device)
if 'port_id' in device_details:
LOG.info(_LI("Port %(device)s updated. Details: %(details)s"),
{'device': device, 'details': device_details})
port_id = device_details['port_id']
self.mac_to_port_id_mapping[device] = port_id
profile = device_details['profile']
spoofcheck = device_details.get('port_security_enabled', True)
self.treat_device(device,
profile.get('pci_slot'),
device_details['admin_state_up'],
spoofcheck)
self.ext_manager.handle_port(self.context, device_details)
else:
LOG.info(_LI("Device with MAC %s not defined on plugin"),
device)
return False
示例12: clean_vrfs
def clean_vrfs(self, conn, router_id_dict, parsed_cfg):
ostk_router_ids = self.get_ostk_router_ids(router_id_dict)
rconf_ids = self.get_running_config_router_ids(parsed_cfg)
source_set = set(ostk_router_ids)
dest_set = set(rconf_ids)
# add_set = source_set.difference(dest_set)
del_set = dest_set.difference(source_set)
LOG.info(_LI("VRF DB set: %s"), (source_set))
LOG.info(_LI("VRFs to delete: %s"), (del_set))
# LOG.info("VRFs to add: %s" % (add_set))
is_multi_region_enabled = cfg.CONF.multi_region.enable_multi_region
invalid_vrfs = []
for router_id in del_set:
if (is_multi_region_enabled):
my_region_id = cfg.CONF.multi_region.region_id
invalid_vrfs.append("nrouter-%s-%s" % (router_id,
my_region_id))
else:
invalid_vrfs.append("nrouter-%s" % (router_id))
if not self.test_mode:
for vrf_name in invalid_vrfs:
confstr = asr_snippets.REMOVE_VRF_DEFN % vrf_name
conn.edit_config(target='running', config=confstr)
return invalid_vrfs
示例13: get_running_config_router_ids
def get_running_config_router_ids(self, parsed_cfg):
rconf_ids = []
is_multi_region_enabled = cfg.CONF.multi_region.enable_multi_region
if (is_multi_region_enabled):
vrf_regex_new = VRF_MULTI_REGION_REGEX_NEW
else:
vrf_regex_new = VRF_REGEX_NEW
for parsed_obj in parsed_cfg.find_objects(vrf_regex_new):
LOG.info(_LI("VRF object: %s"), (str(parsed_obj)))
match_obj = re.match(vrf_regex_new, parsed_obj.text)
router_id = match_obj.group(1)
LOG.info(_LI(" First 6 digits of router ID: %s\n"),
(router_id))
if (is_multi_region_enabled):
region_id = match_obj.group(2)
LOG.info(_LI(" region ID: %s\n"),
(region_id))
my_region_id = cfg.CONF.multi_region.region_id
if (my_region_id == region_id):
rconf_ids.append(router_id)
else:
rconf_ids.append(router_id)
return rconf_ids
示例14: daemon_loop
def daemon_loop(self):
LOG.info(_LI("eSwitch Agent Started!"))
sync = True
port_info = {'current': set(),
'added': set(),
'removed': set(),
'updated': set()}
while True:
start = time.time()
try:
port_info = self.scan_ports(previous=port_info, sync=sync)
except exceptions.RequestTimeout:
LOG.exception(_LE("Request timeout in agent event loop "
"eSwitchD is not responding - exiting..."))
raise SystemExit(1)
if sync:
LOG.info(_LI("Agent out of sync with plugin!"))
sync = False
if self._port_info_has_changes(port_info):
LOG.debug("Starting to process devices in:%s", port_info)
try:
sync = self.process_network_ports(port_info)
except Exception:
LOG.exception(_LE("Error in agent event loop"))
sync = True
# sleep till end of polling interval
elapsed = (time.time() - start)
if (elapsed < self._polling_interval):
time.sleep(self._polling_interval - elapsed)
else:
LOG.debug("Loop iteration exceeded interval "
"(%(polling_interval)s vs. %(elapsed)s)",
{'polling_interval': self._polling_interval,
'elapsed': elapsed})
示例15: delete_network_postcommit
def delete_network_postcommit(self, context):
network_id = context.current['id']
vni = context.current['provider:segmentation_id']
# remove vxlan from all hosts - a little unpleasant
for _switch_ip in self.switches:
try:
actions = [
VXLAN_URL.format(
scheme=self.scheme,
base=_switch_ip,
port=self.protocol_port,
vni=vni
),
NETWORKS_URL.format(
scheme=self.scheme,
base=_switch_ip,
port=self.protocol_port,
network=network_id
)
]
for action in actions:
r = requests.delete(action)
if r.status_code != requests.codes.ok:
LOG.info(
_LI('Error during %s delete. HTTP Error:%s'),
action, r.status_code
)
except Exception, e:
# errors might be normal, but should improve this
LOG.info(_LI('Error during net delete. Error %s'), e)