~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/virt/driver.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 14:04:11 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20120816140411-0mr4n241wmk30t9l
Tags: upstream-2012.2~f3
ImportĀ upstreamĀ versionĀ 2012.2~f3

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
FLAGS = flags.FLAGS
32
32
 
33
33
 
34
 
class InstanceInfo(object):
35
 
    def __init__(self, name, state):
36
 
        self.name = name
37
 
        assert state in power_state.valid_states(), "Bad state: %s" % state
38
 
        self.state = state
39
 
 
40
 
 
41
34
def block_device_info_get_root(block_device_info):
42
35
    block_device_info = block_device_info or {}
43
36
    return block_device_info.get('root_device_name')
156
149
        # TODO(Vek): Need to pass context in for access to auth_token
157
150
        raise NotImplementedError()
158
151
 
159
 
    def list_instances_detail(self):
160
 
        """Return a list of InstanceInfo for all registered VMs"""
161
 
        # TODO(Vek): Need to pass context in for access to auth_token
162
 
        raise NotImplementedError()
163
 
 
164
 
    def spawn(self, context, instance, image_meta,
165
 
              network_info=None, block_device_info=None):
 
152
    def spawn(self, context, instance, image_meta, injected_files,
 
153
              admin_password, network_info=None, block_device_info=None):
166
154
        """
167
155
        Create a new instance/VM/domain on the virtualization platform.
168
156
 
179
167
                         the creation of the new instance.
180
168
        :param image_meta: image object returned by nova.image.glance that
181
169
                           defines the image from which to boot this instance
 
170
        :param injected_files: User files to inject into instance.
 
171
        :param admin_password: Administrator password to set in instance.
182
172
        :param network_info:
183
173
           :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
184
174
        :param block_device_info: Information about block devices to be
251
241
        """Detach the disk attached to the instance"""
252
242
        raise NotImplementedError()
253
243
 
254
 
    def compare_cpu(self, cpu_info):
255
 
        """Compares given cpu info against host
256
 
 
257
 
        Before attempting to migrate a VM to this host,
258
 
        compare_cpu is called to ensure that the VM will
259
 
        actually run here.
260
 
 
261
 
        :param cpu_info: (str) JSON structure describing the source CPU.
262
 
        :returns: None if migration is acceptable
263
 
        :raises: :py:class:`~nova.exception.InvalidCPUInfo` if migration
264
 
                 is not acceptable.
265
 
        """
266
 
        raise NotImplementedError()
267
 
 
268
244
    def migrate_disk_and_power_off(self, context, instance, dest,
269
245
                                   instance_type, network_info):
270
246
        """
330
306
        """resume guest state when a host is booted"""
331
307
        raise NotImplementedError()
332
308
 
333
 
    def rescue(self, context, instance, network_info, image_meta):
 
309
    def rescue(self, context, instance, network_info, image_meta,
 
310
               rescue_password):
334
311
        """Rescue the specified instance"""
335
312
        raise NotImplementedError()
336
313
 
357
334
        :param host: hostname that compute manager is currently running
358
335
 
359
336
        """
360
 
        # TODO(Vek): Need to pass context in for access to auth_token
361
337
        raise NotImplementedError()
362
338
 
363
339
    def live_migration(self, ctxt, instance_ref, dest,
364
 
                       post_method, recover_method):
365
 
        """Spawning live_migration operation for distributing high-load.
 
340
                       post_method, recover_method, block_migration=False,
 
341
                       migrate_data=None):
 
342
        """Live migration of an instance to another host.
366
343
 
367
 
        :param ctxt: security context
368
 
        :param instance_ref:
 
344
        :params ctxt: security context
 
345
        :params instance_ref:
369
346
            nova.db.sqlalchemy.models.Instance object
370
347
            instance object that is migrated.
371
 
        :param dest: destination host
372
 
        :param post_method:
 
348
        :params dest: destination host
 
349
        :params post_method:
373
350
            post operation method.
374
351
            expected nova.compute.manager.post_live_migration.
375
 
        :param recover_method:
 
352
        :params recover_method:
376
353
            recovery method when any exception occurs.
377
354
            expected nova.compute.manager.recover_live_migration.
378
 
 
379
 
        """
380
 
        # TODO(Vek): Need to pass context in for access to auth_token
 
355
        :params block_migration: if true, migrate VM disk.
 
356
        :params migrate_data: implementation specific params.
 
357
 
 
358
        """
 
359
        raise NotImplementedError()
 
360
 
 
361
    def check_can_live_migrate_destination(self, ctxt, instance_ref,
 
362
                                           block_migration=False,
 
363
                                           disk_over_commit=False):
 
364
        """Check if it is possible to execute live migration.
 
365
 
 
366
        This runs checks on the destination host, and then calls
 
367
        back to the source host to check the results.
 
368
 
 
369
        :param ctxt: security context
 
370
        :param instance_ref: nova.db.sqlalchemy.models.Instance
 
371
        :param dest: destination host
 
372
        :param block_migration: if true, prepare for block migration
 
373
        :param disk_over_commit: if true, allow disk over commit
 
374
        """
 
375
        raise NotImplementedError()
 
376
 
 
377
    def check_can_live_migrate_destination_cleanup(self, ctxt,
 
378
                                                   dest_check_data):
 
379
        """Do required cleanup on dest host after check_can_live_migrate calls
 
380
 
 
381
        :param ctxt: security context
 
382
        :param dest_check_data: result of check_can_live_migrate_destination
 
383
        """
 
384
        raise NotImplementedError()
 
385
 
 
386
    def check_can_live_migrate_source(self, ctxt, instance_ref,
 
387
                                      dest_check_data):
 
388
        """Check if it is possible to execute live migration.
 
389
 
 
390
        This checks if the live migration can succeed, based on the
 
391
        results from check_can_live_migrate_destination.
 
392
 
 
393
        :param context: security context
 
394
        :param instance_ref: nova.db.sqlalchemy.models.Instance
 
395
        :param dest_check_data: result of check_can_live_migrate_destination
 
396
        """
381
397
        raise NotImplementedError()
382
398
 
383
399
    def refresh_security_group_rules(self, security_group_id):
478
494
        # TODO(Vek): Need to pass context in for access to auth_token
479
495
        raise NotImplementedError()
480
496
 
 
497
    def filter_defer_apply_on(self):
 
498
        """Defer application of IPTables rules"""
 
499
        pass
 
500
 
 
501
    def filter_defer_apply_off(self):
 
502
        """Turn off deferral of IPTables rules and apply the rules now"""
 
503
        pass
 
504
 
481
505
    def unfilter_instance(self, instance, network_info):
482
506
        """Stop filtering instance"""
483
507
        # TODO(Vek): Need to pass context in for access to auth_token
506
530
        # TODO(Vek): Need to pass context in for access to auth_token
507
531
        raise NotImplementedError()
508
532
 
509
 
    def agent_update(self, instance, url, md5hash):
 
533
    def change_instance_metadata(self, context, instance, diff):
510
534
        """
511
 
        Update agent on the specified instance.
 
535
        Applies a diff to the instance metadata.
512
536
 
513
 
        The first parameter is an instance of nova.compute.service.Instance,
514
 
        and so the instance is being specified as instance.name. The second
515
 
        parameter is the URL of the agent to be fetched and updated on the
516
 
        instance; the third is the md5 hash of the file for verification
517
 
        purposes.
 
537
        This is an optional driver method which is used to publish
 
538
        changes to the instance's metadata to the hypervisor.  If the
 
539
        hypervisor has no means of publishing the instance metadata to
 
540
        the instance, then this method should not be implemented.
518
541
        """
519
 
        # TODO(Vek): Need to pass context in for access to auth_token
520
 
        raise NotImplementedError()
 
542
        pass
521
543
 
522
544
    def inject_network_info(self, instance, nw_info):
523
545
        """inject network info for specified instance"""
548
570
        # TODO(Vek): Need to pass context in for access to auth_token
549
571
        raise NotImplementedError()
550
572
 
 
573
    def get_host_uptime(self, host):
 
574
        """Returns the result of calling "uptime" on the target host."""
 
575
        # TODO(Vek): Need to pass context in for access to auth_token
 
576
        raise NotImplementedError()
 
577
 
551
578
    def plug_vifs(self, instance, network_info):
552
579
        """Plug VIFs into networks."""
553
580
        # TODO(Vek): Need to pass context in for access to auth_token
624
651
 
625
652
    def add_to_aggregate(self, context, aggregate, host, **kwargs):
626
653
        """Add a compute host to an aggregate."""
 
654
        #NOTE(jogo) Currently only used for XenAPI-Pool
627
655
        raise NotImplementedError()
628
656
 
629
657
    def remove_from_aggregate(self, context, aggregate, host, **kwargs):
630
658
        """Remove a compute host from an aggregate."""
631
659
        raise NotImplementedError()
632
660
 
 
661
    def undo_aggregate_operation(self, context, op, aggregate_id,
 
662
                                  host, set_error=True):
 
663
        """Undo for  Resource Pools"""
 
664
        raise NotImplementedError()
 
665
 
633
666
    def get_volume_connector(self, instance):
634
667
        """Get connector information for the instance for attaching to volumes.
635
668