def testNonExistingVolume(self): """ An exception is raised if the volume does not exist. """ with self.assertRaises(StratisCliRuntimeError) as ctxt: get_volume(get_object(TOP_OBJECT), self._POOLNAME, 'noname') expected_error = StratisdErrorsGen.get_object().FILESYSTEM_NOTFOUND self.assertEqual(ctxt.exception.rc, expected_error)
def testNonExistingPool(self): """ An exception is raised if the pool does not exist. """ with self.assertRaises(StratisCliRuntimeError) as ctxt: get_pool(get_object(TOP_OBJECT), 'notapool') expected_error = StratisdErrorsGen.get_object().POOL_NOTFOUND self.assertEqual(ctxt.exception.rc, expected_error)
def testCreate(self): """ Create should fail, because there is already a cache. """ command_line = self._MENU + [self._POOLNAME] + self._other_devices() with self.assertRaises(StratisCliRuntimeError) as ctxt: all(run(command_line)) expected_error = StratisdErrorsGen.get_object().POOL_NOTFOUND self.assertEqual(ctxt.exception.rc, expected_error)
def setUp(self): """ Start the stratisd daemon with the simulator. """ self._service = Service() self._service.setUp() time.sleep(1) self._proxy = get_object(TOP_OBJECT) self._errors = StratisdErrorsGen.get_object()
def testCreation(self): """ Creation of the volume must fail since pool is not specified. """ command_line = self._MENU + [self._POOLNAME] + self._VOLNAMES with self.assertRaises(StratisCliRuntimeError) as ctxt: all(run(command_line)) expected_error = StratisdErrorsGen.get_object().POOL_NOTFOUND self.assertEqual(ctxt.exception.rc, expected_error)
def testList(self): """ Listing the volume must fail since the pool does not exist. """ command_line = self._MENU + [self._POOLNAME] with self.assertRaises(StratisCliRuntimeError) as ctxt: all(run(command_line)) expected_error = StratisdErrorsGen.get_object().POOL_NOTFOUND self.assertEqual(ctxt.exception.rc, expected_error)
def testSnapshot(self): """ Snapshot of the volume must fail since there is no volume. """ command_line = \ self._MENU + [self._POOLNAME] + [self._ORIGIN] + [self._SNAP] with self.assertRaises(StratisCliRuntimeError) as ctxt: all(run(command_line)) expected_error = StratisdErrorsGen.get_object().VOLUME_NOTFOUND self.assertEqual(ctxt.exception.rc, expected_error)
def testCreation(self): """ Creation of this volume should fail, because there is an existing volume of the same name. """ command_line = self._MENU + [self._POOLNAME] + self._VOLNAMES with self.assertRaises(StratisCliRuntimeError) as ctxt: all(run(command_line)) expected_error = StratisdErrorsGen.get_object().LIST_FAILURE self.assertEqual(ctxt.exception.rc, expected_error)
def testAdd(self): """ Adding the devices must fail since the pool does not exist. """ command_line = self._MENU + [self._POOLNAME] + \ [d.device_node for d in _device_list(_DEVICES, 1)] with self.assertRaises(StratisCliRuntimeError) as ctxt: all(run(command_line)) expected_error = StratisdErrorsGen.get_object().POOL_NOTFOUND self.assertEqual(ctxt.exception.rc, expected_error)
def testCreate(self): """ Create should fail because the pool does not exist. """ command_line = \ self._MENU + \ [self._POOLNAME] + \ [d.device_node for d in _device_list(_DEVICES, 1)] with self.assertRaises(StratisCliRuntimeError) as ctxt: all(run(command_line)) expected_error = StratisdErrorsGen.get_object().POOL_NOTFOUND self.assertEqual(ctxt.exception.rc, expected_error)
def list_pool(namespace): """ List devices in a pool. """ proxy = get_object(TOP_OBJECT) pool_object = get_pool(proxy, namespace.name) (result, rc, message) = Pool.ListDevs(pool_object) if rc != StratisdErrorsGen.get_object().OK: raise StratisCliRuntimeError(rc, message) for item in result: print(item) return
def add_device(namespace): """ Add a device to a pool. """ proxy = get_object(TOP_OBJECT) pool_object = get_pool(proxy, namespace.name) (_, rc, message) = Pool.AddDevs( pool_object, force=namespace.force, devices=namespace.device ) if rc != StratisdErrorsGen.get_object().OK: raise StratisCliRuntimeError(rc, message) return
def setUp(self): """ Start the stratisd daemon with the simulator. """ self._service = Service() self._service.setUp() time.sleep(1) self._proxy = get_object(TOP_OBJECT) self._errors = StratisdErrorsGen.get_object() Manager.CreatePool(self._proxy, name=self._POOLNAME, redundancy=0, force=False, devices=_DEVICE_STRATEGY.example()) Manager.ConfigureSimulator(self._proxy, denominator=8)
def get_pool(top, name): """ Get pool. :param top: the top object :param str name: the name of the pool :returns: an object corresponding to ``name`` :rtype: ProxyObject :raises StratisCliRuntimeError: if failure to get object """ (pool_object_path, rc, message) = Manager.GetPoolObjectPath(top, name=name) if rc != StratisdErrorsGen.get_object().OK: raise StratisCliRuntimeError(rc, message) return get_object(pool_object_path)
def setUp(self): """ Start the stratisd daemon with the simulator. """ self._service = Service() self._service.setUp() time.sleep(1) self._proxy = get_object(TOP_OBJECT) self._errors = StratisdErrorsGen.get_object() Manager.CreatePool( self._proxy, name=self._POOLNAME, redundancy=0, force=False, devices=[d.device_node for d in _device_list(_DEVICES, 1)] )
def get_cache(top, pool): """ Get cache given ``pool``. :param top: the top object :param str pool: the name of the pool :returns: the corresponding object :rtype: ProxyObject :raises StratisCliRuntimeError: if failure to get object """ (cache_object_path, rc, message) = \ Manager.GetCacheObjectPath(top, name=pool) if rc != StratisdErrorsGen.get_object().OK: raise StratisCliRuntimeError(rc, message) return get_object(cache_object_path)
def destroy_pool(namespace): """ Destroy a stratis pool. If no pool exists, the method succeeds. :raises StratisCliRuntimeError: """ proxy = get_object(TOP_OBJECT) (rc, message) = Manager.DestroyPool(proxy, name=namespace.name) stratisd_errors = StratisdErrorsGen.get_object() if rc != stratisd_errors.OK: raise StratisCliRuntimeError(rc, message) return
def setUp(self): """ Start the stratisd daemon with the simulator. """ self._service = Service() self._service.setUp() time.sleep(1) self._proxy = get_object(TOP_OBJECT) self._errors = StratisdErrorsGen.get_object() ((poolpath, _), _, _) = Manager.CreatePool( self._proxy, name=self._POOLNAME, redundancy=0, force=False, devices=[] ) self._pool_object = get_object(poolpath) Manager.ConfigureSimulator(self._proxy, denominator=8)
def setUp(self): """ Start the stratisd daemon with the simulator. """ self._service = Service() self._service.setUp() time.sleep(1) self._proxy = get_object(TOP_OBJECT) self._errors = StratisdErrorsGen.get_object() self._devs = _DEVICE_STRATEGY.example() ((poolpath, _), _, _) = Manager.CreatePool(self._proxy, name=self._POOLNAME, redundancy=0, force=False, devices=self._devs) self._pool_object = get_object(poolpath) Pool.CreateFilesystems(self._pool_object, specs=[self._VOLNAME]) Manager.ConfigureSimulator(self._proxy, denominator=8)
def list_pools(namespace): """ List all stratis pools. :raises StratisCliRuntimeError: """ # pylint: disable=unused-argument proxy = get_object(TOP_OBJECT) (result, rc, message) = Manager.ListPools(proxy) stratisd_errors = StratisdErrorsGen.get_object() if rc != stratisd_errors.OK: raise StratisCliRuntimeError(rc, message) for item in result: print(item) return
def setUp(self): """ Start the stratisd daemon with the simulator. """ self._service = Service() self._service.setUp() time.sleep(2) self._proxy = get_object(TOP_OBJECT) self._errors = StratisdErrorsGen.get_object() self._devs = [d.device_node for d in _device_list(_DEVICES, 1)] (result, _, _) = Manager.CreatePool(self._proxy, name=self._POOLNAME, redundancy=0, force=False, devices=self._devs) self._pool_object = get_object(result) Pool.CreateFilesystems(self._pool_object, specs=[(self._VOLNAME, '', 0)]) Manager.ConfigureSimulator(self._proxy, denominator=8)
def create_pool(namespace): """ Create a stratis pool. :raises StratisCliRuntimeError: """ stratisd_errors = StratisdErrorsGen.get_object() proxy = get_object(TOP_OBJECT) (_, rc, message) = Manager.CreatePool(proxy, name=namespace.name, redundancy=0, force=namespace.force, devices=namespace.device) if rc != stratisd_errors.OK: raise StratisCliRuntimeError(rc, message) return
def get_volume(top, pool, name): """ Get volume given ``name`` and ``pool``. :param top: the top object :param str pool: the object path of the pool :param str name: the name of the volume :returns: the corresponding object :rtype: ProxyObject :raises StratisCliRuntimeError: if failure to get object """ (volume_object_path, rc, message) = Manager.GetFilesystemObjectPath(top, pool_name=pool, filesystem_name=name) if rc != StratisdErrorsGen.get_object().OK: raise StratisCliRuntimeError(rc, message) return get_object(volume_object_path)