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

Python utils.execute函数代码示例

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

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



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

示例1: _change_file_mode

    def _change_file_mode(self, filepath):
        try:
            utils.execute("chmod", "666", filepath, run_as_root=True)

        except Exception as err:
            LOG.error(_LE("Bad response from change file: %s.") % err)
            raise err
开发者ID:jkasarherou,项目名称:manila,代码行数:7,代码来源:helper.py


示例2: reload_ganesha_config

def reload_ganesha_config(servers, sshlogin, service='ganesha.nfsd'):
    """Request ganesha server reload updated config."""

    # Note:  dynamic reload of ganesha config is not enabled
    # in ganesha v2.0. Therefore, the code uses the ganesha service restart
    # option to make sure the config changes are reloaded
    for server in servers:
        # Until reload is fully implemented and if the reload returns a bad
        # status revert to service restart instead
        LOG.info(_LI('Restart service %(service)s on %(server)s to force a '
                     'config file reload'),
                 {'service': service, 'server': server})
        run_local = True

        reload_cmd = ['service', service, 'restart']
        localserver_iplist = socket.gethostbyname_ex(
            socket.gethostname())[2]
        if server not in localserver_iplist:
            remote_login = sshlogin + '@' + server
            reload_cmd = ['ssh', remote_login] + reload_cmd
            run_local = False
        try:
            utils.execute(*reload_cmd, run_as_root=run_local)
        except exception.ProcessExecutionError as e:
            msg = (_('Could not restart service %(service)s on '
                     '%(server)s: %(excmsg)s')
                   % {'service': service,
                      'server': server,
                      'excmsg': six.text_type(e)})
            LOG.error(msg)
            raise exception.GPFSGaneshaException(msg)
开发者ID:aawm,项目名称:manila,代码行数:31,代码来源:ganesha_utils.py


示例3: copy_data

    def copy_data(self, path):
        if self.cancelled:
            return
        out, err = utils.execute(
            "ls", "-pA1", "--group-directories-first", path,
            run_as_root=True)
        for line in out.split('\n'):
            if self.cancelled:
                return
            if len(line) == 0:
                continue
            src_item = os.path.join(path, line)
            dest_item = src_item.replace(self.src, self.dest)
            if line[-1] == '/':
                if line[0:-1] in self.ignore_list:
                    continue
                utils.execute("mkdir", "-p", dest_item, run_as_root=True)
                self.copy_data(src_item)
            else:
                if line in self.ignore_list:
                    continue
                size, err = utils.execute("stat", "-c", "%s", src_item,
                                          run_as_root=True)

                self.current_copy = {'file_path': dest_item,
                                     'size': int(size)}

                self._copy_and_validate(src_item, dest_item)

                self.current_size += int(size)
                LOG.info(six.text_type(self.get_progress()))
开发者ID:NetApp,项目名称:manila,代码行数:31,代码来源:utils.py


示例4: _publish_local_config

def _publish_local_config(configpath, pre_lines, exports):
    tmp_path = '%s.tmp.%s' % (configpath, time.time())
    LOG.debug("tmp_path = %s", tmp_path)
    cpcmd = ['install', '-m', '666', configpath, tmp_path]
    try:
        utils.execute(*cpcmd, run_as_root=True)
    except exception.ProcessExecutionError as e:
        msg = (_('Failed while publishing ganesha config locally. '
                 'Error: %s.') % six.text_type(e))
        LOG.error(msg)
        raise exception.GPFSGaneshaException(msg)

    with open(tmp_path, 'w+') as f:
        for l in pre_lines:
            f.write('%s\n' % l)
        for e in exports:
            f.write('EXPORT\n{\n')
            for attr in exports[e]:
                f.write('%s = %s ;\n' % (attr, exports[e][attr]))

            f.write('}\n')
    mvcmd = ['mv', tmp_path, configpath]
    try:
        utils.execute(*mvcmd, run_as_root=True)
    except exception.ProcessExecutionError as e:
        msg = (_('Failed while publishing ganesha config locally. '
                 'Error: %s.') % six.text_type(e))
        LOG.error(msg)
        raise exception.GPFSGaneshaException(msg)
    LOG.info(_LI('Ganesha config %s published locally.'), configpath)
开发者ID:ISCAS-VDI,项目名称:manila-base,代码行数:30,代码来源:ganesha_utils.py


示例5: _validate_item

def _validate_item(src_item, dest_item):
    src_sum, err = utils.execute(
        "sha256sum", "%s" % src_item, run_as_root=True)
    dest_sum, err = utils.execute(
        "sha256sum", "%s" % dest_item, run_as_root=True)
    if src_sum.split()[0] != dest_sum.split()[0]:
        msg = _("Data corrupted while copying. Aborting data copy.")
        raise exception.ShareDataCopyFailed(reason=msg)
开发者ID:NetApp,项目名称:manila,代码行数:8,代码来源:utils.py


