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

Python rest_util.api_call函数代码示例

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

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



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

示例1: do_config

    def do_config(self, args):
        """configure a network interface. dhcp and static ipv4 configurations are
        supported. Note that there is a risk of losing connectivity to the
        system. So this is best done via console connection.

        to configure using dhcp:
        config <interface> -d

        to configure static ip: config <interface> -s <ip_addr> <netmask>
        <gateway> <dns_servers> <domain>

        """
        fields = args.split()
        if (len(fields) < 2):
            return self.do_help(args)
        url = ('%s/%s' % (self.baseurl, fields[0]))
        if (fields[1] == '-d'):
            print(api_call(url, data={'boot_protocol': 'dhcp', },
                           calltype='put'))
        elif (fields[1] == '-s'):
            if (len(fields) < 7):
                return self.do_help(args[:2])
            input_data = {'boot_protocol': 'static',
                          'ipaddr': fields[2],
                          'netmask': fields[3],
                          'gateway': fields[4],
                          'dns_servers': fields[5],
                          'domain': fields[6],
                          'itype': 'management', }
            print(api_call(url, data=input_data, calltype='put'))
        else:
            return self.do_help(args)
开发者ID:MFlyer,项目名称:rockstor-core,代码行数:32,代码来源:network_console.py


示例2: do_delete

 def do_delete(self, args):
     if (len(args) == 0):
         return self.help_wrapper('missing pool_name', 'delete')
     url = ('%s/%s' % (self.url, args))
     print("Deleting pool %s" % args[0])
     api_call(url, calltype='delete')
     print("Pool %s deleted" % args[0])
开发者ID:MFlyer,项目名称:rockstor-core,代码行数:7,代码来源:pools_console.py


示例3: do_data2

 def do_data2(self, args):
     if args is not None:
         tap_fields = args.split()
         url = "%s%s?%s" % (self.baseurl, tap_fields[0], tap_fields[1])
         print api_call(url)
     else:
         return self.do_help(args)
开发者ID:Stoney49th,项目名称:rockstor-core,代码行数:7,代码来源:sm_console.py


示例4: do_bootstrap

 def do_bootstrap(self, args):
     """
     bootraps the storage state, mounts anything that needs to be mounted
     etc..
     """
     url = ('%scommands/bootstrap' % BaseConsole.url)
     print api_call(url, calltype='post')
开发者ID:aliamir,项目名称:rockstor-core,代码行数:7,代码来源:rock_cli.py


示例5: _plugin_command

    def _plugin_command(self, command):
        """
        Current status of the plugin

        status
        """
        url = ('%s/plugin/%s' % (self.url, command))
        print api_call(url, calltype='post')
开发者ID:Ajunboys,项目名称:rockstor-core,代码行数:8,代码来源:backup_plugin_console.py


示例6: do_delete

    def do_delete(self, args):
        """
        Delete a offlined disk

        delete disk_name
        """
        url = ('%s/%s' % (self.baseurl, args))
        api_call(url, calltype='delete')
        print_disk_info(api_call(self.baseurl))
开发者ID:sigkill,项目名称:rockstor-core,代码行数:9,代码来源:disks_console.py


示例7: do_rollback

    def do_rollback(self, args):
        """
        Rollback a share to the state of one of it's snapshots.

        rollback <share_name> <snap_name>
        """
        fields = args.split()
        input_data = {'name': fields[1], }
        url = ('%s/%s/rollback' % (self.url, fields[0]))
        print api_call(url, data=input_data, calltype='post')
开发者ID:Ajunboys,项目名称:rockstor-core,代码行数:10,代码来源:shares_console.py


示例8: do_clone

    def do_clone(self, args):
        """
        Clone a snapshot into a brand new share

        clone <snap_name> <new_share_name>
        """
        fields = args.split()
        url = ('%s/%s/clone' % (self.url, fields[0]))
        input_data = {'name': fields[1],}
        print api_call(url, data=input_data, calltype='post')
