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.
Create a new server from attributes
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 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 a single server
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 a server
Create an image from a server
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
Return a dictionary of metadata for a server
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 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 (list) – The keys to delete. If left empty complete metadata will be removed.
None
Wait for a server to be in a particular status.
server (Server
:) – The Server
to wait
on to reach the specified status.
status (str) – 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.
Fetch security groups with details for a server.
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 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
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
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
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
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
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
Pauses a server and changes its status to PAUSED
.
server – Either the ID of a server or a
Server
instance.
None
Unpauses a paused server and changes its status to ACTIVE
.
server – Either the ID of a server or a
Server
instance.
None
Suspends a server and changes its status to SUSPENDED
.
server – Either the ID of a server or a
Server
instance.
None
Resumes a suspended server and changes its status to ACTIVE
.
server – Either the ID of a server or a
Server
instance.
None
Locks a server.
server – Either the ID of a server or a
Server
instance.
locked_reason – The reason behind locking the server. Limited to 255 characters in length.
None
Unlocks a locked server.
server – Either the ID of a server or a
Server
instance.
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
Unrescues a server and changes its status to ACTIVE
.
server – Either the ID of a server or a
Server
instance.
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
Starts a stopped server and changes its state to ACTIVE
.
server – Either the ID of a server or a
Server
instance.
None
Stops a running server and changes its state to SHUTOFF
.
server – Either the ID of a server or a
Server
instance.
None
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
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
Migrate a server from one host to another
server – Either the ID of a server or a
Server
instance.
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
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.
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 the administrator password
server – Either the ID of a server or a
Server
instance.
encrypted password.
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 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 a server
Confirm a server resize
server – Either the ID of a server or a
Server
instance.
None
Revert a server resize
server – Either the ID of a server or a
Server
instance.
None
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 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 a single image
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
Return a dictionary of metadata for an image
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 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 (list) – The keys to delete. If left empty complete metadata will be removed.
None
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.
get_extra_specs (bool) – When set to True
and extra_specs not
present in the response will invoke additional API call to fetch
extra_specs.
query (kwargs) – Optional query parameters to be sent to limit the flavors being returned.
One Flavor
or None
Create a new flavor from attributes
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 a single flavor
Return a generator of flavors
details (bool) – When True
, returns
Flavor
objects,
with additional attributes filled.
get_extra_specs (bool) – When set to True
and extra_specs not
present in the response will invoke additional API call to fetch
extra_specs.
query (kwargs) – Optional query parameters to be sent to limit the flavors being returned.
A generator of flavor objects
Adds tenant/project access to flavor.
Removes tenant/project access to flavor.
Lists tenants who have access to private flavor
flavor – Either the ID of a flavor or a
Flavor
instance.
List of dicts with flavor_id and tenant_id attributes.
Lists Extra Specs of a flavor
Lists Extra Specs of a flavor
Get specific Extra Spec property of a flavor
flavor – Either the ID of a flavor or a
Flavor
instance.
prop (str) – Property name.
String value of the requested property.
Update specific Extra Spec property of a flavor
flavor – Either the ID of a flavor or a
Flavor
instance.
prop (str) – Property name.
val (str) – Property value.
String value of the requested property.
Delete specific Extra Spec property of a flavor
flavor – Either the ID of a flavor or a
Flavor
instance.
prop (str) – Property name.
None
Update service forced_down information
service – Either the ID of a service or a
Service
instance.
host (str) – The host where service runs.
binary (str) – The name of service.
forced (bool) – Whether or not this service was forced down manually by an administrator after the service was fenced.
Updated service instance
class: ~openstack.compute.v2.service.Service
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.
Updated service instance
class: ~openstack.compute.v2.service.Service
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.
Updated service instance
class: ~openstack.compute.v2.service.Service
Return a generator of service
Query parameters
A generator of service
class: ~openstack.compute.v2.service.Service
Find a service from name or id to get the corresponding info
name_or_id – The name or id of a service
attrs (dict) – Additional attributes like ‘host’
One: class:~openstack.compute.v2.hypervisor.Hypervisor object or None
Delete a service
service – The value can be either the ID of a service or a
Service
instance.
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
Update a service
service – Either the ID of a service or a
Service
instance.
attrs – The attributes to update on the service represented
by service
.
The updated service
Service
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 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 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 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.
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
Create a new keypair from attributes
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.
user_id (str) – Optional user_id owning the keypair
None
Get a single keypair
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.
user_id (str) – Optional user_id owning the keypair
One Keypair
or None
Return a generator of keypairs
query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
A generator of keypair objects
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 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 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 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.
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
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 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 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.
Return a generator of server interfaces
server – The server can be either the ID of a server or a
Server
.
query – Optional query parameters to be sent to limit the resources being returned.
A generator of ServerInterface objects
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
Retrieve limits that are applied to the project’s account
A Limits object, including both
AbsoluteLimits
and
RateLimits
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 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 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.
Get uptime information for 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.
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
Retrieve a generator of extensions
A generator of extension instances.
Show QuotaSet information for the project
project – ID or instance of
Project
of the project for
which the quota should be retrieved
usage (bool) – When set to True
quota usage and reservations
would be filled.
query (dict) – Additional query parameters to use.
One QuotaSet
ResourceNotFound
when no resource can be found.
Show QuotaSet defaults for the project
project – ID or instance of
Project
of the project for
which the quota should be retrieved
One QuotaSet
ResourceNotFound
when no resource can be found.
Reset Quota for the project/user.
project – ID or instance of
Project
of the project for
which the quota should be resetted.
query (dict) – Additional parameters to be used.
None
Update a QuotaSet.
Abort an in-progress server migration
server_migration – The value can be either the ID of a server
migration or a
ServerMigration
instance.
server – This parameter needs to be specified when
ServerMigration ID is given as value. It can be either the ID of a
server or a Server
instance
that the migration 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
Force complete an in-progress server migration
server_migration – The value can be either the ID of a server
migration or a
ServerMigration
instance.
server – This parameter needs to be specified when
ServerMigration ID is given as value. It can be either the ID of a
server or a Server
instance
that the migration belongs to.
None
Get a single volume attachment
server_migration – The value can be the ID of a server migration
or a
ServerMigration
instance.
server – This parameter need to be specified when ServerMigration
ID is given as value. It can be either the ID of a server or a
Server
instance that the
migration belongs to.
ignore_missing (bool) – When set to False
ResourceNotFound
will be raised when
the server migration does not exist. When set to True
, no
exception will be set when attempting to delete a nonexistent
server migration.
One
ServerMigration
ResourceNotFound
when no resource can be found.
Return a generator of migrations for a server.
server – The server can be either the ID of a server or a
Server
.
A generator of ServerMigration objects
Return a generator of migrations for all servers.
A generator of Migration objects
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.