コード例 #1
0
 def test_zpool_command_target_with_space(self):
     """
     Test if zpool_command builds the correct string
     """
     with patch.object(zfs, "_zfs_cmd",
                       MagicMock(return_value="/sbin/zfs")):
         with patch.object(zfs, "_zpool_cmd",
                           MagicMock(return_value="/sbin/zpool")):
             with patch.object(zfs, "property_data_zfs",
                               MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(
                         zfs,
                         "property_data_zpool",
                         MagicMock(return_value=self.pmap_zpool),
                 ):
                     fs_props = {
                         "quota": "100G",
                     }
                     pool_props = {
                         "comment": "jorge's comment has a space",
                     }
                     self.assertEqual(
                         zfs.zpool_command(
                             "create",
                             pool_properties=pool_props,
                             filesystem_properties=fs_props,
                             target="my pool",
                         ),
                         "/sbin/zpool create -O quota=107374182400 -o"
                         ' comment="jorge\'s comment has a space" "my pool"',
                     )
コード例 #2
0
ファイル: test_zfs.py プロジェクト: crimv42/saltstack
 def test_zpool_command_target_with_space(self):
     '''
     Test if zpool_command builds the correct string
     '''
     with patch.object(zfs, '_zfs_cmd',
                       MagicMock(return_value='/sbin/zfs')):
         with patch.object(zfs, '_zpool_cmd',
                           MagicMock(return_value='/sbin/zpool')):
             with patch.object(zfs, 'property_data_zfs',
                               MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(zfs, 'property_data_zpool',
                                   MagicMock(return_value=self.pmap_zpool)):
                     fs_props = {
                         'quota': '100G',
                     }
                     pool_props = {
                         'comment': "jorge's comment has a space",
                     }
                     self.assertEqual(
                         zfs.zpool_command('create',
                                           pool_properties=pool_props,
                                           filesystem_properties=fs_props,
                                           target='my pool'),
                         "/sbin/zpool create -O quota=107374182400 -o comment=\"jorge's comment has a space\" \"my pool\""
                     )
コード例 #3
0
ファイル: test_zfs.py プロジェクト: yutiansut/salt
 def test_zpool_command_property(self):
     '''
     Test if zpool_command builds the correct string
     '''
     with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')):
         with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')):
             with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)):
                     self.assertEqual(
                         zfs.zpool_command('get', property_name='comment', target='mypool'),
                         "/sbin/zpool get comment mypool"
                     )
コード例 #4
0
ファイル: test_zfs.py プロジェクト: yutiansut/salt
 def test_zpool_command_simple(self):
     '''
     Test if zfs_command builds the correct string
     '''
     with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')):
         with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')):
             with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)):
                     self.assertEqual(
                         zfs.zpool_command('list'),
                         "/sbin/zpool list"
                     )
コード例 #5
0
ファイル: test_zfs.py プロジェクト: yutiansut/salt
 def test_zpool_command_property_value(self):
     '''
     Test if zpool_command builds the correct string
     '''
     with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')):
         with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')):
             with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)):
                     my_flags = [
                         '-v',  # verbose
                     ]
                     self.assertEqual(
                         zfs.zpool_command('iostat', flags=my_flags, target=['mypool', 60, 1]),
                         "/sbin/zpool iostat -v mypool 60 1"
                     )
コード例 #6
0
ファイル: test_zfs.py プロジェクト: yutiansut/salt
 def test_zpool_command_target(self):
     '''
     Test if zpool_command builds the correct string
     '''
     with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')):
         with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')):
             with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)):
                     my_opts = {
                         '-o': 'name,size',  # show only name and size
                     }
                     self.assertEqual(
                         zfs.zpool_command('list', opts=my_opts, target='mypool'),
                         "/sbin/zpool list -o name,size mypool"
                     )
コード例 #7
0
ファイル: test_zfs.py プロジェクト: yutiansut/salt
 def test_zpool_command_opt_list(self):
     '''
     Test if zpool_command builds the correct string
     '''
     with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')):
         with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')):
             with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)):
                     my_opts = {
                         '-d': ['/tmp', '/zvol'],
                     }
                     self.assertEqual(
                         zfs.zpool_command('import', opts=my_opts, target='mypool'),
                         "/sbin/zpool import -d /tmp -d /zvol mypool"
                     )
