本文整理汇总了Python中networking_brocade._i18n._LE函数的典型用法代码示例。如果您正苦于以下问题:Python _LE函数的具体用法?Python _LE怎么用?Python _LE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_LE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: create_network_postcommit
def create_network_postcommit(self, mech_context):
"""Create VLAN on the switch.
:param:mech_context: Details about the network to be created
:raise: Exception
"""
LOG.debug("create_network_postcommit: called")
network = mech_context.current
network_id = network['id']
tenant_id = network['tenant_id']
segments = mech_context.network_segments
network_type = segments[0]['network_type']
vlan_id = segments[0]['segmentation_id']
physical_network = segments[0]['physical_network']
if physical_network not in self._physical_networks:
LOG.info(_LI("BrocadeFiNiMechanism: Ignoring request to create "
"network. Network cannot be created in the "
"configured physical network %(physnet)s"),
{'physnet': physical_network})
return
if network_type != 'vlan':
LOG.info(_LI("BrocadeFiNiMechanism: Ignoring request to create "
"network for network type %(nw_type)s. Only type "
"vlan is supported"), {'nw_type': network_type})
return
try:
devices = self._physical_networks.get(physical_network)
for device in devices:
device_info = self._devices.get(device)
address = device_info.get('address')
driver = None
try:
driver = self._get_driver(device)
except Exception as e:
LOG.exception(_LE("BrocadeFiNiMechanism: create_network"
"_postcommit failed while configuring "
"device %(host)s exception=%(error)s"),
{'host': address,
'error': e.args})
raise ml2_exc.MechanismDriverError(method='create_network_'
'postcommit')
# Proceed only if the driver is not None
if driver is not None:
driver.create_network(
vlan_id,
device_info.get("ports").split(","))
except Exception as e:
LOG.exception(
_LE("Brocade FI/NI driver: create_network_postcommit failed"
"Error = %(error)s"), {'error': e.args})
raise ml2_exc.MechanismDriverError(method='create_network_postcomm'
'it')
LOG.info(_LI("BrocadeFiNiMechanism:created_network_postcommit: "
"%(network_id)s of network type = %(network_type)s with "
"vlan = %(vlan_id)s for tenant %(tenant_id)s"),
{'network_id': network_id,
'network_type': network_type,
'vlan_id': vlan_id,
'tenant_id': tenant_id})
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:60,代码来源:mechanism_brocade_fi_ni.py
示例2: create_router
def create_router(self, host, username, password, rbridge_id, router_id):
"""create vrf and associate vrf."""
router_id = router_id[0:11]
vrf_name = template.OS_VRF_NAME.format(id=router_id)
rd = "".join(i for i in router_id if i in "0123456789")
rd = rd[:4] + ":" + rd[:4]
try:
mgr = self.connect(host, username, password)
self.create_vrf(mgr, rbridge_id, vrf_name)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
self.close_session()
try:
# For Nos5.0.0
self.configure_rd_for_vrf(mgr, rbridge_id, vrf_name, rd)
self.configure_address_family_for_vrf(mgr, rbridge_id, vrf_name)
except Exception:
with excutils.save_and_reraise_exception() as ctxt:
try:
# This is done because on 4.0.0 rd doesnt accept alpha
# character nor hyphen
rd = "".join(i for i in router_id if i in "0123456789")
rd = rd[:4] + ":" + rd[:4]
self.configure_rd_for_vrf(mgr, rbridge_id, vrf_name, rd)
self.configure_address_family_for_vrf_v1(mgr,
rbridge_id,
vrf_name)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
self.close_session()
ctxt.reraise = False
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:34,代码来源:nosdriver.py
示例3: update_router
def update_router(self, rbridge_id, router_id, added, removed):
"""update router"""
LOG.info(_LI("Inside update_router before sending to switch"))
if added is None:
LOG.info(_LI("Added is None"))
if removed is None:
LOG.info(_LI("Removed is None"))
if not utils.is_vrf_required():
""" Configure the static route at the rbridge mode"""
try:
if added is not None:
LOG.info(_LI("Adding new route"))
for route in added:
self.configure_static_route(rbridge_id,
route['destination'],
route['nexthop'])
if removed is not None:
LOG.info(_LI("Deleting new route"))
for route in removed:
self.delete_static_route(rbridge_id,
route['destination'],
route['nexthop'])
except Exception as e:
with excutils.save_and_reraise_exception():
LOG.exception(
_LE("Failed to create static route %s"), str(e))
else:
""" config the static route in for the VRF"""
vrf_name = template.OS_VRF_NAME.format(id=router_id)
vrf_name = vrf_name[:32]
try:
if added is not None:
LOG.info(_LI("Adding new route with VRF %s"), vrf_name)
for route in added:
self.configure_vrf_static_route(rbridge_id,
vrf_name,
route['destination'],
route['nexthop'])
if removed is not None:
LOG.info(_LI("Deleting new route from vrf %s"), vrf_name)
for route in removed:
self.delete_vrf_static_route(rbridge_id,
vrf_name,
route['destination'],
route['nexthop'])
except Exception as e:
with excutils.save_and_reraise_exception():
LOG.exception(
_LE("Failed to create static route %s"), str(e))
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:51,代码来源:nosdriver.py
示例4: delete_network
def delete_network(self, net_id):
"""Deletes a virtual network."""
try:
self.delete_vlan_interface(net_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:7,代码来源:nosdriver.py
示例5: _aggregate_nics_to_support_lacp
def _aggregate_nics_to_support_lacp(topology, bond_info):
device_dict = {}
lacp_ports = {}
if not bond_info:
po_lo, po_hi = get_port_channel_lo_hi()
for host_physnet in topology.keys():
if len(topology[host_physnet]) >= 1:
for item in topology[host_physnet]:
if ((not bond_info) and (po_hi >= po_lo)):
lacp_ports.setdefault(po_lo, []).append(item)
LOG.debug("po lo %d po_hi %d", po_lo, po_hi)
elif bond_info:
# only one port-channel
po_lo = bond_info[host_physnet][0]
lacp_ports.setdefault(po_lo, []).append(item)
else:
LOG.error(_LE("exhausted all port-channels increase"
"port-channel range or bond mappings"
" not provided"))
sys.exit(0)
device_dict.setdefault(host_physnet, []).append(("port-channel",
str(po_lo)))
if not bond_info:
po_lo = po_lo + 1
LOG.debug("device_dict %s lacp_ports %s", device_dict, lacp_ports)
return device_dict, lacp_ports
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:27,代码来源:utils.py
示例6: bind_port
def bind_port(self, context):
port = context.current
vnic_type = port['binding:vnic_type']
LOG.debug("Brcd:Attempting to bind port %(port)s with vnic_type "
"%(vnic_type)s on network %(network)s",
{'port': port['id'], 'vnic_type': vnic_type,
'network': context.network.current['id']})
if baremetal_util.is_baremetal_deploy(port):
segments = context.segments_to_bind
LOG.info(_LI("Segments:%s"), segments)
params = baremetal_util.validate_physical_net_params(context)
try:
# TODO(rmadapur): Handle local_link_info portgroups
for i in params["local_link_information"]:
speed, name = i['port_id']
vlan_id = segments[0][api.SEGMENTATION_ID]
self._driver.configure_native_vlan_on_interface(
speed,
name, vlan_id)
except Exception:
LOG.exception(_LE("Brocade NOS driver:failed to trunk"
" bare metal vlan"))
raise Exception(_("Brocade switch exception:"
" bind_port failed for baremetal"))
context.set_binding(segments[0][api.ID],
portbindings.VIF_TYPE_OTHER, {},
status=n_const.PORT_STATUS_ACTIVE)
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:29,代码来源:mechanism_brocade.py
示例7: handle_router_interface_add
def handle_router_interface_add(self, context, svi, tenant_id):
fw_list = self.get_firewalls(context)
for fw in fw_list:
fw = self._make_firewall_dict(fw)
policy_name = utils.get_firewall_object_prefix(fw)
if fw['tenant_id'] == tenant_id and\
fw['status'] == const.ACTIVE:
try:
if not self._fwaas_driver._is_policy_exists(policy_name):
fw_with_rules = (
self._make_firewall_dict_with_rules(context,
fw['id']))
self._invoke_driver_for_plugin_api(context,
fw_with_rules,
'update_firewall')
else:
self._fwaas_driver._apply_policy_on_interface(
policy_name, svi)
except Exception as e:
LOG.error(_LE("Error adding Firewall rule to"
"interface %s "), e)
elif fw['tenant_id'] == tenant_id and\
fw['status'] == const.PENDING_CREATE:
fw_with_rules = (
self._make_firewall_dict_with_rules(context, fw['id']))
self._invoke_driver_for_plugin_api(context, fw_with_rules,
'update_firewall')
self.endpoints[0].set_firewall_status(context, fw['id'],
const.ACTIVE)
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:29,代码来源:brocade_fwaas_plugin.py
示例8: delete_network_postcommit
def delete_network_postcommit(self, mech_context):
"""Delete network.
This translates to removng portprofile
from the switch.
"""
LOG.debug("delete_network_postcommit: called")
network = mech_context.current
network_id = network['id']
vlan_id = network['provider:segmentation_id']
tenant_id = network['tenant_id']
try:
self._driver.delete_network(self._switch['address'],
self._switch['username'],
self._switch['password'],
vlan_id)
except Exception:
LOG.exception(_LE("Brocade NOS driver: failed to delete network"))
raise Exception(
_("Brocade switch exception, "
"delete_network_postcommit failed"))
LOG.info(_LI("delete network (postcommit): %(network_id)s"
" with vlan = %(vlan_id)s"
" for tenant %(tenant_id)s"),
{'network_id': network_id,
'vlan_id': vlan_id,
'tenant_id': tenant_id})
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:30,代码来源:mechanism_brocade.py
示例9: configure_protocol_vrrp
def configure_protocol_vrrp(self, rbridge_id):
"""enable protocol vrrp """
try:
self.enable_protocol_vrrp(rbridge_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:7,代码来源:nosdriver.py
示例10: _setup_policy
def _setup_policy(self, apply_list, fw):
# create zones no matter if they exist. Interfaces are added by router
policy_name = utils.get_firewall_object_prefix(fw)
num_seq_id = len(fw['firewall_rule_list']) + len(self._pre_acls) +\
len(self._post_acls)
seq_ids = self.seq_id_bm.get_seq_ids(policy_name, num_seq_id)
index = 0
try:
if not self._driver.is_ip_acl_exists(policy_name):
index = self._config_replay_acls_file(policy_name,
self._pre_acls,
seq_ids, index)
for rule in fw['firewall_rule_list']:
if not rule['enabled']:
continue
if rule['ip_version'] == 4:
self._config_replay_acls(policy_name, rule,
str(seq_ids[index]))
index = index + 1
else:
LOG.warning(_LW("Unsupported IP version rule."))
index = self._config_replay_acls_file(policy_name,
self._post_acls,
seq_ids, index)
self.merge_and_replay_acls(policy_name)
for ri in apply_list:
for svi in ri.router['svis']:
self._apply_policy_on_interface(policy_name, svi)
except Exception as e:
LOG.error(_LE("Error creating ACL policy :Error: %s"), e)
self._clear_policy(apply_list, fw)
raise e
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:33,代码来源:brocade_fwaas_driver.py
示例11: create_port_precommit
def create_port_precommit(self, mech_context):
"""Create logical port on the switch (db update)."""
LOG.debug("create_port_precommit: called")
port = mech_context.current
port_id = port['id']
network_id = port['network_id']
tenant_id = port['tenant_id']
admin_state_up = port['admin_state_up']
context = mech_context._plugin_context
network = brocade_db.get_network(context, network_id)
vlan_id = network['vlan']
try:
brocade_db.create_port(context, port_id, network_id,
None,
vlan_id, tenant_id, admin_state_up)
except Exception:
LOG.exception(_LE("Brocade Mechanism: failed to create port"
" in db"))
raise Exception(
_("Brocade Mechanism: create_port_precommit failed"))
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:25,代码来源:mechanism_brocade.py
示例12: _get_driver
def _get_driver(self, device):
"""
Gets the driver based on the firmware version of the device.
:param:device: Contains device name
:raises: Exception
"""
driver = self._driver_map.get(device)
if driver is None:
driver_factory = importutils.import_object(DRIVER_FACTORY)
device_info = self._devices.get(device)
address = device_info.get('address')
os_type = device_info.get('ostype')
try:
driver = driver_factory.get_driver(device_info)
if driver is not None and os_type in ROUTER_DEVICE_TYPE:
self._driver_map.update({device: driver})
except Exception as e:
LOG.exception(_LE("BrocadeRouterPlugin:"
"_filter_router_devices: Error while getting"
" driver : device - %(host)s: %(error)s"),
{'host': address, 'error': e.args})
raise Exception(_("BrocadeRouterPlugin:"
"_filter_router_devices failed for "
"device %(host)s"), {'host': address})
return driver
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:26,代码来源:l3_router_plugin.py
示例13: connect
def connect(self, host, username, password):
"""Connect via SSH and initialize the NETCONF session."""
# Use the persisted NETCONF connection
if self.mgr and self.mgr.connected:
return self.mgr
# check if someone forgot to edit the conf file with real values
if host == '':
raise Exception(_("Brocade Switch IP address is not set, "
"check config ml2_conf_brocade.ini file"))
# Open new NETCONF connection
try:
self.mgr = manager.connect(host=host, port=SSH_PORT,
username=username, password=password,
unknown_host_cb=nos_unknown_host_cb)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Connect failed to switch"))
LOG.debug("Connect success to host %(host)s:%(ssh_port)d",
dict(host=host, ssh_port=SSH_PORT))
return self.mgr
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:25,代码来源:nosdriver.py
示例14: delete_policy
def delete_policy(self, rbridge_id, policy_name):
"""Remove Acl Policy From VDX"""
try:
self.delete_acl(rbridge_id, policy_name)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:7,代码来源:nosdriver.py
示例15: delete_network_precommit
def delete_network_precommit(self, mech_context):
"""Delete Network from the plugin specific database table."""
LOG.debug("delete_network_precommit: called")
network = mech_context.current
network_id = network['id']
vlan_id = network['provider:segmentation_id']
tenant_id = network['tenant_id']
context = mech_context._plugin_context
try:
brocade_db.delete_network(context, network_id)
except Exception:
LOG.exception(
_LE("Brocade Mechanism: failed to delete network in db"))
raise Exception(
_("Brocade Mechanism: delete_network_precommit failed"))
LOG.info(_LI("delete network (precommit): %(network_id)s"
" with vlan = %(vlan_id)s"
" for tenant %(tenant_id)s"),
{'network_id': network_id,
'vlan_id': vlan_id,
'tenant_id': tenant_id})
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:26,代码来源:mechanism_brocade.py
示例16: create_acl_rule
def create_acl_rule(self, acl):
"""Remove Acl Policy From VDX"""
try:
self.create_rule(acl)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:7,代码来源:nosdriver.py
示例17: create_policy
def create_policy(self, policy_name):
"""Remove Acl Policy From VDX"""
try:
self.create_acl(policy_name)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:7,代码来源:nosdriver.py
示例18: create_network
def create_network(self, host, username, password, net_id):
"""Creates a new virtual network."""
domain_name = "default"
name = template.OS_PORT_PROFILE_NAME.format(id=net_id)
try:
mgr = self.connect(host, username, password)
self.create_vlan_interface(mgr, net_id)
self.create_port_profile(mgr, name)
if self._pp_domains_supported and self._virtual_fabric_enabled:
self.configure_port_profile_in_domain(mgr, domain_name, name)
self.create_vlan_profile_for_port_profile(mgr, name)
if self._pp_domains_supported:
self.configure_l2_mode_for_vlan_profile_with_domains(mgr, name)
else:
self.configure_l2_mode_for_vlan_profile(mgr, name)
self.configure_trunk_mode_for_vlan_profile(mgr, name)
self.configure_allowed_vlans_for_vlan_profile(mgr, name, net_id)
self.activate_port_profile(mgr, name)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
self.close_session()
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:27,代码来源:nosdriver.py
示例19: configure_vrrp_group
def configure_vrrp_group(self, rbridge_id,
vlan_id, vrid, version):
"""config vrrp virtual ip on svi"""
try:
self.create_vrrp_group(rbridge_id, vlan_id, vrid, version)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:8,代码来源:nosdriver.py
示例20: create_network
def create_network(self, topology,
physical_network, net_id):
"""Creates a new virtual network."""
try:
self.create_vlan_interface(net_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("NETCONF error"))
开发者ID:denismakogon,项目名称:networking-brocade,代码行数:8,代码来源:nosdriver.py
注:本文中的networking_brocade._i18n._LE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论