Esempio n. 1
0
    def create_ephemeral_disk(self, instance):
        eph_vhd_size = instance.get('ephemeral_gb', 0) * units.Gi
        if not eph_vhd_size:
            return

        eph_vhd_format = constants.DEFAULT_DISK_FORMAT
        eph_vhd_path = pathutils.ephemeral_vhd_path(instance, eph_vhd_format)
        self._vbox_manage.create_hd(filename=eph_vhd_path,
                                    size=eph_vhd_size / units.Mi,
                                    disk_format=eph_vhd_format,
                                    variant=constants.VARIANT_STANDARD)
        self._vbox_manage.modify_hd(filename=eph_vhd_path,
                                    field=constants.FIELD_HD_TYPE,
                                    value=constants.VHD_TYPE_IMMUTABLE)

        # Note(alexandrucoman): For immutable (differencing) hard disks only
        # Autoreset option determines whether the disk is automatically reset
        # on every VM startup
        # self._vbox_manage.modify_hd(filename=eph_vhd_path,
        #                             field=constants.FIELD_HD_AUTORESET,
        #                             value=constants.ON)
        return eph_vhd_path
Esempio n. 2
0
    def create_ephemeral_disk(self, instance):
        eph_vhd_size = instance.get('ephemeral_gb', 0) * units.Gi
        if not eph_vhd_size:
            return

        eph_vhd_format = constants.DEFAULT_DISK_FORMAT
        eph_vhd_path = pathutils.ephemeral_vhd_path(instance, eph_vhd_format)
        self._vbox_manage.create_hd(filename=eph_vhd_path,
                                    size=eph_vhd_size / units.Mi,
                                    disk_format=eph_vhd_format,
                                    variant=constants.VARIANT_STANDARD)
        self._vbox_manage.modify_hd(filename=eph_vhd_path,
                                    field=constants.FIELD_HD_TYPE,
                                    value=constants.VHD_TYPE_IMMUTABLE)

        # Note(alexandrucoman): For immutable (differencing) hard disks only
        # Autoreset option determines whether the disk is automatically reset
        # on every VM startup
        # self._vbox_manage.modify_hd(filename=eph_vhd_path,
        #                             field=constants.FIELD_HD_AUTORESET,
        #                             value=constants.ON)
        return eph_vhd_path
Esempio n. 3
0
    def test_ephemeral_vhd_path(self, mock_instance_basepath, mock_join):
        pathutils.ephemeral_vhd_path(self._instance, 'fake-disk-format')

        mock_instance_basepath.assert_called_once_with(self._instance)
        self.assertEqual(1, mock_join.call_count)
    def test_ephemeral_vhd_path(self, mock_instance_basepath, mock_join):
        pathutils.ephemeral_vhd_path(self._instance, "fake-disk-format")

        mock_instance_basepath.assert_called_once_with(self._instance)
        self.assertEqual(1, mock_join.call_count)