This repository allows you to access QingCloud and control your resources from your applications.
This SDK is licensed under Apache Licence, Version 2.0.
Note
Requires Python 2.6 or higher, for more information please see QingCloud SDK Documentation
Install via pip
$ pip install qingcloud-sdk
Upgrade to the latest version
$ pip install --upgrade qingcloud-sdk
Install from source
git clone https://github.com/yunify/qingcloud-sdk-python.git cd qingcloud-sdk-python python setup.py install
In order to operate QingCloud IaaS or QingStor (QingCloud Object Storage), you need apply access key on qingcloud console first.
Pass access key id and secret key into method connect_to_zone to create connection
>>> import qingcloud.iaas
>>> conn = qingcloud.iaas.connect_to_zone(
'zone id',
'access key id',
'secret access key'
)
The variable conn is the instance of qingcloud.iaas.connection.APIConnection,
we can use it to call resource related methods.
Example:
# launch instances
>>> ret = conn.run_instances(
image_id='img-xxxxxxxx',
cpu=1,
memory=1024,
vxnets=['vxnet-0'],
login_mode='passwd',
login_passwd='Passw0rd@()'
)
# stop instances
>>> ret = conn.stop_instances(
instances=['i-xxxxxxxx'],
force=True
)
# describe instances
>>> ret = conn.describe_instances(
status=['running', 'stopped']
)
Pass access key id and secret key into method connect to create connection
>>> import qingcloud.qingstor
>>> conn = qingcloud.qingstor.connect(
'pek3a.qingstor.com',
'access key id',
'secret access key'
)
The variable conn is the instance of qingcloud.qingstor.connection.QSConnection,
we can use it to create Bucket which is used for generating Key and MultiPartUpload.
Example:
# Create a bucket
>>> bucket = conn.create_bucket('mybucket')
# Create a key
>>> key = bucket.new_key('myobject')
>>> with open('/tmp/myfile') as f:
>>> key.send_file(f)
# Delete the key
>>> bucket.delete_key('myobject')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。