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, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)create_server
(**attrs)Create a new server from attributes
delete_server
(server, ignore_missing=True, force=False)Delete a server
server – The value can be either the ID of a server or a
Server
instance.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the server does not exist.
When set to True
, no exception will be set when
attempting to delete a nonexistent server
force (bool) – When set to True
, the server deletion will be
forced immediately.
None
find_server
(name_or_id, ignore_missing=True)Find a single server
name_or_id – The name or ID of a server.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the resource does not exist.
When set to True
, None will be returned when
attempting to find a nonexistent resource.
One Server
or None
get_server
(server)Get a single server
servers
(details=True, all_projects=False, **query)Retrieve a generator of servers
details (bool) – When set to False
instances with only basic data will be returned. The default,
True
, will cause instances with full data to be returned.
query (kwargs) – Optional query parameters to be sent to limit the servers being returned. Available parameters can be seen under https://docs.openstack.org/api-ref/compute/#list-servers
A generator of server instances.
update_server
(server, **attrs)Update a server
create_server_image
(server, name, metadata=None, wait=False, timeout=120)Create an image from a server
backup_server
(server, name, backup_type, rotation)Backup a server
server – Either the ID of a server or a
Server
instance.
name – The name of the backup image.
backup_type – The type of the backup, for example, daily.
rotation – The rotation of the back up image, the oldest image will be removed when image count exceed the rotation count.
None
wait_for_server
(server, status='ACTIVE', failures=None, interval=2, wait=120)Wait for a server to be in a particular status.
server (Server
:) – The Server
to wait on
to reach the specified status.
status – Desired status.
failures (list
) – Statuses that would be interpreted as failures.
interval (int) – Number of seconds to wait before to consecutive checks. Default to 2.
wait (int) – Maximum number of seconds to wait before the change. Default to 120.
The resource is returned on success.
ResourceTimeout
if transition
to the desired status failed to occur in specified seconds.
ResourceFailure
if the resource
has transited to one of the failure statuses.
AttributeError
if the resource does not have a
status
attribute.
get_server_metadata
(server)Return a dictionary of metadata for a server
set_server_metadata
(server, **metadata)Update metadata for a server
server – Either the ID of a server or a
Server
instance.
metadata (kwargs) – Key/value pairs to be updated in the server’s metadata. No other metadata is modified by this call. All keys and values are stored as Unicode.
A Server
with only the
server’s metadata. All keys and values are Unicode text.
delete_server_metadata
(server, keys)Delete metadata for a server
Note: This method will do a HTTP DELETE request for every key in keys.
server – Either the ID of a server or a
Server
instance.
keys – The keys to delete
None
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)fetch_server_security_groups
(server)Fetch security groups with details for a server.
add_security_group_to_server
(server, security_group)Add a security group to a server
server – Either the ID of a server or a
Server
instance.
security_group – Either the ID, Name of a security group or a
SecurityGroup
instance.
None
remove_security_group_from_server
(server, security_group)Remove a security group from a server
server – Either the ID of a server or a
Server
instance.
security_group – Either the ID of a security group or a
SecurityGroup
instance.
None
add_fixed_ip_to_server
(server, network_id)Adds a fixed IP address to a server instance.
server – Either the ID of a server or a
Server
instance.
network_id – The ID of the network from which a fixed IP address is about to be allocated.
None
remove_fixed_ip_from_server
(server, address)Removes a fixed IP address from a server instance.
server – Either the ID of a server or a
Server
instance.
address – The fixed IP address to be disassociated from the server.
None
add_floating_ip_to_server
(server, address, fixed_address=None)Adds a floating IP address to a server instance.
server – Either the ID of a server or a
Server
instance.
address – The floating IP address to be added to the server.
fixed_address – The fixed IP address to be associated with the floating IP address. Used when the server is connected to multiple networks.
None
remove_floating_ip_from_server
(server, address)Removes a floating IP address from a server instance.
server – Either the ID of a server or a
Server
instance.
address – The floating IP address to be disassociated from the server.
None
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)reboot_server
(server, reboot_type)Reboot a server
server – Either the ID of a server or a
Server
instance.
reboot_type (str) – The type of reboot to perform. “HARD” and “SOFT” are the current options.
None
pause_server
(server)Pauses a server and changes its status to PAUSED
.
server – Either the ID of a server or a
Server
instance.
None
unpause_server
(server)Unpauses a paused server and changes its status to ACTIVE
.
server – Either the ID of a server or a
Server
instance.
None
suspend_server
(server)Suspends a server and changes its status to SUSPENDED
.
server – Either the ID of a server or a
Server
instance.
None
resume_server
(server)Resumes a suspended server and changes its status to ACTIVE
.
server – Either the ID of a server or a
Server
instance.
None
lock_server
(server)Locks a server.
server – Either the ID of a server or a
Server
instance.
None
unlock_server
(server)Unlocks a locked server.
server – Either the ID of a server or a
Server
instance.
None
rescue_server
(server, admin_pass=None, image_ref=None)Puts a server in rescue mode and changes it status to RESCUE
.
server – Either the ID of a server or a
Server
instance.
admin_pass – The password for the rescued server. If you omit this parameter, the operation generates a new password.
image_ref – The image reference to use to rescue your server. This can be the image ID or its full URL. If you omit this parameter, the base image reference will be used.
None
unrescue_server
(server)Unrescues a server and changes its status to ACTIVE
.
server – Either the ID of a server or a
Server
instance.
None
evacuate_server
(server, host=None, admin_pass=None, force=None)Evacuates a server from a failed host to a new host.
server – Either the ID of a server or a
Server
instance.
host – An optional parameter specifying the name or ID of the host to which the server is evacuated.
admin_pass – An optional parameter specifying the administrative password to access the evacuated or rebuilt server.
force – Force an evacuation by not verifying the provided destination host by the scheduler. (New in API version 2.29).
None
start_server
(server)Starts a stopped server and changes its state to ACTIVE
.
server – Either the ID of a server or a
Server
instance.
None
stop_server
(server)Stops a running server and changes its state to SHUTOFF
.
server – Either the ID of a server or a
Server
instance.
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.
server – Either the ID of a server or a
Server
instance.
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.
server – Either the ID of a server or a
Server
instance.
None
get_server_console_output
(server, length=None)Return the console output for a server.
server – Either the ID of a server or a
Server
instance.
length – Optional number of line to fetch from the end of console log. All lines will be returned if this is not specified.
The console output as a dict. Control characters will be escaped to create a valid JSON string.
migrate_server
(server)Migrate a server from one host to another
server – Either the ID of a server or a
Server
instance.
None
live_migrate_server
(server, host=None, force=False, block_migration=None)Live migrate a server from one host to target host
server – Either the ID of a server or a
Server
instance.
host (str) – The host to which to migrate the server. If the Nova service is
too old, the host parameter implies force=True which causes the
Nova scheduler to be bypassed. On such clouds, a ValueError
will be thrown if host
is given without force
.
force (bool) – Force a live-migration by not verifying the provided destination host by the scheduler. This is unsafe and not recommended.
block_migration – Perform a block live migration to the destination host by the scheduler. Can be ‘auto’, True or False. Some clouds are too old to support ‘auto’, in which case a ValueError will be thrown. If omitted, the value will be ‘auto’ on clouds that support it, and False on clouds that do not.
None
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)change_server_password
(server, new_password)Change the administrator password
server – Either the ID of a server or a
Server
instance.
new_password (str) – The new password to be set.
None
get_server_password
(server)Get the administrator password
server – Either the ID of a server or a
Server
instance.
encrypted password.
reset_server_state
(server, state)Reset the state of server
server – The server can be either the ID of a server or a
Server
.
state – The state of the server to be set, active or error are valid.
None
rebuild_server
(server, name, admin_password, **attrs)Rebuild a server
server – Either the ID of a server or a
Server
instance.
name (str) – The name of the server
admin_password (str) – The administrator password
preserve_ephemeral (bool) – Indicates whether the server is rebuilt with the preservation of the ephemeral partition. Default: False
image (str) – The id of an image to rebuild with. Default: None
access_ipv4 (str) – The IPv4 address to rebuild with. Default: None
access_ipv6 (str) – The IPv6 address to rebuild with. Default: None
metadata (dict) – A dictionary of metadata to rebuild with. Default: None
personality – A list of dictionaries, each including a path and contents key, to be injected into the rebuilt server at launch. Default: None
The rebuilt Server
instance.
resize_server
(server, flavor)Resize a server
confirm_server_resize
(server)Confirm a server resize
server – Either the ID of a server or a
Server
instance.
None
revert_server_resize
(server)Revert a server resize
server – Either the ID of a server or a
Server
instance.
None
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)delete_image
(image, ignore_missing=True)Delete an image
image – The value can be either the ID of an image or a
Image
instance.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the image does not exist.
When set to True
, no exception will be set when
attempting to delete a nonexistent image.
None
find_image
(name_or_id, ignore_missing=True)Find a single image
name_or_id – The name or ID of a image.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the resource does not exist.
When set to True
, None will be returned when
attempting to find a nonexistent resource.
One Image
or None
get_image
(image)Get a single image
images
(details=True, **query)Return a generator of images
details (bool) – When True
, returns
Image
objects with all
available properties, otherwise only basic properties are returned.
Default: ``True``
query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
A generator of image objects
get_image_metadata
(image)Return a dictionary of metadata for an image
set_image_metadata
(image, **metadata)Update metadata for an image
image – Either the ID of an image or a
Image
instance.
metadata (kwargs) – Key/value pairs to be updated in the image’s metadata. No other metadata is modified by this call. All keys and values are stored as Unicode.
A Image
with only the
image’s metadata. All keys and values are Unicode text.
delete_image_metadata
(image, keys)Delete metadata for an image
Note: This method will do a HTTP DELETE request for every key in keys.
image – Either the ID of an image or a
Image
instance.
keys – The keys to delete.
None
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)find_flavor
(name_or_id, ignore_missing=True)Find a single flavor
name_or_id – The name or ID of a flavor.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the resource does not exist.
When set to True
, None will be returned when
attempting to find a nonexistent resource.
One Flavor
or None
create_flavor
(**attrs)Create a new flavor from attributes
delete_flavor
(flavor, ignore_missing=True)Delete a flavor
flavor – The value can be either the ID of a flavor or a
Flavor
instance.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the flavor does not exist.
When set to True
, no exception will be set when
attempting to delete a nonexistent flavor.
None
get_flavor
(flavor)Get a single flavor
flavors
(details=True, **query)Return a generator of flavors
details (bool) – When True
, returns
FlavorDetail
objects,
otherwise Flavor
.
Default: ``True``
query (kwargs) – Optional query parameters to be sent to limit the flavors being returned.
A generator of flavor objects
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)force_service_down
(service, host, binary)Force a service down
service – Either the ID of a service or a
Service
instance.
host (str) – The host where service runs.
binary (str) – The name of service.
None
disable_service
(service, host, binary, disabled_reason=None)Disable a service
service – Either the ID of a service or a
Service
instance.
host (str) – The host where service runs.
binary (str) – The name of service.
disabled_reason (str) – The reason of force down a service.
None
enable_service
(service, host, binary)Enable a service
service – Either the ID of a service or a
Service
instance.
host (str) – The host where service runs.
binary (str) – The name of service.
None
services
()Return a generator of service
A generator of service
class: ~openstack.compute.v2.service.Service
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)create_volume_attachment
(server, **attrs)Create a new volume attachment from attributes
server – The server can be either the ID of a server or a
Server
instance.
attrs (dict) – Keyword arguments which will be used to create a
VolumeAttachment
,
comprised of the properties on the VolumeAttachment class.
The results of volume attachment creation
VolumeAttachment
update_volume_attachment
(volume_attachment, server, **attrs)update a volume attachment
volume_attachment – The value can be either the ID of a volume attachment or a
VolumeAttachment
instance.
server – This parameter need to be specified when
VolumeAttachment ID is given as value. It can be
either the ID of a server or a
Server
instance that the attachment belongs to.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the volume attachment does not exist.
When set to True
, no exception will be set when
attempting to delete a nonexistent volume attachment.
None
delete_volume_attachment
(volume_attachment, server, ignore_missing=True)Delete a volume attachment
volume_attachment – The value can be either the ID of a volume attachment or a
VolumeAttachment
instance.
server – This parameter need to be specified when
VolumeAttachment ID is given as value. It can be either
the ID of a server or a
Server
instance that the attachment belongs to.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the volume attachment does not exist.
When set to True
, no exception will be set when
attempting to delete a nonexistent volume attachment.
None
get_volume_attachment
(volume_attachment, server, ignore_missing=True)Get a single volume attachment
volume_attachment – The value can be the ID of a volume attachment or a
VolumeAttachment
instance.
server – This parameter need to be specified when
VolumeAttachment ID is given as value. It can be either
the ID of a server or a
Server
instance that the attachment belongs to.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the volume attachment does not exist.
When set to True
, no exception will be set when
attempting to delete a nonexistent volume attachment.
One
VolumeAttachment
ResourceNotFound
when no resource can be found.
volume_attachments
(server)Return a generator of volume attachments
server – The server can be either the ID of a server or a
Server
.
A generator of VolumeAttachment objects
VolumeAttachment
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)create_keypair
(**attrs)Create a new keypair from attributes
delete_keypair
(keypair, ignore_missing=True)Delete a keypair
keypair – The value can be either the ID of a keypair or a
Keypair
instance.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the keypair does not exist.
When set to True
, no exception will be set when
attempting to delete a nonexistent keypair.
None
get_keypair
(keypair)Get a single keypair
find_keypair
(name_or_id, ignore_missing=True)Find a single keypair
name_or_id – The name or ID of a keypair.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the resource does not exist.
When set to True
, None will be returned when
attempting to find a nonexistent resource.
One Keypair
or None
keypairs
(**query)Return a generator of keypairs
query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
A generator of keypair objects
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)create_server_group
(**attrs)Create a new server group from attributes
attrs (dict) – Keyword arguments which will be used to create
a ServerGroup
,
comprised of the properties on the ServerGroup class.
The results of server group creation
ServerGroup
delete_server_group
(server_group, ignore_missing=True)Delete a server group
server_group – The value can be either the ID of a server group
or a ServerGroup
instance.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the server group does not exist.
When set to True
, no exception will be set when
attempting to delete a nonexistent server group.
None
find_server_group
(name_or_id, ignore_missing=True)Find a single server group
name_or_id – The name or ID of a server group.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the resource does not exist.
When set to True
, None will be returned when
attempting to find a nonexistent resource.
One ServerGroup
object
or None
get_server_group
(server_group)Get a single server group
server_group – The value can be the ID of a server group or a
ServerGroup
instance.
A ServerGroup
object.
ResourceNotFound
when no resource can be found.
server_groups
(**query)Return a generator of server groups
query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
A generator of ServerGroup objects
ServerGroup
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)create_server_interface
(server, **attrs)Create a new server interface from attributes
server – The server can be either the ID of a server or a
Server
instance
that the interface belongs to.
attrs (dict) – Keyword arguments which will be used to create
a ServerInterface
,
comprised of the properties on the ServerInterface class.
The results of server interface creation
delete_server_interface
(server_interface, server=None, ignore_missing=True)Delete a server interface
server_interface – The value can be either the ID of a server interface or a
ServerInterface
instance.
server – This parameter need to be specified when ServerInterface
ID is given as value. It can be either the ID of a
server or a Server
instance that the interface belongs to.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the server interface does not exist.
When set to True
, no exception will be set when
attempting to delete a nonexistent server interface.
None
get_server_interface
(server_interface, server=None)Get a single server interface
server_interface – The value can be the ID of a server interface or a
ServerInterface
instance.
server – This parameter need to be specified when ServerInterface
ID is given as value. It can be either the ID of a
server or a Server
instance that the interface belongs to.
One
ServerInterface
ResourceNotFound
when no resource can be found.
server_interfaces
(server)Return a generator of server interfaces
server – The server can be either the ID of a server or a
Server
.
A generator of ServerInterface objects
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)availability_zones
(details=False)Return a generator of availability zones
details (bool) – Return extra details about the availability zones. This defaults to False as it generally requires extra permission.
A generator of availability zone
AvailabilityZone
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)get_limits
()Retrieve limits that are applied to the project’s account
A Limits object, including both
AbsoluteLimits
and
RateLimits
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)hypervisors
(details=False, **query)Return a generator of hypervisor
details (bool) – When set to the default, False
,
Hypervisor
instances will be returned with only basic information populated.
query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
A generator of hypervisor
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
name_or_id – The name or id of a hypervisor
One: class:~openstack.compute.v2.hypervisor.Hypervisor object or None
get_hypervisor
(hypervisor)Get a single hypervisor
hypervisor – The value can be the ID of a hypervisor or a
Hypervisor
instance.
A Hypervisor
object.
ResourceNotFound
when no resource can be found.
openstack.compute.v2._proxy.
Proxy
(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)find_extension
(name_or_id, ignore_missing=True)Find a single extension
name_or_id – The name or ID of an extension.
ignore_missing (bool) – When set to False
ResourceNotFound
will be
raised when the resource does not exist.
When set to True
, None will be returned when
attempting to find a nonexistent resource.
One Extension
or
None
extensions
()Retrieve a generator of extensions
A generator of extension instances.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.