Esempio n. 1
0
 def test_agent_is_disabled(self):
     self.flags(use_agent_default=True, group='xenserver')
     instance = {
         "system_metadata": [{
             "key": "image_xenapi_use_agent",
             "value": "false"
         }]
     }
     self.assertFalse(agent.should_use_agent(instance))
Esempio n. 2
0
 def test_agent_is_present(self):
     self.flags(xenapi_use_agent_default=False)
     instance = {
         "system_metadata": [{
             "key": "image_xenapi_use_agent",
             "value": "true"
         }]
     }
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 3
0
 def test_agent_uses_deafault_when_prop_invalid(self):
     self.flags(xenapi_use_agent_default=True)
     instance = {
         "system_metadata": {
             "image_xenapi_use_agent": "bob"
         },
         "uuid": "uuid"
     }
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 4
0
 def test_agent_uses_deafault_when_prop_invalid(self):
     self.flags(use_agent_default=True, group='xenserver')
     instance = {
         "system_metadata": [{
             "key": "image_xenapi_use_agent",
             "value": "bob"
         }],
         "uuid": "uuid"
     }
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 5
0
    def test_agent_update_setup(self):
        # agent updates need to occur after networking is configured
        instance = {"name": "betelgeuse", "uuid": "1-2-3-4-5-6"}
        vm_ref = "vm_ref"
        agent = xenapi_agent.XenAPIBasedAgent(self.vmops._session, self.vmops._virtapi, instance, vm_ref)

        self.mox.StubOutWithMock(xenapi_agent, "should_use_agent")
        self.mox.StubOutWithMock(self.vmops, "_get_agent")
        self.mox.StubOutWithMock(agent, "get_version")
        self.mox.StubOutWithMock(agent, "resetnetwork")
        self.mox.StubOutWithMock(agent, "update_if_needed")

        xenapi_agent.should_use_agent(instance).AndReturn(True)
        self.vmops._get_agent(instance, vm_ref).AndReturn(agent)
        agent.get_version().AndReturn("1.2.3")
        agent.resetnetwork()
        agent.update_if_needed("1.2.3")

        self.mox.ReplayAll()
        self.vmops._configure_new_instance_with_agent(instance, vm_ref, None, None)
Esempio n. 6
0
    def test_agent_update_setup(self):
        # agent updates need to occur after networking is configured
        instance = {'name': 'betelgeuse', 'uuid': '1-2-3-4-5-6'}
        vm_ref = 'vm_ref'
        agent = xenapi_agent.XenAPIBasedAgent(self.vmops._session,
                                              self.vmops._virtapi, instance,
                                              vm_ref)

        self.mox.StubOutWithMock(xenapi_agent, 'should_use_agent')
        self.mox.StubOutWithMock(self.vmops, '_get_agent')
        self.mox.StubOutWithMock(agent, 'get_version')
        self.mox.StubOutWithMock(agent, 'resetnetwork')
        self.mox.StubOutWithMock(agent, 'update_if_needed')

        xenapi_agent.should_use_agent(instance).AndReturn(True)
        self.vmops._get_agent(instance, vm_ref).AndReturn(agent)
        agent.get_version().AndReturn('1.2.3')
        agent.resetnetwork()
        agent.update_if_needed('1.2.3')

        self.mox.ReplayAll()
        self.vmops._configure_new_instance_with_agent(instance, vm_ref, None,
                                                      None)
Esempio n. 7
0
    def test_agent_update_setup(self):
        # agent updates need to occur after networking is configured
        instance = {'name': 'betelgeuse',
                    'uuid': '1-2-3-4-5-6'}
        vm_ref = 'vm_ref'
        agent = xenapi_agent.XenAPIBasedAgent(self.vmops._session,
                self.vmops._virtapi, instance, vm_ref)

        self.mox.StubOutWithMock(xenapi_agent, 'should_use_agent')
        self.mox.StubOutWithMock(self.vmops, '_get_agent')
        self.mox.StubOutWithMock(agent, 'get_version')
        self.mox.StubOutWithMock(agent, 'resetnetwork')
        self.mox.StubOutWithMock(agent, 'update_if_needed')

        xenapi_agent.should_use_agent(instance).AndReturn(True)
        self.vmops._get_agent(instance, vm_ref).AndReturn(agent)
        agent.get_version().AndReturn('1.2.3')
        agent.resetnetwork()
        agent.update_if_needed('1.2.3')

        self.mox.ReplayAll()
        self.vmops._configure_new_instance_with_agent(instance, vm_ref,
                None, None)
Esempio n. 8
0
 def test_agent_is_disabled(self):
     self.flags(xenapi_use_agent_default=True)
     instance = {"system_metadata": {"image_xenapi_use_agent": "false"}}
     self.assertFalse(agent.should_use_agent(instance))
Esempio n. 9
0
 def test_agent_default_present(self):
     self.flags(use_agent_default=True, group='xenserver')
     instance = {"system_metadata": []}
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 10
0
 def test_agent_default_present(self):
     self.flags(use_agent_default=True, group='xenserver')
     instance = {"system_metadata": []}
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 11
0
 def test_agent_uses_deafault_when_prop_invalid(self):
     self.flags(xenapi_use_agent_default=True)
     instance = {"system_metadata":
         {"image_xenapi_use_agent": "bob"},
         "uuid": "uuid"}
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 12
0
 def test_agent_default_present(self):
     self.flags(xenapi_use_agent_default=True)
     instance = {"system_metadata": []}
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 13
0
 def test_agent_default_not_present(self):
     self.flags(xenapi_use_agent_default=False)
     instance = {"system_metadata": []}
     self.assertFalse(agent.should_use_agent(instance))
Esempio n. 14
0
 def test_agent_is_present(self):
     self.flags(xenapi_use_agent_default=False)
     instance = {"system_metadata":
         [{"key": "image_xenapi_use_agent", "value": "true"}]}
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 15
0
 def test_agent_default_not_present(self):
     self.flags(xenapi_use_agent_default=False)
     instance = {"system_metadata": {}}
     self.assertFalse(agent.should_use_agent(instance))
Esempio n. 16
0
 def test_agent_default_present(self):
     self.flags(xenapi_use_agent_default=True)
     instance = {"system_metadata": {}}
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 17
0
 def test_agent_is_disabled(self):
     self.flags(use_agent_default=True, group='xenserver')
     instance = {"system_metadata":
         [{"key": "image_xenapi_use_agent", "value": "false"}]}
     self.assertFalse(agent.should_use_agent(instance))
Esempio n. 18
0
 def test_agent_uses_deafault_when_prop_invalid(self):
     self.flags(use_agent_default=True, group='xenserver')
     instance = {"system_metadata":
         [{"key": "image_xenapi_use_agent", "value": "bob"}],
         "uuid": "uuid"}
     self.assertTrue(agent.should_use_agent(instance))
Esempio n. 19
0
 def test_agent_is_disabled(self):
     self.flags(xenapi_use_agent_default=True)
     instance = {"system_metadata":
         {"image_xenapi_use_agent": "false"}}
     self.assertFalse(agent.should_use_agent(instance))