コード例 #1
0
ファイル: test_imagecache.py プロジェクト: LiFengPro/nova
    def test_list_base_images(self):
        def fake_get_dynamic_property(vim, mobj, type, property_name):
            return 'fake-ds-browser'

        def fake_get_sub_folders(session, ds_browser, ds_path):
            files = set()
            files.add('image-ref-uuid')
            return files

        with contextlib.nested(
            mock.patch.object(vim_util, 'get_dynamic_property',
                              fake_get_dynamic_property),
            mock.patch.object(ds_util, 'get_sub_folders',
                              fake_get_sub_folders)
        ) as (_get_dynamic, _get_sub_folders):
            fake_ds_ref = fake.ManagedObjectReference('fake-ds-ref')
            datastore = {'name': 'ds', 'ref': fake_ds_ref}
            ds_path = ds_util.build_datastore_path(datastore['name'],
                                                   'base_folder')
            images = self._imagecache._list_datastore_images(
                    ds_path, datastore)
            originals = set()
            originals.add('image-ref-uuid')
            self.assertEqual({'originals': originals,
                              'unexplained_images': []},
                             images)
コード例 #2
0
ファイル: test_imagecache.py プロジェクト: xzj675/nova
    def test_list_base_images(self):
        def fake_get_dynamic_property(vim, mobj, type, property_name):
            return 'fake-ds-browser'

        def fake_get_sub_folders(session, ds_browser, ds_path):
            files = set()
            files.add('image-ref-uuid')
            return files

        with contextlib.nested(
                mock.patch.object(vim_util, 'get_dynamic_property',
                                  fake_get_dynamic_property),
                mock.patch.object(ds_util, 'get_sub_folders',
                                  fake_get_sub_folders)) as (_get_dynamic,
                                                             _get_sub_folders):
            fake_ds_ref = fake.ManagedObjectReference('fake-ds-ref')
            datastore = {'name': 'ds', 'ref': fake_ds_ref}
            ds_path = ds_util.build_datastore_path(datastore['name'],
                                                   'base_folder')
            images = self._imagecache._list_datastore_images(
                ds_path, datastore)
            originals = set()
            originals.add('image-ref-uuid')
            self.assertEqual({
                'originals': originals,
                'unexplained_images': []
            }, images)
コード例 #3
0
ファイル: test_vmops.py プロジェクト: qyxia/nova
 def _setup_create_folder_mocks(self):
     ops = vmops.VMwareVMOps(mock.Mock(), mock.Mock(), mock.Mock())
     base_name = "folder"
     ds_name = "datastore"
     ds_ref = mock.Mock()
     ds_ref.value = 1
     dc_ref = mock.Mock()
     ops._datastore_dc_mapping[ds_ref.value] = vmops.DcInfo(ref=dc_ref, name="fake-name", vmFolder="fake-folder")
     path = ds_util.build_datastore_path(ds_name, base_name)
     ds_util.mkdir = mock.Mock()
     return ds_name, ds_ref, ops, path, dc_ref
コード例 #4
0
ファイル: test_vmops.py プロジェクト: bopopescu/nova-23
 def _setup_create_folder_mocks(self):
     ops = vmops.VMwareVMOps(mock.Mock(), mock.Mock(), mock.Mock())
     base_name = 'folder'
     ds_name = "datastore"
     ds_ref = mock.Mock()
     ds_ref.value = 1
     dc_ref = mock.Mock()
     ops._datastore_dc_mapping[ds_ref.value] = vmops.DcInfo(
         ref=dc_ref, name='fake-name', vmFolder='fake-folder')
     path = ds_util.build_datastore_path(ds_name, base_name)
     ds_util.mkdir = mock.Mock()
     return ds_name, ds_ref, ops, path, dc_ref
コード例 #5
0
ファイル: imagecache.py プロジェクト: wputra/MOS-centos
    def update(self, context, instances, datastores_info):
        """The cache manager entry point.

        This will invoke the cache manager. This will update the cache
        according to the defined cache management scheme. The information
        populated in the cached stats will be used for the cache management.
        """
        # read running instances data
        running = self._list_running_instances(context, instances)
        self.used_images = set(running['used_images'].keys())
        # perform the aging and image verification per datastore
        for (datastore, dc_info) in datastores_info:
            ds_path = ds_util.build_datastore_path(datastore['name'],
                                                   self._base_folder)
            images = self._list_datastore_images(ds_path, datastore)
            self.originals = images['originals']
            self._age_cached_images(context, datastore, dc_info, ds_path)
コード例 #6
0
ファイル: test_ds_util.py プロジェクト: e0ne/nova
 def test_build_datastore_path(self):
     path = ds_util.build_datastore_path('ds', 'folder')
     self.assertEqual('[ds] folder', path)
     path = ds_util.build_datastore_path('ds', 'folder/file')
     self.assertEqual('[ds] folder/file', path)
コード例 #7
0
ファイル: test_ds_util.py プロジェクト: bopopescu/nova-26
 def test_build_datastore_path(self):
     path = ds_util.build_datastore_path('ds', 'folder')
     self.assertEqual('[ds] folder', path)
     path = ds_util.build_datastore_path('ds', 'folder/file')
     self.assertEqual('[ds] folder/file', path)