Handles all requests relating to instances (guest vms).
-
class nova.compute.api.API(image_service=None, network_api=None, volume_api=None, hostname_factory=<function generate_default_hostname at 0x933656c>, **kwargs)
Bases: nova.db.base.Base
API for interacting with the compute manager.
-
add_fixed_ip(*args, **kwargs)
-
add_network_to_project(context, project_id)
Force adds a network to the project.
-
add_security_group(context, instance_id, security_group_name)
Add security group to the instance
-
associate_floating_ip(context, instance_id, address)
Makes calls to network_api to associate_floating_ip.
Parameters: | address – is a string floating ip address |
-
attach_volume(context, instance_id, volume_id, device)
Attach an existing volume to an existing instance.
-
backup(*args, **kwargs)
-
confirm_resize(*args, **kwargs)
-
create(context, instance_type, image_href, kernel_id=None, ramdisk_id=None, min_count=None, max_count=None, display_name='', display_description='', key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata=None, injected_files=None, admin_password=None, zone_blob=None, reservation_id=None, block_device_mapping=None, access_ip_v4=None, access_ip_v6=None, requested_networks=None, config_drive=None)
Provision the instances by sending off a series of single
instance requests to the Schedulers. This is fine for trival
Scheduler drivers, but may remove the effectiveness of the
more complicated drivers.
NOTE: If you change this method, be sure to change
create_all_at_once() at the same time!
Returns a list of instance dicts.
-
create_all_at_once(context, instance_type, image_href, kernel_id=None, ramdisk_id=None, min_count=None, max_count=None, display_name='', display_description='', key_name=None, key_data=None, security_group='default', availability_zone=None, user_data=None, metadata=None, injected_files=None, admin_password=None, zone_blob=None, reservation_id=None, block_device_mapping=None, access_ip_v4=None, access_ip_v6=None, requested_networks=None, config_drive=None)
Provision the instances by passing the whole request to
the Scheduler for execution. Returns a Reservation ID
related to the creation of all of these instances.
-
create_db_entry_for_new_instance(context, instance_type, image, base_options, security_group, block_device_mapping, num=1)
Create an entry in the DB for this new instance,
including any related table updates (such as security group,
etc).
This will called by create() in the majority of situations,
but create_all_at_once() style Schedulers may initiate the call.
If you are changing this method, be sure to update both
call paths.
-
delete(*args, **kwargs)
-
delete_instance_metadata(context, instance_id, key)
Delete the given metadata item from an instance.
-
detach_volume(context, volume_id)
Detach a volume from an instance.
-
ensure_default_security_group(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, instance_id)
Get a single instance with the given instance_id.
-
get_actions(context, instance_id)
Retrieve actions for the given instance.
-
get_active_by_window(context, begin, end=None, project_id=None)
Get instances that were continuously active over a window.
-
get_ajax_console(context, instance_id)
Get a url to an AJAX Console.
-
get_all(context, search_opts=None)
Get all instances filtered by one of the given parameters.
If there is no filter and the context is an admin, it will retreive
all instances in the system.
-
get_console_output(context, instance_id)
Get console output for an an instance.
-
get_diagnostics(*args, **kwargs)
-
get_instance_metadata(context, instance_id)
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, instance_id)
Return the boolean state of given instance’s lock.
-
get_vnc_console(context, instance_id)
Get a url to a VNC Console.
-
has_finished_migration(context, instance_uuid)
Returns true if an instance has a finished migration.
-
host_power_action(context, host, action)
Reboots, shuts down or powers up the host.
-
inject_file(context, instance_id)
Write a file to the given instance.
-
inject_network_info(context, instance_id)
Inject network info for the instance.
-
lock(context, instance_id)
Lock the given instance.
-
pause(*args, **kwargs)
-
reboot(*args, **kwargs)
-
rebuild(*args, **kwargs)
-
remove_fixed_ip(*args, **kwargs)
-
remove_security_group(context, instance_id, security_group_name)
Remove the security group associated with the instance
-
rescue(*args, **kwargs)
-
reset_network(context, instance_id)
Reset networking on the instance.
-
resize(*args, **kwargs)
-
resume(*args, **kwargs)
-
revert_resize(*args, **kwargs)
-
routing_get(*args, **kwargs)
-
set_admin_password(*args, **kwargs)
-
set_host_enabled(context, host, enabled)
Sets the specified host’s ability to accept new instances.
-
snapshot(*args, **kwargs)
-
start(context, instance_id)
Start an instance.
-
stop(*args, **kwargs)
-
suspend(*args, **kwargs)
-
trigger_provider_fw_rules_refresh(context)
Called when a rule is added to or removed from a security_group
-
trigger_security_group_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_security_group_rules_refresh(context, security_group_id)
Called when a rule is added to or removed from a security_group.
-
unlock(context, instance_id)
Unlock the given instance.
-
unpause(*args, **kwargs)
-
unrescue(*args, **kwargs)
-
update(*args, **kwargs)
-
update_instance_metadata(context, instance_id, metadata, delete=False)
Updates or creates instance metadata.
If delete is True, metadata items that are not specified in the
metadata argument will be deleted.
-
nova.compute.api.generate_default_hostname(instance)
Default function to generate a hostname given an instance reference.