Handles all requests relating to compute resources (e.g. guest vms,
networking and storage of vms, and compute hosts on which they run).
-
class API(image_service=None, network_api=None, volume_api=None, security_group_api=None, **kwargs)
Bases: nova.db.base.Base
API for interacting with the compute manager.
-
add_fixed_ip(context, target, *args, **kwargs)
Add fixed_ip from specified network to given instance.
-
attach_volume(context, target, *args, **kwargs)
Attach an existing volume to an existing instance.
-
backup(context, target, *args, **kwargs)
Backup the given instance
Parameters: |
- instance – nova.db.sqlalchemy.models.Instance
- name – name of the backup or snapshot
name = backup_type # daily backups are called ‘daily’
- rotation – int representing how many backups to keep around;
None if rotation shouldn’t be used (as in the case of snapshots)
- extra_properties – dict of extra image properties to include
|
-
confirm_resize(context, target, *args, **kwargs)
Confirms a migration/resize and deletes the ‘old’ instance.
-
create(context, instance_type, image_href, kernel_id=None, ramdisk_id=None, min_count=None, max_count=None, display_name=None, display_description=None, key_name=None, key_data=None, security_group=None, availability_zone=None, user_data=None, metadata=None, injected_files=None, admin_password=None, block_device_mapping=None, access_ip_v4=None, access_ip_v6=None, requested_networks=None, config_drive=None, auto_disk_config=None, scheduler_hints=None)
Provision instances, sending instance information to the
scheduler. The scheduler will determine where the instance(s)
go and will handle creating the DB entries.
Returns a tuple of (instances, reservation_id) where instances
could be ‘None’ or a list of instance dicts depending on if
we waited for information from the scheduler or not.
-
create_db_entry_for_new_instance(context, instance_type, image, base_options, security_group, block_device_mapping, reservations)
Create an entry in the DB for this new instance,
including any related table updates (such as security group,
etc).
This is called by the scheduler after a location for the
instance has been determined.
-
delete(context, target, *args, **kwargs)
Terminate an instance.
-
delete_instance_metadata(context, target, *args, **kwargs)
Delete the given metadata item from an instance.
-
detach_volume(context, volume_id)
Detach a volume from an instance.
-
force_delete(context, target, *args, **kwargs)
Force delete a previously deleted (but not reclaimed) instance.
-
get(context, instance_id)
Get a single instance with the given instance_id.
-
get_active_by_window(context, begin, end=None, project_id=None)
Get instances that were continuously active over a window.
-
get_all(context, search_opts=None, sort_key='created_at', sort_dir='desc')
Get all instances filtered by one of the given parameters.
If there is no filter and the context is an admin, it will retrieve
all instances in the system.
Deleted instances will be returned by default, unless there is a
search option that says otherwise.
The results will be returned sorted in the order specified by the
‘sort_dir’ parameter using the key specified in the ‘sort_key’
parameter.
-
get_console_output(context, target, *args, **kwargs)
Get console output for an instance.
-
get_diagnostics(context, target, *args, **kwargs)
Retrieve diagnostics for the given instance.
-
get_instance_bdms(context, instance)
Get all bdm tables for specified instance.
-
get_instance_faults(context, instances)
Get all faults for a list of instance uuids.
-
get_instance_metadata(context, target, *args, **kwargs)
Get all metadata associated with an instance.
-
get_instance_type(context, instance_type_id)
Get an instance type by instance type id.
-
get_lock(context, target, *args, **kwargs)
Return the boolean state of given instance’s lock.
-
get_vnc_console(context, target, *args, **kwargs)
Get a url to an instance Console.
-
inject_file(context, target, *args, **kwargs)
Write a file to the given instance.
-
inject_network_info(context, target, *args, **kwargs)
Inject network info for the instance.
-
live_migrate(context, instance, *args, **kw)
Migrate a server lively to a new host.
-
lock(context, target, *args, **kwargs)
Lock the given instance.
-
pause(context, target, *args, **kwargs)
Pause the given instance.
-
reboot(context, target, *args, **kwargs)
Reboot the given instance.
-
rebuild(context, target, *args, **kwargs)
Rebuild the given instance with the provided attributes.
-
remove_fixed_ip(context, target, *args, **kwargs)
Remove fixed_ip from specified network to given instance.
-
rescue(context, target, *args, **kwargs)
Rescue the given instance.
-
reset_network(context, target, *args, **kwargs)
Reset networking on the instance.
-
resize(context, target, *args, **kwargs)
Resize (ie, migrate) a running instance.
If flavor_id is None, the process is considered a migration, keeping
the original flavor_id. If flavor_id is not None, the instance should
be migrated to a new host and resized to the new flavor_id.
-
restore(context, target, *args, **kwargs)
Restore a previously deleted (but not reclaimed) instance.
-
resume(context, target, *args, **kwargs)
Resume the given instance.
-
revert_resize(context, target, *args, **kwargs)
Reverts a resize, deleting the ‘new’ instance in the process.
-
set_admin_password(context, target, *args, **kwargs)
Set the root/admin password for the given instance.
-
snapshot(context, target, *args, **kwargs)
Snapshot the given instance.
Parameters: |
- instance – nova.db.sqlalchemy.models.Instance
- name – name of the backup or snapshot
- extra_properties – dict of extra image properties to include
|
Returns: | A dict containing image metadata
|
-
soft_delete(context, target, *args, **kwargs)
Terminate an instance.
-
start(context, target, *args, **kwargs)
Start an instance.
-
stop(context, target, *args, **kwargs)
Stop an instance.
-
suspend(context, target, *args, **kwargs)
Suspend the given instance.
-
trigger_provider_fw_rules_refresh(context)
Called when a rule is added/removed from a provider firewall
-
unlock(context, target, *args, **kwargs)
Unlock the given instance.
-
unpause(context, target, *args, **kwargs)
Unpause the given instance.
-
unrescue(context, target, *args, **kwargs)
Unrescue the given instance.
-
update(context, target, *args, **kwargs)
Updates the instance in the datastore.
Parameters: |
- context – The security context
- instance – The instance to update
- kwargs – All additional keyword args are treated
as data fields of the instance to be
updated
|
Returns: | None
|
-
update_instance_metadata(context, target, *args, **kwargs)
Updates or creates instance metadata.
If delete is True, metadata items that are not specified in the
metadata argument will be deleted.
-
class AggregateAPI(**kwargs)
Bases: nova.db.base.Base
Sub-set of the Compute Manager API for managing host aggregates.
-
add_host_to_aggregate(context, aggregate_id, host)
Adds the host to an aggregate.
-
create_aggregate(context, aggregate_name, availability_zone)
Creates the model for the aggregate.
-
delete_aggregate(context, aggregate_id)
Deletes the aggregate.
-
get_aggregate(context, aggregate_id)
Get an aggregate by id.
-
get_aggregate_list(context)
Get all the aggregates for this zone.
-
remove_host_from_aggregate(context, aggregate_id, host)
Removes host from the aggregate.
-
update_aggregate(context, aggregate_id, values)
Update the properties of an aggregate.
-
update_aggregate_metadata(context, aggregate_id, metadata)
Updates the aggregate metadata.
If a key is set to None, it gets removed from the aggregate metadata.
-
class HostAPI
Bases: nova.db.base.Base
-
host_power_action(context, host, action)
Reboots, shuts down or powers up the host.
-
set_host_enabled(context, host, enabled)
Sets the specified host’s ability to accept new instances.
-
set_host_maintenance(context, host, mode)
Start/Stop host maintenance window. On start, it triggers
guest VMs evacuation.
-
class KeypairAPI(**kwargs)
Bases: nova.db.base.Base
Sub-set of the Compute Manager API for managing key pairs.
-
create_key_pair(context, user_id, key_name)
Create a new key pair.
-
delete_key_pair(context, user_id, key_name)
Delete a keypair by name.
-
get_key_pairs(context, user_id)
List key pairs.
-
import_key_pair(context, user_id, key_name, public_key)
Import a key pair using an existing public key.
-
class SecurityGroupAPI(**kwargs)
Bases: nova.db.base.Base
Sub-set of the Compute API related to managing security groups
and security group rules
-
add_rules(context, id, name, vals)
-
add_to_instance(context, target, *args, **kwargs)
Add security group to the instance
-
create(context, name, description)
-
destroy(context, security_group)
-
ensure_default(context)
Ensure that a context has a security group.
Creates a security group for the security context if it does not
already exist.
Parameters: | context – the security context |
-
get(context, name=None, id=None, map_exception=False)
-
get_rule(context, id)
-
is_associated_with_server(security_group, instance_uuid)
Check if the security group is already associated
with the instance. If Yes, return True.
-
list(context, names=None, ids=None, project=None)
-
static new_cidr_ingress_rule(grantee_cidr, protocol, from_port, to_port)
-
static new_group_ingress_rule(grantee_group_id, protocol, from_port, to_port)
-
parse_cidr(cidr)
-
static raise_group_already_exists(msg)
-
static raise_invalid_cidr(cidr, decoding_exception=None)
-
static raise_invalid_group(msg)
-
static raise_invalid_property(msg)
-
static raise_not_found(msg)
-
static raise_over_quota(msg)
-
remove_from_instance(context, target, *args, **kwargs)
Remove the security group associated with the instance
-
remove_rules(context, security_group, rule_ids)
-
rule_exists(security_group, values)
Indicates whether the specified rule values are already
defined in the given security group.
-
trigger_handler(event, *args)
-
trigger_members_refresh(context, group_ids)
Called when a security group gains a new or loses a member.
Sends an update request to each compute node for whom this is
relevant.
-
trigger_rules_refresh(context, id)
Called when a rule is added to or removed from a security_group.
-
validate_property(value, property, allowed)
Validate given security group property.
Parameters: |
- value – the value to validate, as a string or unicode
- property – the property, either ‘name’ or ‘description’
- allowed – the range of characters allowed
|
-
check_instance_state(vm_state=None, task_state=(None, ))
Decorator to check VM and/or task state before entry to API functions.
If the instance is in the wrong state, the wrapper will raise an exception.
-
check_policy(context, action, target, scope='compute')
-
policy_decorator(scope)
Check corresponding policy prior of wrapped method to execution
-
wrap_check_policy(func)
-
wrap_check_security_groups_policy(func)