Commit 3225dd51fbbf059851e80b380f9b62907b42ed61
1 parent
f3a845b0
first very rudimentary access to lxd rest api
Showing
4 changed files
with
34 additions
and
1 deletions
app/models/lxd.rb
0 → 100644
app/models/lxd/server.rb
0 → 100644
1 | +class Lxd::Server | ||
2 | + include ActiveModel::Model | ||
3 | + | ||
4 | + attr_accessor :api_extensions, :api_status, :api_version, :auth, :config, | ||
5 | + :environment, :public | ||
6 | + | ||
7 | + def self.by_host(host, certificate) | ||
8 | + all = Array.new; | ||
9 | + | ||
10 | + uri = URI.parse(host.uri + '/1.0') | ||
11 | + http = Net::HTTP.new(uri.host, uri.port) | ||
12 | + http.use_ssl = true | ||
13 | + http.cert = OpenSSL::X509::Certificate.new(certificate.cert) | ||
14 | + http.key = OpenSSL::PKey::RSA.new(certificate.key) | ||
15 | + http.verify_mode = OpenSSL::SSL::VERIFY_NONE | ||
16 | + | ||
17 | + request = Net::HTTP::Get.new(uri.request_uri) | ||
18 | + response = http.request(request) | ||
19 | + | ||
20 | + Lxd::Server.new(JSON.parse(response.body)['metadata']) | ||
21 | + end | ||
22 | +end | ||
23 | +# vim: set ts=2 sw=2: |
Please
register
or
login
to post a comment