Merge lp:~soren/nova/virt-layer-cleanup into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Vish Ishaya
Approved revision: 1468
Merged at revision: 1474
Proposed branch: lp:~soren/nova/virt-layer-cleanup
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 815 lines (+270/-297)
2 files modified
nova/virt/driver.py (+267/-24)
nova/virt/fake.py (+3/-273)
To merge this branch: bzr merge lp:~soren/nova/virt-layer-cleanup
Reviewer Review Type Date Requested Status
Dan Prince (community) Approve
Brian Lamar (community) Approve
Review via email: mp+72173@code.launchpad.net

Commit message

Move documentation from nova.virt.fake into nova.virt.driver.

Description of the change

I'm working on cleaning a bunch of things up in the virt layer. This is the first, simple step.

What I've done is simply to move the documentation from nova.virt.fake to nova.virt.driver, remove all claims that these calls "are asynchronous and will return a task", because they're not and they don't. :)

To post a comment you must log in.
Revision history for this message
Brian Lamar (blamar) wrote :

Not sure why the documentation was in fake.py in the first place...

review: Approve
Revision history for this message
Dan Prince (dan-prince) :
review: Approve
Revision history for this message
Soren Hansen (soren) wrote :

> Not sure why the documentation was in fake.py in the first place...

We didn't always have the abstract class.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Soren Hansen (soren) wrote :

hello-o?

Revision history for this message
Vish Ishaya (vishvananda) wrote :

