Ejemplo n.º 1
0
 def test_zfs_create_no_options(self):
     """ zfs.zfs_create passes no options by default """
     pool = 'rpool'
     volume = 'ROOT'
     zfs.zfs_create(pool, volume)
     self.mock_subp.assert_called_with(['zfs', 'create', 'rpool/ROOT'],
                                       capture=True)
Ejemplo n.º 2
0
 def test_zfs_create_sets_zfs_properties(self):
     """ zfs.zfs_create uses zfs_properties parameters """
     zfs_props = {'fsprop1': 'val2'}
     zfs.zfs_create('mypool', 'myvol', zfs_properties=zfs_props)
     params = ["%s=%s" % (k, v) for k, v in zfs_props.items()]
     args, _ = self.mock_subp.call_args
     self.assertTrue(set(params).issubset(set(args[0])))
Ejemplo n.º 3
0
 def test_zfs_create_calls_mount_if_canmount_is_noauto(self):
     """ zfs.zfs_create calls zfs mount if canmount=noauto """
     pool = 'rpool'
     volume = 'ROOT'
     props = {'canmount': 'noauto'}
     zfs.zfs_create(pool, volume, zfs_properties=props)
     self.mock_subp.assert_called_with(
         ['zfs', 'mount', "%s/%s" % (pool, volume)], capture=True)
Ejemplo n.º 4
0
    def test_zfs_create_raises_value_errors(self):
        """ zfs.zfs_create raises ValueError for invalid inputs """

        # poolname
        for val in [None, '', {'a': 1}]:
            with self.assertRaises(ValueError):
                zfs.zfs_create(val, [])

        # volume
        for val in [None, '', {'a': 1}]:
            with self.assertRaises(ValueError):
                zfs.zfs_create('pool1', val)

        # properties
        for val in [12, ['a', 1]]:
            with self.assertRaises(AttributeError):
                zfs.zfs_create('pool1', 'vol1', zfs_properties=val)