Table Of Contents

Previous topic

Services, Managers and Drivers

Next topic

Storage Volumes, Disks

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

The Database Layer

The nova.db.api Module

Defines interface for DB access.

The underlying driver is loaded as a LazyPluggable.

Related Flags

db_backend:string to lookup in the list of LazyPluggable backends. sqlalchemy is the only supported backend right now.
sql_connection:string specifying the sqlalchemy connection to use, like: sqlite:///var/lib/nova/nova.sqlite.
enable_new_services:
 when adding a new service to the database, is it in the pool of available hardware (Default: True)
exception nova.db.api.NoMoreBlades(message=None)

Bases: nova.exception.Error

No more available blades.

exception nova.db.api.NoMoreNetworks(message=None)

Bases: nova.exception.Error

No more available networks.

exception nova.db.api.NoMoreTargets(message=None)

Bases: nova.exception.Error

No more available blades

nova.db.api.agent_build_create(context, values)

Create a new agent build entry.

nova.db.api.agent_build_destroy(context, agent_update_id)

Destroy agent build entry.

nova.db.api.agent_build_get_all(context)

Get all agent builds.

nova.db.api.agent_build_get_by_triple(context, hypervisor, os, architecture)

Get agent build by hypervisor/OS/architecture triple.

nova.db.api.agent_build_update(context, agent_build_id, values)

Update agent build entry.

nova.db.api.auth_token_create(context, token)

Creates a new token.

nova.db.api.auth_token_destroy(context, token_id)

Destroy an auth token.

nova.db.api.auth_token_get(context, token_hash)

Retrieves a token given the hash representing it.

nova.db.api.auth_token_update(context, token_hash, values)

Updates a token given the hash representing it.

nova.db.api.block_device_mapping_create(context, values)

Create an entry of block device mapping

nova.db.api.block_device_mapping_destroy(context, bdm_id)

Destroy the block device mapping.

nova.db.api.block_device_mapping_destroy_by_instance_and_volume(context, instance_id, volume_id)

Destroy the block device mapping or raise if it does not exist.

nova.db.api.block_device_mapping_get_all_by_instance(context, instance_id)

Get all block device mapping belonging to a instance

nova.db.api.block_device_mapping_update(context, bdm_id, values)

Update an entry of block device mapping

nova.db.api.block_device_mapping_update_or_create(context, values)

Update an entry of block device mapping. If not existed, create a new entry

nova.db.api.certificate_create(context, values)

Create a certificate from the values dictionary.

nova.db.api.certificate_destroy(context, certificate_id)

Destroy the certificate or raise if it does not exist.

nova.db.api.certificate_get_all_by_project(context, project_id)

Get all certificates for a project.

nova.db.api.certificate_get_all_by_user(context, user_id)

Get all certificates for a user.

nova.db.api.certificate_get_all_by_user_and_project(context, user_id, project_id)

Get all certificates for a user and project.

nova.db.api.certificate_update(context, certificate_id, values)

Set the given properties on an certificate and update it.

Raises NotFound if service does not exist.

nova.db.api.compute_node_create(context, values)

Create a computeNode from the values dictionary.

nova.db.api.compute_node_get(context, compute_id, session=None)

Get an computeNode or raise if it does not exist.

nova.db.api.compute_node_update(context, compute_id, values)

Set the given properties on an computeNode and update it.

Raises NotFound if computeNode does not exist.

nova.db.api.console_create(context, values)

Create a console.

nova.db.api.console_delete(context, console_id)

Delete a console.

nova.db.api.console_get(context, console_id, instance_id=None)

Get a specific console (possibly on a given instance).

nova.db.api.console_get_all_by_instance(context, instance_id)

Get consoles for a given instance.

nova.db.api.console_get_by_pool_instance(context, pool_id, instance_id)

Get console entry for a given instance and pool.

nova.db.api.console_pool_create(context, values)

Create console pool.

nova.db.api.console_pool_get(context, pool_id)

Get a console pool.

nova.db.api.console_pool_get_all_by_host_type(context, host, console_type)

Fetch all pools for given proxy host and type.

nova.db.api.console_pool_get_by_host_type(context, compute_host, proxy_host, console_type)

Fetch a console pool for a given proxy host, compute host, and type.

nova.db.api.export_device_count(context)

Return count of export devices.

nova.db.api.export_device_create_safe(context, values)

Create an export_device from the values dictionary.

The device is not returned. If the create violates the unique constraints because the shelf_id and blade_id already exist, no exception is raised.

nova.db.api.fixed_ip_associate(context, address, instance_id, network_id=None, reserved=False)

Associate fixed ip to instance.

Raises if fixed ip is not available.

nova.db.api.fixed_ip_associate_pool(context, network_id, instance_id=None, host=None)

Find free ip in network and associate it to instance or host.

Raises if one is not available.

nova.db.api.fixed_ip_count_by_project(context, project_id, session=None)

Count fixed ips used by project.

nova.db.api.fixed_ip_create(context, values)

Create a fixed ip from the values dictionary.

nova.db.api.fixed_ip_disassociate(context, address)

Disassociate a fixed ip from an instance by address.

nova.db.api.fixed_ip_disassociate_all_by_timeout(context, host, time)

Disassociate old fixed ips from host.

nova.db.api.fixed_ip_get_all(context)

Get all defined fixed ips.

nova.db.api.fixed_ip_get_all_by_instance_host(context, host)

Get all allocated fixed ips filtered by instance host.

nova.db.api.fixed_ip_get_by_address(context, address)

Get a fixed ip by address or raise if it does not exist.

nova.db.api.fixed_ip_get_by_instance(context, instance_id)

