cloudstack_client 0.9.7 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/bin/cloudstack_client +5 -0
- data/cloudstack_client.gemspec +2 -0
- data/config/4.2.json +1 -0
- data/lib/cloudstack_client/api.rb +29 -0
- data/lib/cloudstack_client/cli.rb +107 -0
- data/lib/cloudstack_client/client.rb +34 -127
- data/lib/cloudstack_client/connection.rb +131 -0
- data/lib/cloudstack_client/error.rb +9 -0
- data/lib/cloudstack_client/version.rb +1 -1
- data/lib/cloudstack_client.rb +0 -1
- metadata +38 -34
- data/lib/cloudstack_client/commands/account.rb +0 -38
- data/lib/cloudstack_client/commands/affinity_group.rb +0 -39
- data/lib/cloudstack_client/commands/capacity.rb +0 -30
- data/lib/cloudstack_client/commands/cluster.rb +0 -19
- data/lib/cloudstack_client/commands/configuration.rb +0 -42
- data/lib/cloudstack_client/commands/disk_offering.rb +0 -49
- data/lib/cloudstack_client/commands/domain.rb +0 -22
- data/lib/cloudstack_client/commands/host.rb +0 -28
- data/lib/cloudstack_client/commands/ip_address.rb +0 -83
- data/lib/cloudstack_client/commands/iso.rb +0 -76
- data/lib/cloudstack_client/commands/job.rb +0 -29
- data/lib/cloudstack_client/commands/load_balancer_rule.rb +0 -61
- data/lib/cloudstack_client/commands/network.rb +0 -130
- data/lib/cloudstack_client/commands/pod.rb +0 -20
- data/lib/cloudstack_client/commands/port_forwarding_rule.rb +0 -49
- data/lib/cloudstack_client/commands/project.rb +0 -32
- data/lib/cloudstack_client/commands/region.rb +0 -19
- data/lib/cloudstack_client/commands/resource_limit.rb +0 -125
- data/lib/cloudstack_client/commands/router.rb +0 -100
- data/lib/cloudstack_client/commands/server.rb +0 -350
- data/lib/cloudstack_client/commands/service_offering.rb +0 -98
- data/lib/cloudstack_client/commands/snapshot.rb +0 -51
- data/lib/cloudstack_client/commands/ssh_key_pair.rb +0 -137
- data/lib/cloudstack_client/commands/storage_pool.rb +0 -31
- data/lib/cloudstack_client/commands/system_vm.rb +0 -82
- data/lib/cloudstack_client/commands/template.rb +0 -60
- data/lib/cloudstack_client/commands/user.rb +0 -32
- data/lib/cloudstack_client/commands/volume.rb +0 -54
- data/lib/cloudstack_client/commands/zone.rb +0 -57
- data/lib/connection_helper.rb +0 -12
@@ -0,0 +1,29 @@
|
|
1
|
+
require "json"
|
2
|
+
require "ostruct"
|
3
|
+
|
4
|
+
module CloudstackClient
|
5
|
+
class Api
|
6
|
+
|
7
|
+
DEFAULT_API_VERSION = "4.2"
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
if options[:api_file]
|
11
|
+
@api_file = options[:api_file]
|
12
|
+
@api_version = File.basename(@api_file, ".json")
|
13
|
+
else
|
14
|
+
@api_version = options[:api_version] || DEFAULT_API_VERSION
|
15
|
+
@api_file = File.expand_path("../../../config/#{@api_version}.json", __FILE__)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def commands
|
20
|
+
begin
|
21
|
+
api = JSON.parse(IO.read @api_file)
|
22
|
+
rescue => e
|
23
|
+
raise "Error: Unable to read file '#{@api_file}' : #{e.message}"
|
24
|
+
end
|
25
|
+
api["api"].map {|command| OpenStruct.new command }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'cloudstack_client/client'
|
2
|
+
require 'thor'
|
3
|
+
require 'yaml'
|
4
|
+
require 'ripl'
|
5
|
+
|
6
|
+
module CloudstackClient
|
7
|
+
class Cli < Thor
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
class_option :config_file,
|
11
|
+
default: File.join(Dir.home, '.cloudstack-cli.yml'),
|
12
|
+
aliases: '-c',
|
13
|
+
desc: 'location of your cloudstack-cli configuration file'
|
14
|
+
|
15
|
+
class_option :env,
|
16
|
+
aliases: '-e',
|
17
|
+
desc: 'environment to use'
|
18
|
+
|
19
|
+
class_option :debug,
|
20
|
+
desc: 'enable debug output',
|
21
|
+
type: :boolean
|
22
|
+
|
23
|
+
desc "version", "Print cloudstack_client version number"
|
24
|
+
def version
|
25
|
+
say "cloudstack_client version #{CloudstackClient::VERSION}"
|
26
|
+
end
|
27
|
+
map %w(-v --version) => :version
|
28
|
+
|
29
|
+
desc "list_apis", "list api commands using the Cloudstack API Discovery service"
|
30
|
+
option :format, default: 'json',
|
31
|
+
enum: %w(json yaml), desc: "output format"
|
32
|
+
option :pretty_print, default: true, type: :boolean,
|
33
|
+
desc: "pretty print json output"
|
34
|
+
option :remove_response, default: true, type: :boolean,
|
35
|
+
desc: "remove response sections"
|
36
|
+
option :remove_description, default: true, type: :boolean,
|
37
|
+
desc: "remove description sections"
|
38
|
+
def list_apis
|
39
|
+
apis = client.send_request('command' => 'listApis')
|
40
|
+
apis.each do |command|
|
41
|
+
command.delete("response") if options[:remove_response]
|
42
|
+
if options[:remove_description]
|
43
|
+
command.delete("description")
|
44
|
+
command["params"].each {|param| param.delete("description")}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
output = if options[:format] == "json"
|
48
|
+
options[:pretty_print] ? JSON.pretty_generate(apis) : data.to_json
|
49
|
+
else
|
50
|
+
apis.to_yaml
|
51
|
+
end
|
52
|
+
puts output
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "console", "Cloudstack Client interactive shell"
|
56
|
+
def console
|
57
|
+
puts "cloudstack_client version #{CloudstackClient::VERSION}"
|
58
|
+
puts ' try: list_virtual_machines state: "Started"'
|
59
|
+
ARGV.clear
|
60
|
+
env = options[:env] ? options[:env] : load_configuration.last
|
61
|
+
Ripl.config[:prompt] = "#{env} >> "
|
62
|
+
Ripl.start binding: client.instance_eval('binding')
|
63
|
+
end
|
64
|
+
|
65
|
+
no_commands do
|
66
|
+
def client(opts = {})
|
67
|
+
@config ||= load_configuration.first
|
68
|
+
@client ||= CloudstackClient::Client.new(
|
69
|
+
@config[:url],
|
70
|
+
@config[:api_key],
|
71
|
+
@config[:secret_key]
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def load_configuration(config_file = options[:config_file], env = options[:env])
|
76
|
+
unless File.exists?(config_file)
|
77
|
+
say "Configuration file #{config_file} not found.", :red
|
78
|
+
say "Please run \'cloudstack-cli environment add\' to create one."
|
79
|
+
exit 1
|
80
|
+
end
|
81
|
+
|
82
|
+
begin
|
83
|
+
config = YAML::load(IO.read(config_file))
|
84
|
+
rescue
|
85
|
+
say "Can't load configuration from file #{config_file}.", :red
|
86
|
+
exit 1
|
87
|
+
end
|
88
|
+
|
89
|
+
env ||= config[:default]
|
90
|
+
if env
|
91
|
+
unless config = config[env]
|
92
|
+
say "Can't find environment #{env}.", :red
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
unless config.key?(:url) && config.key?(:api_key) && config.key?(:secret_key)
|
98
|
+
say "The environment #{env || '\'-\''} contains no valid data.", :red
|
99
|
+
exit 1
|
100
|
+
end
|
101
|
+
return config, env
|
102
|
+
end
|
103
|
+
|
104
|
+
end # no_commands
|
105
|
+
|
106
|
+
end # class
|
107
|
+
end # module
|
@@ -1,147 +1,54 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require 'cgi'
|
5
|
-
require 'net/http'
|
6
|
-
require 'net/https'
|
7
|
-
require 'json'
|
8
|
-
require 'yaml'
|
1
|
+
require "cloudstack_client/api"
|
2
|
+
require "cloudstack_client/error"
|
3
|
+
require "cloudstack_client/connection"
|
9
4
|
|
10
5
|
module CloudstackClient
|
11
|
-
class Connection
|
6
|
+
class Client < Connection
|
12
7
|
|
13
|
-
|
14
|
-
@@async_timeout = 400
|
8
|
+
attr_accessor :api_version, :api_path
|
15
9
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
def initialize(api_url, api_key, secret_key, options = {})
|
11
|
+
super(api_url, api_key, secret_key, options = {})
|
12
|
+
@api_version = options[:api_version] if options[:api_version]
|
13
|
+
@api_file = options[:api_file] if options[:api_file]
|
14
|
+
define_api_methods unless options[:no_api_methods]
|
21
15
|
end
|
22
16
|
|
23
|
-
|
24
|
-
|
17
|
+
def define_api_methods
|
18
|
+
Api.new(api_file: @api_file, api_version: @api_version).commands.each do |command|
|
19
|
+
method_name = underscore(command.name).to_sym
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
@api_key = api_key
|
29
|
-
@secret_key = secret_key
|
30
|
-
@verbose = opts[:quiet] ? false : true
|
31
|
-
@debug = opts[:debug] ? true : false
|
32
|
-
end
|
33
|
-
|
34
|
-
##
|
35
|
-
# Sends a synchronous request to the CloudStack API and returns the response as a Hash.
|
36
|
-
#
|
37
|
-
# The wrapper element of the response (e.g. mycommandresponse) is discarded and the
|
38
|
-
# contents of that element are returned.
|
39
|
-
|
40
|
-
def send_request(params)
|
41
|
-
params['response'] = 'json'
|
42
|
-
params['apiKey'] = @api_key
|
43
|
-
|
44
|
-
params_arr = []
|
45
|
-
params.sort.each { |elem|
|
46
|
-
params_arr << elem[0].to_s + '=' + CGI.escape(elem[1].to_s).gsub('+', '%20').gsub(' ','%20')
|
47
|
-
}
|
48
|
-
|
49
|
-
debug_output JSON.pretty_generate(params) if @debug
|
50
|
-
|
51
|
-
data = params_arr.join('&')
|
52
|
-
signature = OpenSSL::HMAC.digest('sha1', @secret_key, data.downcase)
|
53
|
-
signature = Base64.encode64(signature).chomp
|
54
|
-
signature = CGI.escape(signature)
|
55
|
-
|
56
|
-
url = "#{@api_url}?#{data}&signature=#{signature}"
|
21
|
+
define_singleton_method(method_name) do |args = {}, options = {}|
|
22
|
+
params = {"command" => command.name}
|
57
23
|
|
58
|
-
|
59
|
-
|
24
|
+
args.each do |k, v|
|
25
|
+
k = normalize_key(k)
|
26
|
+
if v != nil && command_supports_key?(command, k)
|
27
|
+
params[k] = v
|
28
|
+
end
|
29
|
+
end
|
60
30
|
|
61
|
-
|
62
|
-
|
63
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
64
|
-
end
|
65
|
-
|
66
|
-
begin
|
67
|
-
response = http.request(Net::HTTP::Get.new(uri.request_uri))
|
68
|
-
rescue
|
69
|
-
puts "Error connecting to API:"
|
70
|
-
puts "#{@api_url} is not reachable"
|
71
|
-
exit 1
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
if response.is_a? Net::HTTPOK
|
76
|
-
begin
|
77
|
-
json = JSON.parse(response.body)
|
78
|
-
json = json[params['command'].downcase + 'response']
|
79
|
-
rescue JSON::ParserError
|
80
|
-
puts "Error parsing response from server:"
|
81
|
-
puts response.body
|
82
|
-
exit 2
|
83
|
-
end
|
84
|
-
else
|
85
|
-
begin
|
86
|
-
json = JSON.parse(response.body)
|
87
|
-
puts "Error executing command..."
|
88
|
-
puts json if @debug
|
89
|
-
json = json[params['command'].downcase + 'response']
|
90
|
-
puts "#{json['errorcode']}: #{json['errortext']}"
|
91
|
-
rescue
|
92
|
-
puts "Error parsing response from server..."
|
93
|
-
puts "#{response.code}: #{response.body}"
|
31
|
+
sync = command.isasync == false || options[:sync]
|
32
|
+
sync ? send_request(params) : send_async_request(params)
|
94
33
|
end
|
95
|
-
exit 3
|
96
34
|
end
|
97
35
|
end
|
98
36
|
|
99
|
-
|
100
|
-
# Sends an asynchronous request and waits for the response.
|
101
|
-
#
|
102
|
-
# The contents of the 'jobresult' element are returned upon completion of the command.
|
103
|
-
|
104
|
-
def send_async_request(params)
|
105
|
-
|
106
|
-
json = send_request(params)
|
107
|
-
|
108
|
-
params = {
|
109
|
-
'command' => 'queryAsyncJobResult',
|
110
|
-
'jobId' => json['jobid']
|
111
|
-
}
|
112
|
-
|
113
|
-
max_tries = (@@async_timeout / @@async_poll_interval).round
|
114
|
-
max_tries.times do
|
115
|
-
json = send_request(params)
|
116
|
-
status = json['jobstatus']
|
117
|
-
|
118
|
-
print "." if @verbose
|
119
|
-
|
120
|
-
if status == 1
|
121
|
-
return json['jobresult']
|
122
|
-
elsif status == 2
|
123
|
-
puts
|
124
|
-
puts "Request failed (#{json['jobresultcode']}): #{json['jobresult']}"
|
125
|
-
exit 1
|
126
|
-
end
|
127
|
-
|
128
|
-
STDOUT.flush
|
129
|
-
sleep @@async_poll_interval
|
130
|
-
end
|
37
|
+
private
|
131
38
|
|
132
|
-
|
133
|
-
|
134
|
-
exit 1
|
39
|
+
def normalize_key(key)
|
40
|
+
key.to_s.gsub("_", "")
|
135
41
|
end
|
136
42
|
|
137
|
-
|
43
|
+
def command_supports_key?(command, key)
|
44
|
+
command.params.detect { |p| p["name"] == key }
|
45
|
+
end
|
138
46
|
|
139
|
-
def
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
puts
|
47
|
+
def underscore(camel_case)
|
48
|
+
camel_case.gsub(/::/, '/').
|
49
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
50
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
51
|
+
tr("-", "_").downcase
|
145
52
|
end
|
146
53
|
|
147
54
|
end # class
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'openssl'
|
3
|
+
require 'uri'
|
4
|
+
require 'cgi'
|
5
|
+
require 'net/http'
|
6
|
+
require 'net/https'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
module CloudstackClient
|
10
|
+
class Connection
|
11
|
+
|
12
|
+
attr_accessor :api_url, :api_key, :secret_key, :verbose, :debug
|
13
|
+
attr_accessor :async_poll_interval, :async_timeout
|
14
|
+
|
15
|
+
def initialize(api_url, api_key, secret_key, options = {})
|
16
|
+
@api_url = api_url
|
17
|
+
@api_key = api_key
|
18
|
+
@secret_key = secret_key
|
19
|
+
@verbose = options[:quiet] ? false : true
|
20
|
+
@debug = options[:debug] ? true : false
|
21
|
+
@async_poll_interval = options[:async_poll_interval] || 2.0
|
22
|
+
@async_timeout = options[:async_timeout] || 400
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Sends a synchronous request to the CloudStack API and returns the response as a Hash.
|
27
|
+
#
|
28
|
+
|
29
|
+
def send_request(params)
|
30
|
+
params['response'] = 'json'
|
31
|
+
params['apiKey'] = @api_key
|
32
|
+
|
33
|
+
params_arr = params.sort.map do |key, value|
|
34
|
+
value = CGI.escape(value.to_s).gsub('+', '%20').gsub(' ','%20')
|
35
|
+
"#{key}=#{value}"
|
36
|
+
end
|
37
|
+
|
38
|
+
debug_output JSON.pretty_generate(params) if @debug
|
39
|
+
|
40
|
+
data = params_arr.join('&')
|
41
|
+
signature = OpenSSL::HMAC.digest('sha1', @secret_key, data.downcase)
|
42
|
+
signature = Base64.encode64(signature).chomp
|
43
|
+
signature = CGI.escape(signature)
|
44
|
+
|
45
|
+
url = "#{@api_url}?#{data}&signature=#{signature}"
|
46
|
+
|
47
|
+
uri = URI.parse(url)
|
48
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
49
|
+
|
50
|
+
if uri.scheme == 'https'
|
51
|
+
http.use_ssl = true
|
52
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
53
|
+
end
|
54
|
+
|
55
|
+
begin
|
56
|
+
response = http.request(Net::HTTP::Get.new(uri.request_uri))
|
57
|
+
rescue
|
58
|
+
raise ConnectionError, "API URL \'#{@api_url}\' is not reachable."
|
59
|
+
end
|
60
|
+
|
61
|
+
begin
|
62
|
+
body = JSON.parse(response.body).values.first
|
63
|
+
rescue JSON::ParserError
|
64
|
+
raise ParseError, "Error parsing response from server: #{response.body}."
|
65
|
+
end
|
66
|
+
|
67
|
+
if response.is_a? Net::HTTPOK
|
68
|
+
return body unless body.respond_to?(:keys)
|
69
|
+
if body.size == 2 && body.key?('count')
|
70
|
+
return body.reject { |key, _| key == 'count' }.values.first
|
71
|
+
elsif body.size == 1 && body.values.first.respond_to?(:keys)
|
72
|
+
item = body.values.first
|
73
|
+
return item.is_a?(Array) ? item : []
|
74
|
+
else
|
75
|
+
body.reject! { |key, _| key == 'count' } if body.key?('count')
|
76
|
+
body.size == 0 ? [] : body
|
77
|
+
end
|
78
|
+
else
|
79
|
+
message = data[data.keys.first]['errortext'] rescue data
|
80
|
+
raise ApiError, "Error #{response.code} - #{message}."
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Sends an asynchronous request and waits for the response.
|
86
|
+
#
|
87
|
+
# The contents of the 'jobresult' element are returned upon completion of the command.
|
88
|
+
|
89
|
+
def send_async_request(params)
|
90
|
+
data = send_request(params)
|
91
|
+
|
92
|
+
params = {
|
93
|
+
'command' => 'queryAsyncJobResult',
|
94
|
+
'jobid' => data['jobid']
|
95
|
+
}
|
96
|
+
|
97
|
+
max_tries.times do
|
98
|
+
data = send_request(params)
|
99
|
+
|
100
|
+
print "." if @verbose
|
101
|
+
|
102
|
+
case data['jobstatus']
|
103
|
+
when 1
|
104
|
+
return data['jobresult']
|
105
|
+
when 2
|
106
|
+
raise JobError, "Request failed (#{data['jobresultcode']}). #{data['jobresult']}."
|
107
|
+
end
|
108
|
+
|
109
|
+
STDOUT.flush if @verbose
|
110
|
+
sleep @async_poll_interval
|
111
|
+
end
|
112
|
+
|
113
|
+
raise TimeoutError, "Asynchronous request timed out."
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def max_tries
|
119
|
+
(@async_timeout / @async_poll_interval).round
|
120
|
+
end
|
121
|
+
|
122
|
+
def debug_output(output, seperator = '-' * 80)
|
123
|
+
puts
|
124
|
+
puts seperator
|
125
|
+
puts output
|
126
|
+
puts seperator
|
127
|
+
puts
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
data/lib/cloudstack_client.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudstack_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nik Wolfgramm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -44,6 +44,34 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 10.0.4
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: thor
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: ripl
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
47
75
|
description: CloudStack API client written in Ruby
|
48
76
|
email:
|
49
77
|
- nik.wolfgramm@gmail.com
|
@@ -56,40 +84,16 @@ files:
|
|
56
84
|
- LICENSE.txt
|
57
85
|
- README.md
|
58
86
|
- Rakefile
|
87
|
+
- bin/cloudstack_client
|
59
88
|
- cloudstack_client.gemspec
|
89
|
+
- config/4.2.json
|
60
90
|
- lib/cloudstack_client.rb
|
91
|
+
- lib/cloudstack_client/api.rb
|
92
|
+
- lib/cloudstack_client/cli.rb
|
61
93
|
- lib/cloudstack_client/client.rb
|
62
|
-
- lib/cloudstack_client/
|
63
|
-
- lib/cloudstack_client/
|
64
|
-
- lib/cloudstack_client/commands/capacity.rb
|
65
|
-
- lib/cloudstack_client/commands/cluster.rb
|
66
|
-
- lib/cloudstack_client/commands/configuration.rb
|
67
|
-
- lib/cloudstack_client/commands/disk_offering.rb
|
68
|
-
- lib/cloudstack_client/commands/domain.rb
|
69
|
-
- lib/cloudstack_client/commands/host.rb
|
70
|
-
- lib/cloudstack_client/commands/ip_address.rb
|
71
|
-
- lib/cloudstack_client/commands/iso.rb
|
72
|
-
- lib/cloudstack_client/commands/job.rb
|
73
|
-
- lib/cloudstack_client/commands/load_balancer_rule.rb
|
74
|
-
- lib/cloudstack_client/commands/network.rb
|
75
|
-
- lib/cloudstack_client/commands/pod.rb
|
76
|
-
- lib/cloudstack_client/commands/port_forwarding_rule.rb
|
77
|
-
- lib/cloudstack_client/commands/project.rb
|
78
|
-
- lib/cloudstack_client/commands/region.rb
|
79
|
-
- lib/cloudstack_client/commands/resource_limit.rb
|
80
|
-
- lib/cloudstack_client/commands/router.rb
|
81
|
-
- lib/cloudstack_client/commands/server.rb
|
82
|
-
- lib/cloudstack_client/commands/service_offering.rb
|
83
|
-
- lib/cloudstack_client/commands/snapshot.rb
|
84
|
-
- lib/cloudstack_client/commands/ssh_key_pair.rb
|
85
|
-
- lib/cloudstack_client/commands/storage_pool.rb
|
86
|
-
- lib/cloudstack_client/commands/system_vm.rb
|
87
|
-
- lib/cloudstack_client/commands/template.rb
|
88
|
-
- lib/cloudstack_client/commands/user.rb
|
89
|
-
- lib/cloudstack_client/commands/volume.rb
|
90
|
-
- lib/cloudstack_client/commands/zone.rb
|
94
|
+
- lib/cloudstack_client/connection.rb
|
95
|
+
- lib/cloudstack_client/error.rb
|
91
96
|
- lib/cloudstack_client/version.rb
|
92
|
-
- lib/connection_helper.rb
|
93
97
|
homepage: https://github.com/niwo/cloudstack_client
|
94
98
|
licenses:
|
95
99
|
- MIT
|
@@ -107,9 +111,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
111
|
version: 1.9.3
|
108
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
113
|
requirements:
|
110
|
-
- - "
|
114
|
+
- - ">"
|
111
115
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
116
|
+
version: 1.3.1
|
113
117
|
requirements: []
|
114
118
|
rubyforge_project:
|
115
119
|
rubygems_version: 2.2.2
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module Account
|
4
|
-
|
5
|
-
##
|
6
|
-
# Lists accounts.
|
7
|
-
|
8
|
-
def list_accounts(args = { :name => nil })
|
9
|
-
params = {
|
10
|
-
'command' => 'listAccounts',
|
11
|
-
'listall' => 'true',
|
12
|
-
'isrecursive' => 'true'
|
13
|
-
}
|
14
|
-
params['name'] = args[:name] if args[:name]
|
15
|
-
|
16
|
-
json = send_request(params)
|
17
|
-
json['account'] || []
|
18
|
-
end
|
19
|
-
|
20
|
-
##
|
21
|
-
# Lists project accounts.
|
22
|
-
|
23
|
-
def list_project_accounts(project_id, args = {})
|
24
|
-
params = {
|
25
|
-
'command' => 'listProjectAccounts',
|
26
|
-
'projectid' => project_id,
|
27
|
-
'listall' => 'true',
|
28
|
-
'isrecursive' => 'true'
|
29
|
-
}
|
30
|
-
params['name'] = args[:name] if args[:name]
|
31
|
-
|
32
|
-
json = send_request(params)
|
33
|
-
json['account'] || []
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module AffinityGroup
|
4
|
-
|
5
|
-
##
|
6
|
-
# List Affinity Groups.
|
7
|
-
|
8
|
-
def list_affinity_groups(args = {})
|
9
|
-
params = {
|
10
|
-
'command' => 'listAffinityGroups',
|
11
|
-
}
|
12
|
-
|
13
|
-
if args[:account]
|
14
|
-
account = list_accounts({name: args[:account]}).first
|
15
|
-
unless account
|
16
|
-
puts "Error: Account #{args[:account]} not found."
|
17
|
-
exit 1
|
18
|
-
end
|
19
|
-
params['domainid'] = account["domainid"]
|
20
|
-
params['account'] = args[:account]
|
21
|
-
end
|
22
|
-
|
23
|
-
if args['listall']
|
24
|
-
params['listall'] = true
|
25
|
-
params['isrecursive'] = true
|
26
|
-
end
|
27
|
-
|
28
|
-
params['name'] = args['name'] if args['name']
|
29
|
-
params['type'] = args['type'] if args['type']
|
30
|
-
params['virtualmachineid'] = args['virtualmachine_id'] if args['virtualmachine_id']
|
31
|
-
params['keyword'] = args['keyword'] if args['keyword']
|
32
|
-
|
33
|
-
json = send_request(params)
|
34
|
-
json['affinitygroup'] || []
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module Capacity
|
4
|
-
|
5
|
-
##
|
6
|
-
# List capacity.
|
7
|
-
|
8
|
-
def list_capacity(args = {})
|
9
|
-
params = {
|
10
|
-
'command' => 'listCapacity',
|
11
|
-
}
|
12
|
-
|
13
|
-
if args[:zone]
|
14
|
-
zone = get_zone(args[:zone])
|
15
|
-
unless zone
|
16
|
-
puts "Error: Zone #{args[:zone]} not found"
|
17
|
-
exit 1
|
18
|
-
end
|
19
|
-
params['zoneid'] = zone['id']
|
20
|
-
end
|
21
|
-
|
22
|
-
params['type'] = args[:type] if args[:type]
|
23
|
-
|
24
|
-
json = send_request(params)
|
25
|
-
json['capacity'] || []
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|