当前位置: 首页>>代码示例>>Python>>正文


Python utils.execute函数代码示例

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


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


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