Get fixed ips by instance or raise if none exist.

nova.db.api.fixed_ip_get_by_network_host(context, network_id, host)

Get fixed ip for a host in a network.

nova.db.api.fixed_ip_get_by_virtual_interface(context, vif_id)

Get fixed ips by virtual interface or raise if none exist.

nova.db.api.fixed_ip_get_network(context, address)

Get a network for a fixed ip by address.

nova.db.api.fixed_ip_update(context, address, values)

Create a fixed ip from the values dictionary.

nova.db.api.floating_ip_allocate_address(context, project_id)

Allocate free floating ip and return the address.

Raises if one is not available.

nova.db.api.floating_ip_count_by_project(context, project_id)

Count floating ips used by project.

nova.db.api.floating_ip_create(context, values)

Create a floating ip from the values dictionary.

nova.db.api.floating_ip_deallocate(context, address)

Deallocate an floating ip by address.

nova.db.api.floating_ip_destroy(context, address)

Destroy the floating_ip or raise if it does not exist.

nova.db.api.floating_ip_disassociate(context, address)

Disassociate an floating ip from a fixed ip by address.

Returns:the address of the existing fixed ip.
nova.db.api.floating_ip_fixed_ip_associate(context, floating_address, fixed_address, host)

Associate an floating ip to a fixed_ip by address.

nova.db.api.floating_ip_get(context, id)
nova.db.api.floating_ip_get_all(context)

Get all floating ips.

nova.db.api.floating_ip_get_all_by_host(context, host)

Get all floating ips by host.

nova.db.api.floating_ip_get_all_by_project(context, project_id)

Get all floating ips by project.

nova.db.api.floating_ip_get_by_address(context, address)

Get a floating ip by address or raise if it doesn’t exist.

nova.db.api.floating_ip_set_auto_assigned(context, address)

Set auto_assigned flag to floating ip

nova.db.api.floating_ip_update(context, address, values)

Update a floating ip by address or raise if it doesn’t exist.

nova.db.api.instance_action_create(context, values)

Create an instance action from the values dictionary.

nova.db.api.instance_add_security_group(context, instance_id, security_group_id)

Associate the given security group with the given instance.

nova.db.api.instance_create(context, values)

Create an instance from the values dictionary.

nova.db.api.instance_data_get_for_project(context, project_id)

Get (instance_count, total_cores, total_ram) for project.

nova.db.api.instance_destroy(context, instance_id)

Destroy the instance or raise if it does not exist.

nova.db.api.instance_get(context, instance_id)

Get an instance or raise if it does not exist.

nova.db.api.instance_get_actions(context, instance_id)

Get instance actions by instance id.

nova.db.api.instance_get_active_by_window(context, begin, end=None, project_id=None)

Get instances active during a certain time window.

Specifying a project_id will filter for a certain project.

nova.db.api.instance_get_active_by_window_joined(context, begin, end=None, project_id=None)

Get instances and joins active during a certain time window.

Specifying a project_id will filter for a certain project.

nova.db.api.instance_get_all(context)

Get all instances.

nova.db.api.instance_get_all_by_filters(context, filters)

Get all instances that match all filters.

nova.db.api.instance_get_all_by_host(context, host)

Get all instance belonging to a host.

nova.db.api.instance_get_all_by_project(context, project_id)

Get all instance belonging to a project.

nova.db.api.instance_get_all_by_reservation(context, reservation_id)

Get all instances belonging to a reservation.

nova.db.api.instance_get_all_by_user(context, user_id)

Get all instances.

nova.db.api.instance_get_by_fixed_ip(context, address)

Get an instance for a fixed ip by address.

nova.db.api.instance_get_by_fixed_ipv6(context, address)

Get an instance for a fixed ip by IPv6 address.

nova.db.api.instance_get_by_uuid(context, uuid)

Get an instance or raise if it does not exist.

nova.db.api.instance_get_fixed_addresses(context, instance_id)

Get the fixed ip address of an instance.

nova.db.api.instance_get_fixed_addresses_v6(context, instance_id)
nova.db.api.instance_get_floating_address(context, instance_id)

Get the first floating ip address of an instance.

nova.db.api.instance_get_project_vpn(context, project_id)

Get a vpn instance by project or return None.

nova.db.api.instance_metadata_delete(context, instance_id, key)

Delete the given metadata item.

nova.db.api.instance_metadata_get(context, instance_id)

Get all metadata for an instance.

nova.db.api.instance_metadata_update(context, instance_id, metadata, delete)

Update metadata if it exists, otherwise create it.

nova.db.api.instance_remove_security_group(context, instance_id, security_group_id)

Disassociate the given security group from the given instance.

nova.db.api.instance_set_state(context, instance_id, state, description=None)

Set the state of an instance.

nova.db.api.instance_stop(context, instance_id)

Stop the instance or raise if it does not exist.

nova.db.api.instance_type_create(context, values)

Create a new instance type.

nova.db.api.instance_type_destroy(context, name)

Delete a instance type.

nova.db.api.instance_type_extra_specs_delete(context, instance_type_id, key)

Delete the given extra specs item.

nova.db.api.instance_type_extra_specs_get(context, instance_type_id)

Get all extra specs for an instance type.

nova.db.api.instance_type_extra_specs_update_or_create(context, instance_type_id, extra_specs)

Create or update instance type extra specs. This adds or modifies the key/value pairs specified in the extra specs dict argument

nova.db.api.instance_type_get(context, id)

Get instance type by id.

nova.db.api.instance_type_get_all(context, inactive=False)

Get all instance types.

nova.db.api.instance_type_get_by_flavor_id(context, id)

Get instance type by name.

