Пример #1
0
class TestBlockID:
    def setup(self):
        self.blkid = BlockID('device')

    @patch('kiwi.utils.block.Command.run')
    def test_setup_with_uuid_format(self, mock_command):
        BlockID('UUID=uuid')
        mock_command.assert_called_once_with(['blkid', '--uuid', 'uuid'])

    @patch('kiwi.utils.block.Command.run')
    def test_get_blkid(self, mock_command):
        self.blkid.get_blkid('LABEL')
        mock_command.assert_called_once_with(
            ['blkid', 'device', '-s', 'LABEL', '-o', 'value'])

    @patch('kiwi.utils.block.BlockID.get_blkid')
    def test_get_filesystem(self, mock_get_blkid):
        self.blkid.get_filesystem()
        mock_get_blkid.assert_called_once_with('TYPE')

    @patch('kiwi.utils.block.BlockID.get_blkid')
    def test_get_label(self, mock_get_blkid):
        self.blkid.get_label()
        mock_get_blkid.assert_called_once_with('LABEL')

    @patch('kiwi.utils.block.BlockID.get_blkid')
    def test_get_uuid(self, mock_get_blkid):
        self.blkid.get_uuid()
        mock_get_blkid.assert_called_once_with('UUID')
Пример #2
0
class TestBlockID(object):
    def setup(self):
        self.blkid = BlockID('device')

    @patch('kiwi.utils.block.Command.run')
    def test_get_blkid(self, mock_command):
        self.blkid.get_blkid('LABEL')
        mock_command.assert_called_once_with(
            ['blkid', 'device', '-s', 'LABEL', '-o', 'value']
        )

    @patch('kiwi.utils.block.BlockID.get_blkid')
    def test_get_filesystem(self, mock_get_blkid):
        self.blkid.get_filesystem()
        mock_get_blkid.assert_called_once_with('TYPE')

    @patch('kiwi.utils.block.BlockID.get_blkid')
    def test_get_label(self, mock_get_blkid):
        self.blkid.get_label()
        mock_get_blkid.assert_called_once_with('LABEL')

    @patch('kiwi.utils.block.BlockID.get_blkid')
    def test_get_uuid(self, mock_get_blkid):
        self.blkid.get_uuid()
        mock_get_blkid.assert_called_once_with('UUID')
Пример #3
0
 def _add_fstab_entry(self,
                      device: str,
                      mount_point: str,
                      options: List = None,
                      check: str = '0 0') -> None:
     if not options:
         options = ['defaults']
     block_operation = BlockID(device)
     if self.volume_manager_name and self.volume_manager_name == 'lvm' \
        and (mount_point == '/' or mount_point == 'swap'):
         fstab_entry = ' '.join([
             device, mount_point,
             block_operation.get_filesystem(), ','.join(options), check
         ])
     else:
         blkid_type = 'LABEL' if self.persistency_type == 'by-label' \
             else 'UUID'
         device_id = block_operation.get_blkid(blkid_type)
         fstab_entry = ' '.join([
             blkid_type + '=' + device_id, mount_point,
             block_operation.get_filesystem(), ','.join(options), check
         ])
     self.fstab.add_entry(fstab_entry)
Пример #4
0
 def _add_generic_fstab_entry(self,
                              device,
                              mount_point,
                              options=None,
                              check='0 0'):
     if not options:
         options = ['defaults']
     block_operation = BlockID(device)
     blkid_type = 'LABEL' if self.persistency_type == 'by-label' else 'UUID'
     device_id = block_operation.get_blkid(blkid_type)
     fstab_entry = ' '.join([
         blkid_type + '=' + device_id, mount_point,
         block_operation.get_filesystem(), ','.join(options), check
     ])
     self.fstab.add_entry(fstab_entry)
Пример #5
0
 def _add_generic_fstab_entry(
     self, device, mount_point, options=None, check='0 0'
 ):
     if not options:
         options = ['defaults']
     block_operation = BlockID(device)
     blkid_type = 'LABEL' if self.persistency_type == 'by-label' else 'UUID'
     device_id = block_operation.get_blkid(blkid_type)
     fstab_entry = ' '.join(
         [
             blkid_type + '=' + device_id, mount_point,
             block_operation.get_filesystem(), ','.join(options), check
         ]
     )
     if fstab_entry not in self.generic_fstab_entries:
         self.generic_fstab_entries.append(
             fstab_entry
         )