Gyun的软件开发工具包。
gyun-sdk的Python项目详细描述
此存储库允许您访问GYUN 从应用程序中控制资源。
此sdk的许可 Apache Licence, Version 2.0。
注意
要求Python2.6或更高版本,与Python3兼容, 有关详细信息,请参见 GYUN SDK Documentation
安装
通过pip安装
$ pip install gyun-sdk
升级至最新版本
$ pip install --upgrade gyun-sdk
从源安装
git clone https://github.com/gyun-gome/gyun-sdk-python.git cd gyun-sdk-python python setup.py install
开始
为了操作Gyun Iaas或Gomestor(Gyun对象存储), 您需要首先在gyun console上应用access key。
Gyun Iaas原料药
将访问密钥id和密钥传入方法connect_to_zone以创建连接
>>> import gyun.iaas >>> conn = gyun.iaas.connect_to_zone( 'zone id', 'access key id', 'secret access key' )
变量conn是gyun.iaas.connection.APIConnection的实例, 我们可以使用它来调用与资源相关的方法。
示例:
# 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'] )
Gyun Gomestor原料药
将访问密钥id和密钥传入方法connect以创建连接
>>> import gyun.gomestor >>> conn = gyun.gomestor.connect( 'pek3a.gomestor.com', 'access key id', 'secret access key' )
变量conn是gyun.gomestor.connection.QSConnection的实例, 我们可以用它来创建bucket,用于生成key和multipartupload。
示例:
# 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')