It'd be better to use a RABL file here to describe the different console types (spice, vnc, log):

    def console
      return unless @host.compute_resource
      @console = @host.compute_resource.console @host.uuid
      @console[:name] ||= URI.parse(Setting[:foreman_url]).host
      @console = OpenStruct.new @console
    end

(no `render` needed)

Then in app/views/api/v2/hosts/console.json.rabl reference `object @console`.  I'd then do something like app/views/api/v2/compute_resources/main.json.rabl (partials) to call one of `{spice,vnc,log}.json.rabl` using the `type` attribute as they're going to use different attributes ("log" especially as we actually have the console contents in `@console[:log]`).

As an example of VNC, you can do something like:

    attributes :proxy_port => :port
    attributes :host, :type, :password