本文整理汇总了Python中rest_util.api_call函数的典型用法代码示例。如果您正苦于以下问题:Python api_call函数的具体用法?Python api_call怎么用?Python api_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_call函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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])
示例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)
示例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')
示例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')
示例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))
示例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')
示例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')
示例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)
示例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)
示例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))
示例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)
示例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)
示例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)
示例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)