Example #1
0
 def test_list__valid_unit_empty_cmd_output(self):
     with patch('salt.modules.parted._validate_device', MagicMock()):
         self.cmdrun_stdout.return_value = self.parted_print_output('empty')
         output = parted.list_('/dev/sda', unit='s')
         self.cmdrun_stdout.assert_called_once_with('parted -m -s /dev/sda unit s print')
         expected = {'info': {}, 'partitions': {}}
         self.assertEqual(output, expected)
Example #2
0
 def test_list__valid_unit_valid_legacy_cmd_output(self):
     self.cmdrun_stdout.return_value = self.parted_print_output('valid_legacy')
     output = parted.list_('/dev/sda', unit='s')
     self.cmdrun_stdout.assert_called_once_with('parted -m -s /dev/sda unit s print')
     expected = {
         'info': {
             'logical sector': '512',
             'physical sector': '512',
             'interface': 'scsi',
             'model': 'AMCC 9650SE-24M DISK',
             'disk': '/dev/sda',
             'partition table': 'gpt',
             'size': '4000GB'
         },
         'partitions': {
             '1': {
                 'end': '150MB',
                 'number': '1',
                 'start': '17.4kB',
                 'file system': '',
                 'flags': 'boot',
                 'type': 'ext3',
                 'size': '150MB'},
             '2': {
                 'end': '4000GB',
                 'number': '2',
                 'start': '3921GB',
                 'file system': '',
                 'flags': '',
                 'type': 'linux-swap(v1)',
                 'size': '79.3GB'
             }
         }
     }
     self.assertEqual(output, expected)
Example #3
0
 def test_list__valid_unit_valid_legacy_cmd_output(self):
     self.cmdrun_stdout.return_value = self.parted_print_output('valid_legacy')
     output = parted.list_('/dev/sda', unit='s')
     self.cmdrun_stdout.assert_called_once_with('parted -m -s /dev/sda unit s print')
     expected = {
         'info': {
             'logical sector': '512',
             'physical sector': '512',
             'interface': 'scsi',
             'model': 'AMCC 9650SE-24M DISK',
             'disk': '/dev/sda',
             'partition table': 'gpt',
             'size': '4000GB'
         },
         'partitions': {
             '1': {
                 'end': '150MB',
                 'number': '1',
                 'start': '17.4kB',
                 'file system': '',
                 'flags': 'boot',
                 'type': 'ext3',
                 'size': '150MB'},
             '2': {
                 'end': '4000GB',
                 'number': '2',
                 'start': '3921GB',
                 'file system': '',
                 'flags': '',
                 'type': 'linux-swap(v1)',
                 'size': '79.3GB'
             }
         }
     }
     self.assertEqual(output, expected)
Example #4
0
 def test_list__valid_unit_empty_cmd_output(self):
     self.cmdrun.return_value = self.parted_print_output('empty')
     output = parted.list_('/dev/sda', unit='s')
     self.cmdrun.assert_called_once_with(
         'parted -m -s /dev/sda unit s print')
     expected = {'info': {}, 'partitions': {}}
     self.assertEqual(output, expected)
Example #5
0
 def test_list__valid_unit_chs_valid_cmd_output(self):
     with patch('salt.modules.parted._validate_device', MagicMock()):
         self.cmdrun_stdout.return_value = self.parted_print_output('valid chs')
         output = parted.list_('/dev/sda', unit='chs')
         self.cmdrun_stdout.assert_called_once_with('parted -m -s /dev/sda unit chs print')
         expected = {
             'info': {
                 'logical sector': '512',
                 'physical sector': '512',
                 'interface': 'scsi',
                 'model': 'AMCC 9650SE-24M DISK',
                 'disk': '/dev/sda',
                 'disk flags': '',
                 'partition table': 'gpt',
                 'size': '3133,0,2'
             },
             'partitions': {
                 '1': {
                     'end': '2431,134,43',
                     'number': '1',
                     'start': '0,0,34',
                     'file system': 'ext3',
                     'flags': 'boot',
                     'name': ''},
                 '2': {
                     'end': '2492,80,42',
                     'number': '2',
                     'start': '2431,134,44',
                     'file system': 'linux-swap(v1)',
                     'flags': '',
                     'name': ''}
             }
         }
         self.assertEqual(output, expected)
Example #6
0
 def test_list__valid_unit_empty_cmd_output(self):
     self.cmdrun.return_value = self.parted_print_output('empty')
     output = parted.list_('/dev/sda', unit='s')
     self.cmdrun.called_once_with(
         ['parted', '-m', '-s', '/dev/sda'
          'unit', 's', 'print'])
     expected = {'info': {}, 'partitions': {}}
     self.assertEqual(output, expected)
Example #7
0
 def test_list__valid_unit_valid_cmd_output(self):
     self.cmdrun_stdout.return_value = self.parted_print_output("valid")
     output = parted.list_("/dev/sda", unit="s")
     self.cmdrun_stdout.assert_called_once_with("parted -m -s /dev/sda unit s print")
     expected = {
         "info": {
             "logical sector": "512",
             "physical sector": "512",
             "interface": "scsi",
             "model": "AMCC 9650SE-24M DISK",
             "disk": "/dev/sda",
             "disk flags": "",
             "partition table": "gpt",
             "size": "4000GB",
         },
         "partitions": {
             "1": {
                 "end": "150MB",
                 "number": "1",
                 "start": "17.4kB",
                 "file system": "",
                 "flags": "boot",
                 "type": "ext3",
                 "size": "150MB",
             },
             "2": {
                 "end": "4000GB",
                 "number": "2",
                 "start": "3921GB",
                 "file system": "",
                 "flags": "",
                 "type": "linux-swap(v1)",
                 "size": "79.3GB",
             },
         },
     }
     self.assertEqual(output, expected)
Example #8
0
 def test_list__valid_unit_empty_cmd_output(self):
     self.cmdrun_stdout.return_value = self.parted_print_output('empty')
     output = parted.list_('/dev/sda', unit='s')
     self.cmdrun_stdout.assert_called_once_with('parted -m -s /dev/sda unit s print')
     expected = {'info': {}, 'partitions': {}}
     self.assertEqual(output, expected)
Example #9
0
 def test_list__valid_unit_empty_cmd_output(self):
     self.cmdrun_stdout.return_value = self.parted_print_output("empty")
     output = parted.list_("/dev/sda", unit="s")
     self.cmdrun_stdout.assert_called_once_with("parted -m -s /dev/sda unit s print")
     expected = {"info": {}, "partitions": {}}
     self.assertEqual(output, expected)