Пример #1
0
    def testCreate(self):
        """
        Type of result should always be correct.

        If rc is OK, then pool must exist.
        """
        (result, rc, _) = checked_call(
           Manager.CreatePool(
              self._proxy,
              name=self._POOLNAME,
              redundancy=0,
              force=False,
              devices=[d.device_node for d in _device_list(_DEVICES, 1)]
           ),
           ManagerSpec.OUTPUT_SIGS[_MN.CreatePool]
        )

        (pool, rc1, _) = checked_call(
           Manager.GetPoolObjectPath(self._proxy, name=self._POOLNAME),
           ManagerSpec.OUTPUT_SIGS[_MN.GetPoolObjectPath]
        )

        (pools, _, _) = checked_call(
           Manager.ListPools(self._proxy),
           ManagerSpec.OUTPUT_SIGS[_MN.ListPools]
        )

        if rc == self._errors.OK:
            self.assertEqual(pool, result)
            self.assertEqual(rc1, self._errors.OK)
            self.assertEqual(len(pools), 1)
        else:
            self.assertEqual(rc1, self._errors.POOL_NOTFOUND)
            self.assertEqual(len(pools), 0)
Пример #2
0
    def testCreate(self):
        """
        Create should fail trying to create new pool with same name as previous.
        """
        (pools1, _, _) = checked_call(
           Manager.ListPools(self._proxy),
           ManagerSpec.OUTPUT_SIGS[_MN.ListPools]
        )

        (_, rc, _) = checked_call(
           Manager.CreatePool(
              self._proxy,
              name=self._POOLNAME,
              redundancy=0,
              force=False,
              devices=[d.device_node for d in _device_list(_DEVICES, 1)]
           ),
           ManagerSpec.OUTPUT_SIGS[_MN.CreatePool]
        )
        expected_rc = self._errors.ALREADY_EXISTS
        self.assertEqual(rc, expected_rc)

        (_, rc1, _) = checked_call(
           Manager.GetPoolObjectPath(self._proxy, name=self._POOLNAME),
           ManagerSpec.OUTPUT_SIGS[_MN.GetPoolObjectPath]
        )

        (pools2, _, _) = checked_call(
           Manager.ListPools(self._proxy),
           ManagerSpec.OUTPUT_SIGS[_MN.ListPools]
        )

        self.assertEqual(rc1, self._errors.OK)
        self.assertEqual(pools1, pools2)
Пример #3
0
 def testNonExistingPool(self):
     """
     An error code is returned if the pool does not exist.
     """
     (_, rc, _) = checked_call(
        Manager.GetPoolObjectPath(self._proxy, name="notapool"),
        ManagerSpec.OUTPUT_SIGS[_MN.GetPoolObjectPath]
     )
     self.assertEqual(rc, self._errors.POOL_NOTFOUND)
Пример #4
0
 def testUnknownName(self):
     """
     Getting a non-existing pool should fail.
     """
     (_, rc, _) = checked_call(
        Manager.GetPoolObjectPath(self._proxy, name='nopool'),
        ManagerSpec.OUTPUT_SIGS[_MN.GetPoolObjectPath],
     )
     self.assertEqual(rc, self._errors.POOL_NOTFOUND)
Пример #5
0
 def testExecution(self):
     """
     Getting an existing pool should succeed.
     """
     (result, rc, _) = checked_call(
        Manager.GetPoolObjectPath(self._proxy, name=self._POOLNAME),
        ManagerSpec.OUTPUT_SIGS[_MN.GetPoolObjectPath],
     )
     self.assertEqual(rc, self._errors.OK)
     self.assertNotEqual(result, '')
Пример #6
0
    def remove_device(namespace):
        """
        Remove a device from the given pool.
        """
        proxy = get_object(TOP_OBJECT)
        (pool_object_path, rc, message) = \
            Manager.GetPoolObjectPath(proxy, name=namespace.pool)
        if rc != 0:
            return (rc, message)

        pool_object = get_object(pool_object_path)
        return Pool.RemoveCacheDevs(pool_object)
Пример #7
0
    def testExecution(self):
        """
        Destroy should succeed.
        """
        (rc, _) = checked_call(
            Manager.DestroyPool(self._proxy, name=self._POOLNAME),
            ManagerSpec.OUTPUT_SIGS[_MN.DestroyPool])
        self.assertEqual(rc, self._errors.OK)

        (_, rc1, _) = checked_call(
            Manager.GetPoolObjectPath(self._proxy, name=self._POOLNAME),
            ManagerSpec.OUTPUT_SIGS[_MN.GetPoolObjectPath])

        self.assertEqual(rc1, self._errors.POOL_NOTFOUND)
Пример #8
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)
Пример #9
0
    def list_cache(namespace):
        """
        List information about the cache belonging to a pool.
        """
        proxy = get_object(TOP_OBJECT)
        (pool_object_path, rc, message) = \
            Manager.GetPoolObjectPath(proxy, name=namespace.pool)
        if rc != 0:
            return (rc, message)

        pool_object = get_object(pool_object_path)
        (result, rc, message) = Pool.ListCacheDevs(pool_object)
        if rc != 0:
            return (rc, message)

        for item in result:
            print(item)

        return (rc, message)
Пример #10
0
    def testExecution(self):
        """
        The pool was just created, so must be destroyable.
        """
        (rc, _) = checked_call(
            Manager.DestroyPool(self._proxy, name=self._POOLNAME),
            ManagerSpec.OUTPUT_SIGS[_MN.DestroyPool])

        (_, rc1, _) = checked_call(
            Manager.GetPoolObjectPath(self._proxy, name=self._POOLNAME),
            ManagerSpec.OUTPUT_SIGS[_MN.GetPoolObjectPath],
        )

        if rc is self._errors.OK:
            expected_rc = self._errors.POOL_NOTFOUND
        else:
            expected_rc = self._errors.OK

        self.assertEqual(rc1, expected_rc)