retrying

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/virt/driver.py'
--- nova/virt/driver.py 2011-08-13 05:36:10 +0000
+++ nova/virt/driver.py 2011-08-19 18:12:26 +0000
@@ -62,11 +62,41 @@
62class ComputeDriver(object):62class ComputeDriver(object):
63 """Base class for compute drivers.63 """Base class for compute drivers.
6464
65 Lots of documentation is currently on fake.py.65 The interface to this class talks in terms of 'instances' (Amazon EC2 and
66 internal Nova terminology), by which we mean 'running virtual machine'
67 (XenAPI terminology) or domain (Xen or libvirt terminology).
68
69 An instance has an ID, which is the identifier chosen by Nova to represent
70 the instance further up the stack. This is unfortunately also called a
71 'name' elsewhere. As far as this layer is concerned, 'instance ID' and
72 'instance name' are synonyms.
73
74 Note that the instance ID or name is not human-readable or
75 customer-controlled -- it's an internal ID chosen by Nova. At the
76 nova.virt layer, instances do not have human-readable names at all -- such
77 things are only known higher up the stack.
78
79 Most virtualization platforms will also have their own identity schemes,
80 to uniquely identify a VM or domain. These IDs must stay internal to the
81 platform-specific layer, and never escape the connection interface. The
82 platform-specific layer is responsible for keeping track of which instance
83 ID maps to which platform-specific ID, and vice versa.
84
85 In contrast, the list_disks and list_interfaces calls may return
86 platform-specific IDs. These identify a specific virtual disk or specific
87 virtual network interface, and these IDs are opaque to the rest of Nova.
88
89 Some methods here take an instance of nova.compute.service.Instance. This
90 is the datastructure used by nova.compute to store details regarding an
91 instance, and pass them into this layer. This layer is responsible for
92 translating that generic datastructure into terms that are specific to the
93 virtualization platform.
94
66 """95 """
6796
68 def init_host(self, host):97 def init_host(self, host):
69 """Adopt existing VM's running here"""98 """Initialize anything that is necessary for the driver to function,
99 including catching up with currently running VM's on the given host."""
70 # TODO(Vek): Need to pass context in for access to auth_token100 # TODO(Vek): Need to pass context in for access to auth_token
71 raise NotImplementedError()101 raise NotImplementedError()
72102
@@ -74,6 +104,7 @@
74 """Get the current status of an instance, by name (not ID!)104 """Get the current status of an instance, by name (not ID!)
75105
76 Returns a dict containing:106 Returns a dict containing:
107
77 :state: the running state, one of the power_state codes108 :state: the running state, one of the power_state codes
78 :max_mem: (int) the maximum memory in KBytes allowed109 :max_mem: (int) the maximum memory in KBytes allowed
79 :mem: (int) the memory in KBytes used by the domain110 :mem: (int) the memory in KBytes used by the domain
@@ -84,6 +115,10 @@
84 raise NotImplementedError()115 raise NotImplementedError()
85116
86 def list_instances(self):117 def list_instances(self):
118 """
119 Return the names of all the instances known to the virtualization
120 layer, as a list.
121 """
87 # TODO(Vek): Need to pass context in for access to auth_token122 # TODO(Vek): Need to pass context in for access to auth_token
88 raise NotImplementedError()123 raise NotImplementedError()
89124
@@ -94,28 +129,53 @@
94129
95 def spawn(self, context, instance,130 def spawn(self, context, instance,
96 network_info=None, block_device_info=None):131 network_info=None, block_device_info=None):
97 """Launch a VM for the specified instance"""132 """
133 Create a new instance/VM/domain on the virtualization platform.
134
135 Once this successfully completes, the instance should be
136 running (power_state.RUNNING).
137
138 If this fails, any partial instance should be completely
139 cleaned up, and the virtualization platform should be in the state
140 that it was before this call began.
141
142 :param context: security context
143 :param instance: Instance of {nova.compute.service.Instance}.
144 This function should use the data there to guide
145 the creation of the new instance.
146 :param network_info:
147 :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
148 :param block_device_info:
149 """
98 raise NotImplementedError()150 raise NotImplementedError()
99151
100 def destroy(self, instance, network_info, cleanup=True):152 def destroy(self, instance, network_info, cleanup=True):
101 """Destroy (shutdown and delete) the specified instance.153 """Destroy (shutdown and delete) the specified instance.
102154
103 The given parameter is an instance of nova.compute.service.Instance,155 The given parameter is an instance of nova.compute.service.Instance,
104 and so the instance is being specified as instance.name.
105
106 The work will be done asynchronously. This function returns a
107 task that allows the caller to detect when it is complete.
108156
109 If the instance is not found (for example if networking failed), this157 If the instance is not found (for example if networking failed), this
110 function should still succeed. It's probably a good idea to log a158 function should still succeed. It's probably a good idea to log a
111 warning in that case.159 warning in that case.
112160
161 :param instance: Instance of {nova.compute.service.Instance} and so
162 the instance is being specified as instance.name.
163 :param network_info:
164 :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
165 :param cleanup:
166
113 """167 """
114 # TODO(Vek): Need to pass context in for access to auth_token168 # TODO(Vek): Need to pass context in for access to auth_token
115 raise NotImplementedError()169 raise NotImplementedError()
116170
117 def reboot(self, instance, network_info):171 def reboot(self, instance, network_info):
118 """Reboot specified VM"""172 """Reboot the specified instance.
173
174 :param instance: Instance of {nova.compute.service.Instance} and so
175 the instance is being specified as instance.name.
176 :param network_info:
177 :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
178 """
119 # TODO(Vek): Need to pass context in for access to auth_token179 # TODO(Vek): Need to pass context in for access to auth_token
120 raise NotImplementedError()180 raise NotImplementedError()
121181
@@ -140,31 +200,60 @@
140 raise NotImplementedError()200 raise NotImplementedError()
141201
142 def get_host_ip_addr(self):202 def get_host_ip_addr(self):
203 """
204 Retrieves the IP address of the dom0
205 """
143 # TODO(Vek): Need to pass context in for access to auth_token206 # TODO(Vek): Need to pass context in for access to auth_token
144 raise NotImplementedError()207 raise NotImplementedError()
145208
146 def attach_volume(self, context, instance_id, volume_id, mountpoint):209 def attach_volume(self, context, instance_id, volume_id, mountpoint):
210 """Attach the disk at device_path to the instance at mountpoint"""
147 raise NotImplementedError()211 raise NotImplementedError()
148212
149 def detach_volume(self, context, instance_id, volume_id):213 def detach_volume(self, context, instance_id, volume_id):
214 """Detach the disk attached to the instance at mountpoint"""
150 raise NotImplementedError()215 raise NotImplementedError()
151216
152 def compare_cpu(self, context, cpu_info):217 def compare_cpu(self, cpu_info):
218 """Compares given cpu info against host
219
220 Before attempting to migrate a VM to this host,
221 compare_cpu is called to ensure that the VM will
222 actually run here.
223
224 :param cpu_info: (str) JSON structure describing the source CPU.
225 :returns: None if migration is acceptable
226 :raises: :py:class:`~nova.exception.InvalidCPUInfo` if migration
227 is not acceptable.
228 """
153 raise NotImplementedError()229 raise NotImplementedError()
154230
155 def migrate_disk_and_power_off(self, instance, dest):231 def migrate_disk_and_power_off(self, instance, dest):
156 """Transfers the VHD of a running instance to another host, then shuts232 """
157 off the instance copies over the COW disk"""233 Transfers the disk of a running instance in multiple phases, turning
234 off the instance before the end.
235 """
158 # TODO(Vek): Need to pass context in for access to auth_token236 # TODO(Vek): Need to pass context in for access to auth_token
159 raise NotImplementedError()237 raise NotImplementedError()
160238
161 def snapshot(self, context, instance, image_id):239 def snapshot(self, context, instance, image_id):
162 """Create snapshot from a running VM instance."""240 """
241 Snapshots the specified instance.
242
243 The given parameter is an instance of nova.compute.service.Instance,
244 and so the instance is being specified as instance.name.
245
246 The second parameter is the name of the snapshot.
247 """
163 raise NotImplementedError()248 raise NotImplementedError()
164249
165 def finish_migration(self, context, instance, disk_info, network_info,250 def finish_migration(self, context, instance, disk_info, network_info,
166 resize_instance):251 resize_instance):
167 """Completes a resize, turning on the migrated instance"""252 """Completes a resize, turning on the migrated instance
253
254 :param network_info:
255 :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
256 """
168 raise NotImplementedError()257 raise NotImplementedError()
169258
170 def revert_migration(self, instance):259 def revert_migration(self, instance):
@@ -173,7 +262,7 @@
173 raise NotImplementedError()262 raise NotImplementedError()
174263
175 def pause(self, instance, callback):264 def pause(self, instance, callback):
176 """Pause VM instance"""265 """Pause the specified instance."""
177 # TODO(Vek): Need to pass context in for access to auth_token266 # TODO(Vek): Need to pass context in for access to auth_token
178 raise NotImplementedError()267 raise NotImplementedError()
179268
@@ -218,15 +307,15 @@
218 post_method, recover_method):307 post_method, recover_method):
219 """Spawning live_migration operation for distributing high-load.308 """Spawning live_migration operation for distributing high-load.
220309
221 :params ctxt: security context310 :param ctxt: security context
222 :params instance_ref:311 :param instance_ref:
223 nova.db.sqlalchemy.models.Instance object312 nova.db.sqlalchemy.models.Instance object
224 instance object that is migrated.313 instance object that is migrated.
225 :params dest: destination host314 :param dest: destination host
226 :params post_method:315 :param post_method:
227 post operation method.316 post operation method.
228 expected nova.compute.manager.post_live_migration.317 expected nova.compute.manager.post_live_migration.
229 :params recover_method:318 :param recover_method:
230 recovery method when any exception occurs.319 recovery method when any exception occurs.
231 expected nova.compute.manager.recover_live_migration.320 expected nova.compute.manager.recover_live_migration.
232321
@@ -235,15 +324,69 @@
235 raise NotImplementedError()324 raise NotImplementedError()
236325
237 def refresh_security_group_rules(self, security_group_id):326 def refresh_security_group_rules(self, security_group_id):
327 """This method is called after a change to security groups.
328
329 All security groups and their associated rules live in the datastore,
330 and calling this method should apply the updated rules to instances
331 running the specified security group.
332
333 An error should be raised if the operation cannot complete.
334
335 """
238 # TODO(Vek): Need to pass context in for access to auth_token336 # TODO(Vek): Need to pass context in for access to auth_token
239 raise NotImplementedError()337 raise NotImplementedError()
240338
241 def refresh_security_group_members(self, security_group_id):339 def refresh_security_group_members(self, security_group_id):
340 """This method is called when a security group is added to an instance.
341
342 This message is sent to the virtualization drivers on hosts that are
343 running an instance that belongs to a security group that has a rule
344 that references the security group identified by `security_group_id`.
345 It is the responsiblity of this method to make sure any rules
346 that authorize traffic flow with members of the security group are
347 updated and any new members can communicate, and any removed members
348 cannot.
349
350 Scenario:
351 * we are running on host 'H0' and we have an instance 'i-0'.
352 * instance 'i-0' is a member of security group 'speaks-b'
353 * group 'speaks-b' has an ingress rule that authorizes group 'b'
354 * another host 'H1' runs an instance 'i-1'
355 * instance 'i-1' is a member of security group 'b'
356
357 When 'i-1' launches or terminates we will recieve the message
358 to update members of group 'b', at which time we will make
359 any changes needed to the rules for instance 'i-0' to allow
360 or deny traffic coming from 'i-1', depending on if it is being
361 added or removed from the group.
362
363 In this scenario, 'i-1' could just as easily have been running on our
364 host 'H0' and this method would still have been called. The point was
365 that this method isn't called on the host where instances of that
366 group are running (as is the case with
367 :method:`refresh_security_group_rules`) but is called where references
368 are made to authorizing those instances.
369
370 An error should be raised if the operation cannot complete.
371
372 """
242 # TODO(Vek): Need to pass context in for access to auth_token373 # TODO(Vek): Need to pass context in for access to auth_token
243 raise NotImplementedError()374 raise NotImplementedError()
244375
245 def refresh_provider_fw_rules(self, security_group_id):376 def refresh_provider_fw_rules(self, security_group_id):
246 """See: nova/virt/fake.py for docs."""377 """This triggers a firewall update based on database changes.
378
379 When this is called, rules have either been added or removed from the
380 datastore. You can retrieve rules with
381 :method:`nova.db.api.provider_fw_rule_get_all`.
382
383 Provider rules take precedence over security group rules. If an IP
384 would be allowed by a security group ingress rule, but blocked by
385 a provider rule, then packets from the IP are dropped. This includes
386 intra-project traffic in the case of the allow_project_net_traffic
387 flag for the libvirt-derived classes.
388
389 """
247 # TODO(Vek): Need to pass context in for access to auth_token390 # TODO(Vek): Need to pass context in for access to auth_token
248 raise NotImplementedError()391 raise NotImplementedError()
249392
@@ -284,18 +427,38 @@
284 raise NotImplementedError()427 raise NotImplementedError()
285428
286 def set_admin_password(self, context, instance_id, new_pass=None):429 def set_admin_password(self, context, instance_id, new_pass=None):
287 """Set the root/admin password for an instance on this server."""430 """
431 Set the root password on the specified instance.
432
433 The first parameter is an instance of nova.compute.service.Instance,
434 and so the instance is being specified as instance.name. The second
435 parameter is the value of the new password.
436 """
288 raise NotImplementedError()437 raise NotImplementedError()
289438
290 def inject_file(self, instance, b64_path, b64_contents):439 def inject_file(self, instance, b64_path, b64_contents):
291 """Create a file on the VM instance. The file path and contents440 """
292 should be base64-encoded.441 Writes a file on the specified instance.
442
443 The first parameter is an instance of nova.compute.service.Instance,
444 and so the instance is being specified as instance.name. The second
445 parameter is the base64-encoded path to which the file is to be
446 written on the instance; the third is the contents of the file, also
447 base64-encoded.
293 """448 """
294 # TODO(Vek): Need to pass context in for access to auth_token449 # TODO(Vek): Need to pass context in for access to auth_token
295 raise NotImplementedError()450 raise NotImplementedError()
296451
297 def agent_update(self, instance, url, md5hash):452 def agent_update(self, instance, url, md5hash):
298 """Update agent on the VM instance."""453 """
454 Update agent on the specified instance.
455
456 The first parameter is an instance of nova.compute.service.Instance,
457 and so the instance is being specified as instance.name. The second
458 parameter is the URL of the agent to be fetched and updated on the
459 instance; the third is the md5 hash of the file for verification
460 purposes.
461 """
299 # TODO(Vek): Need to pass context in for access to auth_token462 # TODO(Vek): Need to pass context in for access to auth_token
300 raise NotImplementedError()463 raise NotImplementedError()
301464
@@ -322,3 +485,83 @@
322 """Plugs in VIFs to networks."""485 """Plugs in VIFs to networks."""
323 # TODO(Vek): Need to pass context in for access to auth_token486 # TODO(Vek): Need to pass context in for access to auth_token
324 raise NotImplementedError()487 raise NotImplementedError()
488
489 def update_host_status(self):
490 """Refresh host stats"""
491 raise NotImplementedError()
492
493 def get_host_stats(self, refresh=False):
494 """Return currently known host stats"""
495 raise NotImplementedError()
496
497 def list_disks(self, instance_name):
498 """
499 Return the IDs of all the virtual disks attached to the specified
500 instance, as a list. These IDs are opaque to the caller (they are
501 only useful for giving back to this layer as a parameter to
502 disk_stats). These IDs only need to be unique for a given instance.
503
504 Note that this function takes an instance ID.
505 """
506 raise NotImplementedError()
507
508 def list_interfaces(self, instance_name):
509 """
510 Return the IDs of all the virtual network interfaces attached to the
511 specified instance, as a list. These IDs are opaque to the caller
512 (they are only useful for giving back to this layer as a parameter to
513 interface_stats). These IDs only need to be unique for a given
514 instance.
515
516 Note that this function takes an instance ID.
517 """
518 raise NotImplementedError()
519
520 def resize(self, instance, flavor):
521 """
522 Resizes/Migrates the specified instance.
523
524 The flavor parameter determines whether or not the instance RAM and
525 disk space are modified, and if so, to what size.
526 """
527 raise NotImplementedError()
528
529 def block_stats(self, instance_name, disk_id):
530 """
531 Return performance counters associated with the given disk_id on the
532 given instance_name. These are returned as [rd_req, rd_bytes, wr_req,
533 wr_bytes, errs], where rd indicates read, wr indicates write, req is
534 the total number of I/O requests made, bytes is the total number of
535 bytes transferred, and errs is the number of requests held up due to a
536 full pipeline.
537
538 All counters are long integers.
539
540 This method is optional. On some platforms (e.g. XenAPI) performance
541 statistics can be retrieved directly in aggregate form, without Nova
542 having to do the aggregation. On those platforms, this method is
543 unused.
544
545 Note that this function takes an instance ID.
546 """
547 raise NotImplementedError()
548
549 def interface_stats(self, instance_name, iface_id):
550 """
551 Return performance counters associated with the given iface_id on the
552 given instance_id. These are returned as [rx_bytes, rx_packets,
553 rx_errs, rx_drop, tx_bytes, tx_packets, tx_errs, tx_drop], where rx
554 indicates receive, tx indicates transmit, bytes and packets indicate
555 the total number of bytes or packets transferred, and errs and dropped
556 is the total number of packets failed / dropped.
557
558 All counters are long integers.
559
560 This method is optional. On some platforms (e.g. XenAPI) performance
561 statistics can be retrieved directly in aggregate form, without Nova
562 having to do the aggregation. On those platforms, this method is
563 unused.
564
565 Note that this function takes an instance ID.
566 """
567 raise NotImplementedError()
325568
=== modified file 'nova/virt/fake.py'
--- nova/virt/fake.py 2011-08-15 20:31:43 +0000
+++ nova/virt/fake.py 2011-08-19 18:12:26 +0000
@@ -48,37 +48,7 @@
4848
4949
50class FakeConnection(driver.ComputeDriver):50class FakeConnection(driver.ComputeDriver):
51 """51 """Fake hypervisor driver"""
52 The interface to this class talks in terms of 'instances' (Amazon EC2 and
53 internal Nova terminology), by which we mean 'running virtual machine'
54 (XenAPI terminology) or domain (Xen or libvirt terminology).
55
56 An instance has an ID, which is the identifier chosen by Nova to represent
57 the instance further up the stack. This is unfortunately also called a
58 'name' elsewhere. As far as this layer is concerned, 'instance ID' and
59 'instance name' are synonyms.
60
61 Note that the instance ID or name is not human-readable or
62 customer-controlled -- it's an internal ID chosen by Nova. At the
63 nova.virt layer, instances do not have human-readable names at all -- such
64 things are only known higher up the stack.
65
66 Most virtualization platforms will also have their own identity schemes,
67 to uniquely identify a VM or domain. These IDs must stay internal to the
68 platform-specific layer, and never escape the connection interface. The
69 platform-specific layer is responsible for keeping track of which instance
70 ID maps to which platform-specific ID, and vice versa.
71
72 In contrast, the list_disks and list_interfaces calls may return
73 platform-specific IDs. These identify a specific virtual disk or specific
74 virtual network interface, and these IDs are opaque to the rest of Nova.
75
76 Some methods here take an instance of nova.compute.service.Instance. This
77 is the datastructure used by nova.compute to store details regarding an
78 instance, and pass them into this layer. This layer is responsible for
79 translating that generic datastructure into terms that are specific to the
80 virtualization platform.
81 """
8252
83 def __init__(self):53 def __init__(self):
84 self.instances = {}54 self.instances = {}
@@ -105,17 +75,9 @@
105 return cls._instance75 return cls._instance
10676
107 def init_host(self, host):77 def init_host(self, host):
108 """
109 Initialize anything that is necessary for the driver to function,
110 including catching up with currently running VM's on the given host.
111 """
112 return78 return
11379
114 def list_instances(self):80 def list_instances(self):
115 """
116 Return the names of all the instances known to the virtualization
117 layer, as a list.
118 """
119 return self.instances.keys()81 return self.instances.keys()
12082
121 def _map_to_instance_info(self, instance):83 def _map_to_instance_info(self, instance):
@@ -131,167 +93,54 @@
13193
132 def spawn(self, context, instance,94 def spawn(self, context, instance,
133 network_info=None, block_device_info=None):95 network_info=None, block_device_info=None):
134 """
135 Create a new instance/VM/domain on the virtualization platform.
136
137 The given parameter is an instance of nova.compute.service.Instance.
138 This function should use the data there to guide the creation of
139 the new instance.
140
141 The work will be done asynchronously. This function returns a
142 task that allows the caller to detect when it is complete.
143
144 Once this successfully completes, the instance should be
145 running (power_state.RUNNING).
146
147 If this fails, any partial instance should be completely
148 cleaned up, and the virtualization platform should be in the state
149 that it was before this call began.
150 """
151
152 name = instance.name96 name = instance.name
153 state = power_state.RUNNING97 state = power_state.RUNNING
154 fake_instance = FakeInstance(name, state)98 fake_instance = FakeInstance(name, state)
155 self.instances[name] = fake_instance99 self.instances[name] = fake_instance
156100
157 def snapshot(self, context, instance, name):101 def snapshot(self, context, instance, name):
158 """
159 Snapshots the specified instance.
160
161 The given parameter is an instance of nova.compute.service.Instance,
162 and so the instance is being specified as instance.name.
163
164 The second parameter is the name of the snapshot.
165
166 The work will be done asynchronously. This function returns a
167 task that allows the caller to detect when it is complete.
168 """
169 pass102 pass
170103
171 def reboot(self, instance, network_info):104 def reboot(self, instance, network_info):
172 """
173 Reboot the specified instance.
174
175 The given parameter is an instance of nova.compute.service.Instance,
176 and so the instance is being specified as instance.name.
177
178 The work will be done asynchronously. This function returns a
179 task that allows the caller to detect when it is complete.
180 """
181 pass105 pass
182106
183 def get_host_ip_addr(self):107 def get_host_ip_addr(self):
184 """108 return '192.168.0.1'
185 Retrieves the IP address of the dom0
186 """
187 pass
188109
189 def resize(self, instance, flavor):110 def resize(self, instance, flavor):
190 """
191 Resizes/Migrates the specified instance.
192
193 The flavor parameter determines whether or not the instance RAM and
194 disk space are modified, and if so, to what size.
195
196 The work will be done asynchronously. This function returns a task
197 that allows the caller to detect when it is complete.
198 """
199 pass111 pass
200112
201 def set_admin_password(self, instance, new_pass):113 def set_admin_password(self, instance, new_pass):
202 """
203 Set the root password on the specified instance.
204
205 The first parameter is an instance of nova.compute.service.Instance,
206 and so the instance is being specified as instance.name. The second
207 parameter is the value of the new password.
208
209 The work will be done asynchronously. This function returns a
210 task that allows the caller to detect when it is complete.
211 """
212 pass114 pass
213115
214 def inject_file(self, instance, b64_path, b64_contents):116 def inject_file(self, instance, b64_path, b64_contents):
215 """
216 Writes a file on the specified instance.
217
218 The first parameter is an instance of nova.compute.service.Instance,
219 and so the instance is being specified as instance.name. The second
220 parameter is the base64-encoded path to which the file is to be
221 written on the instance; the third is the contents of the file, also
222 base64-encoded.
223
224 The work will be done asynchronously. This function returns a
225 task that allows the caller to detect when it is complete.
226 """
227 pass117 pass
228118
229 def agent_update(self, instance, url, md5hash):119 def agent_update(self, instance, url, md5hash):
230 """
231 Update agent on the specified instance.
232
233 The first parameter is an instance of nova.compute.service.Instance,
234 and so the instance is being specified as instance.name. The second
235 parameter is the URL of the agent to be fetched and updated on the
236 instance; the third is the md5 hash of the file for verification
237 purposes.
238
239 The work will be done asynchronously. This function returns a
240 task that allows the caller to detect when it is complete.
241 """
242 pass120 pass
243121
244 def rescue(self, context, instance, callback, network_info):122 def rescue(self, context, instance, callback, network_info):
245 """
246 Rescue the specified instance.
247 """
248 pass123 pass
249124
250 def unrescue(self, instance, callback, network_info):125 def unrescue(self, instance, callback, network_info):
251 """
252 Unrescue the specified instance.
253 """
254 pass126 pass
255127
256 def poll_rescued_instances(self, timeout):128 def poll_rescued_instances(self, timeout):
257 """Poll for rescued instances"""
258 pass129 pass
259130
260 def migrate_disk_and_power_off(self, instance, dest):131 def migrate_disk_and_power_off(self, instance, dest):
261 """
262 Transfers the disk of a running instance in multiple phases, turning
263 off the instance before the end.
264 """
265 pass
266
267 def attach_disk(self, instance, disk_info):
268 """
269 Attaches the disk to an instance given the metadata disk_info
270 """
271 pass132 pass
272133
273 def pause(self, instance, callback):134 def pause(self, instance, callback):
274 """
275 Pause the specified instance.
276 """
277 pass135 pass
278136
279 def unpause(self, instance, callback):137 def unpause(self, instance, callback):
280 """
281 Unpause the specified instance.
282 """
283 pass138 pass
284139
285 def suspend(self, instance, callback):140 def suspend(self, instance, callback):
286 """
287 suspend the specified instance
288 """
289 pass141 pass
290142
291 def resume(self, instance, callback):143 def resume(self, instance, callback):
292 """
293 resume the specified instance
294 """
295 pass144 pass
296145
297 def destroy(self, instance, network_info, cleanup=True):146 def destroy(self, instance, network_info, cleanup=True):
@@ -303,25 +152,12 @@
303 (key, self.instances))152 (key, self.instances))
304153
305 def attach_volume(self, instance_name, device_path, mountpoint):154 def attach_volume(self, instance_name, device_path, mountpoint):
306 """Attach the disk at device_path to the instance at mountpoint"""
307 return True155 return True
308156
309 def detach_volume(self, instance_name, mountpoint):157 def detach_volume(self, instance_name, mountpoint):
310 """Detach the disk attached to the instance at mountpoint"""
311 return True158 return True
312159
313 def get_info(self, instance_name):160 def get_info(self, instance_name):
314 """
315 Get a block of information about the given instance. This is returned
316 as a dictionary containing 'state': The power_state of the instance,
317 'max_mem': The maximum memory for the instance, in KiB, 'mem': The
318 current memory the instance has, in KiB, 'num_cpu': The current number
319 of virtual CPUs the instance has, 'cpu_time': The total CPU time used
320 by the instance, in nanoseconds.
321
322 This method should raise exception.NotFound if the hypervisor has no
323 knowledge of the instance
324 """
325 if instance_name not in self.instances:161 if instance_name not in self.instances:
326 raise exception.InstanceNotFound(instance_id=instance_name)162 raise exception.InstanceNotFound(instance_id=instance_name)
327 i = self.instances[instance_name]163 i = self.instances[instance_name]
@@ -332,69 +168,18 @@
332 'cpu_time': 0}168 'cpu_time': 0}
333169
334 def get_diagnostics(self, instance_name):170 def get_diagnostics(self, instance_name):
335 pass171 return {}
336172
337 def list_disks(self, instance_name):173 def list_disks(self, instance_name):
338 """
339 Return the IDs of all the virtual disks attached to the specified
340 instance, as a list. These IDs are opaque to the caller (they are
341 only useful for giving back to this layer as a parameter to
342 disk_stats). These IDs only need to be unique for a given instance.
343
344 Note that this function takes an instance ID.
345 """
346 return ['A_DISK']174 return ['A_DISK']
347175
348 def list_interfaces(self, instance_name):176 def list_interfaces(self, instance_name):
349 """
350 Return the IDs of all the virtual network interfaces attached to the
351 specified instance, as a list. These IDs are opaque to the caller
352 (they are only useful for giving back to this layer as a parameter to
353 interface_stats). These IDs only need to be unique for a given
354 instance.
355
356 Note that this function takes an instance ID.
357 """
358 return ['A_VIF']177 return ['A_VIF']
359178
360 def block_stats(self, instance_name, disk_id):179 def block_stats(self, instance_name, disk_id):
361 """
362 Return performance counters associated with the given disk_id on the
363 given instance_name. These are returned as [rd_req, rd_bytes, wr_req,
364 wr_bytes, errs], where rd indicates read, wr indicates write, req is
365 the total number of I/O requests made, bytes is the total number of
366 bytes transferred, and errs is the number of requests held up due to a
367 full pipeline.
368
369 All counters are long integers.
370
371 This method is optional. On some platforms (e.g. XenAPI) performance
372 statistics can be retrieved directly in aggregate form, without Nova
373 having to do the aggregation. On those platforms, this method is
374 unused.
375
376 Note that this function takes an instance ID.
377 """
378 return [0L, 0L, 0L, 0L, None]180 return [0L, 0L, 0L, 0L, None]
379181
380 def interface_stats(self, instance_name, iface_id):182 def interface_stats(self, instance_name, iface_id):
381 """
382 Return performance counters associated with the given iface_id on the
383 given instance_id. These are returned as [rx_bytes, rx_packets,
384 rx_errs, rx_drop, tx_bytes, tx_packets, tx_errs, tx_drop], where rx
385 indicates receive, tx indicates transmit, bytes and packets indicate
386 the total number of bytes or packets transferred, and errs and dropped
387 is the total number of packets failed / dropped.
388
389 All counters are long integers.
390
391 This method is optional. On some platforms (e.g. XenAPI) performance
392 statistics can be retrieved directly in aggregate form, without Nova
393 having to do the aggregation. On those platforms, this method is
394 unused.
395
396 Note that this function takes an instance ID.
397 """
398 return [0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]183 return [0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]
399184
400 def get_console_output(self, instance):185 def get_console_output(self, instance):
@@ -416,67 +201,12 @@
416 'password': 'fakepassword'}201 'password': 'fakepassword'}
417202
418 def refresh_security_group_rules(self, security_group_id):203 def refresh_security_group_rules(self, security_group_id):
419 """This method is called after a change to security groups.
420
421 All security groups and their associated rules live in the datastore,
422 and calling this method should apply the updated rules to instances
423 running the specified security group.
424
425 An error should be raised if the operation cannot complete.
426
427 """
428 return True204 return True
429205
430 def refresh_security_group_members(self, security_group_id):206 def refresh_security_group_members(self, security_group_id):
431 """This method is called when a security group is added to an instance.
432
433 This message is sent to the virtualization drivers on hosts that are
434 running an instance that belongs to a security group that has a rule
435 that references the security group identified by `security_group_id`.
436 It is the responsiblity of this method to make sure any rules
437 that authorize traffic flow with members of the security group are
438 updated and any new members can communicate, and any removed members
439 cannot.
440
441 Scenario:
442 * we are running on host 'H0' and we have an instance 'i-0'.
443 * instance 'i-0' is a member of security group 'speaks-b'
444 * group 'speaks-b' has an ingress rule that authorizes group 'b'
445 * another host 'H1' runs an instance 'i-1'
446 * instance 'i-1' is a member of security group 'b'
447
448 When 'i-1' launches or terminates we will recieve the message
449 to update members of group 'b', at which time we will make
450 any changes needed to the rules for instance 'i-0' to allow
451 or deny traffic coming from 'i-1', depending on if it is being
452 added or removed from the group.
453
454 In this scenario, 'i-1' could just as easily have been running on our
455 host 'H0' and this method would still have been called. The point was
456 that this method isn't called on the host where instances of that
457 group are running (as is the case with
458 :method:`refresh_security_group_rules`) but is called where references
459 are made to authorizing those instances.
460
461 An error should be raised if the operation cannot complete.
462
463 """
464 return True207 return True
465208
466 def refresh_provider_fw_rules(self):209 def refresh_provider_fw_rules(self):
467 """This triggers a firewall update based on database changes.
468
469 When this is called, rules have either been added or removed from the
470 datastore. You can retrieve rules with
471 :method:`nova.db.api.provider_fw_rule_get_all`.
472
473 Provider rules take precedence over security group rules. If an IP
474 would be allowed by a security group ingress rule, but blocked by
475 a provider rule, then packets from the IP are dropped. This includes
476 intra-project traffic in the case of the allow_project_net_traffic
477 flag for the libvirt-derived classes.
478
479 """
480 pass210 pass
481211
482 def update_available_resource(self, ctxt, host):212 def update_available_resource(self, ctxt, host):