nova.db.api.instance_type_get_by_name(context, name)

Get instance type by name.

nova.db.api.instance_type_purge(context, name)

Purges (removes) an instance type from DB.

Use instance_type_destroy for most cases

nova.db.api.instance_update(context, instance_id, values)

Set the given properties on an instance and update it.

Raises NotFound if instance does not exist.

nova.db.api.iscsi_target_count_by_host(context, host)

Return count of export devices.

nova.db.api.iscsi_target_create_safe(context, values)

Create an iscsi_target from the values dictionary.

The device is not returned. If the create violates the unique constraints because the iscsi_target and host already exist, no exception is raised.

nova.db.api.key_pair_create(context, values)

Create a key_pair from the values dictionary.

nova.db.api.key_pair_destroy(context, user_id, name)

Destroy the key_pair or raise if it does not exist.

nova.db.api.key_pair_destroy_all_by_user(context, user_id)

Destroy all key_pairs by user.

nova.db.api.key_pair_get(context, user_id, name)

Get a key_pair or raise if it does not exist.

nova.db.api.key_pair_get_all_by_user(context, user_id)

Get all key_pairs by user.

nova.db.api.migration_create(context, values)

Create a migration record.

nova.db.api.migration_get(context, migration_id)

Finds a migration by the id.

nova.db.api.migration_get_by_instance_and_status(context, instance_uuid, status)

Finds a migration by the instance uuid its migrating.

nova.db.api.migration_update(context, id, values)

Update a migration instance.

nova.db.api.network_associate(context, project_id, force=False)

Associate a free network to a project.

nova.db.api.network_count(context)

Return the number of networks.

nova.db.api.network_count_allocated_ips(context, network_id)

Return the number of allocated non-reserved ips in the network.

nova.db.api.network_count_available_ips(context, network_id)

Return the number of available ips in the network.

nova.db.api.network_count_reserved_ips(context, network_id)

Return the number of reserved ips in the network.

nova.db.api.network_create_fixed_ips(context, network_id, num_vpn_clients)

Create the ips for the network, reserving sepecified ips.

nova.db.api.network_create_safe(context, values)

Create a network from the values dict.

The network is only returned if the create succeeds. If the create violates constraints because the network already exists, no exception is raised.

nova.db.api.network_delete_safe(context, network_id)

Delete network with key network_id.

This method assumes that the network is not associated with any project

nova.db.api.network_disassociate(context, network_id)

Disassociate the network from project or raise if it does not exist.

nova.db.api.network_disassociate_all(context)

Disassociate all networks from projects.

nova.db.api.network_get(context, network_id)

Get an network or raise if it does not exist.

nova.db.api.network_get_all(context)

Return all defined networks.

nova.db.api.network_get_all_by_host(context, host)

All networks for which the given host is the network host.

nova.db.api.network_get_all_by_instance(context, instance_id)

Get all networks by instance id or raise if none exist.

nova.db.api.network_get_all_by_uuids(context, network_uuids, project_id=None)

Return networks by ids.

nova.db.api.network_get_associated_fixed_ips(context, network_id)

Get all network’s ips that have been associated.

nova.db.api.network_get_by_bridge(context, bridge)

Get a network by bridge or raise if it does not exist.

nova.db.api.network_get_by_cidr(context, cidr)

Get a network by cidr or raise if it does not exist

nova.db.api.network_get_by_instance(context, instance_id)

Get a network by instance id or raise if it does not exist.

nova.db.api.network_get_by_uuid(context, uuid)

Get a network by uuid or raise if it does not exist.

nova.db.api.network_get_index(context, network_id)

Get non-conflicting index for network.

nova.db.api.network_get_vpn_ip(context, network_id)

Get non-conflicting index for network.

nova.db.api.network_set_cidr(context, network_id, cidr)

Set the Classless Inner Domain Routing for the network.

nova.db.api.network_set_host(context, network_id, host_id)

Safely set the host for network.

nova.db.api.network_update(context, network_id, values)

Set the given properties on an network and update it.

Raises NotFound if network does not exist.

nova.db.api.project_add_member(context, project_id, user_id)

Add user to project.

nova.db.api.project_create(context, values)

Create a new project.

nova.db.api.project_delete(context, project_id)

Delete project.

nova.db.api.project_get(context, id)

Get project by id.

nova.db.api.project_get_all(context)

Get all projects.

nova.db.api.project_get_by_user(context, user_id)

Get all projects of which the given user is a member.

nova.db.api.project_get_networks(context, project_id, associate=True)

Return the network associated with the project.

If associate is true, it will attempt to associate a new network if one is not found, otherwise it returns None.

nova.db.api.project_get_networks_v6(context, project_id)
nova.db.api.project_remove_member(context, project_id, user_id)

Remove the given user from the given project.

nova.db.api.project_update(context, project_id, values)

Update Remove the given user from the given project.

nova.db.api.provider_fw_rule_create(context, rule)

Add a firewall rule at the provider level (all hosts & instances).

nova.db.api.provider_fw_rule_destroy(context, rule_id)

Delete a provider firewall rule from the database.

nova.db.api.provider_fw_rule_get_all(context)

Get all provider-level firewall rules.

nova.db.api.provider_fw_rule_get_all_by_cidr(context, cidr)

Get all provider-level firewall rules.

nova.db.api.queue_get_for(context, topic, physical_node_id)

Return a channel to send a message to a node with a topic.

nova.db.api.quota_create(context, project_id, resource, limit)

Create a quota for the given project and resource.

nova.db.api.quota_destroy(context, project_id, resource)

Destroy the quota or raise if it does not exist.

nova.db.api.quota_destroy_all_by_project(context, project_id)

