Using OpenStack Compute
Before working with the Compute service, you'll need to create a connection
to your OpenStack cloud by following the :doc:connect
user guide. This will
provide you with the conn
variable used in the examples below.
.. contents:: Table of Contents
:local:
The primary resource of the Compute service is the server. (compute service的主要资源就是server(服务器))
List Servers (列出servers)
A server is a virtual machine that provides access to a compute instance
being run by your cloud provider.
(一个server就是一个你的云提供者提供计算实例的虚拟机)(?:这个cloud provider是指的openstack吗)
.. literalinclude:: ../examples/compute/list.py (例子)
:pyobject: list_servers
Full example: compute resource list
_
List Images
An image is the operating system you want to use for your server.
(image就是你想为server使用的操作系统)
.. literalinclude:: ../examples/compute/list.py
:pyobject: list_images
Full example: compute resource list
_
List Flavors
A flavor is the resource configuration for a server. Each flavor is a
unique combination of disk, memory, vCPUs, and network bandwidth.
(一个flavor就是一个server的资源配置。每一个flavor就是磁盘,内存,虚拟cpu和网络宽带的唯一的结合体。)
.. literalinclude:: ../examples/compute/list.py
:pyobject: list_flavors
Full example: compute resource list
_
List Networks
A network provides connectivity to servers.
.. literalinclude:: ../examples/network/list.py
:pyobject: list_networks
Full example: network resource list
_
Create Key Pair (创建密钥对)
A key pair is the public key and private key of
public–key cryptography
_. They are used to encrypt and decrypt login
information when connecting to your server.
(key pair是公钥密码系统的公钥和私钥。他们被用于加密和解密登录信息,当你要连接你的server的时候。)
.. literalinclude:: ../examples/compute/create.py
:pyobject: create_keypair
Full example: compute resource create
_
Create Server
At minimum, a server requires a name, an image, a flavor, and a network on
creation. You can discover the names and IDs of these attributes by listing
them as above and then using the find methods to get the appropriate
resources.
(最起码的,一个server需要一个名字,一个镜像,一个flavor,和一个网络,在创建的时候。
你可以发现它们的名字和ID在list 它们的时候,然后使用find methods 去获得适当的资源。)
Ideally you'll also create a server using a keypair so you can login to that
server with the private key.
(理想地,你一般会使用密钥对创建一个server,因此你能使用私钥登录。)
Servers take time to boot so we call wait_for_server
to wait
for it to become active.
(server会占用时间去启动,所以我们调用wait_for_server去等待server启动起来。)
.. literalinclude:: ../examples/compute/create.py
:pyobject: create_server
Full example: compute resource create
_
.. _compute resource list: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/compute/list.py
.. _network resource list: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/network/list.py
.. _compute resource create: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/compute/create.py
.. _public–key cryptography: https://en.wikipedia.org/wiki/Public-key_cryptography
网友评论