def testExecution(self): """ Destroy should succeed since there is nothing to pass to DestroyPool. """ managed_objects = get_managed_objects(self._proxy) pool = next(managed_objects.pools({'Name': self._POOLNAME}), None) self.assertIsNone(pool)
def testExecution(self): """ This should fail since the pool has a filesystem on it. """ managed_objects = get_managed_objects(self._proxy) (pool, _) = next(managed_objects.pools({'Name': self._POOLNAME})) (result, rc, _) = checked_call(Manager.DestroyPool(self._proxy, pool=pool), ManagerSpec.OUTPUT_SIGS[_MN.DestroyPool]) self.assertEqual(rc, self._errors.BUSY) self.assertEqual(result, False) managed_objects = get_managed_objects(self._proxy) (pool1, _) = next(managed_objects.pools({'Name': self._POOLNAME})) self.assertEqual(pool, pool1)
def testExecution(self): """ The pool was just created, so it must always be possible to destroy it. """ managed_objects = get_managed_objects(self._proxy) (pool1, _) = next(managed_objects.pools({'Name': self._POOLNAME})) (result, rc, _) = checked_call(Manager.DestroyPool(self._proxy, pool=pool1), ManagerSpec.OUTPUT_SIGS[_MN.DestroyPool]) managed_objects = get_managed_objects(self._proxy) pool2 = next(managed_objects.pools({'Name': self._POOLNAME}), None) self.assertEqual(rc, self._errors.OK) self.assertIsNone(pool2) self.assertTrue(result)
def testExecution(self): """ The pool was just created and has no devices. It should always be possible to destroy it. """ managed_objects = get_managed_objects(self._proxy) (pool, _) = next(managed_objects.pools({'Name': self._POOLNAME})) (result, rc, _) = checked_call(Manager.DestroyPool(self._proxy, pool=pool), ManagerSpec.OUTPUT_SIGS[_MN.DestroyPool]) self.assertEqual(rc, self._errors.OK) self.assertEqual(result, True) managed_objects = get_managed_objects(self._proxy) self.assertIsNone( next(managed_objects.pools({'Name': self._POOLNAME}), None))
def testDestroyOne(self): """ Test calling with a non-existant object path. This should succeed, because at the end the filesystem is not there. """ (result, rc, _) = checked_call( Pool.DestroyFilesystems(self._pool_object, filesystems=['/']), PoolSpec.OUTPUT_SIGS[_PN.DestroyFilesystems] ) self.assertEqual(rc, self._errors.OK) self.assertEqual(len(result), 0) result = [x for x in get_managed_objects(self._proxy).filesystems()] self.assertEqual(len(result), 0)
def testCreate(self): """ Test calling with no actual volume specification. An empty volume list should always succeed, and it should not increase the number of volumes. """ (result, rc, _) = checked_call(Pool.CreateFilesystems(self._pool_object, specs=[]), PoolSpec.OUTPUT_SIGS[_PN.CreateFilesystems]) self.assertEqual(len(result), 0) self.assertEqual(rc, self._errors.OK) result = [x for x in get_managed_objects(self._proxy).filesystems()] self.assertEqual(len(result), 0)
def testCreate(self): """ Test calling by specifying a volume name. Because there is already a volume with the given name, the creation of the new volume should fail, and no additional volume should be created. """ (result, rc, _) = checked_call( Pool.CreateFilesystems(self._pool_object, specs=[self._VOLNAME]), PoolSpec.OUTPUT_SIGS[_PN.CreateFilesystems]) self.assertEqual(rc, self._errors.ALREADY_EXISTS) self.assertEqual(len(result), 0) result = [x for x in get_managed_objects(self._proxy).filesystems()] self.assertEqual(len(result), 1)
def testNullMapping(self): """ Test rename to same name. """ (result, rc, _) = checked_call( Pool.SetName(self._pool_object, name=self._POOLNAME), PoolSpec.OUTPUT_SIGS[_PN.SetName] ) self.assertEqual(rc, self._errors.OK) self.assertFalse(result) managed_objects = get_managed_objects(self._proxy) result = next(managed_objects.pools({'Name': self._POOLNAME}), None) self.assertIsNotNone(result) (pool, _) = result self.assertEqual(pool, self._pool_object_path)
def testDuplicateSpecs(self): """ Test calling with duplicate specification for same filesystem name. """ new_name = "name" (result, rc, _) = checked_call( Pool.CreateFilesystems(self._pool_object, specs=[new_name, new_name]), PoolSpec.OUTPUT_SIGS[_PN.CreateFilesystems]) self.assertEqual(rc, self._errors.OK) self.assertEqual(len(result), 1) (_, fs_name) = result[0] self.assertEqual(fs_name, new_name) result = [x for x in get_managed_objects(self._proxy).filesystems()] self.assertEqual(len(result), 1)
def testCreateOne(self): """ Test calling by specifying a new and different volume name. The new volume will be created. """ new_name = "newname" (result, rc, _) = checked_call( Pool.CreateFilesystems(self._pool_object, specs=[new_name]), PoolSpec.OUTPUT_SIGS[_PN.CreateFilesystems]) self.assertEqual(rc, self._errors.OK) self.assertEqual(len(result), 1) (_, fs_name) = result[0] self.assertEqual(fs_name, new_name) result = [x for x in get_managed_objects(self._proxy).filesystems()] self.assertEqual(len(result), 2)
def testDestroyOne(self): """ Test calling by specifying the object path. Assume that destruction should always succeed. """ fs_object_path = self._filesystems[0][0] (result, rc, _) = checked_call( Pool.DestroyFilesystems( self._pool_object, filesystems=[fs_object_path] ), PoolSpec.OUTPUT_SIGS[_PN.DestroyFilesystems] ) self.assertEqual(len(result), 1) self.assertEqual(rc, self._errors.OK) result = [x for x in get_managed_objects(self._proxy).filesystems()] self.assertEqual(len(result), 0)
def testNewName(self): """ Test rename to new name. """ filesystem = get_object(self._filesystem_object_path) (result, rc, _) = checked_call(Filesystem.SetName(filesystem, name="new"), FilesystemSpec.OUTPUT_SIGS[_FN.SetName]) self.assertEqual(rc, self._errors.OK) self.assertTrue(result) managed_objects = get_managed_objects(self._proxy) (fs_object_path, _) = next(managed_objects.filesystems({'Name': 'new'})) self.assertEqual(self._filesystem_object_path, fs_object_path) fs_object_path = \ next(managed_objects.filesystems({'Name': self._fs_name}), None) self.assertIsNone(fs_object_path)
def testDestroyTwo(self): """ Test calling by specifying one existing volume name and one non-existing. Should succeed, but only the existing name should be returned. """ fs_object_path = self._filesystems[0][0] (result, rc, _) = checked_call( Pool.DestroyFilesystems( self._pool_object, filesystems=[fs_object_path, "/"] ), PoolSpec.OUTPUT_SIGS[_PN.DestroyFilesystems] ) self.assertEqual(len(result), 1) self.assertEqual(rc, self._errors.OK) result = [x for x in get_managed_objects(self._proxy).filesystems()] self.assertEqual(len(result), 0)
def testNewName(self): """ Test rename to new name. """ new_name = "new" (result, rc, _) = checked_call( Pool.SetName(self._pool_object, name=new_name), PoolSpec.OUTPUT_SIGS[_PN.SetName] ) self.assertTrue(result) self.assertEqual(rc, self._errors.OK) managed_objects = get_managed_objects(self._proxy) self.assertIsNone( next(managed_objects.pools({'Name': self._POOLNAME}), None) ) result = next(managed_objects.pools({'Name': new_name}), None) self.assertIsNotNone(result) (pool, _) = result self.assertEqual(pool, self._pool_object_path)