コード例 #8
0
 def test_zpool_command_simple(self):
     """
     Test if zfs_command builds the correct string
     """
     with patch.object(zfs, "_zfs_cmd",
                       MagicMock(return_value="/sbin/zfs")):
         with patch.object(zfs, "_zpool_cmd",
                           MagicMock(return_value="/sbin/zpool")):
             with patch.object(zfs, "property_data_zfs",
                               MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(
                         zfs,
                         "property_data_zpool",
                         MagicMock(return_value=self.pmap_zpool),
                 ):
                     self.assertEqual(zfs.zpool_command("list"),
                                      "/sbin/zpool list")
コード例 #9
0
 def test_zpool_command_property(self):
     """
     Test if zpool_command builds the correct string
     """
     with patch.object(zfs, "_zfs_cmd",
                       MagicMock(return_value="/sbin/zfs")):
         with patch.object(zfs, "_zpool_cmd",
                           MagicMock(return_value="/sbin/zpool")):
             with patch.object(zfs, "property_data_zfs",
                               MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(
                         zfs,
                         "property_data_zpool",
                         MagicMock(return_value=self.pmap_zpool),
                 ):
                     self.assertEqual(
                         zfs.zpool_command("get",
                                           property_name="comment",
                                           target="mypool"),
                         "/sbin/zpool get comment mypool",
                     )
コード例 #10
0
 def test_zpool_command_flag_opt(self):
     """
     Test if zpool_command builds the correct string
     """
     with patch.object(zfs, "_zfs_cmd",
                       MagicMock(return_value="/sbin/zfs")):
         with patch.object(zfs, "_zpool_cmd",
                           MagicMock(return_value="/sbin/zpool")):
             with patch.object(zfs, "property_data_zfs",
                               MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(
                         zfs,
                         "property_data_zpool",
                         MagicMock(return_value=self.pmap_zpool),
                 ):
                     my_opts = {
                         "-o": "name,size",  # show only name and size
                     }
                     self.assertEqual(
                         zfs.zpool_command("list", opts=my_opts),
                         "/sbin/zpool list -o name,size",
                     )
コード例 #11
0
 def test_zpool_command_property_value(self):
     """
     Test if zpool_command builds the correct string
     """
     with patch.object(zfs, "_zfs_cmd",
                       MagicMock(return_value="/sbin/zfs")):
         with patch.object(zfs, "_zpool_cmd",
                           MagicMock(return_value="/sbin/zpool")):
             with patch.object(zfs, "property_data_zfs",
                               MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(
                         zfs,
                         "property_data_zpool",
                         MagicMock(return_value=self.pmap_zpool),
                 ):
                     my_flags = [
                         "-v",  # verbose
                     ]
                     self.assertEqual(
                         zfs.zpool_command("iostat",
                                           flags=my_flags,
                                           target=["mypool", 60, 1]),
                         "/sbin/zpool iostat -v mypool 60 1",
                     )
コード例 #12
0
 def test_zpool_command_opt_list(self):
     """
     Test if zpool_command builds the correct string
     """
     with patch.object(zfs, "_zfs_cmd",
                       MagicMock(return_value="/sbin/zfs")):
         with patch.object(zfs, "_zpool_cmd",
                           MagicMock(return_value="/sbin/zpool")):
             with patch.object(zfs, "property_data_zfs",
                               MagicMock(return_value=self.pmap_zfs)):
                 with patch.object(
                         zfs,
                         "property_data_zpool",
                         MagicMock(return_value=self.pmap_zpool),
                 ):
                     my_opts = {
                         "-d": ["/tmp", "/zvol"],
                     }
                     self.assertEqual(
                         zfs.zpool_command("import",
                                           opts=my_opts,
                                           target="mypool"),
                         "/sbin/zpool import -d /tmp -d /zvol mypool",
                     )