Destroy all quotas associated with a given project.

nova.db.api.quota_get(context, project_id, resource)

Retrieve a quota or raise if it does not exist.

nova.db.api.quota_get_all_by_project(context, project_id)

Retrieve all quotas associated with a given project.

nova.db.api.quota_update(context, project_id, resource, limit)

Update a quota or raise if it does not exist.

nova.db.api.security_group_count_by_project(context, project_id)

Count number of security groups in a project.

nova.db.api.security_group_create(context, values)

Create a new security group.

nova.db.api.security_group_destroy(context, security_group_id)

Deletes a security group.

nova.db.api.security_group_destroy_all(context)

Deletes a security group.

nova.db.api.security_group_exists(context, project_id, group_name)

Indicates if a group name exists in a project.

nova.db.api.security_group_get(context, security_group_id)

Get security group by its id.

nova.db.api.security_group_get_all(context)

Get all security groups.

nova.db.api.security_group_get_by_instance(context, instance_id)

Get security groups to which the instance is assigned.

nova.db.api.security_group_get_by_name(context, project_id, group_name)

Returns a security group with the specified name from a project.

nova.db.api.security_group_get_by_project(context, project_id)

Get all security groups belonging to a project.

nova.db.api.security_group_rule_count_by_group(context, security_group_id)

Count rules in a given security group.

nova.db.api.security_group_rule_create(context, values)

Create a new security group.

nova.db.api.security_group_rule_destroy(context, security_group_rule_id)

Deletes a security group rule.

nova.db.api.security_group_rule_get(context, security_group_rule_id)

Gets a security group rule.

nova.db.api.security_group_rule_get_by_security_group(context, security_group_id)

Get all rules for a a given security group.

nova.db.api.security_group_rule_get_by_security_group_grantee(context, security_group_id)

Get all rules that grant access to the given security group.

nova.db.api.service_create(context, values)

Create a service from the values dictionary.

nova.db.api.service_destroy(context, instance_id)

Destroy the service or raise if it does not exist.

nova.db.api.service_get(context, service_id)

Get a service or raise if it does not exist.

nova.db.api.service_get_all(context, disabled=None)

Get all services.

nova.db.api.service_get_all_by_host(context, host)

Get all services for a given host.

nova.db.api.service_get_all_by_topic(context, topic)

Get all services for a given topic.

nova.db.api.service_get_all_compute_by_host(context, host)

Get all compute services for a given host.

nova.db.api.service_get_all_compute_sorted(context)

Get all compute services sorted by instance count.

Returns:a list of (Service, instance_count) tuples.
nova.db.api.service_get_all_network_sorted(context)

Get all network services sorted by network count.

Returns:a list of (Service, network_count) tuples.
nova.db.api.service_get_all_volume_sorted(context)

Get all volume services sorted by volume count.

Returns:a list of (Service, volume_count) tuples.
nova.db.api.service_get_by_args(context, host, binary)

Get the state of an service by node name and binary.

nova.db.api.service_get_by_host_and_topic(context, host, topic)

Get a service by host it’s on and topic it listens to.

nova.db.api.service_update(context, service_id, values)

Set the given properties on an service and update it.

Raises NotFound if service does not exist.

nova.db.api.snapshot_create(context, values)

Create a snapshot from the values dictionary.

nova.db.api.snapshot_destroy(context, snapshot_id)

Destroy the snapshot or raise if it does not exist.

nova.db.api.snapshot_get(context, snapshot_id)

Get a snapshot or raise if it does not exist.

nova.db.api.snapshot_get_all(context)

Get all snapshots.

nova.db.api.snapshot_get_all_by_project(context, project_id)

Get all snapshots belonging to a project.

nova.db.api.snapshot_update(context, snapshot_id, values)

Set the given properties on an snapshot and update it.

Raises NotFound if snapshot does not exist.

nova.db.api.user_add_project_role(context, user_id, project_id, role)

Add project role for user.

nova.db.api.user_add_role(context, user_id, role)

Add another global role for user.

nova.db.api.user_create(context, values)

Create a new user.

nova.db.api.user_delete(context, id)

Delete a user.

nova.db.api.user_get(context, id)

Get user by id.

nova.db.api.user_get_all(context)

Create a new user.

nova.db.api.user_get_by_access_key(context, access_key)

Get user by access key.

nova.db.api.user_get_by_uid(context, uid)

Get user by uid.

nova.db.api.user_get_roles(context, user_id)

Get global roles for user.

nova.db.api.user_get_roles_for_project(context, user_id, project_id)

Return list of roles a user holds on project.

nova.db.api.user_remove_project_role(context, user_id, project_id, role)

Remove project role from user.

nova.db.api.user_remove_role(context, user_id, role)

Remove global role from user.

nova.db.api.user_update(context, user_id, values)

Update user.

nova.db.api.virtual_interface_create(context, values)

Create a virtual interface record in the database.

nova.db.api.virtual_interface_delete(context, vif_id)

Delete virtual interface record from the database.

nova.db.api.virtual_interface_delete_by_instance(context, instance_id)

Delete virtual interface records associated with instance.

nova.db.api.virtual_interface_get(context, vif_id)

Gets a virtual interface from the table,

nova.db.api.virtual_interface_get_by_address(context, address)

Gets a virtual interface from the table filtering on address.

nova.db.api.virtual_interface_get_by_fixed_ip(context, fixed_ip_id)

Gets the virtual interface fixed_ip is associated with.

nova.db.api.virtual_interface_get_by_instance(context, instance_id)

Gets all virtual_interfaces for instance.

nova.db.api.virtual_interface_get_by_instance_and_network(context, instance_id, network_id)

