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

Python utils.execute函数代码示例

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

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



在下文中一共展示了execute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: create

    def create(self):
        common_utils.execute(['mkdir', '-p', self._directory],
                             run_as_root=True)

        user_id = os.geteuid()
        common_utils.execute(['chown', user_id, self._directory],
                             run_as_root=True)
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:7,代码来源:rt_tables.py


示例2: _connect_tap_device_to_vswitch

 def _connect_tap_device_to_vswitch(self, vswitch_name, tap_name):
     """Connect the tap device to the given vswitch, and add it to the
     ovsdb.
     :param vswitch_name: The name of the vswitch to connect the device
     :type vswitch_name:  String
     :param tap_name:     The name of the device to connect
     :type tap_name:      String
     """
     full_args = ['ovs-vsctl', 'add-port', vswitch_name, tap_name]
     utils.execute(full_args, run_as_root=True, process_input=None)
     full_args = ['ovs-vsctl', 'set', 'interface', tap_name,
             'external_ids:iface-id={}'.format(self.lport.get_id())]
     utils.execute(full_args, run_as_root=True, process_input=None)
开发者ID:almightyyeh,项目名称:dragonflow,代码行数:13,代码来源:app_testing_objects.py


示例3: _ovsdb_list_intefaces

 def _ovsdb_list_intefaces(self, specify_interface=None):
     full_args = ["ovs-vsctl", "list", 'interface']
     if specify_interface:
         full_args.append(specify_interface)
     interfaces_info = utils.execute(full_args, run_as_root=True,
                                     process_input=None)
     return interfaces_info
开发者ID:HarborOS,项目名称:dragonflow,代码行数:7,代码来源:utils.py


示例4: get_xapi_iface_id

 def get_xapi_iface_id(self, xs_vif_uuid):
     args = ["xe", "vif-param-get", "param-name=other-config", "param-key=nicira-iface-id", "uuid=%s" % xs_vif_uuid]
     try:
         return utils.execute(args, run_as_root=True).strip()
     except Exception as e:
         with excutils.save_and_reraise_exception():
             LOG.error(_LE("Unable to execute %(cmd)s. " "Exception: %(exception)s"), {"cmd": args, "exception": e})
开发者ID:tidatida,项目名称:neutron,代码行数:7,代码来源:ovs_lib.py


示例5: _get_port_number

 def _get_port_number(self, interface_name):
     ovs_ofctl_args = ['ovs-ofctl', 'dump-ports', 'br-int', interface_name]
     awk_args = ['awk', '/^\\s*port\\s+[0-9]+:/ { print $2 }']
     ofctl_output = utils.execute(
         ovs_ofctl_args,
         run_as_root=True,
         process_input=None,
     )
     awk_output = utils.execute(
         awk_args,
         run_as_root=False,
         process_input=ofctl_output,
     )
     match = re.search('^(\d+):', awk_output)
     port_num_str = match.group(1)
     return int(port_num_str)
开发者ID:FrankDuan,项目名称:df_code,代码行数:16,代码来源:app_testing_objects.py


示例6: get_devices

    def get_devices(self, exclude_loopback=False):
        retval = []
        if self.namespace:
            # we call out manually because in order to avoid screen scraping
            # iproute2 we use find to see what is in the sysfs directory, as
            # suggested by Stephen Hemminger (iproute2 dev).
            output = utils.execute(
                [
                    "ip",
                    "netns",
                    "exec",
                    self.namespace,
                    "find",
                    SYS_NET_PATH,
                    "-maxdepth",
                    "1",
                    "-type",
                    "l",
                    "-printf",
                    "%f ",
                ],
                run_as_root=True,
                log_fail_as_error=self.log_fail_as_error,
            ).split()
        else:
            output = (i for i in os.listdir(SYS_NET_PATH) if os.path.islink(os.path.join(SYS_NET_PATH, i)))

        for name in output:
            if exclude_loopback and name == LOOPBACK_DEVNAME:
                continue
            retval.append(IPDevice(name, namespace=self.namespace))

        return retval
开发者ID:kirajun,项目名称:neutron,代码行数:33,代码来源:ip_lib.py


示例7: get_devices

    def get_devices(self, exclude_loopback=False, exclude_gre_devices=False):
        retval = []
        if self.namespace:
            # we call out manually because in order to avoid screen scraping
            # iproute2 we use find to see what is in the sysfs directory, as
            # suggested by Stephen Hemminger (iproute2 dev).
            output = utils.execute(['ip', 'netns', 'exec', self.namespace,
                                    'find', SYS_NET_PATH, '-maxdepth', '1',
                                    '-type', 'l', '-printf', '%f '],
                                   run_as_root=True,
                                   log_fail_as_error=self.log_fail_as_error
                                   ).split()
        else:
            output = (
                i for i in os.listdir(SYS_NET_PATH)
                if os.path.islink(os.path.join(SYS_NET_PATH, i))
            )

        for name in output:
            if (exclude_loopback and name == LOOPBACK_DEVNAME or
                    exclude_gre_devices and name in GRE_TUNNEL_DEVICE_NAMES):
                continue
            retval.append(IPDevice(name, namespace=self.namespace))

        return retval
