Merge "Remove inject_file from compute manager and virt driver"
This commit is contained in:
commit
8988316b8c
@ -4045,27 +4045,6 @@ class ComputeManager(manager.Manager):
|
||||
raise exception.InstancePasswordSetFailed(
|
||||
instance=instance.uuid, reason=_msg)
|
||||
|
||||
@wrap_exception()
|
||||
@reverts_task_state
|
||||
@wrap_instance_fault
|
||||
def inject_file(self, context, path, file_contents, instance):
|
||||
"""Write a file to the specified path in an instance on this host."""
|
||||
# NOTE(russellb) Remove this method, as well as the underlying virt
|
||||
# driver methods, when the compute rpc interface is bumped to 4.x
|
||||
# as it is no longer used.
|
||||
context = context.elevated()
|
||||
current_power_state = self._get_power_state(context, instance)
|
||||
expected_state = power_state.RUNNING
|
||||
if current_power_state != expected_state:
|
||||
LOG.warning('trying to inject a file into a non-running '
|
||||
'(state: %(current_state)s expected: '
|
||||
'%(expected_state)s)',
|
||||
{'current_state': current_power_state,
|
||||
'expected_state': expected_state},
|
||||
instance=instance)
|
||||
LOG.info('injecting file to %s', path, instance=instance)
|
||||
self.driver.inject_file(instance, path, file_contents)
|
||||
|
||||
def _get_rescue_image(self, context, instance, rescue_image_ref=None):
|
||||
"""Determine what image should be used to boot the rescue VM."""
|
||||
# 1. If rescue_image_ref is passed in, use that for rescue.
|
||||
|
@ -12,7 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import base64
|
||||
from collections import deque
|
||||
import sys
|
||||
import traceback
|
||||
@ -281,13 +280,6 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
|
||||
instance, network_info = self._get_running_instance(obj=True)
|
||||
self.connection.set_admin_password(instance, 'p4ssw0rd')
|
||||
|
||||
@catch_notimplementederror
|
||||
def test_inject_file(self):
|
||||
instance_ref, network_info = self._get_running_instance()
|
||||
self.connection.inject_file(instance_ref,
|
||||
base64.b64encode(b'/testfile'),
|
||||
base64.b64encode(b'testcontents'))
|
||||
|
||||
@catch_notimplementederror
|
||||
def test_resume_state_on_host_boot(self):
|
||||
instance_ref, network_info = self._get_running_instance()
|
||||
|
@ -1351,21 +1351,6 @@ class ComputeDriver(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def inject_file(self, instance, b64_path, b64_contents):
|
||||
"""Writes a file 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 base64-encoded path to which the file is to be
|
||||
written on the instance; the third is the contents of the file, also
|
||||
base64-encoded.
|
||||
|
||||
NOTE(russellb) This method is deprecated and will be removed once it
|
||||
can be removed from nova.compute.manager.
|
||||
"""
|
||||
# TODO(Vek): Need to pass context in for access to auth_token
|
||||
raise NotImplementedError()
|
||||
|
||||
def change_instance_metadata(self, context, instance, diff):
|
||||
"""Applies a diff to the instance metadata.
|
||||
|
||||
|
@ -230,9 +230,6 @@ class FakeDriver(driver.ComputeDriver):
|
||||
def set_admin_password(self, instance, new_pass):
|
||||
pass
|
||||
|
||||
def inject_file(self, instance, b64_path, b64_contents):
|
||||
pass
|
||||
|
||||
def resume_state_on_host_boot(self, context, instance, network_info,
|
||||
block_device_info=None):
|
||||
pass
|
||||
|
@ -263,12 +263,6 @@ class XenAPIDriver(driver.ComputeDriver):
|
||||
"""Set the root/admin password on the VM instance."""
|
||||
self._vmops.set_admin_password(instance, new_pass)
|
||||
|
||||
def inject_file(self, instance, b64_path, b64_contents):
|
||||
"""Create a file on the VM instance. The file path and contents
|
||||
should be base64-encoded.
|
||||
"""
|
||||
self._vmops.inject_file(instance, b64_path, b64_contents)
|
||||
|
||||
def change_instance_metadata(self, context, instance, diff):
|
||||
"""Apply a diff to the instance metadata."""
|
||||
self._vmops.change_instance_metadata(instance, diff)
|
||||
|
@ -1470,15 +1470,6 @@ class VMOps(object):
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
def inject_file(self, instance, path, contents):
|
||||
"""Write a file to the VM instance."""
|
||||
if self.agent_enabled(instance):
|
||||
vm_ref = self._get_vm_opaque_ref(instance)
|
||||
agent = self._get_agent(instance, vm_ref)
|
||||
agent.inject_file(path, contents)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
@staticmethod
|
||||
def _sanitize_xenstore_key(key):
|
||||
"""Xenstore only allows the following characters as keys:
|
||||
|
Loading…
Reference in New Issue
Block a user