Skip to content

Instantly share code, notes, and snippets.

@mrtc0
Created April 29, 2017 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrtc0/dedbc90a2e1e62fd18e85337566f7767 to your computer and use it in GitHub Desktop.
Save mrtc0/dedbc90a2e1e62fd18e85337566f7767 to your computer and use it in GitHub Desktop.
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