开发者ID:brandonlogan,项目名称:neutron,代码行数:25,代码来源:ip_lib.py


示例8: get_devices

    def get_devices(self, exclude_loopback=True, exclude_gre_devices=True):
        retval = []
        if self.namespace:
            # we call out manually because in order to avoid screen scraping
            # iproute2 we use find to see what is in the sysfs directory, as
            # suggested by Stephen Hemminger (iproute2 dev).
            try:
                cmd = ['ip', 'netns', 'exec', self.namespace,
                       'find', SYS_NET_PATH, '-maxdepth', '1',
                       '-type', 'l', '-printf', '%f ']
                output = utils.execute(
                    cmd,
                    run_as_root=True,
                    log_fail_as_error=self.log_fail_as_error).split()
            except RuntimeError:
                # We could be racing with a cron job deleting namespaces.
                # Just return a empty list if the namespace is deleted.
                with excutils.save_and_reraise_exception() as ctx:
                    if not self.netns.exists(self.namespace):
                        ctx.reraise = False
                        return []
        else:
            output = (
                i for i in os.listdir(SYS_NET_PATH)
                if os.path.islink(os.path.join(SYS_NET_PATH, i))
            )

        for name in output:
            if (exclude_loopback and name == LOOPBACK_DEVNAME or
                    exclude_gre_devices and name in GRE_TUNNEL_DEVICE_NAMES):
                continue
            retval.append(IPDevice(name, namespace=self.namespace))

        return retval
开发者ID:huntxu,项目名称:neutron,代码行数:34,代码来源:ip_lib.py


示例9: _execute

 def _execute(cls, options, command, args, run_as_root=False,
              namespace=None, log_fail_as_error=True):
     opt_list = ['-%s' % o for o in options]
     ip_cmd = add_namespace_to_cmd(['ip'], namespace)
     cmd = ip_cmd + opt_list + [command] + list(args)
     return utils.execute(cmd, run_as_root=run_as_root,
                          log_fail_as_error=log_fail_as_error)
开发者ID:Raghunanda,项目名称:neutron,代码行数:7,代码来源:ip_lib.py


示例10: run_ofctl

 def run_ofctl(self, cmd, args, process_input=None):
     full_args = ["ovs-ofctl", cmd, self.br_name] + args
     try:
         return utils.execute(full_args, run_as_root=True,
                              process_input=process_input)
     except Exception as e:
         LOG.error(_LE("Unable to execute %(cmd)s. Exception: "
                       "%(exception)s"),
                   {'cmd': full_args, 'exception': e})
开发者ID:asgard-lab,项目名称:neutron,代码行数:9,代码来源:ovs_lib.py


示例11: run_ofctl

 def run_ofctl(self, cmd, args, process_input=None):
     # We need to dump-groups according to group Id,
     # which is a feature of OpenFlow1.5
     full_args = ["ovs-ofctl", "-O openflow13", cmd, self.br_name] + args
     try:
         return utils.execute(full_args, run_as_root=True, process_input=process_input)
     except Exception as e:
         LOG.exception(e)
         LOG.error(_LE("Unable to execute %(args)s."), {"args": full_args})
开发者ID:CNlukai,项目名称:networking-sfc,代码行数:9,代码来源:ovs_ext_lib.py


示例12: execute

    def execute(self, cmds, addl_env=None, check_exit_code=True, extra_ok_codes=None, run_as_root=False):
        ns_params = []
        kwargs = {"run_as_root": run_as_root}
        if self._parent.namespace:
            kwargs["run_as_root"] = True
            ns_params = ["ip", "netns", "exec", self._parent.namespace]

        env_params = []
        if addl_env:
            env_params = ["env"] + ["%s=%s" % pair for pair in addl_env.items()]
        cmd = ns_params + env_params + list(cmds)
        return utils.execute(cmd, check_exit_code=check_exit_code, extra_ok_codes=extra_ok_codes, **kwargs)
开发者ID:kirajun,项目名称:neutron,代码行数:12,代码来源:ip_lib.py


示例13: run_vsctl

 def run_vsctl(self, args):
     full_args = ["ovs-vsctl"] + self.opts + args
     try:
         # We log our own errors, so never have utils.execute do it
         return utils.execute(full_args, run_as_root=True,
                              log_fail_as_error=False).rstrip()
     except Exception:
         with excutils.save_and_reraise_exception() as ctxt:
             if self.log_errors:
                 LOG.exception(_LE("Unable to execute %(cmd)s."),
                               {'cmd': full_args})
             if not self.check_error:
                 ctxt.reraise = False
开发者ID:cisco-openstack,项目名称:neutron,代码行数:13,代码来源:impl_vsctl.py


