예제 #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 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)
예제 #4
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)
    def setUp(self):
        """
        Obtain the Introspect() xml.
        """
        self._introspection_data = dict()

        self._service = Service()
        self._service.setUp()
        time.sleep(1)
        proxy = get_object(TOP_OBJECT)

        self._introspection_data[ManagerSpec.INTERFACE_NAME] = \
           proxy.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE)

        ((poolpath, _), _, _) = Manager.CreatePool(proxy,
                                                   name="name",
                                                   redundancy=0,
                                                   force=False,
                                                   devices=[])
        pool = get_object(poolpath)
        self._introspection_data[PoolSpec.INTERFACE_NAME] = \
           pool.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE)

        ([(fspath, _)], _, _) = \
           Pool.CreateFilesystems(pool, specs=[("filesystem", '', None)])
        fs = get_object(fspath)
        self._introspection_data[FilesystemSpec.INTERFACE_NAME] = \
           fs.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE)
예제 #6
0
 def testBogusObjectPath(self):
     """
     Success should occur on a bogus object path.
     """
     (_, rc, _) = checked_call(Manager.DestroyPool(self._proxy, pool="/"),
                               ManagerSpec.OUTPUT_SIGS[_MN.DestroyPool])
     self.assertEqual(rc, self._errors.OK)
예제 #7
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 = [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)
     Manager.ConfigureSimulator(self._proxy, denominator=8)
예제 #8
0
 def testExecution(self):
     """
     This should fail since it has a filesystem on it.
     """
     (rc, _) = checked_call(
         Manager.DestroyPool(self._proxy, name=self._POOLNAME),
         ManagerSpec.OUTPUT_SIGS[_MN.DestroyPool])
     self.assertEqual(rc, self._errors.BUSY)
 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)
     Manager.ConfigureSimulator(self._proxy, denominator=8)
예제 #10
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)
예제 #11
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)
예제 #12
0
 def testNonExistingPool1(self):
     """
     Returns an error code, just the wrong one.
     """
     (_, rc, _) = checked_call(
        Manager.GetCacheObjectPath(self._proxy, pool_name='notapool'),
        ManagerSpec.OUTPUT_SIGS[_MN.GetCacheObjectPath]
     )
     self.assertNotEqual(rc, self._errors.OK)
예제 #13
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)
예제 #14
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)
예제 #15
0
 def testNonExistingPool(self):
     """
     Currently, the error return code is DEV_NOTFOUND, it should
     be POOL_NOTFOUND
     """
     (_, rc, _) = checked_call(
        Manager.GetCacheObjectPath(self._proxy, pool_name='notapool'),
        ManagerSpec.OUTPUT_SIGS[_MN.GetCacheObjectPath]
     )
     self.assertEqual(rc, self._errors.POOL_NOTFOUND)
예제 #16
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, '')
예제 #17
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)
예제 #18
0
    def testException1(self):
        """
        An error is returned if the pool does not exist.

        Aside from the error value, the results are correct.
        """
        (_, rc, _) = checked_call(
           Manager.GetCacheObjectPath(self._proxy, pool_name='notapool'),
           ManagerSpec.OUTPUT_SIGS[_MN.GetCacheObjectPath]
        )
        self.assertNotEqual(rc, self._errors.OK)
예제 #19
0
    def testException(self):
        """
        An error is returned if the pool does not exist.

        Unfortunately, it is the wrong error.
        """
        (_, rc, _) = checked_call(
           Manager.GetCacheObjectPath(self._proxy, pool_name='notapool'),
           ManagerSpec.OUTPUT_SIGS[_MN.GetCacheObjectPath]
        )
        self.assertEqual(rc, self._errors.POOL_NOTFOUND)
예제 #20
0
    def setUp(self):
        """
        Start the stratisd daemon with the simulator.
        Create a pool and a filesystem.
        """
        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=[d.device_node for d in _device_list(_DEVICES, 1)])
        Pool.CreateFilesystems(get_object(poolpath),
                               specs=[(self._VOLNAME, '', 0)])
        Manager.ConfigureSimulator(self._proxy, denominator=8)
예제 #21
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)
예제 #22
0
    def testExecution(self):
        """
        There should be success if the pool does exist.

        But, for some reason, there is not.
        """
        (result, rc, _) = checked_call(
           Manager.GetCacheObjectPath(self._proxy, pool_name=self._POOLNAME),
           ManagerSpec.OUTPUT_SIGS[_MN.GetCacheObjectPath]
        )
        self.assertEqual(rc, self._errors.OK)
        self.assertNotEqual(result, "")
예제 #23
0
 def testNonExistingVolume(self):
     """
     The volume does not exist.
     """
     (_, rc, _) = checked_call(
        Manager.GetFilesystemObjectPath(
           self._proxy,
           pool_name=self._POOLNAME,
           filesystem_name='noname'
        ),
        ManagerSpec.OUTPUT_SIGS[_MN.GetFilesystemObjectPath]
     )
     self.assertEqual(rc, self._errors.FILESYSTEM_NOTFOUND)
예제 #24
0
 def testExistingVolume(self):
     """
     The volume should be discovered.
     """
     (result, rc, _) = checked_call(
        Manager.GetFilesystemObjectPath(
           self._proxy,
           pool_name=self._POOLNAME,
           filesystem_name=self._VOLNAME
        ),
        ManagerSpec.OUTPUT_SIGS[_MN.GetFilesystemObjectPath]
     )
     self.assertEqual(rc, self._errors.OK)
     self.assertNotEqual(result, "")
예제 #25
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)
예제 #26
0
    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)
예제 #27
0
    def testNonExistingPool(self):
        """
        If the pool does not exist, the filesystem is not found.

        Given our implementation, it is impossible to distinguish whether that
        is because the filesystem is not found or because the pool is not found.
        """
        (_, rc, _) = checked_call(
           Manager.GetFilesystemObjectPath(
              self._proxy,
              pool_name='notapool',
              filesystem_name='noname'
           ),
           ManagerSpec.OUTPUT_SIGS[_MN.GetFilesystemObjectPath],
        )
        self.assertEqual(rc, self._errors.FILESYSTEM_NOTFOUND)
예제 #28
0
    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)
예제 #29
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)
예제 #30
0
    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))