'Write a file to the specified path in an instance on this host.'

@wrap_exception()
@reverts_task_state
@wrap_instance_fault
def inject_file(self, context, path, file_contents, instance):

    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)
