Example #1
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)
Example #2
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)
Example #3
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