本文整理汇总了Python中networking_vsphere._i18n._LI函数的典型用法代码示例。如果您正苦于以下问题:Python _LI函数的具体用法?Python _LI怎么用?Python _LI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_LI函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: release_local_vlan
def release_local_vlan(net_info):
session = db_api.get_session()
with session.begin(subtransactions=True):
res_keys = ['vcenter_id', 'cluster_id', 'network_id']
res = dict((k, net_info[k]) for k in res_keys)
try:
query = session.query(models.ClusterVNIAllocations)
allocation = (query.filter(
models.ClusterVNIAllocations.vcenter_id == res['vcenter_id'],
models.ClusterVNIAllocations.cluster_id == res['cluster_id'],
models.ClusterVNIAllocations.network_id == res['network_id']
).with_lockmode('update').one())
if allocation.network_port_count == 0:
allocation.update({'network_id': None,
'allocated': False,
'network_port_count': 0})
LOG.info(_LI("Released lvid for network: %s."), res)
else:
LOG.info(_LI("Unable to release local vlan for network_id %s "
"because ports are available on network."),
res['network_id'])
except sa_exc.NoResultFound:
# Nothing to do, may be another controller cleared the record
# We will just log and return.
LOG.error(_LE("Network %(network)s is already de-allocated for "
"cluster %(cluster)s."),
{'network': net_info['network_id'],
'cluster': net_info['cluster_id']})
示例2: _delete_port_group
def _delete_port_group(self, pg_ref, name):
remove_used_pg_try = 0
while True:
try:
pg_delete_task = self.connection.invoke_api(
self.connection.vim,
'Destroy_Task',
pg_ref)
self.connection.wait_for_task(pg_delete_task)
LOG.info(_LI('Network %(name)s deleted.'), {'name': name})
break
except vmware_exceptions.VimException as e:
if dvs_const.RESOURCE_IN_USE in e.message:
remove_used_pg_try += 1
if remove_used_pg_try > 3:
LOG.info(_LI('Network %(name)s was not deleted. Active'
' ports were found'), {'name': name})
break
else:
sleep(0.2)
else:
raise exceptions.wrap_wmvare_vim_exception(e)
except vmware_exceptions.VMwareDriverException as e:
if dvs_const.DELETED_TEXT in e.message:
sleep(0.1)
else:
raise
示例3: _remove_from_sgid_device_map
def _remove_from_sgid_device_map(self, deleted_dev, deleted_dev_group, ip,
port_id, remove_list):
for group, devices_dict in \
six.iteritems(self.sgid_devices_dict):
for ip, ports_list in six.iteritems(devices_dict):
if port_id in ports_list:
deleted_dev = ip
deleted_dev_group = group
break
else:
ip = None
if ip is not None:
if len(ports_list) == 1:
value = devices_dict.pop(ip, None)
if value is None:
LOG.info(_LI("KeyError for %s"), ip)
LOG.info(_LI("KeyError devices_dict %(ddict)s,"
"%(deleted_dev)s"),
{'ddict': devices_dict,
'deleted_dev': deleted_dev})
else:
ports_list.remove(port_id)
if len(devices_dict) == 0:
remove_list.append(group)
dev_groups = self.device_sgids_dict.get(port_id)
if dev_groups is not None:
if deleted_dev_group in dev_groups:
dev_groups.remove(deleted_dev_group)
if len(dev_groups) == 0:
self.device_sgids_dict.pop(port_id)
if self.pending_rules_dict.get(port_id) is not None:
self.pending_rules_dict.pop(port_id)
LOG.debug("Deleted device ip and group are: %s, %s",
deleted_dev, deleted_dev_group)
return deleted_dev, deleted_dev_group
示例4: 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
devices = self.plugin_rpc.security_group_rules_for_devices(
self.context, device_ids)
self.firewall.update_port_filter(devices.values())
示例5: monitor_events
def monitor_events(self):
try:
LOG.info(_LI("Starting monitoring for vCenter updates"))
version = ""
self.state = constants.DRIVER_RUNNING
while self.state in (constants.DRIVER_RUNNING):
try:
LOG.debug("Waiting for vCenter updates...")
try:
updateSet = self.session._call_method(
vim_util,
"wait_for_updates_ex",
version)
if self.state != constants.DRIVER_RUNNING:
LOG.error(_LE("Driver is not in running state."))
break
except error_util.SocketTimeoutException:
# Ignore timeout.
LOG.warning(_LW("Ignoring socket timeouts while "
"monitoring for vCenter updates."))
continue
if updateSet:
version = updateSet.version
events = self._process_update_set(updateSet)
LOG.debug("Sending events : %s.", events)
self.dispatch_events(events)
except exceptions.VimFaultException as e:
# InvalidCollectorVersionFault happens
# on session re-connect.
# Re-initialize WaitForUpdatesEx.
if "InvalidCollectorVersion" in e.fault_list:
LOG.debug("InvalidCollectorVersion - "
"Re-initializing vCenter updates "
"monitoring.")
version = ""
for cluster_mor in self.clusters_by_id.values():
pfo = self._register_cluster_for_updates(
cluster_mor)
clu_id = cluster_mor.value
self.cluster_id_to_filter[clu_id] = pfo
continue
LOG.exception(_LE("VimFaultException while processing "
"update set %s."), e)
except Exception:
LOG.exception(_LE("Exception while processing update"
" set."))
time.sleep(0)
LOG.info(_LI("Stopped monitoring for vCenter updates."))
except Exception:
LOG.exception(_LE("Monitoring for vCenter updates failed."))
示例6: set_node_state
def set_node_state(self, is_up):
if is_up != self.node_up:
self.node_up = is_up
if is_up:
LOG.info(_LI("Making node up."))
self._initialize_managers()
self._start_managers()
else:
self.state = constants.AGENT_INITIALIZING
self._stop_managers()
else:
LOG.info(_LI("Ignoring node update as agent "
"is already %s."),
"ACTIVE" if self.node_up else "DOWN")
示例7: book_port
def book_port(self, network, port_name, segment):
try:
net_name = self._get_net_name(self.dvs_name, network)
pg = self._get_or_create_pg(net_name, network, segment)
while True:
try:
port_info = self._lookup_unbound_port(pg)
break
except exceptions.UnboundPortNotFound:
try:
self._increase_ports_on_portgroup(pg)
except (vmware_exceptions.VMwareDriverException,
exceptions.VMWareDVSException) as e:
if dvs_const.CONCURRENT_MODIFICATION_TEXT in e.message:
LOG.info(_LI('Concurent modification on '
'increase port group.'))
continue
builder = SpecBuilder(self.connection.vim.client.factory)
port_settings = builder.port_setting()
port_settings.blocked = builder.blocked(False)
update_spec = builder.port_config_spec(
port_info.config.configVersion, port_settings, name=port_name)
update_spec.key = port_info.key
update_task = self.connection.invoke_api(
self.connection.vim, 'ReconfigureDVPort_Task',
self._dvs, port=[update_spec])
self.connection.wait_for_task(update_task)
return port_info.key
except vmware_exceptions.VimException as e:
raise exceptions.wrap_wmvare_vim_exception(e)
示例8: delete_network_postcommit
def delete_network_postcommit(self, context):
network = context.current
segments = context.network_segments
vxlan_segments = []
if segments:
for segment in segments:
if segment[api.NETWORK_TYPE] in self.supported_network_types:
vxlan_segments.append(segment)
if not vxlan_segments:
return
try:
stale_entries = ovsvapp_db.get_stale_local_vlans_for_network(
network['id'])
if stale_entries:
for (vcenter, cluster, lvid) in stale_entries:
network_info = {'vcenter_id': vcenter,
'cluster_id': cluster,
'lvid': lvid,
'network_id': network['id']}
if len(vxlan_segments) == 1:
seg_id = vxlan_segments[0][api.SEGMENTATION_ID]
net_type = vxlan_segments[0][api.NETWORK_TYPE]
network_info.update({'segmentation_id': seg_id,
'network_type': net_type})
LOG.debug("Spawning thread for releasing network "
"VNI allocations for %s.", network_info)
self.threadpool.spawn_n(self._notify_agent, network_info)
LOG.info(_LI("Spawned a thread for releasing network "
"vni allocations for network: %s."),
network_info)
except Exception:
LOG.exception(_LE("Failed checking stale local vlan allocations."))
示例9: create_network
def create_network(self, network, segment):
name = self._get_net_name(network)
blocked = not network['admin_state_up']
if network['provider:physical_network'] in self.uplink_map:
uplinks = self.uplink_map[network['provider:physical_network']]
else:
uplinks = None
try:
pg_spec = self._build_pg_create_spec(
name,
segment['segmentation_id'],
blocked, uplinks)
pg_create_task = self.connection.invoke_api(
self.connection.vim,
'CreateDVPortgroup_Task',
self._dvs, spec=pg_spec)
result = self.connection.wait_for_task(pg_create_task)
except vmware_exceptions.VimException as e:
raise exceptions.wrap_wmvare_vim_exception(e)
else:
pg = result.result
LOG.info(_LI('Network %(name)s created \n%(pg_ref)s'),
{'name': name, 'pg_ref': pg})
return pg
示例10: refresh_firewall
def refresh_firewall(self, device_ids=None):
"""Removes all rules for input port_ids and puts in new rules for them.
This routine erases all rules and puts in new rules for the
input ports shippped as device_ids.
:param device_ids: set of port_ids for which firewall rules
need to be refreshed.
"""
if not device_ids:
device_ids = self.firewall.ports.keys()
if not device_ids:
LOG.info(_LI("No ports here to refresh firewall."))
return
LOG.info(_LI("Refresh firewall rules for %s ports."), len(device_ids))
self._process_port_set(set(device_ids), True)
示例11: check_to_reclaim_local_vlan
def check_to_reclaim_local_vlan(port_info):
lvid = -1
session = db_api.get_session()
with session.begin(subtransactions=True):
res_keys = ['vcenter_id', 'cluster_id', 'network_id']
res = dict((k, port_info[k]) for k in res_keys)
try:
query = session.query(models.ClusterVNIAllocations)
allocation = (query.filter(
models.ClusterVNIAllocations.vcenter_id == res['vcenter_id'],
models.ClusterVNIAllocations.cluster_id == res['cluster_id'],
models.ClusterVNIAllocations.network_id == res['network_id']
).with_lockmode('update').one())
count = allocation.network_port_count
if count >= 1:
count -= 1
allocation.update({'network_port_count': count})
LOG.debug("Decremented the allocated port count for network "
"%s.", res)
if count == 0:
lvid = allocation.lvid
LOG.info(_LI("lvid can be released for network: %s."), res)
except sa_exc.NoResultFound:
# Nothing to do, may be another controller cleared the record
# We will just log and return back status as False.
LOG.debug("Network %(network)s is already de-allocated for "
"cluster %(cluster)s.",
{'network': port_info['network_id'],
'cluster': port_info['cluster_id']})
return lvid
示例12: rpc_loop
def rpc_loop(self, polling_manager=None):
if not polling_manager:
polling_manager = polling.get_polling_manager(
minimize_polling=False)
while self.run_daemon_loop:
start = time.time()
port_stats = {'regular': {'added': 0,
'updated': 0,
'removed': 0}}
if self.fullsync:
LOG.info(_LI("Agent out of sync with plugin!"))
connected_ports = self._get_dvs_ports()
self.added_ports = connected_ports - self.known_ports
if cfg.CONF.DVS.clean_on_restart:
self._clean_up_vsphere_extra_resources(connected_ports)
self.fullsync = False
polling_manager.force_polling()
if self._agent_has_updates(polling_manager):
LOG.debug("Agent rpc_loop - update")
self.process_ports()
port_stats['regular']['added'] = len(self.added_ports)
port_stats['regular']['updated'] = len(self.updated_ports)
port_stats['regular']['removed'] = len(self.deleted_ports)
polling_manager.polling_completed()
self.loop_count_and_wait(start)
示例13: update_network
def update_network(self, network, original=None):
original_name = self._get_net_name(original) if original else None
current_name = self._get_net_name(network)
blocked = not network['admin_state_up']
try:
pg_ref = self._get_pg_by_name(original_name or current_name)
pg_config_info = self._get_config_by_ref(pg_ref)
if (pg_config_info.defaultPortConfig.blocked.value != blocked or
(original_name and original_name != current_name)):
# we upgrade only defaultPortConfig, because it is inherited
# by all ports in PortGroup, unless they are explicit
# overwritten on specific port.
pg_spec = self._build_pg_update_spec(
pg_config_info.configVersion,
blocked=blocked)
pg_spec.name = current_name
pg_update_task = self.connection.invoke_api(
self.connection.vim,
'ReconfigureDVPortgroup_Task',
pg_ref, spec=pg_spec)
self.connection.wait_for_task(pg_update_task)
LOG.info(_LI('Network %(name)s updated'),
{'name': current_name})
except vmware_exceptions.VimException as e:
raise exceptions.wrap_wmvare_vim_exception(e)
示例14: create_network_precommit
def create_network_precommit(self, context):
if CONF.DVS.precreate_networks and self._check_net_type(context):
LOG.info(_LI('Precreate network cast'))
self.dvs_notifier.create_network_cast(context.current,
context.network_segments[0])
# need to wait for agents. Cast message
sleep(2)
示例15: _notify_agent
def _notify_agent(self, network_info):
host = None
cluster_id = network_info['cluster_id']
if 'host' in network_info:
host = network_info['host']
else:
agent = self._get_ovsvapp_agent_from_cluster(self.context,
cluster_id)
LOG.debug("Agent chosen for notification: %s.", agent)
if agent and 'host' in agent:
host = agent['host']
else:
LOG.error(_LE("Failed to find OVSvApp Agent with host "
"%(host)s while releasing network allocations "
"for %(cluster)s in vCenter %(vcenter)s."),
{'host': host,
'vcenter': network_info['vcenter_id'],
'cluster': cluster_id})
return
try:
LOG.info(_LI("Initiating device_delete RPC for network "
"%(network)s to OVSvApp agent on host %(host)s."),
{'host': host, 'network': network_info})
self.notifier.device_delete(self.context, network_info, host,
cluster_id)
except Exception:
LOG.exception(_LE("Failed to notify agent to delete port group."))