|
|
@ -13,7 +13,7 @@ require 'pp'
|
|
|
|
module CloudClient
|
|
|
|
module CloudClient
|
|
|
|
|
|
|
|
|
|
|
|
# OpenNebula version
|
|
|
|
# OpenNebula version
|
|
|
|
VERSION = '5.9.80'
|
|
|
|
VERSION = '5.11.80'
|
|
|
|
|
|
|
|
|
|
|
|
# #########################################################################
|
|
|
|
# #########################################################################
|
|
|
|
# Default location for the authentication file
|
|
|
|
# Default location for the authentication file
|
|
|
@ -299,9 +299,12 @@ module OneGate
|
|
|
|
return state_str
|
|
|
|
return state_str
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.print(json_hash)
|
|
|
|
def self.print(json_hash, extended = false)
|
|
|
|
OneGate.print_header("VM " + json_hash["VM"]["ID"])
|
|
|
|
OneGate.print_header("VM " + json_hash["VM"]["ID"])
|
|
|
|
OneGate.print_key_value("NAME", json_hash["VM"]["NAME"])
|
|
|
|
OneGate.print_key_value("NAME", json_hash["VM"]["NAME"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return unless extended
|
|
|
|
|
|
|
|
|
|
|
|
OneGate.print_key_value(
|
|
|
|
OneGate.print_key_value(
|
|
|
|
"STATE",
|
|
|
|
"STATE",
|
|
|
|
self.state_to_str(
|
|
|
|
self.state_to_str(
|
|
|
@ -352,7 +355,7 @@ module OneGate
|
|
|
|
return STATE_STR[state_number.to_i]
|
|
|
|
return STATE_STR[state_number.to_i]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.print(json_hash)
|
|
|
|
def self.print(json_hash, extended = false)
|
|
|
|
OneGate.print_header("SERVICE " + json_hash["SERVICE"]["id"])
|
|
|
|
OneGate.print_header("SERVICE " + json_hash["SERVICE"]["id"])
|
|
|
|
OneGate.print_key_value("NAME", json_hash["SERVICE"]["name"])
|
|
|
|
OneGate.print_key_value("NAME", json_hash["SERVICE"]["name"])
|
|
|
|
OneGate.print_key_value("STATE", Service.state_str(json_hash["SERVICE"]['state']))
|
|
|
|
OneGate.print_key_value("STATE", Service.state_str(json_hash["SERVICE"]['state']))
|
|
|
@ -364,7 +367,7 @@ module OneGate
|
|
|
|
|
|
|
|
|
|
|
|
if role["nodes"]
|
|
|
|
if role["nodes"]
|
|
|
|
role["nodes"].each{ |node|
|
|
|
|
role["nodes"].each{ |node|
|
|
|
|
OneGate::VirtualMachine.print(node["vm_info"])
|
|
|
|
OneGate::VirtualMachine.print(node["vm_info"], extended)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -394,8 +397,9 @@ module OneGate
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def get(path)
|
|
|
|
def get(path, extra = nil)
|
|
|
|
req = Net::HTTP::Proxy(@host, @port)::Get.new(path)
|
|
|
|
req = Net::HTTP::Proxy(@host, @port)::Get.new(path)
|
|
|
|
|
|
|
|
req.body = extra if extra
|
|
|
|
|
|
|
|
|
|
|
|
do_request(req)
|
|
|
|
do_request(req)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -496,7 +500,7 @@ module OneGate
|
|
|
|
Available commands
|
|
|
|
Available commands
|
|
|
|
$ onegate vm show [VMID] [--json]
|
|
|
|
$ onegate vm show [VMID] [--json]
|
|
|
|
|
|
|
|
|
|
|
|
$ onegate vm update [VMID] --data KEY=VALUE[\\nKEY2=VALUE2]
|
|
|
|
$ onegate vm update [VMID] --data KEY=VALUE\\nKEY2=VALUE2
|
|
|
|
|
|
|
|
|
|
|
|
$ onegate vm update [VMID] --erase KEY
|
|
|
|
$ onegate vm update [VMID] --erase KEY
|
|
|
|
|
|
|
|
|
|
|
@ -512,7 +516,7 @@ Available commands
|
|
|
|
$ onegate hold [VMID]
|
|
|
|
$ onegate hold [VMID]
|
|
|
|
$ onegate release [VMID]
|
|
|
|
$ onegate release [VMID]
|
|
|
|
|
|
|
|
|
|
|
|
$ onegate service show [--json]
|
|
|
|
$ onegate service show [--json][--extended]
|
|
|
|
|
|
|
|
|
|
|
|
$ onegate service scale --role ROLE --cardinality CARDINALITY
|
|
|
|
$ onegate service scale --role ROLE --cardinality CARDINALITY
|
|
|
|
EOT
|
|
|
|
EOT
|
|
|
@ -545,6 +549,10 @@ OptionParser.new do |opts|
|
|
|
|
options[:json] = json
|
|
|
|
options[:json] = json
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opts.on("", "--extended", "Print resource extended information") do |ext|
|
|
|
|
|
|
|
|
options[:extended] = ext
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
opts.on("-f", "--hard", "Hard option for power off operations") do |hard|
|
|
|
|
opts.on("-f", "--hard", "Hard option for power off operations") do |hard|
|
|
|
|
options[:hard] = hard
|
|
|
|
options[:hard] = hard
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -640,13 +648,24 @@ when "vm"
|
|
|
|
when "service"
|
|
|
|
when "service"
|
|
|
|
case ARGV[1]
|
|
|
|
case ARGV[1]
|
|
|
|
when "show"
|
|
|
|
when "show"
|
|
|
|
response = client.get("/service")
|
|
|
|
if options[:extended]
|
|
|
|
|
|
|
|
extra = {}
|
|
|
|
|
|
|
|
extra['extended'] = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extra = URI.encode_www_form(extra)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response = client.get("/service", extra)
|
|
|
|
json_hash = OneGate.parse_json(response)
|
|
|
|
json_hash = OneGate.parse_json(response)
|
|
|
|
#pp json_hash
|
|
|
|
#pp json_hash
|
|
|
|
if options[:json]
|
|
|
|
if options[:json]
|
|
|
|
puts JSON.pretty_generate(json_hash)
|
|
|
|
puts JSON.pretty_generate(json_hash)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
OneGate::Service.print(json_hash)
|
|
|
|
if options[:extended]
|
|
|
|
|
|
|
|
OneGate::Service.print(json_hash, true)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
OneGate::Service.print(json_hash)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
when "scale"
|
|
|
|
when "scale"
|
|
|
|
response = client.put(
|
|
|
|
response = client.put(
|
|
|
|