本文整理汇总了Python中networking_ovn._i18n._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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
示例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
示例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)
示例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)
示例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()
示例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"))
示例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()
示例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"))
示例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"))
示例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"))
示例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))
示例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"))
示例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()
示例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')