• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python idlutils.row_by_value函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neutron.agent.ovsdb.native.idlutils.row_by_value函数的典型用法代码示例。如果您正苦于以下问题:Python row_by_value函数的具体用法?Python row_by_value怎么用?Python row_by_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了row_by_value函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:doonhammer,项目名称:networking-ovn,代码行数:26,代码来源:commands.py


示例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)
开发者ID:muraliran,项目名称:networking-ovn,代码行数:30,代码来源:commands.py


示例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()
开发者ID:coreycb,项目名称:neutron,代码行数:34,代码来源:commands.py


示例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)
开发者ID:zjtheone,项目名称:networking-ovn,代码行数:28,代码来源:commands.py


示例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()
开发者ID:flavio-fernandes,项目名称:networking-ovn,代码行数:14,代码来源:commands.py


示例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)
开发者ID:openstack,项目名称:neutron,代码行数:7,代码来源:commands.py


示例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
开发者ID:no2key,项目名称:dragonflow,代码行数:31,代码来源:ovsdb_vswitch_impl.py


示例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)
开发者ID:muraliran,项目名称:networking-ovn,代码行数:30,代码来源:test_ovn_db_resources.py


示例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
开发者ID:HarborOS,项目名称:dragonflow,代码行数:27,代码来源:ovsdb_vswitch_impl.py


示例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
开发者ID:no2key,项目名称:dragonflow,代码行数:25,代码来源:ovsdb_vswitch_impl.py


示例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
开发者ID:hwoarang,项目名称:networking-ovn,代码行数:32,代码来源:commands.py


示例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', ''))
开发者ID:flavio-fernandes,项目名称:networking-ovn,代码行数:8,代码来源:impl_idl_ovn.py


示例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()
开发者ID:charloco,项目名称:networking-ovn,代码行数:17,代码来源:commands.py


示例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
开发者ID:FrankDuan,项目名称:df_code,代码行数:8,代码来源:ovsdb_vswitch_impl.py


示例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
开发者ID:sheepcat,项目名称:dragonflow,代码行数:8,代码来源:ovsdb_nb_impl.py


示例16: get_tunnel_ports

    def get_tunnel_ports(self):
        res = []
        br_int = idlutils.row_by_value(self.idl, "Bridge", "name", "br-int")

        for port in br_int.ports:
            if "df-chassis-id" in port.external_ids:
                chassis_id = port.external_ids["df-chassis-id"]
                res.append(OvsdbTunnelPort(port, chassis_id))
        return res
开发者ID:no2key,项目名称:dragonflow,代码行数:9,代码来源:ovsdb_vswitch_impl.py


示例17: 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 fail_mode is not set, len(fail_mode) is 0
     if br_int is not None and (
        len(br_int.fail_mode) > 0 and
        br_int.fail_mode[0] == fail_mode):
         is_fail_mode_set = True
     return is_fail_mode_set
开发者ID:paperandsoap,项目名称:dragonflow,代码行数:9,代码来源:ovsdb_vswitch_impl.py


示例18: check_controller

 def check_controller(self, target):
     is_controller_set = False
     br_int = idlutils.row_by_value(self.idl, 'Bridge', 'name', 'br-int')
     # if controller is not set, len(controller) is 0
     if br_int is not None and (
        len(br_int.controller) > 0 and
        br_int.controller[0].target == target):
         is_controller_set = True
     return is_controller_set
开发者ID:paperandsoap,项目名称:dragonflow,代码行数:9,代码来源:ovsdb_vswitch_impl.py


示例19: get_local_port_id_from_name

    def get_local_port_id_from_name(self, name):
        br_int = idlutils.row_by_value(self.idl, 'Bridge', 'name', 'br-int')
        for port in br_int.ports:
            if port.name != name:
                continue
            for interface in port.interfaces:
                if 'iface-id' in interface.external_ids:
                    return interface.external_ids['iface-id']

        return None
开发者ID:FrankDuan,项目名称:df_code,代码行数:10,代码来源:ovsdb_vswitch_impl.py


示例20: _get_port_pair_uuid

 def _get_port_pair_uuid(self, port_pair_name):
     lpp_uuid = None
     try:
         lpp = idlutils.row_by_value(self._ovn.idl, 'Logical_Port_Pair',
                                     'name', port_pair_name)
         lpp_uuid = lpp.uuid
     except idlutils.RowNotFound:
         LOG.error("Logical Port Pair %s does not exist", port_pair_name)
         lpp_uuid = None
     return lpp_uuid
开发者ID:doonhammer,项目名称:networking-sfc,代码行数:10,代码来源:driver.py



注:本文中的neutron.agent.ovsdb.native.idlutils.row_by_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rpc.create_consumers函数代码示例发布时间:2022-05-27
下一篇:
Python idlutils.row_by_record函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap