For details on how to use compute, see Using OpenStack Compute
The compute high-level interface is available through the compute
member of a Connection
object. The
compute
member will only be added if the service is detected.
openstack.compute.v2._proxy.
Proxy
(session)¶find_extension
(name_or_id, ignore_missing=True)¶Find a single extension
Parameters: |
|
---|---|
Returns: | One |
extensions
()¶Retrieve a generator of extensions
Returns: | A generator of extension instances. |
---|---|
Return type: | Extension |
find_flavor
(name_or_id, ignore_missing=True)¶Find a single flavor
Parameters: |
|
---|---|
Returns: | One |
create_flavor
(**attrs)¶Create a new flavor from attributes
Parameters: | attrs (dict) – Keyword arguments which will be used to create
a Flavor ,
comprised of the properties on the Flavor class. |
---|---|
Returns: | The results of flavor creation |
Return type: | Flavor |
delete_flavor
(flavor, ignore_missing=True)¶Delete a flavor
Parameters: | |
---|---|
Returns: |
|
get_flavor
(flavor)¶Get a single flavor
Parameters: | flavor – The value can be the ID of a flavor or a
Flavor instance. |
---|---|
Returns: | One Flavor |
Raises: | ResourceNotFound
when no resource can be found. |
flavors
(details=True, **query)¶Return a generator of flavors
Parameters: |
|
---|---|
Returns: | A generator of flavor objects |
delete_image
(image, ignore_missing=True)¶Delete an image
Parameters: | |
---|---|
Returns: |
|
find_image
(name_or_id, ignore_missing=True)¶Find a single image
Parameters: |
|
---|---|
Returns: | One |
get_image
(image)¶Get a single image
Parameters: | image – The value can be the ID of an image or a
Image instance. |
---|---|
Returns: | One Image |
Raises: | ResourceNotFound
when no resource can be found. |
images
(details=True, **query)¶Return a generator of images
Parameters: |
|
---|---|
Returns: | A generator of image objects |
get_image_metadata
(image)¶Return a dictionary of metadata for an image
Parameters: | image – Either the ID of an image or a
Image or
ImageDetail
instance. |
---|---|
Returns: | A Image with only the
image’s metadata. All keys and values are Unicode text. |
Return type: | Image |
set_image_metadata
(image, **metadata)¶Update metadata for an image
Parameters: |
|
---|---|
Returns: | A |
Return type: |
delete_image_metadata
(image, keys)¶Delete metadata for an image
Note: This method will do a HTTP DELETE request for every key in keys.
Parameters: |
|
---|---|
Return type: |
|
create_keypair
(**attrs)¶Create a new keypair from attributes
Parameters: | attrs (dict) – Keyword arguments which will be used to create
a Keypair ,
comprised of the properties on the Keypair class. |
---|---|
Returns: | The results of keypair creation |
Return type: | Keypair |
delete_keypair
(keypair, ignore_missing=True)¶Delete a keypair
Parameters: | |
---|---|
Returns: |
|
get_keypair
(keypair)¶Get a single keypair
Parameters: | keypair – The value can be the ID of a keypair or a
Keypair
instance. |
---|---|
Returns: | One Keypair |
Raises: | ResourceNotFound
when no resource can be found. |
find_keypair
(name_or_id, ignore_missing=True)¶Find a single keypair
Parameters: |
|
---|---|
Returns: | One |
keypairs
()¶Return a generator of keypairs
Returns: | A generator of keypair objects |
---|---|
Return type: | Keypair |
get_limits
()¶Retrieve limits that are applied to the project’s account
Returns: | A Limits object, including both
AbsoluteLimits and
RateLimits |
---|---|
Return type: | Limits |
create_server
(**attrs)¶Create a new server from attributes
Parameters: | attrs (dict) – Keyword arguments which will be used to create
a Server ,
comprised of the properties on the Server class. |
---|---|
Returns: | The results of server creation |
Return type: | Server |
delete_server
(server, ignore_missing=True, force=False)¶Delete a server
Parameters: |
|
---|---|
Returns: |
|
find_server
(name_or_id, ignore_missing=True)¶Find a single server
Parameters: |
|
---|---|
Returns: | One |
get_server
(server)¶Get a single server
Parameters: | server – The value can be the ID of a server or a
Server instance. |
---|---|
Returns: | One Server |
Raises: | ResourceNotFound
when no resource can be found. |
servers
(details=True, **query)¶Retrieve a generator of servers
Parameters: |
|
---|---|
Returns: | A generator of server instances. |
update_server
(server, **attrs)¶Update a server
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Attrs kwargs: | The attributes to update on the server represented
by server . |
Returns: | The updated server |
Return type: | Server |
change_server_password
(server, new_password)¶Change the administrator password
Parameters: | |
---|---|
Returns: | None |
reset_server_state
(server, state)¶Reset the state of server
Parameters: |
|
---|---|
Returns: | None |
reboot_server
(server, reboot_type)¶Reboot a server
Parameters: | |
---|---|
Returns: | None |
rebuild_server
(server, name, admin_password, **attrs)¶Rebuild a server
Parameters: |
|
---|---|
Returns: | The rebuilt |
resize_server
(server, flavor)¶Resize a server
Parameters: | |
---|---|
Returns: | None |
confirm_server_resize
(server)¶Confirm a server resize
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
revert_server_resize
(server)¶Revert a server resize
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
create_server_image
(server, name, metadata=None)¶Create an image from a server
Parameters: | |
---|---|
Returns: | None |
add_security_group_to_server
(server, security_group)¶Add a security group to a server
Parameters: |
|
---|---|
Returns: | None |
remove_security_group_from_server
(server, security_group)¶Add a security group to a server
Parameters: |
|
---|---|
Returns: | None |
add_fixed_ip_to_server
(server, network_id)¶Adds a fixed IP address to a server instance.
Parameters: |
|
---|---|
Returns: | None |
remove_fixed_ip_from_server
(server, address)¶Removes a fixed IP address from a server instance.
Parameters: |
|
---|---|
Returns: | None |
add_floating_ip_to_server
(server, address, fixed_address=None)¶Adds a floating IP address to a server instance.
Parameters: |
|
---|---|
Returns: | None |
remove_floating_ip_from_server
(server, address)¶Removes a floating IP address from a server instance.
Parameters: |
|
---|---|
Returns: | None |
pause_server
(server)¶Pauses a server and changes its status to PAUSED
.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
unpause_server
(server)¶Unpauses a paused server and changes its status to ACTIVE
.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
suspend_server
(server)¶Suspends a server and changes its status to SUSPENDED
.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
resume_server
(server)¶Resumes a suspended server and changes its status to ACTIVE
.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
lock_server
(server)¶Locks a server.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
unlock_server
(server)¶Unlocks a locked server.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
rescue_server
(server, admin_pass=None, image_ref=None)¶Puts a server in rescue mode and changes it status to RESCUE
.
Parameters: |
|
---|---|
Returns: | None |
unrescue_server
(server)¶Unrescues a server and changes its status to ACTIVE
.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
evacuate_server
(server, host=None, admin_pass=None, force=None)¶Evacuates a server from a failed host to a new host.
Parameters: |
|
---|---|
Returns: | None |
start_server
(server)¶Starts a stopped server and changes its state to ACTIVE
.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
stop_server
(server)¶Stops a running server and changes its state to SHUTOFF
.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
shelve_server
(server)¶Shelves a server.
All associated data and resources are kept but anything still in memory is not retained. Policy defaults enable only users with administrative role or the owner of the server to perform this operation. Cloud provides could change this permission though.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
unshelve_server
(server)¶Unselves or restores a shelved server.
Policy defaults enable only users with administrative role or the owner of the server to perform this operation. Cloud provides could change this permission though.
Parameters: | server – Either the ID of a server or a
Server instance. |
---|---|
Returns: | None |
create_server_interface
(server, **attrs)¶Create a new server interface from attributes
Parameters: |
|
---|---|
Returns: | The results of server interface creation |
Return type: |
delete_server_interface
(server_interface, server=None, ignore_missing=True)¶Delete a server interface
Parameters: |
|
---|---|
Returns: |
|
get_server_interface
(server_interface, server=None)¶Get a single server interface
Parameters: |
|
---|---|
Returns: | One
|
Raises: |
|
server_interfaces
(server)¶Return a generator of server interfaces
Parameters: | server – The server can be either the ID of a server or a
Server . |
---|---|
Returns: | A generator of ServerInterface objects |
Return type: | ServerInterface |
server_ips
(server, network_label=None)¶Return a generator of server IPs
Parameters: |
|
---|---|
Returns: | A generator of ServerIP objects |
Return type: |
availability_zones
(details=False)¶Return a generator of availability zones
Parameters: | details (bool) – Return extra details about the availability zones. This defaults to False as it generally requires extra permission. |
---|---|
Returns: | A generator of availability zone |
Return type: | :class:`~openstack.compute.v2.availability_zone. |
AvailabilityZone`
get_server_metadata
(server)¶Return a dictionary of metadata for a server
Parameters: | server – Either the ID of a server or a
Server or
ServerDetail
instance. |
---|---|
Returns: | A Server with only the
server’s metadata. All keys and values are Unicode text. |
Return type: | Server |
set_server_metadata
(server, **metadata)¶Update metadata for a server
Parameters: |
|
---|---|
Returns: | A |
Return type: |
delete_server_metadata
(server, keys)¶Delete metadata for a server
Note: This method will do a HTTP DELETE request for every key in keys.
Parameters: |
|
---|---|
Return type: |
|
create_server_group
(**attrs)¶Create a new server group from attributes
Parameters: | attrs (dict) – Keyword arguments which will be used to create
a ServerGroup ,
comprised of the properties on the ServerGroup class. |
---|---|
Returns: | The results of server group creation |
Return type: | ServerGroup |
delete_server_group
(server_group, ignore_missing=True)¶Delete a server group
Parameters: |
|
---|---|
Returns: |
|
find_server_group
(name_or_id, ignore_missing=True)¶Find a single server group
Parameters: |
|
---|---|
Returns: | One |
get_server_group
(server_group)¶Get a single server group
Parameters: | server_group – The value can be the ID of a server group or a
ServerGroup
instance. |
---|---|
Returns: | A ServerGroup object. |
Raises: | ResourceNotFound
when no resource can be found. |
server_groups
(**query)¶Return a generator of server groups
Parameters: | **query (kwargs) – Optional query parameters to be sent to limit the resources being returned. |
---|---|
Returns: | A generator of ServerGroup objects |
Return type: | ServerGroup |
hypervisors
()¶Return a generator of hypervisor
Returns: | A generator of hypervisor |
---|---|
Return type: | class: ~openstack.compute.v2.hypervisor.Hypervisor |
find_hypervisor
(name_or_id, ignore_missing=True)¶Find a hypervisor from name or id to get the corresponding info
Parameters: | name_or_id – The name or id of a hypervisor |
---|---|
Returns: | One: class:~openstack.compute.v2.hypervisor.Hypervisor object or None |
get_hypervisor
(hypervisor)¶Get a single hypervisor
Parameters: | hypervisor – The value can be the ID of a hypervisor or a
Hypervisor
instance. |
---|---|
Returns: | A Hypervisor object. |
Raises: | ResourceNotFound
when no resource can be found. |
get_service
(service)¶Get a single service
Parameters: | service – The value can be the ID of a serivce or a
Service
instance. |
---|---|
Returns: | A Service object. |
Raises: | ResourceNotFound
when no resource can be found. |
force_service_down
(service, host, binary)¶Force a service down
Parameters: | |
---|---|
Returns: | None |
disable_service
(service, host, binary, disabled_reason=None)¶Disable a service
Parameters: | |
---|---|
Returns: | None |
enable_service
(service, host, binary)¶Enable a service
Parameters: | |
---|---|
Returns: | None |
services
()¶Return a generator of service
Returns: | A generator of service |
---|---|
Return type: | class: ~openstack.compute.v2.service.Service |
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.