ucloud python client and command line tools
Project description
###Ucloud Python SDK and Command-Line Tool
#####this is a python sdk for ucloud,as well as a CLI tools for ucloud in linux bash env.
####1. sdk usage:
from ucloud-python-sdk import client as uclient
cl=uclient(base_url, public_key, private_key)
print cl.uhost.get(region="cnnorth-03",uhostids="uhost-4dmzop")
output:
{u'Action': u'DescribeUHostInstanceResponse', u'TotalCount': 1, u'RetCode': 0,
u'UHostSet': [{u'Remark': u'', u'Tag': u'Default', u'Name': u'yan-1',
u'State': u'Running', u'IPSet': [{u'IP': u'10.11.1.126', u'Type': u'Private'},
{u'IPId': u'eip-yci4qr', u'IP': u'107.150.97.103', u'Bandwidth': 2,
u'Type': u'International'}], u'DiskSet': [{u'Type': u'Boot',
u'Drive': u'/dev/sda', u'DiskId': u'ce3b1751-d837-4949-9c73-29368b7fe820',
u'Size': 20}], u'CPU': 1, u'OsName': u'Ubuntu 14.04 64\u4f4d',
u'BasicImageId': u'uimage-nhwrqn',
u'ImageId': u'ce3b1751-d837-4949-9c73-29368b7fe820', u'ExpireTime': 1429632272,
u'UHostType': u'Normal', u'UHostId': u'uhost-4dmzop', u'NetworkState': u'Connected',
u'ChargeType': u'Month', u'Memory': 2048, u'OsType': u'Linux', u'CreateTime': 1426953872,
u'BasicImageName': u'Ubuntu 14.04 64\u4f4d'}]}
####2. command-line usage:
使用之前,先编辑下uclud.rc文件,然后导入环境变量,接下来的命令就不用输入你的认证信息了.
hyphendeMacBook-Air:ucloud-python-sdk hyphen$ cat ucloud.rc
export UCLOUD_REGION="cn-north-03"
export UCLOUD_URL="https://api.ucloud.cn"
export UCLOUD_PUBKEY="asdf"
export UCLOUD_PRIKEY="asdf"
hyphendeMacBook-Air:ucloud-python-sdk hyphen$ source ucloud.rc
hyphendeMacBook-Air:ucloud-python-sdk hyphen$ python shell.py
usage: ucloud [--debug] [--timings] <subcommand> ...
Command line interface for ucloud
Positional arguments:
<subcommand>
uhost-create boot a host
uhost-image-list
list all images
uhost-list list uhosts
uhost-show show a uhost
bash-completion
Prints all of the commands and options to stdout so that
the ucloud.bash_completion script doesn't have to hard
code them.
help Display help about this program or one of its subcommands.
Optional arguments:
--debug Print debugging output
--timings Print call timing info
See "ucloud help COMMAND" for help on a specific command.
hyphendeMacBook-Air:ucloud-python-sdk hyphen$ python shell.py uhost-show --uhostid uhost-4dmzop
+----------------+------------------------------------------------------------------+
| Property | Value |
+----------------+------------------------------------------------------------------+
| BasicImageId | uimage-nhwrqn |
| BasicImageName | Ubuntu 14.04 64位 |
| CPU | 1 |
| ChargeType | Month |
| CreateTime | 2015-03-22 00:04:32 |
| Disk_0 | /dev/sda 20GB Type:Boot ID:ce3b1751-d837-4949-9c73-29368b7fe820 |
| ExpireTime | 2015-04-22 00:04:32 |
| IP_0 | Private 10.11.1.126 |
| IP_1 | International 2Mb/s 107.150.97.103 ID:eip-yci4qr |
| ImageId | ce3b1751-d837-4949-9c73-29368b7fe820 |
| Memory | 2048 |
| Name | yan-1 |
| NetworkState | Connected |
| OsType | Linux |
| Remark | |
| State | Running |
| Tag | Default |
| UHostId | uhost-4dmzop |
| UHostType | Normal |
+----------------+------------------------------------------------------------------+
#####this is a python sdk for ucloud,as well as a CLI tools for ucloud in linux bash env.
####1. sdk usage:
from ucloud-python-sdk import client as uclient
cl=uclient(base_url, public_key, private_key)
print cl.uhost.get(region="cnnorth-03",uhostids="uhost-4dmzop")
output:
{u'Action': u'DescribeUHostInstanceResponse', u'TotalCount': 1, u'RetCode': 0,
u'UHostSet': [{u'Remark': u'', u'Tag': u'Default', u'Name': u'yan-1',
u'State': u'Running', u'IPSet': [{u'IP': u'10.11.1.126', u'Type': u'Private'},
{u'IPId': u'eip-yci4qr', u'IP': u'107.150.97.103', u'Bandwidth': 2,
u'Type': u'International'}], u'DiskSet': [{u'Type': u'Boot',
u'Drive': u'/dev/sda', u'DiskId': u'ce3b1751-d837-4949-9c73-29368b7fe820',
u'Size': 20}], u'CPU': 1, u'OsName': u'Ubuntu 14.04 64\u4f4d',
u'BasicImageId': u'uimage-nhwrqn',
u'ImageId': u'ce3b1751-d837-4949-9c73-29368b7fe820', u'ExpireTime': 1429632272,
u'UHostType': u'Normal', u'UHostId': u'uhost-4dmzop', u'NetworkState': u'Connected',
u'ChargeType': u'Month', u'Memory': 2048, u'OsType': u'Linux', u'CreateTime': 1426953872,
u'BasicImageName': u'Ubuntu 14.04 64\u4f4d'}]}
####2. command-line usage:
使用之前,先编辑下uclud.rc文件,然后导入环境变量,接下来的命令就不用输入你的认证信息了.
hyphendeMacBook-Air:ucloud-python-sdk hyphen$ cat ucloud.rc
export UCLOUD_REGION="cn-north-03"
export UCLOUD_URL="https://api.ucloud.cn"
export UCLOUD_PUBKEY="asdf"
export UCLOUD_PRIKEY="asdf"
hyphendeMacBook-Air:ucloud-python-sdk hyphen$ source ucloud.rc
hyphendeMacBook-Air:ucloud-python-sdk hyphen$ python shell.py
usage: ucloud [--debug] [--timings] <subcommand> ...
Command line interface for ucloud
Positional arguments:
<subcommand>
uhost-create boot a host
uhost-image-list
list all images
uhost-list list uhosts
uhost-show show a uhost
bash-completion
Prints all of the commands and options to stdout so that
the ucloud.bash_completion script doesn't have to hard
code them.
help Display help about this program or one of its subcommands.
Optional arguments:
--debug Print debugging output
--timings Print call timing info
See "ucloud help COMMAND" for help on a specific command.
hyphendeMacBook-Air:ucloud-python-sdk hyphen$ python shell.py uhost-show --uhostid uhost-4dmzop
+----------------+------------------------------------------------------------------+
| Property | Value |
+----------------+------------------------------------------------------------------+
| BasicImageId | uimage-nhwrqn |
| BasicImageName | Ubuntu 14.04 64位 |
| CPU | 1 |
| ChargeType | Month |
| CreateTime | 2015-03-22 00:04:32 |
| Disk_0 | /dev/sda 20GB Type:Boot ID:ce3b1751-d837-4949-9c73-29368b7fe820 |
| ExpireTime | 2015-04-22 00:04:32 |
| IP_0 | Private 10.11.1.126 |
| IP_1 | International 2Mb/s 107.150.97.103 ID:eip-yci4qr |
| ImageId | ce3b1751-d837-4949-9c73-29368b7fe820 |
| Memory | 2048 |
| Name | yan-1 |
| NetworkState | Connected |
| OsType | Linux |
| Remark | |
| State | Running |
| Tag | Default |
| UHostId | uhost-4dmzop |
| UHostType | Normal |
+----------------+------------------------------------------------------------------+
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ucloud-client-1.0.tar.gz
(12.0 kB
view details)
Built Distribution
ucloud_client-1.0-py2.7.egg
(32.5 kB
view details)
File details
Details for the file ucloud-client-1.0.tar.gz
.
File metadata
- Download URL: ucloud-client-1.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7cc747d7357111c298d6e4d48b588f7ab9c062646310bb91d102657c2e2dc5d |
|
MD5 | af66bd1e49ca0c159d50aeccd34ba7ab |
|
BLAKE2b-256 | 46318a87247c52e04ef0bfd860c23c1c2238d7bc57bb9b2694bea9de00bd3b74 |
File details
Details for the file ucloud_client-1.0-py2.7.egg
.
File metadata
- Download URL: ucloud_client-1.0-py2.7.egg
- Upload date:
- Size: 32.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77955186fe2c610d5a9e56df8bf8485a207801a7af8ace41e44bbf2681342ebd |
|
MD5 | 3409077cdbda98397cfb56a56cd65a57 |
|
BLAKE2b-256 | 06527cc169af8e74f4ff6332747e11311062f2181c92033f81b459d9ee37e461 |