开发者ID:sigkill,项目名称:rockstor-core,代码行数:10,代码来源:snapshot_console.py


示例9: do_log

    def do_log(self, args):
        """
        print all task logs, or optionally for the given task

        log <task_id>
        """
        url = ('%slog' % self.baseurl)
        if (len(args) > 0):
            url = ('%s/taskdef/%s' % (url, args))
        print api_call(url)
开发者ID:sigkill,项目名称:rockstor-core,代码行数:10,代码来源:task_console.py


示例10: do_list

    def do_list(self, args):
        """
        print all scheduled tasks, or optionally for the given id.

        list <task_id>
        """
        url = self.baseurl
        if (len(args) > 0):
            url = ('%s%s' % (url, args))
        print api_call(url)
开发者ID:sigkill,项目名称:rockstor-core,代码行数:10,代码来源:task_console.py


示例11: do_wipe

    def do_wipe(self, args):
        """
        Wipe the partition table of a disk. This is required for
        used/partitioned disks to be usable by rockstor.

        wipe disk_name
        """
        url = ('%s/%s/wipe' % (self.baseurl, args))
        api_call(url, calltype='post')
        print_disk_info(api_call(self.baseurl))
开发者ID:sigkill,项目名称:rockstor-core,代码行数:10,代码来源:disks_console.py


示例12: do_config

 def do_config(self, args):
     """
     config server_name
     """
     url = ('%s/config' % self.baseurl)
     fields = args.split()
     input_data = {'config': {'server': fields[0],},}
     headers = {'content-type': 'application/json'}
     api_call(url, data=json.dumps(input_data), calltype='post',
              headers=headers)
开发者ID:aliamir,项目名称:rockstor-core,代码行数:10,代码来源:ntp_console.py


示例13: do_list

 def do_list(self, args):
     url = self.url+'?format=json'
     if (args):
         # print info for a single pool
         url = ('%s/%s' % (self.url, args))
         pool_info = api_call(url)
         print_pool_info(pool_info, True)
     else:
         pools_info = api_call(url)
         print_pools_info(pools_info)
开发者ID:MFlyer,项目名称:rockstor-core,代码行数:10,代码来源:pools_console.py


示例14: do_list

 def do_list(self, args):
     url = self.baseurl
     if (args):
         # print info for a single disk
         url = ('%s/%s' % (url, args))
         disk_info = api_call(url)
         print_disk_info(disk_info, True)
     else:
         # print info for all disks
         disks_info = api_call(url)
         print_disks_info(disks_info)
开发者ID:Ajunboys,项目名称:rockstor-core,代码行数:11,代码来源:disks_console.py


示例15: do_add

    def do_add(self, args):
        """
        Create a new pool.

        Create a new pool: add pool_name disk_list raid_type

        Parameters:
        pool_name:    Intended name of the pool.
        disk_list:    A list of comma-separated(no whitespace) disks. For
                      example: sdb,sdc.
        raid_type:    One of the following: single, raid0, raid1 and raid10

        Examples:
        To create a raid0 pool with two disks(sdb and sdc) called pool0
            add pool0 sdb,sdc raid0
        """
        arg_fields = args.split()
        if (len(arg_fields) < 3):
            error = '3 arguments expected. %d given' % len(arg_fields)
            return self.help_wrapper(error, 'add')

        input_data = {'pname': arg_fields[0],
                      'disks': arg_fields[1],
                      'raid_level': arg_fields[2]}
        url = (self.url)
        pool_info = api_call(url, data=input_data, calltype='post')
        print_pool_info(pool_info)
开发者ID:sigkill,项目名称:rockstor-core,代码行数:27,代码来源:pools_console.py