Gets all virtual interfaces for instance.

nova.db.api.virtual_interface_get_by_network(context, network_id)

Gets all virtual interfaces on network.

nova.db.api.virtual_interface_get_by_uuid(context, vif_uuid)

Gets a virtual interface from the table filtering on vif uuid.

nova.db.api.virtual_interface_update(context, vif_id, values)

Update a virtual interface record in the database.

nova.db.api.volume_allocate_iscsi_target(context, volume_id, host)

Atomically allocate a free iscsi_target from the pool.

nova.db.api.volume_allocate_shelf_and_blade(context, volume_id)

Atomically allocate a free shelf and blade from the pool.

nova.db.api.volume_attached(context, volume_id, instance_id, mountpoint)

Ensure that a volume is set as attached.

nova.db.api.volume_create(context, values)

Create a volume from the values dictionary.

nova.db.api.volume_data_get_for_project(context, project_id)

Get (volume_count, gigabytes) for project.

nova.db.api.volume_destroy(context, volume_id)

Destroy the volume or raise if it does not exist.

nova.db.api.volume_detached(context, volume_id)

Ensure that a volume is set as detached.

nova.db.api.volume_get(context, volume_id)

Get a volume or raise if it does not exist.

nova.db.api.volume_get_all(context)

Get all volumes.

nova.db.api.volume_get_all_by_host(context, host)

Get all volumes belonging to a host.

nova.db.api.volume_get_all_by_instance(context, instance_id)

Get all volumes belonging to a instance.

nova.db.api.volume_get_all_by_project(context, project_id)

Get all volumes belonging to a project.

nova.db.api.volume_get_by_ec2_id(context, ec2_id)

Get a volume by ec2 id.

nova.db.api.volume_get_instance(context, volume_id)

Get the instance that a volume is attached to.

nova.db.api.volume_get_iscsi_target_num(context, volume_id)

Get the target num (tid) allocated to the volume.

nova.db.api.volume_get_shelf_and_blade(context, volume_id)

Get the shelf and blade allocated to the volume.

nova.db.api.volume_metadata_delete(context, volume_id, key)

Delete the given metadata item.

nova.db.api.volume_metadata_get(context, volume_id)

Get all metadata for a volume.

nova.db.api.volume_metadata_update(context, volume_id, metadata, delete)

Update metadata if it exists, otherwise create it.

nova.db.api.volume_type_create(context, values)

Create a new volume type.

nova.db.api.volume_type_destroy(context, name)

Delete a volume type.

nova.db.api.volume_type_extra_specs_delete(context, volume_type_id, key)

Delete the given extra specs item.

nova.db.api.volume_type_extra_specs_get(context, volume_type_id)

Get all extra specs for a volume type.

nova.db.api.volume_type_extra_specs_update_or_create(context, volume_type_id, extra_specs)

Create or update volume type extra specs. This adds or modifies the key/value pairs specified in the extra specs dict argument

nova.db.api.volume_type_get(context, id)

Get volume type by id.

nova.db.api.volume_type_get_all(context, inactive=False)

Get all volume types.

nova.db.api.volume_type_get_by_name(context, name)

Get volume type by name.

nova.db.api.volume_type_purge(context, name)

Purges (removes) a volume type from DB.

Use volume_type_destroy for most cases

nova.db.api.volume_update(context, volume_id, values)

Set the given properties on an volume and update it.

Raises NotFound if volume does not exist.

nova.db.api.vsa_create(context, values)

Creates Virtual Storage Array record.

nova.db.api.vsa_destroy(context, vsa_id)

Deletes Virtual Storage Array record.

nova.db.api.vsa_get(context, vsa_id)

Get Virtual Storage Array record by ID.

nova.db.api.vsa_get_all(context)

Get all Virtual Storage Array records.

nova.db.api.vsa_get_all_by_project(context, project_id)

Get all Virtual Storage Array records by project ID.

nova.db.api.vsa_update(context, vsa_id, values)

Updates Virtual Storage Array record.

nova.db.api.zone_create(context, values)

Create a new child Zone entry.

nova.db.api.zone_delete(context, zone_id)

Delete a child Zone.

nova.db.api.zone_get(context, zone_id)

Get a specific child Zone.

nova.db.api.zone_get_all(context)

Get all child Zones.

nova.db.api.zone_update(context, zone_id, values)

Update a child Zone entry.

The Sqlalchemy Driver

The nova.db.sqlalchemy.api Module

Implementation of SQLAlchemy backend.

The nova.db.sqlalchemy.models Module

SQLAlchemy models for nova data.

