~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/tests/test_hypervapi.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2013-08-09 10:12:27 UTC
  • mfrom: (1.1.74)
  • Revision ID: package-import@ubuntu.com-20130809101227-4n60fzcgra8dzk3d
Tags: 1:2013.1.3-0ubuntu1
* Resynchronize with stable/grizzly (89c7ee4) (LP: #1210447):
  - [8e6edd2] Bump stable/grizzly next version to 2013.1.3
  - [61fc529] attach quantum security group to an existing vm failed
    LP: 1189059
  - [60774bd] nova-compute fails to start if quantum is down LP: 1186357
  - [8e6d4b6] asymmetric routes in nova network with external gateway and
    routing_source_ip LP: 1182143
  - [8849413] Failed VM's not set to error state on exception LP: 1182056
  - [ef10eee] Double healing of info_cache with cells LP: 1180304
  - [7422d83] Can't log into  VM after powervm is resized LP: 1169848
  - [49ab0e8] stack trace when instance_actions extension can not find
    instance in GET LP: 1182867
  - [e71247c] nova service-list returns illegal result with non db service
    heartbeat LP: 1168861
  - [3f60606] Volume IO usage gets reset to 0 after a reboot / crash
    LP: 1169097
  - [19c443b] unused method  list_interfaces in vmware driver can be removed
    LP: 1187251
  - [a8dab9f] No cleanup done when file transfer fails with powervm driver
    LP: 1173017
  - [fc98015] nova consoleauth depends on Conductor Service LP: 1186123
  - [1066418] VMware drivers are no longer passing quantum port-id to
    vCenter LP: 1183452
  - [b92075c] nova net-list fails on empty list with Quantum backend
    LP: 1189976
  - [3ba31f2] Create VM with no networks with Quantum Gives SecurityGroups
    Exception LP: 1191044
  - [89150b2] Periodic ValueErrors when using qpid LP: 1185465
  - [0e0d615] Libvirt pre-Grizzly instances cannot be block migrated
    LP: 1185588
  - [27960ef] ZMQ ipc socket file is created using un-sanitized network
    input LP: 1122763
  - [265b868] cannot block migrate old style instances libvirt complains
    LP: 1175286
  - [008a68a] code logical error exists in vmwareapi vif.py  LP: 1177635
  - [378c045] Instance IP addresses are re-used even when previous instance
    could not be powered off LP: 1180178
  - [48ddffe] Reboot of compute node breaks VMs with volumes LP: 1188326
  - [f427f01] Missing dashes from console-log LP: 1194032
  - [78ebf1a] network-create returns an internal error when network
    conflicts LP: 1158075
  - [767c850] Instance nics are reorder after reboot LP: 1187092
  - [0b45996] instance directory naming update to use uuid  LP: 1186944
  - [06cfad5] Disassociate failed dhcp fixed ip in deallocate_for_instance()
    method LP: 1180766
  - [cbcdfc5] Allow confirm_resize action on an instance in 'deleting'
    status LP: 1189391
  - [2563c44] aggregate_get_by_host returns aggregates from other hosts
    LP: 1201277
  - [109f3a9] nova libvirt driver requires iscsi initiator name regardless
    of using it in volume drivers LP: 1007084
  - [7f1c336] Host is always set to None in get_instance_nw_info(...)
    LP: 1194178
  - [1cf30a3] nova boot with colume should fail if the volume is already
    attached to another instance LP: 1166770
  - [9cb9361] Aggregate metadata filtering by key returns unrelated metadata
    LP: 1201283
  - [a61872b] Need clean up  ftp transfer faiure  in powervm driver
    LP: 1188884
  - [91bcd15] Race can cause soft deleted instance to be erased by mistake
    LP: 1186243
  - [c57fded] Nova fails to create a security group rule if ::0/0 is used as
    cidr LP: 1199943
  - [c698dd3] VMwareESXDriver and VMwareVCDriver report incorrect stat
    LP: 1180779
  - [e572faf] novnc fails when amqp_rpc_single_reply_queue=True LP: 1193031
  - [34ddd27] eventlet.monkey_patch() for spice and vnc proxy
  - [864837f] hypervisor_hostname not updated on evacuate LP: 1198284
  - [756a772] libvirt migrate/resize on shared storage can cause data loss
    LP: 1177247
  - [889b215] nova live-migration of volume-backed VM fails because of image
    is None LP: 1199811
  - [60712a4] VNC console does not work with VCDriver LP: 1178369
  - [e0aa0f5] metadata service throws error 500 when compute_driver is not
    set LP: 1184641
  - [340d337] Instance IP addresses are re-used even when previous instance
    could not be powered off LP: 1180178
  - [8247dc8] Resource limit circumvention in Nova private flavors
    (CVE-2013-2256) LP: 1194093
  - [bd7e467] Denial of Service in Nova network source security groups
    (CVE-2013-4185) LP: 1184041
  - [c3fddb7] Resize a VM when a volume is attached fails LP: 1190364
  - [01edbaa] Hyper-V versions before 2012 are not properly recognized
    LP: 1203059
  - [b18818a] driver libvirt doesn't honor vif quota LP: 1185030
  - [798984d] config drive not visible to windows LP: 1155842
  - [d18ceb1] nova live-migration failed due to exception.MigrationError
    LP: 1171526
  - [1934dbc] vmware Hyper for nova vnc console url parameters error
    LP: 1172177
  - [89c7ee4] [OSSA 2013-023] Potential unsafe XML usage (CVE-2013-4179,
    CVE-2013-4202) LP: 1190229
* debian/rules: Clean new setuptools-git cruft.
* debian/control: Update Vcs fields.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
from nova.virt.hyperv import pathutils
53
53
from nova.virt.hyperv import vhdutils
54
54
from nova.virt.hyperv import vmutils
55
 
from nova.virt.hyperv import volumeops
56
55
from nova.virt.hyperv import volumeutils
57
56
from nova.virt.hyperv import volumeutilsv2
58
57
from nova.virt import images
84
83
        self._instance_ide_dvds = []
85
84
        self._instance_volume_disks = []
86
85
        self._test_vm_name = None
 
86
        self._check_min_windows_version_satisfied = True
87
87
 
88
88
        self._setup_stubs()
89
89
 
90
90
        self.flags(instances_path=r'C:\Hyper-V\test\instances',
91
91
                   network_api_class='nova.network.quantumv2.api.API')
 
92
        self.flags(force_volumeutils_v1=True, group='hyperv')
92
93
 
93
94
        self._conn = driver_hyperv.HyperVDriver(None)
94
95
 
112
113
        self.stubs.Set(glance, 'get_remote_image_service',
113
114
                       fake_get_remote_image_service)
114
115
 
 
116
        def fake_check_min_windows_version(fake_self, major, minor):
 
117
            return self._check_min_windows_version_satisfied
 
118
        self.stubs.Set(hostutils.HostUtils, 'check_min_windows_version',
 
119
                       fake_check_min_windows_version)
 
120
 
115
121
        def fake_sleep(ms):
116
122
            pass
117
123
        self.stubs.Set(time, 'sleep', fake_sleep)
120
126
            pass
121
127
        vmutils.VMUtils.__init__ = fake_vmutils__init__
122
128
 
123
 
        def fake_get_volume_utils(self):
124
 
            return volumeutils.VolumeUtils()
125
 
        volumeops.VolumeOps._get_volume_utils = fake_get_volume_utils
126
 
 
127
129
        self.stubs.Set(pathutils, 'PathUtils', fake.PathUtils)
128
130
        self._mox.StubOutWithMock(fake.PathUtils, 'open')
129
131
        self._mox.StubOutWithMock(fake.PathUtils, 'copyfile')
490
492
                                   constants.HYPERV_VM_STATE_DISABLED)
