Exemplo n.º 1
0
    def test_mddisplay_nostate_detail(self, mock_exec):
        mock_exec.return_value = (
            """/dev/md127:
        Version : imsm
     Raid Level : container
  Total Devices : 2

Working Devices : 2


           UUID : 46a4fc60:21554de1:1edfad0f:c137ddac
  Member Arrays :

    Number   Major   Minor   RaidDevice

       0       8        0        -        /dev/sda
       1       8       16        -        /dev/sdb""",
            ''
        )

        expected = [{
            'Raid Level': 'container',
            'UUID': '46a4fc60:21554de1:1edfad0f:c137ddac',
            'Version': 'imsm',
            'devices': ['/dev/sda', '/dev/sdb'],
            'name': '/dev/md127',
        }]

        mds = mu.mddisplay(['/dev/md127'])
        mock_exec.assert_called_once_with(
            'mdadm', '--detail', '/dev/md127', check_exit_code=[0])

        self.assertItemsEqual(expected, mds)
Exemplo n.º 2
0
    def test_mddisplay_nostate_detail(self, mock_exec):
        mock_exec.return_value = ("""/dev/md127:
        Version : imsm
     Raid Level : container
  Total Devices : 2

Working Devices : 2


           UUID : 46a4fc60:21554de1:1edfad0f:c137ddac
  Member Arrays :

    Number   Major   Minor   RaidDevice

       0       8        0        -        /dev/sda
       1       8       16        -        /dev/sdb""", '')

        expected = [{
            'Raid Level': 'container',
            'UUID': '46a4fc60:21554de1:1edfad0f:c137ddac',
            'Version': 'imsm',
            'devices': ['/dev/sda', '/dev/sdb'],
            'name': '/dev/md127',
        }]

        mds = mu.mddisplay(['/dev/md127'])
        mock_exec.assert_called_once_with('mdadm',
                                          '--detail',
                                          '/dev/md127',
                                          check_exit_code=[0])

        self.assertItemsEqual(expected, mds)
Exemplo n.º 3
0
    def test_mddisplay(self, mock_exec):
        # should read file /proc/mdstat
        # should get detailed description for all md devices
        # should return list of dicts representing md devices

        mock_open_data = """Personalities : [raid1]
md0 : active raid1 loop5[1] loop4[0]
      102272 blocks super 1.2 [2/2] [UU]

unused devices: <none>


        """
        mock_open = mock.mock_open(read_data=mock_open_data)
        patcher = mock.patch(OPEN_FUNCTION_NAME, new=mock_open)
        patcher.start()

        mock_exec.return_value = (
            """/dev/md0:
        Version : 1.2
  Creation Time : Wed Jun 18 18:44:57 2014
     Raid Level : raid1
     Array Size : 102272 (99.89 MiB 104.73 MB)
  Used Dev Size : 102272 (99.89 MiB 104.73 MB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Wed Jun 18 18:45:01 2014
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : localhost.localdomain:0  (local to host
localhost.localdomain)
           UUID : 12dd4cfc:6b2ac9db:94564538:a6ffee82
         Events : 17

    Number   Major   Minor   RaidDevice State
       0       7        4        0      active sync   /dev/loop4
       1       7        5        1      active sync   /dev/loop5""",
            ''
        )

        expected = [{
            'name': '/dev/md0',
            'Version': '1.2',
            'Raid Level': 'raid1',
            'Raid Devices': '2',
            'Active Devices': '2',
            'Spare Devices': '0',
            'Failed Devices': '0',
            'State': 'clean',
            'UUID': '12dd4cfc:6b2ac9db:94564538:a6ffee82',
            'devices': ['/dev/loop4', '/dev/loop5']
        }]

        mds = mu.mddisplay()
        mock_exec.assert_called_once_with(
            'mdadm', '--detail', '/dev/md0', check_exit_code=[0])

        key = lambda x: x['name']
        self.assertEqual(sorted(expected, key=key), sorted(mds, key=key))
        patcher.stop()
Exemplo n.º 4
0
    def test_mddisplay(self, mock_exec):
        # should read file /proc/mdstat
        # should get detailed description for all md devices
        # should return list of dicts representing md devices

        mock_open_data = """Personalities : [raid1]
md0 : active raid1 loop5[1] loop4[0]
      102272 blocks super 1.2 [2/2] [UU]

unused devices: <none>


        """
        mock_open = mock.mock_open(read_data=mock_open_data)
        patcher = mock.patch(OPEN_FUNCTION_NAME, new=mock_open)
        patcher.start()

        mock_exec.return_value = ("""/dev/md0:
        Version : 1.2
  Creation Time : Wed Jun 18 18:44:57 2014
     Raid Level : raid1
     Array Size : 102272 (99.89 MiB 104.73 MB)
  Used Dev Size : 102272 (99.89 MiB 104.73 MB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Wed Jun 18 18:45:01 2014
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : localhost.localdomain:0  (local to host
localhost.localdomain)
           UUID : 12dd4cfc:6b2ac9db:94564538:a6ffee82
         Events : 17

    Number   Major   Minor   RaidDevice State
       0       7        4        0      active sync   /dev/loop4
       1       7        5        1      active sync   /dev/loop5""", '')

        expected = [{
            'name': '/dev/md0',
            'Version': '1.2',
            'Raid Level': 'raid1',
            'Raid Devices': '2',
            'Active Devices': '2',
            'Spare Devices': '0',
            'Failed Devices': '0',
            'State': 'clean',
            'UUID': '12dd4cfc:6b2ac9db:94564538:a6ffee82',
            'devices': ['/dev/loop4', '/dev/loop5']
        }]

        mds = mu.mddisplay()
        mock_exec.assert_called_once_with('mdadm',
                                          '--detail',
                                          '/dev/md0',
                                          check_exit_code=[0])

        key = lambda x: x['name']
        self.assertEqual(sorted(expected, key=key), sorted(mds, key=key))
        patcher.stop()