Exemple #1
0
    def test_vcpu_pin(self):
        '''
            Test to Set which CPUs a VCPU can use.
        '''
        with patch.object(xapi, "_get_xapi_session", MagicMock()):
            mock = MagicMock(side_effect=[False, ["a", "b", "c"]])
            with patch.object(xapi, "_get_label_uuid", mock):
                self.assertFalse(xapi.vcpu_pin("salt", "1", "2"))

                self.assertTrue(xapi.vcpu_pin("salt", "1", "2"))

        with patch.object(xapi, "_check_xenapi",
                          MagicMock(return_value=Mockxapi)):
            mock = MagicMock(return_value=True)
            with patch.dict(xapi.__salt__, {'config.option': mock}):
                with patch.object(xapi, "_get_label_uuid", mock):
                    with patch.dict(xapi.__salt__, {'cmd.run': mock}):
                        self.assertTrue(xapi.vcpu_pin("salt", "1", "2"))
Exemple #2
0
    def test_vcpu_pin(self):
        '''
            Test to Set which CPUs a VCPU can use.
        '''
        with patch.object(xapi, "_get_xapi_session", MagicMock()):
            mock = MagicMock(side_effect=[False, ["a", "b", "c"]])
            with patch.object(xapi, "_get_label_uuid", mock):
                self.assertFalse(xapi.vcpu_pin("salt", "1", "2"))

                self.assertTrue(xapi.vcpu_pin("salt", "1", "2"))

        with patch.object(xapi, "_check_xenapi",
                          MagicMock(return_value=Mockxapi)):
            mock = MagicMock(return_value=True)
            with patch.dict(xapi.__salt__, {'config.option': mock}):
                with patch.object(xapi, "_get_label_uuid", mock):
                    with patch.dict(xapi.__salt__, {'cmd.run': mock}):
                        self.assertTrue(xapi.vcpu_pin("salt", "1", "2"))