connection.rb
1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class Lxd::Connection
attr_reader :con, :host, :port
"""
/1.0
/1.0/certificates
/1.0/certificates/<fingerprint>
/1.0/containers
/1.0/containers/<name>
/1.0/containers/<name>/exec
/1.0/containers/<name>/files
/1.0/containers/<name>/snapshots
/1.0/containers/<name>/snapshots/<name>
/1.0/containers/<name>/state
/1.0/containers/<name>/logs
/1.0/containers/<name>/logs/<logfile>
/1.0/events
/1.0/images
/1.0/images/<fingerprint>
/1.0/images/<fingerprint>/export
/1.0/images/aliases
/1.0/images/aliases/<name>
/1.0/networks
/1.0/networks/<name>
/1.0/operations
/1.0/operations/<uuid>
/1.0/operations/<uuid>/wait
/1.0/operations/<uuid>/websocket
/1.0/profiles
/1.0/profiles/<name>
"""
def initialize host, certificate
uri = URI.parse host.uri
@host = uri.host
@port = uri.port
@con = Net::HTTP.new @host, @port
@con.use_ssl = true
@con.cert = OpenSSL::X509::Certificate.new certificate.cert
@con.key = OpenSSL::PKey::EC.new certificate.key
@con.verify_mode = OpenSSL::SSL:VERIFY_NONE
end
def call
if not @api_version
@con.request(Net::HTTP::Get.new '/')
versions
end
end
# vim: set et ts=2 sw=2: