Created
April 29, 2017 15:38
-
-
Save mrtc0/dedbc90a2e1e62fd18e85337566f7767 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net_http_unix' | |
require 'json' | |
def sample(url) | |
req = Net::HTTP::Get.new(url) | |
client = NetX::HTTPUnix.new('unix:///var/lib/lxd/unix.socket') | |
resp = client.request(req) | |
puts resp.body | |
end | |
req = Net::HTTP::Post.new("/1.0/containers/admin") | |
payload = { | |
"name" => "test", | |
}.to_json | |
req.body = payload | |
client = NetX::HTTPUnix.new('unix:///var/lib/lxd/unix.socket') | |
resp = client.request(req) | |
j = JSON.parse(resp.body) | |
puts j["operation"] | |
sample(j["operation"] + "/wait") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment