本文整理汇总了Python中neutron.agent.ovsdb.native.idlutils.row_by_value函数的典型用法代码示例。如果您正苦于以下问题:Python row_by_value函数的具体用法?Python row_by_value怎么用?Python row_by_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了row_by_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_idl
def run_idl(self, txn):
try:
lport_pair = idlutils.row_by_value(self.api.idl,
'Logical_Port_Pair',
'name', self.lport_pair)
lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch',
'name', self.lswitch)
lppg = idlutils.row_by_value(self.api.idl,
'Logical_Port_Pair_Group',
'name', self.lport_pair_group)
port_pairs = getattr(lswitch, 'port_pairs', [])
port_pairs_ppg = getattr(lppg, 'port_pairs', [])
except idlutils.RowNotFound:
if self.if_exists:
return
msg = _("Port Pair %s does not exist") % self.lport_pair
raise RuntimeError(msg)
lswitch.verify('port_pairs')
lppg.verify('port_pairs')
port_pairs.remove(lport_pair)
port_pairs_ppg.remove(lport_pair)
setattr(lswitch, 'port_pairs', port_pairs)
setattr(lppg, 'port_pairs', port_pairs_ppg)
self.api._tables['Logical_Port_Pair'].rows[lport_pair.uuid].delete()
示例2: 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)
示例3: run_idl
def run_idl(self, txn):
try:
port = idlutils.row_by_value(self.api.idl, 'Port', 'name',
self.port)
except idlutils.RowNotFound:
if self.if_exists:
return
msg = _("Port %s does not exist") % self.port
raise RuntimeError(msg)
if self.bridge:
br = idlutils.row_by_value(self.api.idl, 'Bridge', 'name',
self.bridge)
else:
br = next(b for b in self.api._tables['Bridge'].rows.values()
if port in b.ports)
if port.uuid not in br.ports and not self.if_exists:
# TODO(twilson) Make real errors across both implementations
msg = _("Port %(port)s does not exist on %(bridge)s!") % {
'port': self.name, 'bridge': self.bridge
}
LOG.error(msg)
raise RuntimeError(msg)
br.verify('ports')
ports = br.ports
ports.remove(port)
br.ports = ports
# Also remove port/interface directly for indexing?
port.verify('interfaces')
for iface in port.interfaces:
self.api._tables['Interface'].rows[iface.uuid].delete()
self.api._tables['Port'].rows[port.uuid].delete()
示例4: 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)
示例5: run_idl
def run_idl(self, txn):
try:
lport = idlutils.row_by_value(self.api.idl, 'Logical_Switch_Port',
'name', self.lport)
lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch',
'name', self.lswitch)
except idlutils.RowNotFound:
if self.if_exists:
return
msg = _("Port %s does not exist") % self.lport
raise RuntimeError(msg)
_delvalue_from_list(lswitch, 'ports', lport)
self.api._tables['Logical_Switch_Port'].rows[lport.uuid].delete()
示例6: run_idl
def run_idl(self, txn):
interface = idlutils.row_by_value(self.api.idl, "Interface", "name", self.name)
ports = self.api._tables["Port"].rows.values()
pname = next(port for port in ports if interface in port.interfaces)
bridges = self.api._tables["Bridge"].rows.values()
self.result = next(br.name for br in bridges if pname in br.ports)
示例7: add_tunnel_port
def add_tunnel_port(self, chassis):
bridge = idlutils.row_by_value(self.idl, "Bridge", "name", "br-int")
txn = idl.Transaction(self.idl)
port_name = "df-" + chassis.get_name()
interface = txn.insert(self.idl.tables["Interface"])
interface.name = port_name
interface.type = chassis.get_encap_type()
options_dict = getattr(interface, "options", {})
options_dict["remote_ip"] = chassis.get_ip()
options_dict["key"] = "flow"
interface.options = options_dict
port = txn.insert(self.idl.tables["Port"])
port.name = port_name
port.verify("interfaces")
ifaces = getattr(port, "interfaces", [])
ifaces.append(interface)
port.interfaces = ifaces
external_ids_dict = getattr(interface, "external_ids", {})
external_ids_dict["df-chassis-id"] = chassis.get_name()
port.external_ids = external_ids_dict
bridge.verify("ports")
ports = getattr(bridge, "ports", [])
ports.append(port)
bridge.ports = ports
status = txn.commit_block()
return status
示例8: _verify_dhcp_option_row_for_port
def _verify_dhcp_option_row_for_port(self, port_id,
expected_lsp_dhcpv4_options,
expected_lsp_dhcpv6_options=None):
lsp = idlutils.row_by_value(self.monitor_nb_db_idl,
'Logical_Switch_Port', 'name', port_id,
None)
if lsp.dhcpv4_options:
observed_lsp_dhcpv4_options = {
'cidr': lsp.dhcpv4_options[0].cidr,
'external_ids': lsp.dhcpv4_options[0].external_ids,
'options': lsp.dhcpv4_options[0].options}
else:
observed_lsp_dhcpv4_options = {}
if lsp.dhcpv6_options:
observed_lsp_dhcpv6_options = {
'cidr': lsp.dhcpv6_options[0].cidr,
'external_ids': lsp.dhcpv6_options[0].external_ids,
'options': lsp.dhcpv6_options[0].options}
else:
observed_lsp_dhcpv6_options = {}
if expected_lsp_dhcpv6_options is None:
expected_lsp_dhcpv6_options = {}
self.assertEqual(expected_lsp_dhcpv4_options,
observed_lsp_dhcpv4_options)
self.assertEqual(expected_lsp_dhcpv6_options,
observed_lsp_dhcpv6_options)
示例9: run_idl
def run_idl(self, txn):
bridge = idlutils.row_by_value(self.api.idl, 'Bridge',
'name', self.integration_bridge)
port_name = "df-" + self.chassis.get_id()
interface = txn.insert(self.api.idl.tables['Interface'])
interface.name = port_name
interface.type = self.chassis.get_encap_type()
options_dict = getattr(interface, 'options', {})
options_dict['remote_ip'] = self.chassis.get_ip()
options_dict['key'] = 'flow'
interface.options = options_dict
port = txn.insert(self.api.idl.tables['Port'])
port.name = port_name
port.verify('interfaces')
ifaces = getattr(port, 'interfaces', [])
ifaces.append(interface)
port.interfaces = ifaces
external_ids_dict = getattr(interface, 'external_ids', {})
external_ids_dict['df-chassis-id'] = self.chassis.get_id()
port.external_ids = external_ids_dict
bridge.verify('ports')
ports = getattr(bridge, 'ports', [])
ports.append(port)
bridge.ports = ports
示例10: get_local_ports_to_ofport_mapping
def get_local_ports_to_ofport_mapping(self):
lport_to_ofport = {}
chassis_to_ofport = {}
br_int = idlutils.row_by_value(self.idl, "Bridge", "name", "br-int")
for port in br_int.ports:
if port.name == "br-int":
continue
chassis_id = port.external_ids.get("df-chassis-id")
for interface in port.interfaces:
if interface.ofport is None:
# TODO(gsagie) log error
continue
ofport = interface.ofport[0]
if ofport < 1 or ofport > 65533:
# TODO(gsagie) log error
continue
if chassis_id is not None:
chassis_to_ofport[chassis_id] = ofport
else:
ifaceid = interface.external_ids.get("iface-id")
if ifaceid is not None:
lport_to_ofport[ifaceid] = ofport
return chassis_to_ofport, lport_to_ofport
示例11: _get_update_data_without_compare
def _get_update_data_without_compare(self):
lswitch_ovsdb_dict = {}
for switch_name in self.lswitch_names:
switch_name = utils.ovn_name(switch_name)
lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch',
'name', switch_name)
lswitch_ovsdb_dict[switch_name] = lswitch
if self.is_add_acl:
acl_add_values_dict = {}
for port in self.port_list:
switch_name = utils.ovn_name(port['network_id'])
if switch_name not in acl_add_values_dict:
acl_add_values_dict[switch_name] = []
if port['id'] in self.acl_new_values_dict:
acl_add_values_dict[switch_name].append(
self.acl_new_values_dict[port['id']])
acl_del_objs_dict = {}
else:
acl_add_values_dict = {}
acl_del_objs_dict = {}
del_acl_matches = []
for acl_dict in self.acl_new_values_dict.values():
del_acl_matches.append(acl_dict['match'])
for switch_name, lswitch in six.iteritems(lswitch_ovsdb_dict):
if switch_name not in acl_del_objs_dict:
acl_del_objs_dict[switch_name] = []
lswitch.verify('acls')
acls = getattr(lswitch, 'acls', [])
for acl in acls:
if getattr(acl, 'match') in del_acl_matches:
acl_del_objs_dict[switch_name].append(acl)
return lswitch_ovsdb_dict, acl_del_objs_dict, acl_add_values_dict
示例12: get_chassis_datapath_and_iface_types
def get_chassis_datapath_and_iface_types(self, hostname):
try:
chassis = idlutils.row_by_value(self.idl, 'Chassis',
'hostname', hostname)
except idlutils.RowNotFound:
return (None, None)
return (chassis.external_ids.get('datapath-type', ''),
chassis.external_ids.get('iface-types', ''))
示例13: run_idl
def run_idl(self, txn):
try:
lport = idlutils.row_by_value(self.api.idl, 'Logical_Port',
'name', self.lport)
lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch',
'name', self.lswitch)
ports = getattr(lswitch, 'ports', [])
except idlutils.RowNotFound:
if self.if_exists:
return
msg = _("Port %s does not exist") % self.lport
raise RuntimeError(msg)
ports.remove(lport)
lswitch.verify('ports')
setattr(lswitch, 'ports', ports)
self.api._tables['Logical_Port'].rows[lport.uuid].delete()
示例14: check_controller_fail_mode
def check_controller_fail_mode(self, fail_mode):
is_fail_mode_set = False
br_int = idlutils.row_by_value(self.idl, 'Bridge', 'name', 'br-int')
if br_int is not None and\
br_int.fail_mode is not [] and\
br_int.fail_mode[0] == fail_mode:
is_fail_mode_set = True
return is_fail_mode_set
示例15: get_chassis
def get_chassis(self, name):
try:
chassis = idlutils.row_by_value(self.idl,
'Chassis',
'name', name)
return OvsdbChassis(chassis)
except idlutils.RowNotFound:
return None