示例6: cleanup_unmount_temp_folder

    def cleanup_unmount_temp_folder(self, instance, migration_info):

        try:
            utils.execute(*migration_info['umount'], run_as_root=True)
        except Exception as utfe:
            LOG.exception(six.text_type(utfe))
            LOG.error(_LE("Could not unmount folder of instance"
                          " %(instance_id)s for migration of "
                          "share %(share_id)s") % {
                              'instance_id': instance['id'],
                              'share_id': self.share['id']})
开发者ID:nidhimittalhada,项目名称:access_group_repo,代码行数:11,代码来源:migration.py


示例7: mount_share_instance

    def mount_share_instance(self, mount_template, mount_path,
                             share_instance_id):

        path = os.path.join(mount_path, share_instance_id)

        if not os.path.exists(path):
            os.makedirs(path)
        self._check_dir_exists(path)

        mount_command = mount_template % {'path': path}

        utils.execute(*(mount_command.split()), run_as_root=True)
开发者ID:ISCAS-VDI,项目名称:manila-base,代码行数:12,代码来源:helper.py


示例8: cleanup_temp_folder

    def cleanup_temp_folder(self, instance, mount_path):

        try:
            utils.execute('rmdir', mount_path + instance['id'],
                          check_exit_code=False)

        except Exception as tfe:
            LOG.exception(six.text_type(tfe))
            LOG.error(_LE("Could not cleanup instance %(instance_id)s "
                          "temporary folders for migration of "
                          "share %(share_id)s") % {
                              'instance_id': instance['id'],
                              'share_id': self.share['id']})
开发者ID:nidhimittalhada,项目名称:access_group_repo,代码行数:13,代码来源:migration.py


示例9: _ovs_add_port

 def _ovs_add_port(self, bridge, device_name, port_id, mac_address,
                   internal=True):
     cmd = ['ovs-vsctl', '--', '--may-exist',
            'add-port', bridge, device_name]
     if internal:
         cmd += ['--', 'set', 'Interface', device_name, 'type=internal']
     cmd += ['--', 'set', 'Interface', device_name,
             'external-ids:iface-id=%s' % port_id,
             '--', 'set', 'Interface', device_name,
             'external-ids:iface-status=active',
             '--', 'set', 'Interface', device_name,
             'external-ids:attached-mac=%s' % mac_address]
     utils.execute(*cmd, run_as_root=True)
开发者ID:Hussnain1,项目名称:manila,代码行数:13,代码来源:interface.py


示例10: _publish_remote_config

def _publish_remote_config(server, sshlogin, sshkey, configpath):
    dest = '%[email protected]%s:%s' % (sshlogin, server, configpath)
    scpcmd = ['scp', '-i', sshkey, configpath, dest]
    try:
        utils.execute(*scpcmd, run_as_root=False)
    except exception.ProcessExecutionError as e:
        msg = (_('Failed while publishing ganesha config on remote server. '
                 'Error: %s.') % six.text_type(e))
        LOG.error(msg)
        raise exception.GPFSGaneshaException(msg)
    LOG.info(_LI('Ganesha config %(path)s published to %(server)s.'),
             {'path': configpath,
              'server': server})
开发者ID:aawm,项目名称:manila,代码行数:13,代码来源:ganesha_utils.py


示例11: unmount_share_instance

    def unmount_share_instance(self, unmount_template, mount_path,
                               share_instance_id):

        path = os.path.join(mount_path, share_instance_id)

        unmount_command = unmount_template % {'path': path}

        utils.execute(*(unmount_command.split()), run_as_root=True)

        try:
            if os.path.exists(path):
                os.rmdir(path)
            self._check_dir_not_exists(path)
        except Exception:
            LOG.warning(_LW("Folder %s could not be removed."), path)
开发者ID:vponomaryov,项目名称:manila,代码行数:15,代码来源:helper.py


示例12: run_vsctl

 def run_vsctl(self, args):
     full_args = ["ovs-vsctl", "--timeout=2"] + args
     try:
         return utils.execute(*full_args, run_as_root=True)
     except Exception:
         LOG.exception(_LE("Unable to execute %(cmd)s."),
                       {'cmd': full_args})
开发者ID:vponomaryov,项目名称:manila,代码行数:7,代码来源:ovs_lib.py


示例13: get_progress

    def get_progress(self):

        if self.current_copy is not None:

            try:
                size, err = utils.execute("stat", "-c", "%s",
                                          self.current_copy['file_path'],
                                          run_as_root=True)
                size = int(size)
            except utils.processutils.ProcessExecutionError:
                size = 0

            total_progress = 0
            if self.total_size > 0:
                total_progress = self.current_size * 100 / self.total_size
            current_file_progress = 0
            if self.current_copy['size'] > 0:
                current_file_progress = size * 100 / self.current_copy['size']
            current_file_path = self.current_copy['file_path']

            progress = {
                'total_progress': total_progress,
                'current_file_path': current_file_path,
                'current_file_progress': current_file_progress
            }

            return progress
        else:
            return {'total_progress': 100}