class nova.db.sqlalchemy.models.AgentBuild(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents an agent build.

AgentBuild.architecture
AgentBuild.created_at
AgentBuild.deleted
AgentBuild.deleted_at
AgentBuild.hypervisor
AgentBuild.id
AgentBuild.md5hash
AgentBuild.os
AgentBuild.updated_at
AgentBuild.url
AgentBuild.version
class nova.db.sqlalchemy.models.AuthToken(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents an authorization token for all API transactions.

Fields are a string representing the actual token and a user id for mapping to the actual user

AuthToken.cdn_management_url
AuthToken.created_at
AuthToken.deleted
AuthToken.deleted_at
AuthToken.server_management_url
AuthToken.storage_url
AuthToken.token_hash
AuthToken.updated_at
AuthToken.user_id
class nova.db.sqlalchemy.models.BlockDeviceMapping(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents block device mapping that is defined by EC2

BlockDeviceMapping.created_at
BlockDeviceMapping.delete_on_termination
BlockDeviceMapping.deleted
BlockDeviceMapping.deleted_at
BlockDeviceMapping.device_name
BlockDeviceMapping.id
BlockDeviceMapping.instance
BlockDeviceMapping.instance_id
BlockDeviceMapping.no_device
BlockDeviceMapping.snapshot
BlockDeviceMapping.snapshot_id
BlockDeviceMapping.updated_at
BlockDeviceMapping.virtual_name
BlockDeviceMapping.volume
BlockDeviceMapping.volume_id
BlockDeviceMapping.volume_size
class nova.db.sqlalchemy.models.Certificate(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a an x509 certificate

Certificate.created_at
Certificate.deleted
Certificate.deleted_at
Certificate.file_name
Certificate.id
Certificate.project_id
Certificate.updated_at
Certificate.user_id
class nova.db.sqlalchemy.models.ComputeNode(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a running compute service on a host.

ComputeNode.cpu_info
ComputeNode.created_at
ComputeNode.deleted
ComputeNode.deleted_at
ComputeNode.hypervisor_type
ComputeNode.hypervisor_version
ComputeNode.id
ComputeNode.local_gb
ComputeNode.local_gb_used
ComputeNode.memory_mb
ComputeNode.memory_mb_used
ComputeNode.service
ComputeNode.service_id
ComputeNode.updated_at
ComputeNode.vcpus
ComputeNode.vcpus_used
class nova.db.sqlalchemy.models.Console(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a console session for an instance.

Console.created_at
Console.deleted
Console.deleted_at
Console.id
Console.instance_id
Console.instance_name
Console.password
Console.pool
Console.pool_id
Console.port
Console.updated_at
class nova.db.sqlalchemy.models.ConsolePool(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents pool of consoles on the same physical node.

ConsolePool.address
ConsolePool.compute_host
ConsolePool.console_type
ConsolePool.created_at
ConsolePool.deleted
ConsolePool.deleted_at
ConsolePool.host
ConsolePool.id
ConsolePool.password
ConsolePool.public_hostname
ConsolePool.updated_at
ConsolePool.username
class nova.db.sqlalchemy.models.ExportDevice(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represates a shelf and blade that a volume can be exported on.

ExportDevice.blade_id
ExportDevice.created_at
ExportDevice.deleted
ExportDevice.deleted_at
ExportDevice.id
ExportDevice.shelf_id
ExportDevice.updated_at
ExportDevice.volume
ExportDevice.volume_id
class nova.db.sqlalchemy.models.FixedIp(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a fixed ip for an instance.

FixedIp.address
FixedIp.allocated
FixedIp.created_at
FixedIp.deleted
FixedIp.deleted_at
FixedIp.host
FixedIp.id
FixedIp.instance
FixedIp.instance_id
FixedIp.leased
FixedIp.network
FixedIp.network_id
FixedIp.reserved
FixedIp.updated_at
FixedIp.virtual_interface
FixedIp.virtual_interface_id
class nova.db.sqlalchemy.models.FloatingIp(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a floating ip that dynamically forwards to a fixed ip.

FloatingIp.address
FloatingIp.auto_assigned
FloatingIp.created_at
FloatingIp.deleted
FloatingIp.deleted_at
FloatingIp.fixed_ip
FloatingIp.fixed_ip_id
FloatingIp.host
FloatingIp.id
FloatingIp.project_id
FloatingIp.updated_at
class nova.db.sqlalchemy.models.Instance(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a guest vm.

Instance.access_ip_v4
Instance.access_ip_v6
Instance.architecture
Instance.availability_zone
Instance.config_drive
Instance.created_at
Instance.default_local_device
Instance.default_swap_device
Instance.deleted
Instance.deleted_at
Instance.display_description
Instance.display_name
Instance.host
Instance.hostname
Instance.id
Instance.image_ref
Instance.instance_type_id
Instance.kernel_id
Instance.key_data
Instance.key_name
Instance.launch_index
Instance.launched_at
Instance.launched_on
Instance.local_gb
Instance.locked
Instance.memory_mb
Instance.name
Instance.os_type
Instance.power_state
Instance.project_id
Instance.ramdisk_id
Instance.reservation_id
Instance.root_device_name
Instance.scheduled_at
Instance.server_name
Instance.task_state
Instance.terminated_at
Instance.updated_at
Instance.user_data
Instance.user_id
Instance.uuid
Instance.vcpus
Instance.vm_mode
Instance.vm_state
class nova.db.sqlalchemy.models.InstanceActions(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a guest VM’s actions and results

InstanceActions.action
InstanceActions.created_at
InstanceActions.deleted
InstanceActions.deleted_at
InstanceActions.error
InstanceActions.id
InstanceActions.instance_id
InstanceActions.updated_at
class nova.db.sqlalchemy.models.InstanceMetadata(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a metadata key/value pair for an instance

InstanceMetadata.created_at
InstanceMetadata.deleted
InstanceMetadata.deleted_at
InstanceMetadata.id
InstanceMetadata.instance
InstanceMetadata.instance_id
InstanceMetadata.key
InstanceMetadata.updated_at
InstanceMetadata.value
class nova.db.sqlalchemy.models.InstanceTypeExtraSpecs(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents additional specs as key/value pairs for an instance_type

InstanceTypeExtraSpecs.created_at
InstanceTypeExtraSpecs.deleted
InstanceTypeExtraSpecs.deleted_at
InstanceTypeExtraSpecs.id
InstanceTypeExtraSpecs.instance_type
InstanceTypeExtraSpecs.instance_type_id
InstanceTypeExtraSpecs.key
InstanceTypeExtraSpecs.updated_at
InstanceTypeExtraSpecs.value
class nova.db.sqlalchemy.models.InstanceTypes(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represent possible instance_types or flavor of VM offered

InstanceTypes.created_at
InstanceTypes.deleted
InstanceTypes.deleted_at
InstanceTypes.flavorid
InstanceTypes.id
InstanceTypes.instances
InstanceTypes.local_gb
InstanceTypes.memory_mb
InstanceTypes.name
InstanceTypes.rxtx_cap
InstanceTypes.rxtx_quota
InstanceTypes.swap
InstanceTypes.updated_at
InstanceTypes.vcpus
InstanceTypes.vsas
class nova.db.sqlalchemy.models.IscsiTarget(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represates an iscsi target for a given host

IscsiTarget.created_at
IscsiTarget.deleted
IscsiTarget.deleted_at
IscsiTarget.host
IscsiTarget.id
IscsiTarget.target_num
IscsiTarget.updated_at
IscsiTarget.volume
IscsiTarget.volume_id
class nova.db.sqlalchemy.models.KeyPair(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a public key pair for ssh.

KeyPair.created_at
KeyPair.deleted
KeyPair.deleted_at
KeyPair.fingerprint
KeyPair.id
KeyPair.name
KeyPair.public_key
KeyPair.updated_at
KeyPair.user_id
class nova.db.sqlalchemy.models.Migration(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a running host-to-host migration.

Migration.created_at
Migration.deleted
Migration.deleted_at
Migration.dest_compute
Migration.dest_host
Migration.id
Migration.instance_uuid
Migration.new_instance_type_id
Migration.old_instance_type_id
Migration.source_compute
Migration.status
Migration.updated_at
class nova.db.sqlalchemy.models.Network(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a network.

Network.bridge
Network.bridge_interface
Network.broadcast
Network.cidr
Network.cidr_v6
Network.created_at
Network.deleted
Network.deleted_at
Network.dhcp_start
Network.dns1
Network.dns2
Network.gateway
Network.gateway_v6
Network.host
Network.id
Network.injected
Network.label
Network.multi_host
Network.netmask
Network.netmask_v6
Network.priority
Network.project_id
Network.updated_at
Network.uuid
Network.vlan
Network.vpn_private_address
Network.vpn_public_address
Network.vpn_public_port
class nova.db.sqlalchemy.models.NovaBase

Bases: object

Base class for Nova Models.

NovaBase.delete(session=None)

Delete this object.

NovaBase.get(key, default=None)
NovaBase.iteritems()

Make the model object behave like a dict.

Includes attributes from joins.

NovaBase.next()
NovaBase.save(session=None)

Save this object.

NovaBase.update(values)

Make the model object behave like a dict

class nova.db.sqlalchemy.models.Project(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a project.

Project.created_at
Project.deleted
Project.deleted_at
Project.description
Project.id
Project.members
Project.name
Project.project_manager
Project.updated_at
class nova.db.sqlalchemy.models.ProviderFirewallRule(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a rule in a security group.

ProviderFirewallRule.cidr
ProviderFirewallRule.created_at
ProviderFirewallRule.deleted
ProviderFirewallRule.deleted_at
ProviderFirewallRule.from_port
ProviderFirewallRule.id
ProviderFirewallRule.protocol
ProviderFirewallRule.to_port
ProviderFirewallRule.updated_at
class nova.db.sqlalchemy.models.Quota(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a single quota override for a project.

If there is no row for a given project id and resource, then the default for the deployment is used. If the row is present but the hard limit is Null, then the resource is unlimited.

Quota.created_at
Quota.deleted
Quota.deleted_at
Quota.hard_limit
Quota.id
Quota.project_id
Quota.resource
Quota.updated_at
class nova.db.sqlalchemy.models.SecurityGroup(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a security group.

SecurityGroup.created_at
SecurityGroup.deleted
SecurityGroup.deleted_at
SecurityGroup.description
SecurityGroup.id
SecurityGroup.instances
SecurityGroup.name
SecurityGroup.project_id
SecurityGroup.updated_at
SecurityGroup.user_id
class nova.db.sqlalchemy.models.SecurityGroupIngressRule(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a rule in a security group.

SecurityGroupIngressRule.cidr
SecurityGroupIngressRule.created_at
SecurityGroupIngressRule.deleted
SecurityGroupIngressRule.deleted_at
SecurityGroupIngressRule.from_port
SecurityGroupIngressRule.grantee_group
SecurityGroupIngressRule.group_id
SecurityGroupIngressRule.id
SecurityGroupIngressRule.parent_group
SecurityGroupIngressRule.parent_group_id
SecurityGroupIngressRule.protocol
SecurityGroupIngressRule.to_port
SecurityGroupIngressRule.updated_at
class nova.db.sqlalchemy.models.SecurityGroupInstanceAssociation(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

SecurityGroupInstanceAssociation.created_at
SecurityGroupInstanceAssociation.deleted
SecurityGroupInstanceAssociation.deleted_at
SecurityGroupInstanceAssociation.id
SecurityGroupInstanceAssociation.instance_id
SecurityGroupInstanceAssociation.security_group_id
SecurityGroupInstanceAssociation.updated_at
class nova.db.sqlalchemy.models.Service(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a running service on a host.

Service.availability_zone
Service.binary
Service.created_at
Service.deleted
Service.deleted_at
Service.disabled
Service.host
Service.id
Service.report_count
Service.topic
Service.updated_at
class nova.db.sqlalchemy.models.Snapshot(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a block storage device that can be attached to a vm.

Snapshot.created_at
Snapshot.deleted
Snapshot.deleted_at
Snapshot.display_description
Snapshot.display_name
Snapshot.id
Snapshot.name
Snapshot.progress
Snapshot.project_id
Snapshot.status
Snapshot.updated_at
Snapshot.user_id
Snapshot.volume_id
Snapshot.volume_name
Snapshot.volume_size
class nova.db.sqlalchemy.models.User(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a user.

User.access_key
User.created_at
User.deleted
User.deleted_at
User.id
User.is_admin
User.name
User.secret_key
User.updated_at
class nova.db.sqlalchemy.models.UserProjectAssociation(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

UserProjectAssociation.created_at
UserProjectAssociation.deleted
UserProjectAssociation.deleted_at
UserProjectAssociation.project_id
UserProjectAssociation.updated_at
UserProjectAssociation.user_id
class nova.db.sqlalchemy.models.UserProjectRoleAssociation(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

UserProjectRoleAssociation.created_at
UserProjectRoleAssociation.deleted
UserProjectRoleAssociation.deleted_at
UserProjectRoleAssociation.project
UserProjectRoleAssociation.project_id
UserProjectRoleAssociation.role
UserProjectRoleAssociation.updated_at
UserProjectRoleAssociation.user
UserProjectRoleAssociation.user_id
class nova.db.sqlalchemy.models.UserRoleAssociation(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

UserRoleAssociation.created_at
UserRoleAssociation.deleted
UserRoleAssociation.deleted_at
UserRoleAssociation.role
UserRoleAssociation.updated_at
UserRoleAssociation.user
UserRoleAssociation.user_id
class nova.db.sqlalchemy.models.VirtualInterface(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a virtual interface on an instance.

VirtualInterface.address
VirtualInterface.created_at
VirtualInterface.deleted
VirtualInterface.deleted_at
VirtualInterface.fixed_ipv6
VirtualInterface.id
VirtualInterface.instance
VirtualInterface.instance_id
VirtualInterface.network
VirtualInterface.network_id
VirtualInterface.updated_at
VirtualInterface.uuid
class nova.db.sqlalchemy.models.VirtualStorageArray(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a virtual storage array supplying block storage to instances.

VirtualStorageArray.availability_zone
VirtualStorageArray.created_at
VirtualStorageArray.deleted
VirtualStorageArray.deleted_at
VirtualStorageArray.display_description
VirtualStorageArray.display_name
VirtualStorageArray.id
VirtualStorageArray.image_ref
VirtualStorageArray.instance_type_id
VirtualStorageArray.name
VirtualStorageArray.project_id
VirtualStorageArray.status
VirtualStorageArray.updated_at
VirtualStorageArray.vc_count
VirtualStorageArray.vol_count
class nova.db.sqlalchemy.models.Volume(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a block storage device that can be attached to a vm.

Volume.attach_status
Volume.attach_time
Volume.availability_zone
Volume.created_at
Volume.deleted
Volume.deleted_at
Volume.display_description
Volume.display_name
Volume.host
Volume.id
Volume.instance
Volume.instance_id
Volume.launched_at
Volume.mountpoint
Volume.name
Volume.project_id
Volume.provider_auth
Volume.provider_location
Volume.scheduled_at
Volume.size
Volume.snapshot_id
Volume.status
Volume.terminated_at
Volume.updated_at
Volume.user_id
Volume.volume_type_id
class nova.db.sqlalchemy.models.VolumeMetadata(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a metadata key/value pair for a volume

VolumeMetadata.created_at
VolumeMetadata.deleted
VolumeMetadata.deleted_at
VolumeMetadata.id
VolumeMetadata.key
VolumeMetadata.updated_at
VolumeMetadata.value
VolumeMetadata.volume
VolumeMetadata.volume_id
class nova.db.sqlalchemy.models.VolumeTypeExtraSpecs(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents additional specs as key/value pairs for a volume_type

VolumeTypeExtraSpecs.created_at
VolumeTypeExtraSpecs.deleted
VolumeTypeExtraSpecs.deleted_at
VolumeTypeExtraSpecs.id
VolumeTypeExtraSpecs.key
VolumeTypeExtraSpecs.updated_at
VolumeTypeExtraSpecs.value
VolumeTypeExtraSpecs.volume_type
VolumeTypeExtraSpecs.volume_type_id
class nova.db.sqlalchemy.models.VolumeTypes(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represent possible volume_types of volumes offered

VolumeTypes.created_at
VolumeTypes.deleted
VolumeTypes.deleted_at
VolumeTypes.id
VolumeTypes.name
VolumeTypes.updated_at
VolumeTypes.volumes
class nova.db.sqlalchemy.models.Zone(**kwargs)

Bases: sqlalchemy.ext.declarative.Base, nova.db.sqlalchemy.models.NovaBase

Represents a child zone of this zone.

Zone.api_url
Zone.created_at
Zone.deleted
Zone.deleted_at
Zone.id
Zone.password
Zone.updated_at
Zone.username
Zone.weight_offset
Zone.weight_scale
nova.db.sqlalchemy.models.register_models()

Register Models and create metadata.

Called from nova.db.sqlalchemy.__init__ as part of loading the driver, it will never need to be called explicitly elsewhere unless the connection is lost and needs to be reestablished.

The nova.db.sqlalchemy.session Module

Session Handling for SQLAlchemy backend

nova.db.sqlalchemy.session.get_engine()

Return a SQLAlchemy engine.

nova.db.sqlalchemy.session.get_maker(engine, autocommit=True, expire_on_commit=False)

Return a SQLAlchemy sessionmaker using the given engine.

nova.db.sqlalchemy.session.get_session(autocommit=True, expire_on_commit=False)

Return a SQLAlchemy session.

Tests

Tests are lacking for the db api layer and for the sqlalchemy driver. Failures in the drivers would be detected in other test cases, though.