diff options
| -rw-r--r-- | nova/compute/api.py | 8 | ||||
| -rw-r--r-- | nova/tests/test_compute.py | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 060dcd799..ab81dfbd7 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1455,9 +1455,13 @@ class API(base.Base): {"method": "set_admin_password", "args": {"instance_id": instance_id, "new_pass": password}}) - def inject_file(self, context, instance_id): + @scheduler_api.reroute_compute("inject_file") + def inject_file(self, context, instance, path, file_contents): """Write a file to the given instance.""" - self._cast_compute_message('inject_file', context, instance_id) + instance_id = instance['id'] + params = {'path': path, 'file_contents': file_contents} + self._cast_compute_message('inject_file', context, + instance_id, params=params) def get_ajax_console(self, context, instance_id): """Get a url to an AJAX Console.""" diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index bf3c1ea59..f99927909 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -1882,3 +1882,11 @@ class ComputeAPITestCase(BaseTestCase): self.compute_api.add_fixed_ip(self.context, instance, '1') self.compute_api.remove_fixed_ip(self.context, instance, '192.168.1.1') self.compute_api.delete(self.context, instance) + + def test_inject_file(self): + """Ensure we can write a file to an instance""" + instance_id = self._create_instance() + instance = self.compute_api.get(self.context, instance_id) + self.compute_api.inject_file(self.context, instance, + "/tmp/test", "File Contents") + db.instance_destroy(self.context, instance_id) |
