Driver base-classes:
(Beginning of) the contract that compute drivers must follow, and shared types that support that contract
Bases: object
Base class for compute drivers.
The interface to this class talks in terms of ‘instances’ (Amazon EC2 and internal Nova terminology), by which we mean ‘running virtual machine’ (XenAPI terminology) or domain (Xen or libvirt terminology).
An instance has an ID, which is the identifier chosen by Nova to represent the instance further up the stack. This is unfortunately also called a ‘name’ elsewhere. As far as this layer is concerned, ‘instance ID’ and ‘instance name’ are synonyms.
Note that the instance ID or name is not human-readable or customer-controlled – it’s an internal ID chosen by Nova. At the nova.virt layer, instances do not have human-readable names at all – such things are only known higher up the stack.
Most virtualization platforms will also have their own identity schemes, to uniquely identify a VM or domain. These IDs must stay internal to the platform-specific layer, and never escape the connection interface. The platform-specific layer is responsible for keeping track of which instance ID maps to which platform-specific ID, and vice versa.
In contrast, the list_disks and list_interfaces calls may return platform-specific IDs. These identify a specific virtual disk or specific virtual network interface, and these IDs are opaque to the rest of Nova.
Some methods here take an instance of nova.compute.service.Instance. This is the datastructure used by nova.compute to store details regarding an instance, and pass them into this layer. This layer is responsible for translating that generic datastructure into terms that are specific to the virtualization platform.
Update agent on the specified instance.
The first parameter is an instance of nova.compute.service.Instance, and so the instance is being specified as instance.name. The second parameter is the URL of the agent to be fetched and updated on the instance; the third is the md5 hash of the file for verification purposes.
Attach the disk at device_path to the instance at mountpoint
Return performance counters associated with the given disk_id on the given instance_name. These are returned as [rd_req, rd_bytes, wr_req, wr_bytes, errs], where rd indicates read, wr indicates write, req is the total number of I/O requests made, bytes is the total number of bytes transferred, and errs is the number of requests held up due to a full pipeline.
All counters are long integers.
This method is optional. On some platforms (e.g. XenAPI) performance statistics can be retrieved directly in aggregate form, without Nova having to do the aggregation. On those platforms, this method is unused.
Note that this function takes an instance ID.
Compares given cpu info against host
Before attempting to migrate a VM to this host, compare_cpu is called to ensure that the VM will actually run here.
Parameters: | cpu_info – (str) JSON structure describing the source CPU. |
---|---|
Returns: | None if migration is acceptable |
Raises : | InvalidCPUInfo if migration is not acceptable. |
Destroy (shutdown and delete) the specified instance.
If the instance is not found (for example if networking failed), this function should still succeed. It’s probably a good idea to log a warning in that case.
Parameters: |
|
---|
Detach the disk attached to the instance at mountpoint
Setting up filtering rules and waiting for its completion.
To migrate an instance, filtering rules to hypervisors and firewalls are inevitable on destination host. ( Waiting only for filtering rules to hypervisor, since filtering rules to firewall rules can be set faster).
Concretely, the below method must be called. - setup_basic_filtering (for nova-basic, etc.) - prepare_instance_filter(for nova-instance-instance-xxx, etc.)
to_xml may have to be called since it defines PROJNET, PROJMASK. but libvirt migrates those value through migrateToURI(), so , no need to be called.
Don’t use thread for this method since migration should not be started when setting-up filtering rules operations are not completed.
Params instance_ref: | |
---|---|
nova.db.sqlalchemy.models.Instance object |
Completes a resize, turning on the migrated instance
Parameters: | network_info – get_instance_nw_info() |
---|
Return data about VM diagnostics
Retrieves the IP address of the dom0
Return currently known host stats
Get the current status of an instance, by name (not ID!)
Returns a dict containing:
State : | the running state, one of the power_state codes |
---|---|
Max_mem : | (int) the maximum memory in KBytes allowed |
Mem : | (int) the memory in KBytes used by the domain |
Num_cpu : | (int) the number of virtual CPUs for the domain |
Cpu_time : | (int) the CPU time used in nanoseconds |
Reboots, shuts down or powers up the host.
Initialize anything that is necessary for the driver to function, including catching up with currently running VM’s on the given host.
Writes a file on the specified instance.
The first parameter is an instance of nova.compute.service.Instance, and so the instance is being specified as instance.name. The second parameter is the base64-encoded path to which the file is to be written on the instance; the third is the contents of the file, also base64-encoded.
inject network info for specified instance
Return performance counters associated with the given iface_id on the given instance_id. These are returned as [rx_bytes, rx_packets, rx_errs, rx_drop, tx_bytes, tx_packets, tx_errs, tx_drop], where rx indicates receive, tx indicates transmit, bytes and packets indicate the total number of bytes or packets transferred, and errs and dropped is the total number of packets failed / dropped.
All counters are long integers.
This method is optional. On some platforms (e.g. XenAPI) performance statistics can be retrieved directly in aggregate form, without Nova having to do the aggregation. On those platforms, this method is unused.
Note that this function takes an instance ID.
Return the IDs of all the virtual disks attached to the specified instance, as a list. These IDs are opaque to the caller (they are only useful for giving back to this layer as a parameter to disk_stats). These IDs only need to be unique for a given instance.
Note that this function takes an instance ID.
Return the names of all the instances known to the virtualization layer, as a list.
Return a list of InstanceInfo for all registered VMs
Return the IDs of all the virtual network interfaces attached to the specified instance, as a list. These IDs are opaque to the caller (they are only useful for giving back to this layer as a parameter to interface_stats). These IDs only need to be unique for a given instance.
Note that this function takes an instance ID.
Spawning live_migration operation for distributing high-load.
Parameters: |
|
---|
Transfers the disk of a running instance in multiple phases, turning off the instance before the end.
Pause the specified instance.
Plugs in VIFs to networks.
Poll for rescued instances
Reboot the specified instance.
Parameters: |
|
---|
This triggers a firewall update based on database changes.
When this is called, rules have either been added or removed from the datastore. You can retrieve rules with :method:`nova.db.api.provider_fw_rule_get_all`.
Provider rules take precedence over security group rules. If an IP would be allowed by a security group ingress rule, but blocked by a provider rule, then packets from the IP are dropped. This includes intra-project traffic in the case of the allow_project_net_traffic flag for the libvirt-derived classes.
This method is called when a security group is added to an instance.
This message is sent to the virtualization drivers on hosts that are running an instance that belongs to a security group that has a rule that references the security group identified by security_group_id. It is the responsiblity of this method to make sure any rules that authorize traffic flow with members of the security group are updated and any new members can communicate, and any removed members cannot.
When ‘i-1’ launches or terminates we will recieve the message to update members of group ‘b’, at which time we will make any changes needed to the rules for instance ‘i-0’ to allow or deny traffic coming from ‘i-1’, depending on if it is being added or removed from the group.
In this scenario, ‘i-1’ could just as easily have been running on our host ‘H0’ and this method would still have been called. The point was that this method isn’t called on the host where instances of that group are running (as is the case with :method:`refresh_security_group_rules`) but is called where references are made to authorizing those instances.
An error should be raised if the operation cannot complete.
This method is called after a change to security groups.
All security groups and their associated rules live in the datastore, and calling this method should apply the updated rules to instances running the specified security group.
An error should be raised if the operation cannot complete.
Rescue the specified instance
reset networking for specified instance
Resizes/Migrates the specified instance.
The flavor parameter determines whether or not the instance RAM and disk space are modified, and if so, to what size.
resume the specified instance
Reverts a resize, powering back on the instance
Set the root password on the specified instance.
The first parameter is an instance of nova.compute.service.Instance, and so the instance is being specified as instance.name. The second parameter is the value of the new password.
Sets the specified host’s ability to accept new instances.
Snapshots the specified instance.
Parameters: |
|
---|
Create a new instance/VM/domain on the virtualization platform.
Once this successfully completes, the instance should be running (power_state.RUNNING).
If this fails, any partial instance should be completely cleaned up, and the virtualization platform should be in the state that it was before this call began.
Parameters: |
|
---|
suspend the specified instance
Stop filtering instance
Unpause paused VM instance
Unrescue the specified instance
Updates compute manager resource info on ComputeNode table.
This method is called when nova-compute launches, and whenever admin executes “nova-manage service update_resource”.
Parameters: |
|
---|
Refresh host stats
Bases: object