示例16: do_enable

    def do_enable(self, args):
        """
        Make the share available via smb. all flags are optional.

        enable -c comment [-b <yes|no> -g <yes|no> -r <yes|no> -m 0755]
        """
        arg_fields = args.split()
        input_data = {}
        for f in arg_fields:
            if (f[0:2] == '-c'):
                input_data['comment'] = f[2:]
            elif (f[0:2] == '-b'):
                input_data['browsable'] = f[2:]
            elif (f[0:2] == '-g'):
                input_data['guest_ok'] = f[2:]
            elif (f[0:2] == '-r'):
                input_data['read_only'] = f[2:]
            elif (f[0:2] == '-m'):
                input_data['create_mask'] = f[2:]
            else:
                return self.do_help(args)
        if (len(input_data) == 0):
            return self.do_help(args)
        samba_info = api_call(self.url, data=input_data, calltype='post')
        print samba_info
开发者ID:Ajunboys,项目名称:rockstor-core,代码行数:25,代码来源:share_smb_console.py


示例17: do_list

    def do_list(self, args):
        """
        List brief information about all pools

        """
        pool_info = api_call(self.url)
        print_pool_info(pool_info)
开发者ID:adommeti,项目名称:rockstor-core,代码行数:7,代码来源:pools_console.py


示例18: do_data2

 def do_data2(self, args):
     if (args is not None):
         tap_fields = args.split()
         url = ('%s%s?%s' % (self.baseurl, tap_fields[0], tap_fields[1]))
         print(api_call(url))
     else:
         return self.do_help(args)
开发者ID:MFlyer,项目名称:rockstor-core,代码行数:7,代码来源:sm_console.py


示例19: do_list

 def do_list(self, args):
     url = BaseConsole.url + 'disks/'
     input_disk_list = args.split()
     if (len(input_disk_list) > 0):
         url = url + input_disk_list[0] + '/'
     disk_info = api_call(url)
     print_disk_info(disk_info)
开发者ID:adommeti,项目名称:rockstor-core,代码行数:7,代码来源:disks_console.py


示例20: do_add

    def do_add(self, args):
        """
        Create a new share.

        Create a new share: add share_name pool_name size

        Parameters:
        share_name:    Intended name of the share.
        pool_name:     Pool in which to create the share. The pool should
                       exist in order to create shares.
        size:          Intened size of the share. An integer is expected with
                       an optional suffix(MB, GB, TB, PB). When no suffix is
                       given, MB is presumed.

        Examples:
        To create a 20 GB share in a valid pool called pool0.
            add share1234 pool0 20GB

        To create a 100 MB share in a valid pool called mypool.
            add share100 mypool 100
        """
        arg_fields = args.split()
        if (len(arg_fields) < 3):
            error = ('3 arguments expected. %d given' % len(arg_fields))
            return self.help_wrapper(error, 'add')

        multiplier = 1024
        num = None
        try:
            num = int(arg_fields[2])
        except:
            if (len(arg_fields[2]) > 2):
                try:
                    num = int(arg_fields[2][:-2])
                except:
                    error = ('Invalid size parameter: %s' % arg_fields[2])
                    return self.help_wrapper(error, 'add')
                suffix = arg_fields[2][-2:].lower()
                if (suffix == 'mb'):
                    multiplier = multiplier ** 1
                elif (suffix == 'gb'):
                    multiplier = multiplier ** 2
                elif (suffix == 'tb'):
                    multiplier = multiplier ** 3
                elif (suffix == 'pb'):
                    multiplier = multiplier ** 4
                else:
                    error = ('Invalid size suffix: %s. must be one of '
                             'MB, GB, TB or PB' % suffix)
                    return self.help_wrapper(error, 'add')
            else:
                error = 'Invalid size parameter: %s' % arg_fields[2]
                return self.help_wrapper(error, 'add')
        size = num * multiplier
        input_data = {'pool' : arg_fields[1],
                      'size': size,}
        url = ('%s%s' % (self.url, arg_fields[0]))
        share_info = api_call(url, data=input_data, calltype='post')
        print_share_info(share_info)
开发者ID:aliamir,项目名称:rockstor-core,代码行数:59,代码来源:shares_console.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python restclient.get函数代码示例发布时间:2022-05-26
下一篇:
Python views.get_swagger_view函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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