首页 > 代码库 > The novaclient Python API
The novaclient Python API
The novaclient Python API
Usage
First create a client instance with your credentials:
>>> from novaclient.client import Client>>> nova = Client(VERSION, USERNAME, PASSWORD, PROJECT_ID, AUTH_URL)
Here VERSION can be: 1.1, 2 and 3.
Alternatively, you can create a client instance using the keystoneclient session API:
>>> from keystoneclient.auth.identity import v2>>> from keystoneclient import session>>> from novaclient.client import Client>>> auth = v2.Password(auth_url=AUTH_URL, username=USERNAME, password=PASSWORD, tenant_name=PROJECT_ID)>>> sess = session.Session(auth=auth)>>> nova = client.Client(VERSION, session=sess)
For more information on this keystoneclient API, see Using Sessions.
Then call methods on its managers:
>>> nova.servers.list()[<Server: buildslave-ubuntu-9.10>]>>> nova.flavors.list()[<Flavor: 256 server>, <Flavor: 512 server>, <Flavor: 1GB server>, <Flavor: 2GB server>, <Flavor: 4GB server>, <Flavor: 8GB server>, <Flavor: 15.5GB server>]>>> fl = nova.flavors.find(ram=512)>>> nova.servers.create("my-server", flavor=fl)<Server: my-server>
Reference¶
For more information, see the reference:
- Exceptions
- Exceptions
- Version 1.1, Version 2 API Reference
- Flavors
- Images
- Servers
- Hosts
- Agents
- Aggregates
- Availability_zones
- Certs
- Fixed_ips
- Floating_ip_pools
- Floating_ips
- Hypervisors
- Keypairs
- Limits
- Networks
- Quota_classes
- Quotas
- Security_group_rules
- Security_groups
- Services
- Virtual_interfaces
- Volume_snapshots
- Volumes
- Volume_types
- Version 3 API Reference
- Flavors
- Hosts
- Agents
- Aggregates
- Availability_zones
- Certs
- Hypervisors
- Images
- Keypairs
- Quotas
- Quotas_classes
- Servers
- Services
The novaclient Python API
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。