开发者ID:ISCAS-VDI,项目名称:manila-base,代码行数:29,代码来源:utils.py


示例14: _mount_for_migration

        def _mount_for_migration(migration_info):

            try:
                utils.execute(*migration_info['mount'], run_as_root=True)
            except Exception:
                LOG.error(_LE("Failed to mount temporary folder for "
                              "migration of share instance "
                              "%(share_instance_id)s "
                              "to %(new_share_instance_id)s") % {
                    'share_instance_id': share_instance['id'],
                    'new_share_instance_id': new_share_instance['id']})
                helper.cleanup_migration_access(
                    src_access_ref, src_access)
                helper.cleanup_migration_access(
                    dest_access_ref, dest_access)
                raise
开发者ID:jcsp,项目名称:manila,代码行数:16,代码来源:driver.py


示例15: _publish_access

 def _publish_access(self, *cmd):
     for server in self.configuration.gpfs_nfs_server_list:
         localserver_iplist = socket.gethostbyname_ex(
             socket.gethostname())[2]
         run_local = True
         if server not in localserver_iplist:
             sshlogin = self.configuration.gpfs_ssh_login
             remote_login = sshlogin + '@' + server
             cmd = ['ssh', remote_login] + list(cmd)
             run_local = False
         try:
             utils.execute(*cmd,
                           run_as_root=run_local,
                           check_exit_code=True)
         except exception.ProcessExecutionError:
             raise
开发者ID:JosonYuan,项目名称:manila,代码行数:16,代码来源:gpfs.py


示例16: run_vsctl

 def run_vsctl(self, args):
     full_args = ["ovs-vsctl", "--timeout=2"] + args
     try:
         return utils.execute(*full_args, run_as_root=True)
     except Exception as e:
         LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"),
                   {'cmd': full_args, 'exception': e})
开发者ID:bobcallaway,项目名称:manila,代码行数:7,代码来源:ovs_lib.py


示例17: _execute

 def _execute(self, *cmd, **kwargs):
     for x in range(0, len(self.hosts)):
         try:
             check_exit_code = kwargs.pop('check_exit_code', True)
             host = self.hosts[x]
             if host in self.local_hosts:
                 cmd = self._as_user(cmd,
                                     self.configuration.maprfs_ssh_name)
                 out, err = utils.execute(*cmd,
                                          check_exit_code=check_exit_code)
             else:
                 out, err = self._run_ssh(host, cmd, check_exit_code)
             # move available cldb host to the beginning
             if x > 0:
                 self.hosts[0], self.hosts[x] = self.hosts[x], self.hosts[0]
             return out, err
         except exception.ProcessExecutionError as e:
             if self._check_error(e):
                 raise
             elif x < len(self.hosts) - 1:
                 msg = ('Error running SSH command. Trying another host')
                 LOG.error(msg)
             else:
                 raise
         except Exception as e:
             if x < len(self.hosts) - 1:
                 msg = ('Error running SSH command. Trying another host')
                 LOG.error(msg)
             else:
                 raise exception.ProcessExecutionError(six.text_type(e))
开发者ID:openstack,项目名称:manila,代码行数:30,代码来源:driver_util.py


示例18: _execute

 def _execute(cls, options, command, args, namespace=None, as_root=False):
     opt_list = ["-%s" % o for o in options]
     if namespace:
         ip_cmd = ["ip", "netns", "exec", namespace, "ip"]
     else:
         ip_cmd = ["ip"]
     total_cmd = ip_cmd + opt_list + [command] + list(args)
     return utils.execute(*total_cmd, run_as_root=as_root)[0]
开发者ID:ajarr,项目名称:manila,代码行数:8,代码来源:ip_lib.py


示例19: _gpfs_local_execute

    def _gpfs_local_execute(self, *cmd, **kwargs):
        if 'run_as_root' not in kwargs:
            kwargs.update({'run_as_root': True})
        if 'ignore_exit_code' in kwargs:
            check_exit_code = kwargs.pop('ignore_exit_code')
            check_exit_code.append(0)
            kwargs.update({'check_exit_code': check_exit_code})

        return utils.execute(*cmd, **kwargs)
开发者ID:vponomaryov,项目名称:manila,代码行数:9,代码来源:gpfs.py


示例20: _ipv6_configured

    def _ipv6_configured():
        try:
            out, err = utils.execute('cat', '/proc/net/if_inet6')
        except exception.ProcessExecutionError:
            return False

        if not out:
            return False
        return True
开发者ID:aostapenko,项目名称:manila,代码行数:9,代码来源:test_wsgi.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.last_completed_audit_period函数代码示例发布时间: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