本文整理汇总了Python中networking_ovn._i18n._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run_idl
def run_idl(self, txn):
try:
lrouter = idlutils.row_by_value(self.api.idl, 'Logical_Router',
'name', self.lrouter)
except idlutils.RowNotFound:
msg = _("Logical Router %s does not exist") % self.lrouter
raise RuntimeError(msg)
try:
idlutils.row_by_value(self.api.idl, 'Logical_Router_Port',
'name', self.name)
# The LRP entry with certain name has already exist, raise an
# exception to notice caller. It's caller's responsibility to
# call UpdateLRouterPortCommand to get LRP entry processed
# correctly.
msg = _("Logical Router Port with name \"%s\" "
"already exists.") % self.name
raise RuntimeError(msg)
except idlutils.RowNotFound:
lrouter_port = txn.insert(self.api._tables['Logical_Router_Port'])
lrouter_port.name = self.name
for col, val in self.columns.items():
setattr(lrouter_port, col, val)
lrouter.verify('ports')
lrouter_ports = getattr(lrouter, 'ports', [])
if lrouter_port not in lrouter_ports:
lrouter_ports.append(lrouter_port)
setattr(lrouter, 'ports', lrouter_ports)
开发者ID:zjtheone,项目名称:networking-ovn,代码行数:28,代码来源:commands.py
示例2: _get_l3_admin_net
def _get_l3_admin_net(self, create=False):
network = None
context = self._get_admin_context()
filters = self._get_l3_admin_net_query_filter()
networks = self._plugin.get_networks(context, filters=filters)
if len(networks) == 0 and create:
try:
network = self._create_l3_admin_net(context)
self._create_l3_admin_subnet(context, network["id"])
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Error in creating L3 admin network."))
elif len(networks) == 1:
network = networks[0]
subnet_ids = network.get("subnets")
net_id = network["id"]
if not subnet_ids and create:
try:
self._create_l3_admin_subnet(context, net_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Error in creating l3 admin subnet."))
elif len(subnet_ids) == 1:
self._validate_l3_admin_subnet(context, subnet_ids[0])
else:
msg = _("Expected number of subnets in l3 admin network is " "1, found %d.") % len(subnet_ids)
raise exc.L3AdminNetSubnetError(error_message=msg)
else:
msg = _("Expected number of l3 admin networks is 1, found " "%d.") % len(networks)
raise exc.L3AdminNetError(error_message=msg)
return network
开发者ID:muraliran,项目名称:networking-ovn,代码行数:32,代码来源:l3_ovn_admin_net.py
示例3: validate_and_get_data_from_binding_profile
def validate_and_get_data_from_binding_profile(self, port):
if (ovn_const.OVN_PORT_BINDING_PROFILE not in port or
not validators.is_attr_set(
port[ovn_const.OVN_PORT_BINDING_PROFILE])):
return {}
param_set = {}
param_dict = {}
for param_set in ovn_const.OVN_PORT_BINDING_PROFILE_PARAMS:
param_keys = param_set.keys()
for param_key in param_keys:
try:
param_dict[param_key] = (port[
ovn_const.OVN_PORT_BINDING_PROFILE][param_key])
except KeyError:
pass
if len(param_dict) == 0:
continue
if len(param_dict) != len(param_keys):
msg = _('Invalid binding:profile. %s are all '
'required.') % param_keys
raise n_exc.InvalidInput(error_message=msg)
if (len(port[ovn_const.OVN_PORT_BINDING_PROFILE]) != len(
param_keys)):
msg = _('Invalid binding:profile. too many parameters')
raise n_exc.InvalidInput(error_message=msg)
break
if not param_dict:
return {}
for param_key, param_type in param_set.items():
if param_type is None:
continue
param_value = param_dict[param_key]
if not isinstance(param_value, param_type):
msg = _('Invalid binding:profile. %(key)s %(value)s '
'value invalid type') % {'key': param_key,
'value': param_value}
raise n_exc.InvalidInput(error_message=msg)
# Make sure we can successfully look up the port indicated by
# parent_name. Just let it raise the right exception if there is a
# problem.
if 'parent_name' in param_set:
self._plugin.get_port(n_context.get_admin_context(),
param_dict['parent_name'])
if 'tag' in param_set:
tag = int(param_dict['tag'])
if tag < 0 or tag > 4095:
msg = _('Invalid binding:profile. tag "%s" must be '
'an integer between 0 and 4095, inclusive') % tag
raise n_exc.InvalidInput(error_message=msg)
return param_dict
开发者ID:bali2016,项目名称:networking-ovn,代码行数:55,代码来源:mech_driver.py
示例4: run_idl
def run_idl(self, txn):
try:
port_chain = idlutils.row_by_value(self.api.idl,
'Logical_Port_Chain',
'name', self.lport_chain)
fc = getattr(port_chain, 'flow_classifier', [])
except idlutils.RowNotFound:
msg = _("Logical port chain %s does not exist") % self.lport_chain
raise RuntimeError(msg)
if self.may_exist:
flow_classifier = idlutils.row_by_value(
self.api.idl, 'Logical_Flow_Classifier', 'name',
self.lflow_classifier, None)
if flow_classifier:
return
port_chain.verify('flow_classifier')
flow_classifier = txn.insert(
self.api._tables['Logical_Flow_Classifier'])
flow_classifier.name = self.lflow_classifier
for col, val in self.columns.items():
setattr(flow_classifier, col, val)
# add the newly created flow_classifier to existing lswitch
fc.append(flow_classifier.uuid)
setattr(port_chain, 'flow_classifier', fc)
开发者ID:doonhammer,项目名称:networking-ovn,代码行数:25,代码来源:commands.py
示例5: run_idl
def run_idl(self, txn):
try:
lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch',
'name', self.lswitch)
except idlutils.RowNotFound:
msg = _("Logical Switch %s does not exist") % self.lswitch
raise RuntimeError(msg)
if self.may_exist:
port = idlutils.row_by_value(self.api.idl,
'Logical_Switch_Port', 'name',
self.lport, None)
if port:
return
port = txn.insert(self.api._tables['Logical_Switch_Port'])
port.name = self.lport
dhcpv4_options = self.columns.pop('dhcpv4_options', [])
if isinstance(dhcpv4_options, list):
port.dhcpv4_options = dhcpv4_options
else:
port.dhcpv4_options = [dhcpv4_options.result]
dhcpv6_options = self.columns.pop('dhcpv6_options', [])
if isinstance(dhcpv6_options, list):
port.dhcpv6_options = dhcpv6_options
else:
port.dhcpv6_options = [dhcpv6_options.result]
for col, val in self.columns.items():
setattr(port, col, val)
# add the newly created port to existing lswitch
_addvalue_to_list(lswitch, 'ports', port.uuid)
开发者ID:muraliran,项目名称:networking-ovn,代码行数:30,代码来源:commands.py
示例6: _delete_acls
def _delete_acls(self, lswitch_name, acls, acls_delete):
for acl_delete in acls_delete:
try:
acls.remove(acl_delete)
except ValueError:
msg = _("Logical Switch %s missing acl") % lswitch_name
raise RuntimeError(msg)
acl_delete.delete()
开发者ID:hwoarang,项目名称:networking-ovn,代码行数:8,代码来源:commands.py
示例7: delete_lswitch_port
def delete_lswitch_port(self, lport_name=None, lswitch_name=None,
ext_id=None, if_exists=True):
if lport_name is not None:
return cmd.DelLSwitchPortCommand(self, lport_name,
lswitch_name, if_exists)
else:
raise RuntimeError(_("Currently only supports "
"delete by lport-name"))
开发者ID:hzhou8,项目名称:networking-ovn,代码行数:8,代码来源:impl_idl_ovn.py
示例8: run_idl
def run_idl(self, txn):
if self.row_uuid not in self.api._tables['DHCP_Options'].rows:
if self.if_exists:
return
msg = _("DHCP Options row %s does not exist") % self.row_uuid
raise RuntimeError(msg)
self.api._tables['DHCP_Options'].rows[self.row_uuid].delete()
开发者ID:flavio-fernandes,项目名称:networking-ovn,代码行数:8,代码来源:commands.py
示例9: delete_lport_pair_group
def delete_lport_pair_group(self, lport_pair_group_name=None,
lport_chain=None, ext_id=None,
if_exists=True):
if lport_pair_group_name is not None:
return cmd.DelLogicalPortPairGroupCommand(
self, lport_pair_group_name, lport_chain, if_exists)
else:
raise RuntimeError(_("Currently only supports "
"delete by lport-pair-group-name"))
开发者ID:doonhammer,项目名称:networking-ovn,代码行数:9,代码来源:impl_idl_ovn.py
示例10: delete_lport_chain
def delete_lport_chain(self, lswitch_name, lport_chain_name=None,
if_exists=True):
if lport_chain_name is not None:
return cmd.DelLPortChainCommand(self, lswitch_name,
lport_chain_name,
if_exists)
else:
raise RuntimeError(_("Currently only supports delete "
"by lport-chain-name"))
开发者ID:doonhammer,项目名称:networking-ovn,代码行数:9,代码来源:impl_idl_ovn.py
示例11: delete_lport_pair
def delete_lport_pair(self, lport_pair_name=None, lswitch=None,
lport_pair_group_name=None, if_exists=True):
if lport_pair_name is not None:
return cmd.DelLogicalPortPairCommand(self, lport_pair_name,
lswitch,
lport_pair_group_name,
if_exists)
else:
raise RuntimeError(_("Currently only supports "
"delete by lport-pair-name"))
开发者ID:doonhammer,项目名称:networking-ovn,代码行数:10,代码来源:impl_idl_ovn.py
示例12: get_chassis_data_for_ml2_bind_port
def get_chassis_data_for_ml2_bind_port(self, hostname):
try:
chassis = idlutils.row_by_value(self.idl, 'Chassis',
'hostname', hostname)
except idlutils.RowNotFound:
msg = _('Chassis with hostname %s does not exist') % hostname
raise RuntimeError(msg)
return (chassis.external_ids.get('datapath-type', ''),
chassis.external_ids.get('iface-types', ''),
self._get_chassis_physnets(chassis))
开发者ID:muraliran,项目名称:networking-ovn,代码行数:10,代码来源:impl_idl_ovn.py
示例13: delete_lflow_classifier
def delete_lflow_classifier(self, lport_chain_name,
lflow_classifier_name=None,
if_exists=True):
if lflow_classifier_name is not None:
return cmd.DelLogicalFlowClassifierCommand(self, lport_chain_name,
lflow_classifier_name,
if_exists)
else:
raise RuntimeError(_("Currently only delete "
"supports by lflow-classifier-name"))
开发者ID:doonhammer,项目名称:networking-ovn,代码行数:10,代码来源:impl_idl_ovn.py
示例14: run_idl
def run_idl(self, txn):
try:
lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch',
'name', self.name)
except idlutils.RowNotFound:
if self.if_exists:
return
msg = _("Logical Switch %s does not exist") % self.name
raise RuntimeError(msg)
self.api._tables['Logical_Switch'].rows[lswitch.uuid].delete()
开发者ID:hwoarang,项目名称:networking-ovn,代码行数:11,代码来源:commands.py
示例15: run_idl
def run_idl(self, txn):
try:
port = idlutils.row_by_value(self.api.idl, 'Logical_Port',
'name', self.lport)
except idlutils.RowNotFound:
msg = _("Logical Port %s does not exist") % self.lport
raise RuntimeError(msg)
options = {'router-port': self.lrouter_port}
setattr(port, 'options', options)
setattr(port, 'type', 'router')
开发者ID:bigclouds,项目名称:networking-ovn,代码行数:11,代码来源:commands.py
示例16: _validate_l3_admin_subnet
def _validate_l3_admin_subnet(self, context, subnet_id):
subnet = None
try:
subnet = self._plugin.get_subnet(context, subnet_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("L3 admin subnet not found"))
if subnet.get("cidr") != self._cidr:
msg = _("Subnet CIDR %(a)s does not match configured value " "%(e)s.") % {
"a": subnet.get("cidr"),
"e": self._cidr,
}
raise exc.L3AdminNetSubnetError(error_message=msg)
if subnet.get("name") != ovn_const.OVN_L3_ADMIN_NET_SUBNET_NAME:
msg = _("Subnet name %(a)s does not match expected name " "%(e)s.") % {
"a": subnet.get("name"),
"e": ovn_const.OVN_L3_ADMIN_NET_SUBNET_NAME,
}
raise exc.L3AdminNetSubnetError(error_message=msg)
开发者ID:muraliran,项目名称:networking-ovn,代码行数:20,代码来源:l3_ovn_admin_net.py
示例17: run_idl
def run_idl(self, txn):
try:
lrouter_port = idlutils.row_by_value(self.api.idl,
'Logical_Router_Port',
'name', self.name)
except idlutils.RowNotFound:
if self.if_exists:
return
msg = _("Logical Router Port %s does not exist") % self.name
raise RuntimeError(msg)
try:
lrouter = idlutils.row_by_value(self.api.idl, 'Logical_Router',
'name', self.lrouter)
except idlutils.RowNotFound:
msg = _("Logical Router %s does not exist") % self.lrouter
raise RuntimeError(msg)
lrouter_ports = getattr(lrouter, 'ports', [])
if (lrouter_port in lrouter_ports):
lrouter_ports.remove(lrouter_port)
setattr(lrouter, 'ports', lrouter_ports)
开发者ID:defkev,项目名称:networking-ovn,代码行数:21,代码来源:commands.py
示例18: _validate_l3_admin_net_ports
def _validate_l3_admin_net_ports(self, ports, names):
network = netaddr.IPNetwork(self._cidr)
for port in ports:
fixed_ips = port.get("fixed_ips", [])
if not fixed_ips or (fixed_ips and len(fixed_ips) > 1):
msg = _("Unexpected fixed ips %(f) for port %(n)s.") % {"f": fixed_ips, "n": port.get("name")}
raise exc.L3AdminNetPortsError(error_message=msg)
ip = netaddr.IPAddress(fixed_ips[0]["ip_address"])
if ip not in network:
msg = _("IP %(ip)s of port %(n)s is not in l3 admin subnet " "cidr %(c)s.") % {
"ip": ip,
"n": port.get("name"),
"c": self._cidr,
}
raise exc.L3AdminNetPortsError(error_message=msg)
port_names = [port["name"] for port in ports]
if sorted(port_names) != sorted(names):
msg = _("Port names %(a)r does not match expected names " "%(e)r.") % {"a": port_names, "e": names}
raise exc.L3AdminNetPortsError(error_message=msg)
开发者ID:muraliran,项目名称:networking-ovn,代码行数:21,代码来源:l3_ovn_admin_net.py
示例19: create_network_precommit
def create_network_precommit(self, context):
"""Allocate resources for a new network.
:param context: NetworkContext instance describing the new
network.
Create a new network, allocating resources as necessary in the
database. Called inside transaction context on session. Call
cannot block. Raising an exception will result in a rollback
of the current transaction.
"""
network = context.current
# TODO(rtheis): Add support for multi-provider networks when
# routed networks are supported.
if self._get_attribute(network, mpnet.SEGMENTS):
msg = _("Multi-provider networks are not supported")
raise n_exc.InvalidInput(error_message=msg)
network_segments = context.network_segments
network_type = network_segments[0]["network_type"]
segmentation_id = network_segments[0]["segmentation_id"]
physical_network = network_segments[0]["physical_network"]
LOG.debug(
"Creating network with type %(network_type)s, "
"segmentation ID %(segmentation_id)s, "
"physical network %(physical_network)s"
% {"network_type": network_type, "segmentation_id": segmentation_id, "physical_network": physical_network}
)
if network_type not in [
plugin_const.TYPE_LOCAL,
plugin_const.TYPE_FLAT,
plugin_const.TYPE_GENEVE,
plugin_const.TYPE_VLAN,
]:
msg = _("Network type %s is not supported") % network_type
raise n_exc.InvalidInput(error_message=msg)
开发者ID:hzhou8,项目名称:networking-ovn,代码行数:38,代码来源:mech_driver.py
注:本文中的networking_ovn._i18n._函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论