You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
888 B
54 lines
888 B
class Lxd::API::V1_0
|
|
include Lxd::API
|
|
|
|
def config
|
|
get '/1.0'
|
|
end
|
|
|
|
def config= config={}
|
|
put '/1.0', config: config
|
|
end
|
|
|
|
def certificates
|
|
get '/1.0/certificates'.map { |uri|
|
|
{
|
|
:uri => uri,
|
|
:cert => get(uri)
|
|
}
|
|
}
|
|
end
|
|
|
|
def add_certificate cert={}
|
|
# TODO validate hash
|
|
post '/1.0/certificates', cert
|
|
end
|
|
|
|
def handle_response resp
|
|
"""
|
|
100 Operation created
|
|
101 Started
|
|
102 Stopped
|
|
103 Running
|
|
104 Cancelling
|
|
105 Pending
|
|
106 Starting
|
|
107 Stopping
|
|
108 Aborting
|
|
109 Freezing
|
|
110 Frozen
|
|
111 Thawed
|
|
200 Success
|
|
400 Failure
|
|
401 Cancelled
|
|
|
|
|
|
100 to 199: resource state (started, stopped, ready, ...)
|
|
200 to 399: positive action result
|
|
400 to 599: negative action result
|
|
600 to 999: future use
|
|
"""
|
|
raise "api error" if [400..500].include? resp['error_code']
|
|
resp['metadata']
|
|
end
|
|
end
|
|
# vim: set ts=2 sw=2:
|