491
493
 
492
494
    def test_power_on(self):
493
 
        self._test_vm_state_change(self._conn.power_on,
494
 
                                   constants.HYPERV_VM_STATE_DISABLED,
495
 
                                   constants.HYPERV_VM_STATE_ENABLED)
 
495
        self._instance_data = self._get_instance_data()
 
496
        network_info = fake_network.fake_get_instance_nw_info(self.stubs,
 
497
                                                              spectacular=True)
 
498
        vmutils.VMUtils.set_vm_state(mox.Func(self._check_instance_name),
 
499
                                     constants.HYPERV_VM_STATE_ENABLED)
 
500
        self._mox.ReplayAll()
 
501
        self._conn.power_on(self._context, self._instance_data, network_info)
 
502
        self._mox.VerifyAll()
496
503
 
497
504
    def test_power_on_already_running(self):
498
 
        self._test_vm_state_change(self._conn.power_on, None,
499
 
                                   constants.HYPERV_VM_STATE_ENABLED)
 
505
        self._instance_data = self._get_instance_data()
 
506
        network_info = fake_network.fake_get_instance_nw_info(self.stubs,
 
507
                                                              spectacular=True)
 
508
        vmutils.VMUtils.set_vm_state(mox.Func(self._check_instance_name),
 
509
                                     constants.HYPERV_VM_STATE_ENABLED)
 
510
        self._mox.ReplayAll()
 
511
        self._conn.power_on(self._context, self._instance_data, network_info)
 
512
        self._mox.VerifyAll()
500
513
 
501
514
    def test_reboot(self):
