本文整理汇总了Python中networking_vsphere._i18n._LI函数的典型用法代码示例。如果您正苦于以下问题:Python _LI函数的具体用法?Python _LI怎么用?Python _LI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_LI函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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']})
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:28,代码来源:ovsvapp_db.py
示例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
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:27,代码来源:dvs_util.py
示例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
开发者ID:openstack,项目名称:networking-vsphere,代码行数:35,代码来源:ovsvapp_sg_agent.py
示例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())
开发者ID:priya-j,项目名称:networking-vsphere,代码行数:11,代码来源:dvs_securitygroup_rpc.py
示例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."))
开发者ID:VTabolin,项目名称:networking-vsphere,代码行数:50,代码来源:vc_driver.py
示例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")
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:14,代码来源:agent.py
示例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)
开发者ID:priya-j,项目名称:networking-vsphere,代码行数:30,代码来源:dvs_util.py
示例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."))
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:32,代码来源:ovsvapp_mech_driver.py
示例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
开发者ID:ekosareva,项目名称:networking-vsphere,代码行数:25,代码来源:dvs_util.py
示例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)
开发者ID:openstack,项目名称:networking-vsphere,代码行数:16,代码来源:ovsvapp_sg_agent.py
示例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
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:30,代码来源:ovsvapp_db.py
示例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)
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:25,代码来源:dvs_neutron_agent.py
示例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)
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:26,代码来源:dvs_util.py
示例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)
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:7,代码来源:dvs_mechanism_driver.py
示例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."))
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:27,代码来源:ovsvapp_mech_driver.py
示例16: _get_or_create_pg
def _get_or_create_pg(self, pg_name, network, segment):
try:
return self._get_pg_by_name(pg_name)
except exceptions.PortGroupNotFound:
LOG.info(_LI('Network %(name)s is not present in vcenter. '
'Perform network creation'), {'name': pg_name})
return self.create_network(network, segment)
开发者ID:priya-j,项目名称:networking-vsphere,代码行数:7,代码来源:dvs_util.py
示例17: clean_port_filters
def clean_port_filters(self, ports, remove_port=False):
"""Method to remove OVS rules for an existing VM port."""
LOG.debug("OVSF Cleaning filters for %s ports.", len(ports))
if not ports:
return
with self.sg_br.deferred() as deferred_sec_br:
for port_id in ports:
try:
if not self.filtered_ports.get(port_id):
LOG.debug("Attempted to remove port filter "
"which is not in filtered %s.", port_id)
continue
if not remove_port:
self._remove_all_flows(deferred_sec_br, port_id)
else:
self._remove_all_flows(deferred_sec_br, port_id, True)
if self.provider_port_cache.__contains__(port_id):
self.provider_port_cache.remove(port_id)
else:
LOG.info(_LI("KeyError:Remove requested for "
"port_id not present: %s"),
self.provider_port_cache)
self.filtered_ports.pop(port_id, None)
except Exception:
LOG.exception(_LE("Unable to delete flows for"
" %s."), port_id)
开发者ID:openstack,项目名称:networking-vsphere,代码行数:26,代码来源:ovs_firewall.py
示例18: remove_port_filter
def remove_port_filter(self, ports):
LOG.info(_LI("Remove ports with rules"))
for p_id in ports:
port = self.dvs_ports.get(p_id)
if port:
self.remove_queue.put(port)
self.dvs_ports.pop(p_id, None)
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:7,代码来源:vcenter_firewall.py
示例19: _process_port_filter
def _process_port_filter(self, ports):
LOG.info(_LI("Set security group rules for ports %s"),
[p['id'] for p in ports])
ports_for_update = []
for port in ports:
port_device = port['device']
stored_port_key = self.dvs_ports.get(port_device, {}). \
get('binding:vif_details', {}).get('dvs_port_key')
port_key = port.get('binding:vif_details', {}).get('dvs_port_key')
if port_key and port_key != stored_port_key:
port_dvs = self._get_port_dvs(port)
if port_dvs:
try:
port_info = port_dvs.get_port_info(port)
if port['id'] == port_info.config.name:
self.dvs_ports[port_device] = port
ports_for_update.append(port)
else:
self.dvs_ports.pop(port_device, None)
except exceptions.PortNotFound:
self.dvs_ports.pop(port_device, None)
else:
self.dvs_ports.pop(port_device, None)
else:
self.dvs_ports[port_device] = port
ports_for_update.append(port)
self._apply_sg_rules_for_port(ports_for_update)
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:27,代码来源:vcenter_firewall.py
示例20: create_network
def create_network(self, network, virtual_switch):
LOG.info(
_LI("Creating portgroup %(nm)s with vlan id %(vid)s " "on virtual switch %(sw)s."),
{"nm": network.name, "vid": network.config.vlan.vlanIds[0], "sw": virtual_switch.name},
)
network_util.create_port_group(
self.session, dvs_name=virtual_switch.name, pg_name=network.name, vlan_id=network.config.vlan.vlanIds[0]
)
开发者ID:ekosareva,项目名称:vmware-dvs,代码行数:8,代码来源:dvs_driver.py
注:本文中的networking_vsphere._i18n._LI函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论