示例#1
0
    def test_get_nics(self):
        '''
            Test to return info about the network interfaces of a named vm
        '''
        ret = {'Stack': {'device': 'ETH0', 'mac': 'Stack', 'mtu': 1}}
        with patch.object(xapi, "_get_xapi_session", MagicMock()):
            mock = MagicMock(side_effect=[False, {"VIFs": "salt"}])
            with patch.object(xapi, "_get_record_by_label", mock):
                self.assertFalse(xapi.get_nics("salt"))

                mock = MagicMock(return_value={"MAC": "Stack",
                                               "device": "ETH0", "MTU": 1})
                with patch.object(xapi, "_get_record", mock):
                    self.assertDictEqual(xapi.get_nics("salt"), ret)
示例#2
0
    def test_get_nics(self):
        '''
            Test to return info about the network interfaces of a named vm
        '''
        ret = {'Stack': {'device': 'ETH0', 'mac': 'Stack', 'mtu': 1}}
        with patch.object(xapi, "_get_xapi_session", MagicMock()):
            mock = MagicMock(side_effect=[False, {"VIFs": "salt"}])
            with patch.object(xapi, "_get_record_by_label", mock):
                self.assertFalse(xapi.get_nics("salt"))

                mock = MagicMock(return_value={"MAC": "Stack",
                                               "device": "ETH0", "MTU": 1})
                with patch.object(xapi, "_get_record", mock):
                    self.assertDictEqual(xapi.get_nics("salt"), ret)