Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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()
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 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)
Пример #11
0
    def snapshot(namespace):
        """
        Create a snapshot of an existing volume.
        """
        proxy = get_object(TOP_OBJECT)
        volume_object = get_volume(proxy, namespace.pool, namespace.origin)
        (_, rc, message) = \
           Filesystem.CreateSnapshot(volume_object, names=namespace.volume)
        if rc != StratisdErrorsGen().get_object().OK:
            raise StratisCliRuntimeError(rc, message)

        return
Пример #12
0
 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
Пример #13
0
    def destroy_volumes(namespace):
        """
        Destroy volumes in a pool.

        :raises StratisCliRuntimeError:
        """
        proxy = get_object(TOP_OBJECT)
        pool_object = get_pool(proxy, namespace.pool)
        (_, rc, message) = \
           Pool.DestroyFilesystems(pool_object, names=namespace.volume)
        if rc != StratisdErrorsGen().get_object().OK:
            raise StratisCliRuntimeError(rc, message)

        return
Пример #14
0
    def list_volumes(namespace):
        """
        List the volumes in a pool.
        """
        proxy = get_object(TOP_OBJECT)
        pool_object = get_pool(proxy, namespace.pool)
        (result, rc, message) = Pool.ListFilesystems(pool_object)
        if rc != StratisdErrorsGen().get_object().OK:
            raise StratisCliRuntimeError(rc, message)

        for item in result:
            print(item)

        return
Пример #15
0
    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
Пример #16
0
 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)
Пример #17
0
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)
Пример #18
0
 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)]
     )
Пример #19
0
    def create_volumes(namespace):
        """
        Create volumes in a pool.

        :raises StratisCliRuntimeError:
        """
        proxy = get_object(TOP_OBJECT)
        pool_object = get_pool(proxy, namespace.pool)

        volume_list = [(x, '', None) for x in namespace.volume]
        (_, rc, message) = \
           Pool.CreateFilesystems(pool_object, specs=volume_list)

        if rc != StratisdErrorsGen().get_object().OK:
            raise StratisCliRuntimeError(rc, message)

        return
Пример #20
0
    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
Пример #21
0
 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)
Пример #22
0
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)
Пример #23
0
 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)
Пример #24
0
    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
Пример #25
0
 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)
Пример #26
0
    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
Пример #27
0
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)