Compute Documentation
This page contains the Compute Package documentation.
The disk Module
Utility methods to resize, repartition, and modify disk images.
Includes injection of SSH PGP keys into authorized_keys file.
-
nova.compute.disk.inject_data(*args, **kwargs)
Injects a ssh key and optionally net data into a disk image.
it will mount the image as a fully partitioned disk and attempt to inject
into the specified partition number.
If partition is not specified it mounts the image as a single partition.
-
nova.compute.disk.partition(*args, **kwargs)
Takes a single partition represented by infile and writes a bootable
drive image into outfile.
The first 63 sectors (0-62) of the resulting image is a master boot record.
Infile becomes the first primary partition.
If local bytes is specified, a second primary partition is created and
formatted as ext2.
- In the diagram below, dashes represent drive sectors.
- 0 a b c d e
+—–+——. . .——-+——. . .——+
| mbr | primary partiton | local partition |
+—–+——. . .——-+——. . .——+
The exception Module
Exceptions for Compute Node errors, mostly network addressing.
-
exception nova.compute.exception.AddressAlreadyAssociated(message=None)
- Bases: nova.exception.Error
-
exception nova.compute.exception.AddressNotAllocated(message=None)
- Bases: nova.exception.Error
-
exception nova.compute.exception.AddressNotAssociated(message=None)
- Bases: nova.exception.Error
-
exception nova.compute.exception.NoMoreAddresses(message=None)
- Bases: nova.exception.Error
-
exception nova.compute.exception.NotValidNetworkSize(message=None)
- Bases: nova.exception.Error
The model Module
Datastore Model objects for Compute Instances, with
InstanceDirectory manager.
# Create a new instance?
>>> InstDir = InstanceDirectory()
>>> inst = InstDir.new()
>>> inst.destroy()
True
>>> inst = InstDir[‘i-123’]
>>> inst[‘ip’] = “192.168.0.3”
>>> inst[‘project_id’] = “projectA”
>>> inst.save()
True
>>> InstDir['i-123']
<Instance:i-123>
>>> InstDir.all.next()
<Instance:i-123>
-
class nova.compute.model.Daemon(host_or_combined, binpath=None)
Bases: nova.datastore.BasicModel
A Daemon is a job (compute, api, network, ...) that runs on a host.
-
classmethod by_host(hostname)
-
default_state()
-
destroy()
- Destroy associations, then destroy the object
-
heartbeat()
-
identifier
-
save()
- Call into superclass to save object, then save associations
-
class nova.compute.model.Host(hostname)
Bases: nova.datastore.BasicModel
A Host is the machine where a Daemon is running.
-
default_state()
-
identifier
-
class nova.compute.model.Instance(instance_id)
Bases: nova.datastore.BasicModel
Wrapper around stored properties of an instance
-
default_state()
-
destroy()
- Destroy associations, then destroy the object
-
identifier
-
project
-
reservation
- Returns a reservation object
-
save()
- Call into superclass to save object, then save associations
-
volumes
- returns a list of attached volumes
-
class nova.compute.model.InstanceDirectory
Bases: object
an api for interacting with the global state of instances
-
all
-
by_ip(ip_address)
- returns an instance object that is using the IP
-
by_node(node_id)
- returns a list of instances for a node
-
by_project(*args, **kwargs)
-
by_volume(volume_id)
- returns the instance a volume is attached to
-
exists(*args, **kwargs)
-
get(instance_id)
- returns an instance object for a given id
-
new()
- returns an empty Instance object, with ID
The network Module
Classes for network control, including VLANs, DHCP, and IP allocation.
-
class nova.compute.network.BaseNetwork(network_id, network_str=None)
Bases: nova.datastore.BasicModel
-
allocate_ip(user_id, project_id, mac)
-
assigned
-
available
-
bridge_name
-
broadcast
-
classmethod create(user_id, project_id, security_group, vlan, network_str)
-
deallocate_ip(ip_str)
-
deexpress(address=None)
-
default_state()
-
express(address=None)
-
gateway
-
hosts
-
identifier
-
lease_ip(ip_str)
-
list_addresses()
-
netmask
-
network
-
num_static_ips
-
project
-
release_ip(ip_str)
-
user
-
class nova.compute.network.BridgedNetwork(*args, **kwargs)
Bases: nova.compute.network.BaseNetwork
Virtual Network that can express itself to create a vlan and
a bridge (with or without an IP address/netmask/gateway)
- properties:
bridge_name - string (example value: br42)
vlan - integer (example value: 42)
bridge_dev - string (example: eth0)
bridge_gets_ip - boolean used during bridge creation
- if bridge_gets_ip then network address for bridge uses the properties:
- gateway
broadcast
netmask
-
express(address=None)
-
classmethod get_network_for_project(user_id, project_id, security_group)
-
class nova.compute.network.DHCPNetwork(*args, **kwargs)
Bases: nova.compute.network.BridgedNetwork
- properties:
- dhcp_listen_address: the ip of the gateway / dhcp host
dhcp_range_start: the first ip to give out
dhcp_range_end: the last ip to give out
-
allocate_vpn_ip(mac)
-
deexpress(address=None)
-
express(address=None)
-
express_cloudpipe()
-
class nova.compute.network.PublicAddress(address)
Bases: nova.datastore.BasicModel
-
classmethod create(user_id, project_id, address)
-
default_state()
-
identifier
-
class nova.compute.network.PublicNetworkController(*args, **kwargs)
Bases: nova.compute.network.BaseNetwork
-
associate_address(public_ip, private_ip, instance_id)
-
available
-
deexpress(address=None)
-
disassociate_address(public_ip)
-
express(address=None)
-
get_host(host)
-
get_public_ip_for_instance(instance_id)
-
host_objs
-
class nova.compute.network.Vlan(project, vlan)
Bases: nova.datastore.BasicModel
-
classmethod all(*args, **kwargs)
-
classmethod create(project, vlan)
-
destroy(*args, **kwargs)
-
classmethod dict_by_project(*args, **kwargs)
-
classmethod dict_by_vlan(*args, **kwargs)
-
identifier
-
classmethod lookup(*args, **kwargs)
-
save(*args, **kwargs)
-
subnet()
-
nova.compute.network.allocate_ip(user_id, project_id, mac)
-
nova.compute.network.allocate_simple_ip()
-
nova.compute.network.allocate_vpn_ip(user_id, project_id, mac)
-
nova.compute.network.deallocate_ip(address)
-
nova.compute.network.deallocate_simple_ip(address)
-
nova.compute.network.get_network_by_address(address)
-
nova.compute.network.get_network_by_interface(iface, security_group='default')
-
nova.compute.network.get_project_network(project_id, security_group='default')
- get a project’s private network, allocating one if needed
-
nova.compute.network.get_vlan_for_project(project_id)
- Allocate vlan IDs to individual users.
-
nova.compute.network.lease_ip(address)
-
nova.compute.network.release_ip(address)
-
nova.compute.network.restart_nets()
- Ensure the network for each user is enabled
The node Module
Compute Node:
Runs on each compute node, managing the
hypervisor using libvirt.
-
class nova.compute.node.Group(group_id)
- Bases: object
-
class nova.compute.node.Instance(conn, name, data)
Bases: object
-
basepath(path='')
-
console_output(*args, **kw)
-
describe()
-
destroy(*args, **kw)
-
classmethod fromName(conn, name)
- use the saved data for reloading the instance
-
info()
-
is_destroyed()
-
is_pending()
-
is_running()
-
name
-
reboot(*args, **kwargs)
-
set_state(state_code, state_description=None)
-
spawn(*args, **kwargs)
-
state
-
toXml()
-
update_state()
-
class nova.compute.node.Node
Bases: object, twisted.application.service.Service
Manages the running instances.
-
adopt_instances(*args, **kw)
-
attach_volume(*args, **kwargs)
-
describe_instances(*args, **kw)
-
detach_volume(*args, **kwargs)
-
get_console_output(*args, **kwargs)
-
get_instance(instance_id)
-
noop()
- simple test of an AMQP message call
-
reboot_instance(*args, **kw)
-
report_state(*args, **kwargs)
-
run_instance(instance_id, **_kwargs)
- launch a new instance with specified options
-
terminate_instance(*args, **kw)
-
class nova.compute.node.ProductCode(product_code)
- Bases: object
RELATED TESTS
The node_unittest Module
-
class nova.tests.node_unittest.InstanceXmlTestCase(methodName='runTest')
Bases: nova.test.TrialTestCase
-
test_serialization()
-
class nova.tests.node_unittest.NodeConnectionTestCase(methodName='runTest')
Bases: nova.test.TrialTestCase
-
create_instance()
-
setUp()
-
test_console_output(*args, **kwargs)
-
test_reboot(*args, **kwargs)
-
test_run_describe_terminate(*args, **kwargs)
-
test_run_instance_existing(*args, **kwargs)