diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 391fa2e..dc3e4a4 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,4 +1,8 @@ class DashboardController < ApplicationController def index + @lxd_host = LxdHost.find(1) + @cert = Certificate.find(1) + @lxd = Lxd::Server.by_host @lxd_host, @cert end end +# vim: set et ts=2 sw=2: diff --git a/app/models/lxd.rb b/app/models/lxd.rb new file mode 100644 index 0000000..19242eb --- /dev/null +++ b/app/models/lxd.rb @@ -0,0 +1,3 @@ +module Lxd +end +# vim: set ts=2 sw=2: diff --git a/app/models/lxd/server.rb b/app/models/lxd/server.rb new file mode 100644 index 0000000..6ce48af --- /dev/null +++ b/app/models/lxd/server.rb @@ -0,0 +1,23 @@ +class Lxd::Server + include ActiveModel::Model + + attr_accessor :api_extensions, :api_status, :api_version, :auth, :config, + :environment, :public + + def self.by_host(host, certificate) + all = Array.new; + + uri = URI.parse(host.uri + '/1.0') + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + http.cert = OpenSSL::X509::Certificate.new(certificate.cert) + http.key = OpenSSL::PKey::RSA.new(certificate.key) + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + + request = Net::HTTP::Get.new(uri.request_uri) + response = http.request(request) + + Lxd::Server.new(JSON.parse(response.body)['metadata']) + end +end +# vim: set ts=2 sw=2: diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 8179f3e..0192e53 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -1,2 +1,5 @@

Dashboard#index

-

Find me in app/views/dashboard/index.html.erb

+

<%= @lxd_host.class %>

+

<%= @cert.class %>

+

<%= @lxd.class %>

+

<%= @lxd.auth %>