Ai
3 Star 1 Fork 0

Gitee 极速下载/libcloud

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/apache/libcloud
克隆/下载
getting_started.rst 2.64 KB
一键复制 编辑 原始数据 按行查看 历史
Tomaz Muraus 提交于 2022-05-31 01:05 +08:00 . Fix git repo link in the readme.

Getting Started

Installation (stable version)

Libcloud is available on PyPi. You can install latest stable version using pip:

pip install apache-libcloud

Installation (development version)

You can install latest development version from our Git repository:

pip install -e git+https://git.apache.org/repos/asf/libcloud.git@trunk#egg=apache-libcloud

Upgrading

If you used pip to install the library you can also use it to upgrade it:

pip install --upgrade apache-libcloud

Using it

This section describes a standard work-flow which you follow when working with any of the Libcloud drivers.

  1. Obtain reference to the provider driver
from pprint import pprint

import libcloud

cls = libcloud.get_driver(libcloud.DriverType.COMPUTE, libcloud.DriverType.COMPUTE.RACKSPACE)
  1. Instantiate the driver with your provider credentials
driver = cls('my username', 'my api key')

Keep in mind that some drivers take additional arguments such as region and api_version.

For more information on which arguments you can pass to your provider driver, see provider-specific documentation and the driver docstrings.

  1. Start using the driver
pprint(driver.list_sizes())
pprint(driver.list_nodes())
  1. Putting it all together
from pprint import pprint

import libcloud

cls = libcloud.get_driver(libcloud.DriverType.COMPUTE, libcloud.DriverType.COMPUTE.RACKSPACE)

driver = cls('my username', 'my api key')

pprint(driver.list_sizes())
pprint(driver.list_nodes())

You can find more examples with common patterns which can help you get started on the :doc:`Compute Examples </compute/examples>` page.

Where to go from here?

The best thing to do after understanding the basic driver work-flow is to visit the documentation chapter for the API you are interested in (:doc:`Compute </compute/index>`, :doc:`Object Storage </storage/index>`, :doc:`Load Balancer </loadbalancer/index>`, :doc:`DNS </dns/index>`). Chapter for each API explains some basic terminology and things you need to know to make an effective use of that API.

After you have a good grasp of those basic concepts, you are encouraged to check the driver specific documentation (if available) and usage examples. If the driver specific documentation for the provider you are interested in is not available yet, you are encouraged to check docstrings for that driver.

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/libcloud.git
git@gitee.com:mirrors/libcloud.git
mirrors
libcloud
libcloud
trunk

搜索帮助