502
515
 
533
546
        self._conn.destroy(self._instance_data, None)
534
547
        self._mox.VerifyAll()
535
548
 
 
549
    def test_live_migration_unsupported_os(self):
 
550
        self._check_min_windows_version_satisfied = False
 
551
        self._conn = driver_hyperv.HyperVDriver(None)
 
552
        self._test_live_migration(unsupported_os=True)
 
553
 
536
554
    def test_live_migration_without_volumes(self):
537
555
        self._test_live_migration()
538
556
 
543
561
        self._test_live_migration(test_failure=True)
544
562
 
545
563
    def _test_live_migration(self, test_failure=False,
546
 
                             with_volumes=False):
 
564
                             with_volumes=False,
 
565
                             unsupported_os=False):
547
566
        dest_server = 'fake_server'
548
567
 
549
568
        instance_data = self._get_instance_data()
550
569
        instance_name = instance_data['name']
551
570
 
552
571
        fake_post_method = self._mox.CreateMockAnything()
553
 
        if not test_failure:
 
572
        if not test_failure and not unsupported_os:
554
573
            fake_post_method(self._context, instance_data, dest_server,
555
574
                             False)
556
575
 
570
589
        else:
571
590
            fake_scsi_paths = {}
572
591
 
573
 
        m = livemigrationutils.LiveMigrationUtils.live_migrate_vm(
574
 
            instance_data['name'], dest_server)
575
 
        if test_failure:
576
 
            m.AndRaise(vmutils.HyperVException('Simulated failure'))
 
592
        if not unsupported_os:
 
593
            m = livemigrationutils.LiveMigrationUtils.live_migrate_vm(
 
594
                instance_data['name'], dest_server)
 
595
            if test_failure:
 
596
                m.AndRaise(vmutils.HyperVException('Simulated failure'))
577
597
 
578
 
        if with_volumes:
579
 
            m.AndReturn([(fake_target_iqn, fake_target_lun)])
580
 
            volumeutils.VolumeUtils.logout_storage_target(fake_target_iqn)
581
 
        else:
582
 
            m.AndReturn([])
 
598
            if with_volumes:
 
599
                m.AndReturn([(fake_target_iqn, fake_target_lun)])
 
600
                volumeutils.VolumeUtils.logout_storage_target(fake_target_iqn)
 
601
            else:
 
602
                m.AndReturn([])
583
603
 
584
604
        self._mox.ReplayAll()
585
605
        try:
 
606
            hyperv_exception_raised = False
 
607
            unsupported_os_exception_raised = False
586
608
            self._conn.live_migration(self._context, instance_data,
587
609
                                      dest_server, fake_post_method,
588
610
                                      fake_recover_method)
589
 
            exception_raised = False
590
611
        except vmutils.HyperVException:
591
 
            exception_raised = True
 
612
            hyperv_exception_raised = True
 
613
        except NotImplementedError:
 
614
            unsupported_os_exception_raised = True
592
615
 
593
 
        self.assertTrue(not test_failure ^ exception_raised)
 
616
        self.assertTrue(not test_failure ^ hyperv_exception_raised)
 
617
        self.assertTrue(not unsupported_os ^ unsupported_os_exception_raised)
594
618
        self._mox.VerifyAll()
595
619
 
596
620
    def test_pre_live_migration_cow_image(self):
943
967
                                                        fake_mounted_disk)
944
968
        m.WithSideEffects(self._add_volume_disk)
945
969
 
 
970
    def _test_volumeutils_version(self, is_hyperv_2012=True,
 
971
                                  force_volumeutils_v1=False):
 
972
        self._check_min_windows_version_satisfied = is_hyperv_2012
 
973
        self.flags(force_volumeutils_v1=force_volumeutils_v1, group='hyperv')
 
974
        self._conn = driver_hyperv.HyperVDriver(None)
 
975
        is_volutils_v2 = isinstance(self._conn._volumeops._volutils,
 
976
                                    volumeutilsv2.VolumeUtilsV2)
 
977
 
 
978
        self.assertTrue((is_hyperv_2012 and not force_volumeutils_v1) ^
 
979
                        (not is_volutils_v2))
 
980
 
 
981
    def test_volumeutils_version_hyperv_2012(self):
 
982
        self._test_volumeutils_version(True, False)
 
983
 
 
984
    def test_volumeutils_version_hyperv_2012_force_v1(self):
 
985
        self._test_volumeutils_version(True, True)
 
986
 
 
987
    def test_volumeutils_version_hyperv_2008R2(self):
 
988
        self._test_volumeutils_version(False, False)
 
989
 
946
990
    def test_attach_volume(self):
947
991
        instance_data = self._get_instance_data()
948
992