Ejemplo n.º 1
0
    def test_pvdisplay(self):
        '''
        Tests information about the physical volume(s)
        '''
        mock = MagicMock(return_value={'retcode': 1})
        with patch.dict(linux_lvm.__salt__, {'cmd.run_all': mock}):
            self.assertDictEqual(linux_lvm.pvdisplay(), {})

        mock = MagicMock(return_value={
            'retcode': 0,
            'stdout': 'A:B:C:D:E:F:G:H:I:J:K'
        })
        with patch.dict(linux_lvm.__salt__, {'cmd.run_all': mock}):
            self.assertDictEqual(
                linux_lvm.pvdisplay(), {
                    'A': {
                        'Allocated Physical Extents': 'K',
                        'Current Logical Volumes Here': 'G',
                        'Free Physical Extents': 'J',
                        'Internal Physical Volume Number': 'D',
                        'Physical Extent Size (kB)': 'H',
                        'Physical Volume (not) Allocatable': 'F',
                        'Physical Volume Device': 'A',
                        'Physical Volume Size (kB)': 'C',
                        'Physical Volume Status': 'E',
                        'Total Physical Extents': 'I',
                        'Volume Group Name': 'B'
                    }
                })
Ejemplo n.º 2
0
    def test_pvdisplay(self):
        """
        Tests information about the physical volume(s)
        """
        mock = MagicMock(return_value={"retcode": 1})
        with patch.dict(linux_lvm.__salt__, {"cmd.run_all": mock}):
            self.assertDictEqual(linux_lvm.pvdisplay(), {})

        mock = MagicMock(return_value={"retcode": 1})
        with patch.dict(linux_lvm.__salt__, {"cmd.run_all": mock}):
            self.assertDictEqual(linux_lvm.pvdisplay(quiet=True), {})
            mock.assert_called_with(["pvdisplay", "-c"],
                                    ignore_retcode=True,
                                    python_shell=False)

        mock = MagicMock(return_value={
            "retcode": 0,
            "stdout": "A:B:C:D:E:F:G:H:I:J:K"
        })
        with patch.dict(linux_lvm.__salt__, {"cmd.run_all": mock}):
            self.assertDictEqual(
                linux_lvm.pvdisplay(),
                {
                    "A": {
                        "Allocated Physical Extents": "K",
                        "Current Logical Volumes Here": "G",
                        "Free Physical Extents": "J",
                        "Internal Physical Volume Number": "D",
                        "Physical Extent Size (kB)": "H",
                        "Physical Volume (not) Allocatable": "F",
                        "Physical Volume Device": "A",
                        "Physical Volume Size (kB)": "C",
                        "Physical Volume Status": "E",
                        "Total Physical Extents": "I",
                        "Volume Group Name": "B",
                    }
                },
            )

            mockpath = MagicMock(return_value="Z")
            with patch.object(os.path, "realpath", mockpath):
                self.assertDictEqual(
                    linux_lvm.pvdisplay(real=True),
                    {
                        "Z": {
                            "Allocated Physical Extents": "K",
                            "Current Logical Volumes Here": "G",
                            "Free Physical Extents": "J",
                            "Internal Physical Volume Number": "D",
                            "Physical Extent Size (kB)": "H",
                            "Physical Volume (not) Allocatable": "F",
                            "Physical Volume Device": "A",
                            "Physical Volume Size (kB)": "C",
                            "Physical Volume Status": "E",
                            "Real Physical Volume Device": "Z",
                            "Total Physical Extents": "I",
                            "Volume Group Name": "B",
                        }
                    },
                )
Ejemplo n.º 3
0
    def test_pvdisplay(self):
        '''
        Tests information about the physical volume(s)
        '''
        mock = MagicMock(return_value={'retcode': 1})
        with patch.dict(linux_lvm.__salt__, {'cmd.run_all': mock}):
            self.assertDictEqual(linux_lvm.pvdisplay(), {})

        mock = MagicMock(return_value={'retcode': 1})
        with patch.dict(linux_lvm.__salt__, {'cmd.run_all': mock}):
            self.assertDictEqual(linux_lvm.pvdisplay(quiet=True), {})
            mock.assert_called_with(['pvdisplay', '-c'],
                                    ignore_retcode=True,
                                    python_shell=False)

        mock = MagicMock(return_value={
            'retcode': 0,
            'stdout': 'A:B:C:D:E:F:G:H:I:J:K'
        })
        with patch.dict(linux_lvm.__salt__, {'cmd.run_all': mock}):
            self.assertDictEqual(
                linux_lvm.pvdisplay(), {
                    'A': {
                        'Allocated Physical Extents': 'K',
                        'Current Logical Volumes Here': 'G',
                        'Free Physical Extents': 'J',
                        'Internal Physical Volume Number': 'D',
                        'Physical Extent Size (kB)': 'H',
                        'Physical Volume (not) Allocatable': 'F',
                        'Physical Volume Device': 'A',
                        'Physical Volume Size (kB)': 'C',
                        'Physical Volume Status': 'E',
                        'Total Physical Extents': 'I',
                        'Volume Group Name': 'B'
                    }
                })

            mockpath = MagicMock(return_value='Z')
            with patch.object(os.path, 'realpath', mockpath):
                self.assertDictEqual(
                    linux_lvm.pvdisplay(real=True), {
                        'Z': {
                            'Allocated Physical Extents': 'K',
                            'Current Logical Volumes Here': 'G',
                            'Free Physical Extents': 'J',
                            'Internal Physical Volume Number': 'D',
                            'Physical Extent Size (kB)': 'H',
                            'Physical Volume (not) Allocatable': 'F',
                            'Physical Volume Device': 'A',
                            'Physical Volume Size (kB)': 'C',
                            'Physical Volume Status': 'E',
                            'Real Physical Volume Device': 'Z',
                            'Total Physical Extents': 'I',
                            'Volume Group Name': 'B'
                        }
                    })
Ejemplo n.º 4
0
    def test_pvdisplay(self):
        '''
        Tests information about the physical volume(s)
        '''
        mock = MagicMock(return_value={'retcode': 1})
        with patch.dict(linux_lvm.__salt__, {'cmd.run_all': mock}):
            self.assertDictEqual(linux_lvm.pvdisplay(), {})

        mock = MagicMock(return_value={'retcode': 0,
                                       'stdout': 'A:B:C:D:E:F:G:H:I:J:K'})
        with patch.dict(linux_lvm.__salt__, {'cmd.run_all': mock}):
            self.assertDictEqual(linux_lvm.pvdisplay(),
                                 {'A': {'Allocated Physical Extents': 'K',
                                        'Current Logical Volumes Here': 'G',
                                        'Free Physical Extents': 'J',
                                        'Internal Physical Volume Number': 'D',
                                        'Physical Extent Size (kB)': 'H',
                                        'Physical Volume (not) Allocatable': 'F',
                                        'Physical Volume Device': 'A',
                                        'Physical Volume Size (kB)': 'C',
                                        'Physical Volume Status': 'E',
                                        'Total Physical Extents': 'I',
                                        'Volume Group Name': 'B'}})