Exemple #1
0
    def test_generate_ephemeral_cleans_up_on_error(self):
        self._expect_generate_disk(2000, self.userdevice, self.name_label)
        self._expect_generate_disk(2000, self.userdevice + 1, "name (1)")

        vm_utils._generate_disk(self.session, self.instance, self.vm_ref,
            str(self.userdevice + 2), "name (2)", 'ephemeral', 30 * 1024,
            None).AndRaise(exception.NovaException)

        vm_utils.safe_destroy_vdis(self.session, [4, 5])

        self.mox.ReplayAll()

        self.assertRaises(exception.NovaException, vm_utils.generate_ephemeral,
            self.session, self.instance, self.vm_ref,
            str(self.userdevice), self.name_label, 4030)
Exemple #2
0
    def test_generate_ephemeral_cleans_up_on_error(self):
        self._expect_generate_disk(2000, self.userdevice, self.name_label)
        self._expect_generate_disk(2000, self.userdevice + 1, "name (1)")

        vm_utils._generate_disk(self.session, self.instance, self.vm_ref,
            str(self.userdevice + 2), "name (2)", 'ephemeral', 30 * 1024,
            None).AndRaise(exception.NovaException)

        vm_utils.safe_destroy_vdis(self.session, [4, 5])

        self.mox.ReplayAll()

        self.assertRaises(exception.NovaException, vm_utils.generate_ephemeral,
            self.session, self.instance, self.vm_ref,
            str(self.userdevice), self.name_label, 4030)
Exemple #3
0
    def test_generate_disk_with_no_fs_given(self):
        self._expect_parted_calls()

        self.mox.ReplayAll()
        vdi_ref = vm_utils._generate_disk(self.session, {"uuid": "fake_uuid"},
            self.vm_ref, "2", "name", "user", 10, None)
        self._check_vdi(vdi_ref)
Exemple #4
0
    def test_generate_disk_with_no_fs_given(self):
        self._expect_parted_calls()

        self.mox.ReplayAll()
        vdi_ref = vm_utils._generate_disk(self.session, {"uuid": "fake_uuid"},
            self.vm_ref, "2", "name", "user", 10, None)
        self._check_vdi(vdi_ref)
Exemple #5
0
    def test_generate_disk_swap(self):
        self._expect_parted_calls()
        utils.execute('mkswap', '/dev/fakedev1', run_as_root=True)

        self.mox.ReplayAll()
        vdi_ref = vm_utils._generate_disk(self.session, {"uuid": "fake_uuid"},
            self.vm_ref, "2", "name", "swap", 10, "linux-swap")
        self._check_vdi(vdi_ref)
Exemple #6
0
    def test_generate_disk_swap(self):
        self._expect_parted_calls()
        utils.execute('mkswap', '/dev/fakedev1', run_as_root=True)

        self.mox.ReplayAll()
        vdi_ref = vm_utils._generate_disk(self.session, {"uuid": "fake_uuid"},
            self.vm_ref, "2", "name", "swap", 10, "linux-swap")
        self._check_vdi(vdi_ref)
Exemple #7
0
    def test_generate_disk_ephemeral(self):
        self._expect_parted_calls()
        utils.execute('mkfs', '-t', 'ext4', '/dev/fakedev1',
            run_as_root=True)

        self.mox.ReplayAll()
        vdi_ref = vm_utils._generate_disk(self.session, {"uuid": "fake_uuid"},
            self.vm_ref, "2", "name", "ephemeral", 10, "ext4")
        self._check_vdi(vdi_ref)
Exemple #8
0
    def test_generate_disk_ephemeral(self):
        self._expect_parted_calls()
        utils.execute('mkfs', '-t', 'ext4', '/dev/fakedev1', run_as_root=True)

        self.mox.ReplayAll()
        vdi_ref = vm_utils._generate_disk(self.session, {"uuid": "fake_uuid"},
                                          self.vm_ref, "2", "name",
                                          "ephemeral", 10, "ext4")
        self._check_vdi(vdi_ref)
Exemple #9
0
 def _expect_generate_disk(self, size, device, name_label):
     vm_utils._generate_disk(self.session, self.instance, self.vm_ref,
         str(device), name_label, 'ephemeral', size * 1024,
         None).AndReturn(device)
Exemple #10
0
 def _expect_generate_disk(self, size, device, name_label):
     vm_utils._generate_disk(self.session, self.instance, self.vm_ref,
                             str(device), name_label, 'ephemeral',
                             size * 1024, None).AndReturn(device)