示例14: run_ofctl

    def run_ofctl(self, cmd, args, process_input=None):
        #modify code for networking-ofagent by MelonLi 
        if self.br_name != 'br-int':
            full_args = ["ovs-ofctl", cmd, self.br_name] + args 
        else:
            full_args = ["ovs-ofctl", cmd, self.br_name] + args + ["-O OpenFlow13"]

        try:
            return utils.execute(full_args, run_as_root=True,
                                 process_input=process_input)
        except Exception as e:
            LOG.error(_LE("Unable to execute %(cmd)s. Exception: "
                          "%(exception)s"),
                      {'cmd': full_args, 'exception': e})
开发者ID:melon-li,项目名称:neutron,代码行数:14,代码来源:ovs_lib.py


示例15: execute

    def execute(self, cmds, addl_env=None, check_exit_code=True,
                extra_ok_codes=None, run_as_root=False):
        ns_params = []
        kwargs = {'run_as_root': run_as_root}
        if self._parent.namespace:
            kwargs['run_as_root'] = True
            ns_params = ['ip', 'netns', 'exec', self._parent.namespace]

        env_params = []
        if addl_env:
            env_params = (['env'] +
                          ['%s=%s' % pair for pair in addl_env.items()])
        cmd = ns_params + env_params + list(cmds)
        return utils.execute(cmd, check_exit_code=check_exit_code,
                             extra_ok_codes=extra_ok_codes, **kwargs)
开发者ID:Raghunanda,项目名称:neutron,代码行数:15,代码来源:ip_lib.py


示例16: _run_trace

    def _run_trace(self, brname, spec):
        required_keys = [OVS_TRACE_FINAL_FLOW, OVS_TRACE_DATAPATH_ACTIONS]
        t = utils.execute(["ovs-appctl", "ofproto/trace", brname, spec], run_as_root=True)
        trace = {}
        trace_lines = t.splitlines()
        for line in trace_lines:
            (l, sep, r) = line.partition(":")
            if not sep:
                continue
            elif l in required_keys:
                trace[l] = r
        for k in required_keys:
            if k not in trace:
                self.fail("%s not found in trace %s" % (k, trace_lines))

        return trace
开发者ID:sebrandon1,项目名称:neutron,代码行数:16,代码来源:test_ovs_flows.py


示例17: create_tap_dev

def create_tap_dev(dev, mac_address=None):
    """Create a tap with name dev and MAC address mac_address on the
    operating system.
    :param dev:         The name of the tap device to create
    :type dev:          String
    :param mac_address: The MAC address of the device, format xx:xx:xx:xx:xx:xx
    :type mac_address:  String
    """
    try:
        # First, try with 'ip'
        utils.execute(['ip', 'tuntap', 'add', dev, 'mode', 'tap'],
                      run_as_root=True, check_exit_code=[0, 2, 254])
    except Exception as e:
        print e
        # Second option: tunctl
        utils.execute(['tunctl', '-b', '-t', dev], run_as_root=True)
    if mac_address:
        utils.execute(['ip', 'link', 'set', dev, 'address', mac_address],
                      run_as_root=True, check_exit_code=[0, 2, 254])
    utils.execute(['ip', 'link', 'set', dev, 'up'], run_as_root=True,
                  check_exit_code=[0, 2, 254])
开发者ID:almightyyeh,项目名称:dragonflow,代码行数:21,代码来源:app_testing_objects.py


示例18: run_ofctl

 def run_ofctl(self, cmd, args, process_input=None):
     full_args = ["ovs-ofctl", cmd, self.br_name] + args
     # TODO(kevinbenton): This error handling is really brittle and only
     # detects one specific type of failure. The callers of this need to
     # be refactored to expect errors so we can re-raise and they can
     # take appropriate action based on the type of error.
     for i in range(1, 11):
         try:
             return utils.execute(full_args, run_as_root=True,
                                  process_input=process_input)
         except Exception as e:
             if "failed to connect to socket" in str(e):
                 LOG.debug("Failed to connect to OVS. Retrying "
                           "in 1 second. Attempt: %s/10", i)
                 time.sleep(1)
                 continue
             LOG.error(_LE("Unable to execute %(cmd)s. Exception: "
                           "%(exception)s"),
                       {'cmd': full_args, 'exception': e})
             break
开发者ID:2020human,项目名称:neutron,代码行数:20,代码来源:ovs_lib.py


示例19: get_ovs_flows

 def get_ovs_flows(self, integration_bridge):
     full_args = ["ovs-ofctl", "dump-flows", integration_bridge,
                  "-O Openflow13"]
     flows = utils.execute(full_args, run_as_root=True,
                           process_input=None)
     return flows
开发者ID:HarborOS,项目名称:dragonflow,代码行数:6,代码来源:utils.py


示例20: iproute_arg_supported

def iproute_arg_supported(command, arg):
    command += ['help']
    stdout, stderr = utils.execute(command, check_exit_code=False,
                                   return_stderr=True, log_fail_as_error=False)
    return any(arg in line for line in stderr.split('\n'))
开发者ID:Raghunanda,项目名称:neutron,代码行数:5,代码来源:ip_lib.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.load_interface_driver函数代码示例发布时间:2022-05-27
下一篇:
Python config.setup_logging函数代码示例发布时间: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