Exemple #1
0
    def test_network(self):
        '''
        Test to ensure the DRAC network settings are consistent
        '''
        ip_ = '10.225.108.29'
        netmask = '255.255.255.224'
        gateway = '10.225.108.1'

        ret = {'name': ip_, 'result': None, 'comment': '', 'changes': {}}

        net_info = {
            'IPv4 settings': {
                'IP Address': ip_,
                'Subnet Mask': netmask,
                'Gateway': gateway
            }
        }

        mock_info = MagicMock(return_value=net_info)
        mock_bool = MagicMock(side_effect=[True, False])
        with patch.dict(drac.__salt__, {
                'drac.network_info': mock_info,
                'drac.set_network': mock_bool
        }):
            with patch.dict(drac.__opts__, {'test': True}):
                self.assertDictEqual(drac.network(ip_, netmask, gateway), ret)

            with patch.dict(drac.__opts__, {'test': False}):
                comt = ('Network is in the desired state')
                ret.update({'comment': comt, 'result': True})
                self.assertDictEqual(drac.network(ip_, netmask, gateway), ret)

                comt = ('unable to configure network')
                ret.update({'comment': comt, 'result': False})
                self.assertDictEqual(drac.network(ip_, netmask, gateway), ret)
Exemple #2
0
    def test_network(self):
        '''
        Test to ensure the DRAC network settings are consistent
        '''
        ip_ = '10.225.108.29'
        netmask = '255.255.255.224'
        gateway = '10.225.108.1'

        ret = {'name': ip_,
               'result': None,
               'comment': '',
               'changes': {}}

        net_info = {'IPv4 settings': {'IP Address': ip_, 'Subnet Mask': netmask,
                                      'Gateway': gateway}}

        mock_info = MagicMock(return_value=net_info)
        mock_bool = MagicMock(side_effect=[True, False])
        with patch.dict(drac.__salt__, {'drac.network_info': mock_info,
                                        'drac.set_network': mock_bool}):
            with patch.dict(drac.__opts__, {'test': True}):
                self.assertDictEqual(drac.network(ip_, netmask, gateway), ret)

            with patch.dict(drac.__opts__, {'test': False}):
                comt = ('Network is in the desired state')
                ret.update({'comment': comt, 'result': True})
                self.assertDictEqual(drac.network(ip_, netmask, gateway), ret)

                comt = ('unable to configure network')
                ret.update({'comment': comt, 'result': False})
                self.assertDictEqual(drac.network(ip_, netmask, gateway), ret)
Exemple #3
0
    def test_network(self):
        """
        Test to ensure the DRAC network settings are consistent
        """
        ip_ = "10.225.108.29"
        netmask = "255.255.255.224"
        gateway = "10.225.108.1"

        ret = {"name": ip_, "result": None, "comment": "", "changes": {}}

        net_info = {
            "IPv4 settings": {
                "IP Address": ip_,
                "Subnet Mask": netmask,
                "Gateway": gateway,
            }
        }

        mock_info = MagicMock(return_value=net_info)
        mock_bool = MagicMock(side_effect=[True, False])
        with patch.dict(
            drac.__salt__,
            {"drac.network_info": mock_info, "drac.set_network": mock_bool},
        ):
            with patch.dict(drac.__opts__, {"test": True}):
                self.assertDictEqual(drac.network(ip_, netmask, gateway), ret)

            with patch.dict(drac.__opts__, {"test": False}):
                comt = "Network is in the desired state"
                ret.update({"comment": comt, "result": True})
                self.assertDictEqual(drac.network(ip_, netmask, gateway), ret)

                comt = "unable to configure network"
                ret.update({"comment": comt, "result": False})
                self.assertDictEqual(drac.network(ip_, netmask, gateway), ret)