Coder Social home page Coder Social logo

python-aliyun's Introduction

python-aliyun

Python API wrapper for the Aliyun cloud. This project is starting to use git-flow.

Installing

You should build a virtualenv to contain this project's Python dependencies. The Makefile will create one for you and put it in ~/.virtualenvs/python-aliyun.

git clone [email protected]:quixey/python-aliyun.git
cd python-aliyun
sudo pip install virtualenv
make virtualenv
source ~/.virtualenvs/python-aliyun/bin/activate

Aliyun API

The Aliyun API is well-documented at dev.aliyun.com. Each service's API is very similar: There are regions, actions, and each action has many parameters. It is an OAuth2 API, so you need to have an ID and a secret. You can get these from the Aliyun management console.

Authentication

You will need security credentials for your Aliyun account. You can view and create them in the Aliyun management console. This library will look for credentials in the following places:

  1. Environment variables ALI_ACCESS_KEY_ID and ALI_SECRET_ACCESS_KEY
  2. An ini-style configuration file at ~/.aliyun.cfg with contents like:
[default]
access_key_id=xxxxxxxxxxxxx
secret_access_key=xxxxxxxxxxxxxxxxxxxxxxx
  1. A system-wide version of that file at /etc/aliyun.cfg with similar contents.

We recommend using environment variables whenever possible.

Main Interfaces

The main components of python-aliyun are ECS and SLB. Other Aliyun products will be added as API support develops. Within each Aliyun product, we tried to implement every API Action variation available. We used a boto-style design where most API interaction is done with a connection object which marshalls Python objects and API representations.

ECS

You can create a new ECS connection and interact with ECS like this:

import aliyun.ecs.connection
conn = aliyun.ecs.connection.EcsConnection('cn-hangzhou')
print conn.get_all_instance_ids()

This module makes use of one as-yet undocumented API Action: ModifyInstanceSpec.

This module does not implement the following API Action: ResetDisk.

SLB

Similarly for SLB, get the connection object like this:

import aliyun.slb.connection
conn = aliyun.slb.connection.SlbConnection('cn-hangzhou')
print conn.get_all_load_balancer_ids()

ali command

The ali commandline tool is mostly used for debugging the Aliyun API interactions. It accepts arbitrary Key=Value pairs and passes them on to the API after wrapping them.

ali --region cn-hangzhou ecs Action=DescribeRegions
ali --region cn-hangzhou slb Action=DescribeLoadBalancers

Copyright Notice

Copyright 2014, Quixey Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at

     http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

python-aliyun's People

Contributors

addumb avatar heikkiquixey avatar bwong28 avatar nezaj avatar mkodama avatar tz2wang avatar npt avatar quixeybrian avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.