Add test for agent update
This commit is contained in:
@@ -470,6 +470,24 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
LOG.audit(msg)
|
LOG.audit(msg)
|
||||||
self.driver.inject_file(instance_ref, path, file_contents)
|
self.driver.inject_file(instance_ref, path, file_contents)
|
||||||
|
|
||||||
|
@exception.wrap_exception
|
||||||
|
@checks_instance_lock
|
||||||
|
def agent_update(self, context, instance_id, url, md5hash):
|
||||||
|
"""Update agent running on an instance on this host."""
|
||||||
|
context = context.elevated()
|
||||||
|
instance_ref = self.db.instance_get(context, instance_id)
|
||||||
|
instance_id = instance_ref['id']
|
||||||
|
instance_state = instance_ref['state']
|
||||||
|
expected_state = power_state.RUNNING
|
||||||
|
if instance_state != expected_state:
|
||||||
|
LOG.warn(_('trying to update agent on a non-running '
|
||||||
|
'instance: %(instance_id)s (state: %(instance_state)s '
|
||||||
|
'expected: %(expected_state)s)') % locals())
|
||||||
|
nm = instance_ref['name']
|
||||||
|
msg = _('instance %(nm)s: updating agent to %(url)s') % locals()
|
||||||
|
LOG.audit(msg)
|
||||||
|
self.driver.agent_update(instance_ref, url, md5hash)
|
||||||
|
|
||||||
@exception.wrap_exception
|
@exception.wrap_exception
|
||||||
@checks_instance_lock
|
@checks_instance_lock
|
||||||
def rescue_instance(self, context, instance_id):
|
def rescue_instance(self, context, instance_id):
|
||||||
|
|||||||
@@ -266,6 +266,14 @@ class ComputeTestCase(test.TestCase):
|
|||||||
"File Contents")
|
"File Contents")
|
||||||
self.compute.terminate_instance(self.context, instance_id)
|
self.compute.terminate_instance(self.context, instance_id)
|
||||||
|
|
||||||
|
def test_agent_update(self):
|
||||||
|
"""Ensure instance can have its agent updated"""
|
||||||
|
instance_id = self._create_instance()
|
||||||
|
self.compute.run_instance(self.context, instance_id)
|
||||||
|
self.compute.agent_update(self.context, instance_id,
|
||||||
|
'http://127.0.0.1/agent', '00112233445566778899aabbccddeeff')
|
||||||
|
self.compute.terminate_instance(self.context, instance_id)
|
||||||
|
|
||||||
def test_snapshot(self):
|
def test_snapshot(self):
|
||||||
"""Ensure instance can be snapshotted"""
|
"""Ensure instance can be snapshotted"""
|
||||||
instance_id = self._create_instance()
|
instance_id = self._create_instance()
|
||||||
|
|||||||
@@ -234,6 +234,10 @@ class ComputeDriver(object):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def agent_update(self, instance, url, md5hash):
|
||||||
|
"""Update agent on the VM instance."""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
def inject_network_info(self, instance):
|
def inject_network_info(self, instance):
|
||||||
"""inject network info for specified instance"""
|
"""inject network info for specified instance"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|||||||
@@ -225,6 +225,21 @@ class FakeConnection(driver.ComputeDriver):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def agent_update(self, instance, url, md5hash):
|
||||||
|
"""
|
||||||
|
Update agent on the specified instance.
|
||||||
|
|
||||||
|
The first parameter is an instance of nova.compute.service.Instance,
|
||||||
|
and so the instance is being specified as instance.name. The second
|
||||||
|
parameter is the URL of the agent to be fetched and updated on the
|
||||||
|
instance; the third is the md5 hash of the file for verification
|
||||||
|
purposes.
|
||||||
|
|
||||||
|
The work will be done asynchronously. This function returns a
|
||||||
|
task that allows the caller to detect when it is complete.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def rescue(self, instance):
|
def rescue(self, instance):
|
||||||
"""
|
"""
|
||||||
Rescue the specified instance.
|
Rescue the specified instance.
|
||||||
|
|||||||
Reference in New Issue
Block a user