cloudstack_ruby_client 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/bin/cloudstack_ruby_client +71 -0
- data/cloudstack_ruby_client.gemspec +1 -1
- data/lib/cloudstack_ruby_client/api/accounts_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/apidiscovery_api.rb +7 -0
- data/lib/cloudstack_ruby_client/api/asyncjob_api.rb +8 -0
- data/lib/cloudstack_ruby_client/api/autoscale_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/configuration_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/firewall_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/infra_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/network_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/project_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/securitygroup_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/serviceoffering_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/snapshot_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/storage_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/systemvm_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/template_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/vm_api.rb +2 -2
- data/lib/cloudstack_ruby_client/api/volume_api.rb +2 -2
- data/lib/cloudstack_ruby_client/base_client.rb +6 -21
- data/lib/cloudstack_ruby_client/client.rb +54 -67
- data/lib/cloudstack_ruby_client/client_helper.rb +42 -51
- data/lib/cloudstack_ruby_client/help.rb +9 -0
- data/lib/cloudstack_ruby_client/version.rb +1 -1
- data/lib/cloudstack_ruby_client.rb +3 -2
- data/test/config.yml +3 -2
- data/test/unit/accounts_test.rb +11 -0
- data/test/unit/asyncjob_test.rb +34 -0
- metadata +47 -26
data/Rakefile
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'readline'
|
|
3
|
+
require 'yaml'
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'cloudstack_ruby_client'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
case ARGV.first when '-h', '--help', '--usage', '-?', 'help', nil
|
|
9
|
+
puts CloudstackRubyClient::Help
|
|
10
|
+
exit ARGV.first ? 0 : 1
|
|
11
|
+
when '--version'
|
|
12
|
+
puts CloudstackRubyClient::Version
|
|
13
|
+
exit 0
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
APIKEY = ARGV[2]
|
|
18
|
+
SECRETKEY = ARGV[3]
|
|
19
|
+
URL = "http://#{ARGV[0]}:#{ARGV[1]}/client/api/"
|
|
20
|
+
|
|
21
|
+
comp = proc { |s| CloudstackRubyClient::Client.API_LIST.sort.grep(/^#{Regexp.escape(s)}/) }
|
|
22
|
+
|
|
23
|
+
client = nil
|
|
24
|
+
|
|
25
|
+
begin
|
|
26
|
+
client = CloudstackRubyClient::Client.new(URL, APIKEY, SECRETKEY, false)
|
|
27
|
+
rescue
|
|
28
|
+
puts "Error, cannot initiate the cloudStackRubyClient."
|
|
29
|
+
exit
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
puts "="*100
|
|
33
|
+
puts "Connected to host : #{URL}"
|
|
34
|
+
puts "APIKEY : #{APIKEY}"
|
|
35
|
+
puts "SECRETKEY : #{SECRETKEY}"
|
|
36
|
+
puts "="*100
|
|
37
|
+
|
|
38
|
+
Readline.completion_append_character = " "
|
|
39
|
+
Readline.completion_proc = comp
|
|
40
|
+
Readline.completer_word_break_characters = ""
|
|
41
|
+
|
|
42
|
+
stty_save = `stty -g`.chomp
|
|
43
|
+
|
|
44
|
+
begin
|
|
45
|
+
while line = Readline.readline("cloudstack(#{ARGV[0]}:#{ARGV[1]})>>", true)
|
|
46
|
+
begin
|
|
47
|
+
command = line.split(' ')[0].strip
|
|
48
|
+
argument = line.gsub(command, '').strip
|
|
49
|
+
|
|
50
|
+
if argument
|
|
51
|
+
argument = JSON.parse("{" + line.gsub(command, '').gsub('\'', '"').gsub('=>', ':') + "}")
|
|
52
|
+
puts client.method(command).call argument
|
|
53
|
+
else
|
|
54
|
+
puts client.method(command).call
|
|
55
|
+
end
|
|
56
|
+
rescue ArgumentError => e
|
|
57
|
+
puts "#{e.to_s}"
|
|
58
|
+
rescue RuntimeError => e
|
|
59
|
+
puts "Oops! something bad happened. Please try again"
|
|
60
|
+
rescue
|
|
61
|
+
puts "Sorry, command not supported"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
rescue Interrupt => e
|
|
65
|
+
puts %Q{
|
|
66
|
+
|
|
67
|
+
Disconnected from the host
|
|
68
|
+
}
|
|
69
|
+
system('stty', stty_save) # Restore
|
|
70
|
+
exit
|
|
71
|
+
end
|
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
|
8
8
|
gem.version = CloudstackRubyClient::VERSION
|
|
9
9
|
gem.authors = ["Chip Childers"]
|
|
10
10
|
gem.email = ["chip.childers@gmail.com"]
|
|
11
|
-
gem.description = %q{A Ruby client for CloudStack's API,
|
|
11
|
+
gem.description = %q{A Ruby client for CloudStack's API, including a simple CLI.}
|
|
12
12
|
gem.summary = %q{A Ruby client for CloudStack's API.}
|
|
13
13
|
gem.homepage = "http://chipchilders.github.io/cloudstack_ruby_client/"
|
|
14
14
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module CloudstackRubyClient
|
|
2
|
-
module
|
|
2
|
+
module Api
|
|
3
3
|
module Firewall
|
|
4
4
|
cmd_processor :list_port_forwarding_rules,
|
|
5
5
|
:create_port_forwarding_rule,
|
|
@@ -13,4 +13,4 @@ module CloudstackRubyClient
|
|
|
13
13
|
:list_egress_firewall_rules
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
-
end
|
|
16
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module CloudstackRubyClient
|
|
2
|
-
module
|
|
2
|
+
module Api
|
|
3
3
|
module NetworkOffering
|
|
4
4
|
cmd_processor :create_network_offering,
|
|
5
5
|
:update_network_offering,
|
|
@@ -112,4 +112,4 @@ module CloudstackRubyClient
|
|
|
112
112
|
:list_static_routes
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
|
-
end
|
|
115
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module CloudstackRubyClient
|
|
2
|
-
module
|
|
2
|
+
module Api
|
|
3
3
|
module ServiceOffering
|
|
4
4
|
cmd_processor :create_service_offering,
|
|
5
5
|
:delete_service_offering,
|
|
@@ -14,4 +14,4 @@ module CloudstackRubyClient
|
|
|
14
14
|
:list_disk_offerings
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
|
-
end
|
|
17
|
+
end
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
# require 'rubygems'
|
|
2
|
-
# require 'base64'
|
|
3
|
-
# require 'openssl'
|
|
4
|
-
# require 'uri'
|
|
5
|
-
# require 'cgi'
|
|
6
|
-
# require 'net/http'
|
|
7
|
-
# require 'json'
|
|
8
|
-
|
|
9
1
|
class CloudstackRubyClient::BaseClient
|
|
10
2
|
|
|
11
3
|
def initialize(api_url, api_key, secret_key, use_ssl=nil)
|
|
@@ -18,27 +10,20 @@ class CloudstackRubyClient::BaseClient
|
|
|
18
10
|
def request(params)
|
|
19
11
|
params['response'] = 'json'
|
|
20
12
|
params['apiKey'] = @api_key
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
params_arr << elem[0].to_s + '=' + CGI.escape(elem[1].to_s)\
|
|
25
|
-
.gsub('+', '%20').gsub(' ','%20')
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
data = params_arr.sort.join '&'
|
|
29
|
-
|
|
13
|
+
|
|
14
|
+
data = params.map{ |k,v| "#{k.to_s}=#{CGI.escape(v.to_s).gsub(/\+|\ /, "%20")}" }.sort.join('&')
|
|
15
|
+
|
|
30
16
|
signature = OpenSSL::HMAC.digest 'sha1', @secret_key, data.downcase
|
|
31
17
|
signature = Base64.encode64(signature).chomp
|
|
32
18
|
signature = CGI.escape(signature)
|
|
33
|
-
|
|
19
|
+
|
|
34
20
|
url = "#{@api_url}?#{data}&signature=#{signature}"
|
|
35
21
|
uri = URI.parse(url)
|
|
36
22
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
37
|
-
#http.use_ssl = @use_ssl
|
|
38
|
-
#http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
23
|
+
# http.use_ssl = @use_ssl
|
|
24
|
+
# http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
39
25
|
request = Net::HTTP::Get.new(uri.request_uri)
|
|
40
26
|
|
|
41
27
|
http.request(request)
|
|
42
28
|
end
|
|
43
|
-
|
|
44
29
|
end
|
|
@@ -1,75 +1,62 @@
|
|
|
1
1
|
class CloudstackRubyClient::Client < CloudstackRubyClient::BaseClient
|
|
2
|
-
|
|
3
|
-
## Infra Api commands injection
|
|
4
|
-
include CloudstackRubyClient::Infrastructure::Region
|
|
5
|
-
include CloudstackRubyClient::Infrastructure::Zone
|
|
6
|
-
include CloudstackRubyClient::Infrastructure::Pod
|
|
7
|
-
include CloudstackRubyClient::Infrastructure::Cluster
|
|
8
|
-
include CloudstackRubyClient::Infrastructure::Host
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Accounts Api command injection
|
|
12
|
-
include CloudstackRubyClient::Accounts::Domain
|
|
13
|
-
include CloudstackRubyClient::Accounts::Account
|
|
14
|
-
include CloudstackRubyClient::Accounts::User
|
|
15
|
-
include CloudstackRubyClient::Accounts::Limit
|
|
16
|
-
include CloudstackRubyClient::Accounts::Usage
|
|
17
|
-
|
|
18
|
-
## System VM commands injection
|
|
19
|
-
include CloudstackRubyClient::VirtualMachine::VirtualMachine
|
|
20
|
-
include CloudstackRubyClient::VirtualMachine::VMGroup
|
|
21
|
-
|
|
22
|
-
## Virtual Machine commands insjection
|
|
23
|
-
include CloudstackRubyClient::SystemVm::SystemVm
|
|
24
|
-
include CloudstackRubyClient::SystemVm::Router
|
|
25
|
-
|
|
26
|
-
## Storage commands injection
|
|
27
|
-
include CloudstackRubyClient::Storage::StoragePool
|
|
28
|
-
include CloudstackRubyClient::Storage::ImageStore
|
|
29
|
-
|
|
30
|
-
## Network commands injection
|
|
31
|
-
include CloudstackRubyClient::Network::NetworkOffering
|
|
32
|
-
include CloudstackRubyClient::Network::Network
|
|
33
|
-
include CloudstackRubyClient::Network::PhysicalNetwork
|
|
34
|
-
include CloudstackRubyClient::Network::NetworkServiceProvider
|
|
35
|
-
include CloudstackRubyClient::Network::StorageIpRange
|
|
36
|
-
include CloudstackRubyClient::Network::NetworkDevice
|
|
37
|
-
include CloudstackRubyClient::Network::NetworkACL
|
|
38
|
-
include CloudstackRubyClient::Network::Vlan
|
|
39
|
-
include CloudstackRubyClient::Network::Nat
|
|
40
|
-
include CloudstackRubyClient::Network::VPN
|
|
41
|
-
include CloudstackRubyClient::Network::LoadBalancer
|
|
42
|
-
include CloudstackRubyClient::Network::VPC
|
|
43
2
|
|
|
44
|
-
|
|
45
|
-
include CloudstackRubyClient::Volume::Volume
|
|
3
|
+
@@API_LIST = []
|
|
46
4
|
|
|
47
|
-
##
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## Project command injection
|
|
56
|
-
include CloudstackRubyClient::Project::Project
|
|
57
|
-
|
|
58
|
-
## Snapshot command injection
|
|
59
|
-
include CloudstackRubyClient::Snapshot::Snapshot
|
|
60
|
-
|
|
61
|
-
## Configuraion command injection
|
|
62
|
-
include CloudstackRubyClient::Configuration::Configuration
|
|
63
|
-
include CloudstackRubyClient::Configuration::Event
|
|
5
|
+
## Api command injection
|
|
6
|
+
CloudstackRubyClient::Api.constants.collect{|k|
|
|
7
|
+
CloudstackRubyClient::Api.const_get(k)
|
|
8
|
+
}.select {|k| k.is_a?(Module)}.each do |sub_module|
|
|
9
|
+
include sub_module
|
|
10
|
+
|
|
11
|
+
@@API_LIST.concat sub_module.instance_methods(false)
|
|
12
|
+
end
|
|
64
13
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
14
|
+
def self.API_LIST
|
|
15
|
+
@@API_LIST
|
|
16
|
+
end
|
|
68
17
|
|
|
69
|
-
##
|
|
70
|
-
|
|
18
|
+
## login api command
|
|
19
|
+
def login(params = {})
|
|
20
|
+
auth_request(params, "login")
|
|
21
|
+
end
|
|
71
22
|
|
|
72
|
-
## Firewall command injection
|
|
73
|
-
include CloudstackRubyClient::Firewall::Firewall
|
|
74
23
|
|
|
24
|
+
## logout api command
|
|
25
|
+
def logout(params = {})
|
|
26
|
+
auth_request(params, "logout")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
protected
|
|
30
|
+
|
|
31
|
+
def auth_request(params, command)
|
|
32
|
+
params['response'] = 'json'
|
|
33
|
+
params['command'] = command
|
|
34
|
+
data = params.map{ |k,v| "#{k.to_s}=#{CGI.escape(v.to_s).gsub(/\+|\ /, "%20")}" }.sort.join('&')
|
|
35
|
+
|
|
36
|
+
url = "#{@api_url}?#{data}"
|
|
37
|
+
uri = URI.parse(url)
|
|
38
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
39
|
+
# http.use_ssl = @use_ssl
|
|
40
|
+
# http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
41
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
|
42
|
+
|
|
43
|
+
resp_title = "#{command}response";
|
|
44
|
+
|
|
45
|
+
response = http.request(request)
|
|
46
|
+
json = JSON.parse(response.body)
|
|
47
|
+
|
|
48
|
+
if !response.is_a?(Net::HTTPOK)
|
|
49
|
+
if ["431","530"].include?(response.code) and ["9999","4350"].include?(json[resp_title]['cserrorcode'])
|
|
50
|
+
raise ArgumentError, json[resp_title]['errortext']
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
raise RuntimeError, json['errorresponse']['errortext'] if response.code == "432"
|
|
54
|
+
|
|
55
|
+
puts 'Error ' + response.code + ':'
|
|
56
|
+
puts JSON.pretty_generate(json)
|
|
57
|
+
exit 1
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
json[resp_title]
|
|
61
|
+
end
|
|
75
62
|
end
|
|
@@ -38,9 +38,9 @@ class Module
|
|
|
38
38
|
arga.each_with_index.map {|x, i|
|
|
39
39
|
i==0 ? x : x.capitalize
|
|
40
40
|
}.join('')
|
|
41
|
-
}"
|
|
41
|
+
}"
|
|
42
42
|
|
|
43
|
-
resp_title = "#{arga.join('')}response"
|
|
43
|
+
resp_title = "#{arga.join('')}response"
|
|
44
44
|
} +
|
|
45
45
|
|
|
46
46
|
#
|
|
@@ -48,67 +48,58 @@ class Module
|
|
|
48
48
|
#
|
|
49
49
|
|
|
50
50
|
%Q{
|
|
51
|
-
MALFORMED_RESPONSES.each do |k, v
|
|
52
|
-
if k =~ command
|
|
53
|
-
resp_title = v
|
|
54
|
-
end;
|
|
55
|
-
end;
|
|
56
|
-
|
|
57
|
-
MALFORMED_CMDS.each do |k, v|;
|
|
58
|
-
if k =~ command;
|
|
59
|
-
command = v;
|
|
51
|
+
MALFORMED_RESPONSES.each do |k, v|
|
|
52
|
+
if k =~ command
|
|
53
|
+
resp_title = v
|
|
60
54
|
end
|
|
61
|
-
end
|
|
55
|
+
end
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
MALFORMED_CMDS.each do |k, v|
|
|
58
|
+
if k =~ command
|
|
59
|
+
command = v
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if /(list|create|delete)networkacl.*/i =~ command
|
|
64
|
+
command.gsub!(/acl/i, 'ACL')
|
|
65
|
+
end
|
|
66
66
|
|
|
67
|
-
if /.*(ssh).*/i =~ command
|
|
68
|
-
command.gsub!
|
|
69
|
-
end
|
|
67
|
+
if /.*(ssh).*/i =~ command
|
|
68
|
+
command.gsub!(/ssh/i, 'SSH')
|
|
69
|
+
end
|
|
70
70
|
|
|
71
|
-
if /(list|create|delete)lbstickinesspolic.*/i =~ command
|
|
72
|
-
command.gsub!
|
|
73
|
-
end
|
|
71
|
+
if /(list|create|delete)lbstickinesspolic.*/i =~ command
|
|
72
|
+
command.gsub!(/lb/i, 'LB')
|
|
73
|
+
end
|
|
74
74
|
|
|
75
|
-
if /.*vpc.*/i =~ command
|
|
76
|
-
command.gsub!
|
|
77
|
-
end
|
|
75
|
+
if /.*vpc.*/i =~ command
|
|
76
|
+
command.gsub!(/vpc/i, 'VPC')
|
|
77
|
+
end
|
|
78
78
|
} +
|
|
79
79
|
%Q{
|
|
80
|
-
params = {'command' => command}
|
|
81
|
-
params.merge!
|
|
82
|
-
|
|
83
|
-
response = request
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
raise ArgumentError, JSON.parse(response.body)\
|
|
91
|
-
[resp_title]['errortext'];
|
|
92
|
-
|
|
93
|
-
end;
|
|
94
|
-
|
|
95
|
-
if response.code == "432";
|
|
96
|
-
raise RuntimeError, JSON.parse(response.body)\
|
|
97
|
-
['errorresponse']['errortext'];
|
|
80
|
+
params = {'command' => command}
|
|
81
|
+
params.merge!(args) unless args.empty?
|
|
82
|
+
|
|
83
|
+
response = request(params)
|
|
84
|
+
json = JSON.parse(response.body)
|
|
85
|
+
|
|
86
|
+
if !response.is_a?(Net::HTTPOK)
|
|
87
|
+
if ["431","530"].include?(response.code) and ["9999","4350"].include?(json[resp_title]['cserrorcode'])
|
|
88
|
+
raise ArgumentError, json[resp_title]['errortext']
|
|
89
|
+
end
|
|
98
90
|
|
|
99
|
-
|
|
91
|
+
raise RuntimeError, json['errorresponse']['errortext'] if response.code == "432"
|
|
100
92
|
|
|
101
93
|
puts 'Error ' + response.code + ':'
|
|
102
|
-
puts JSON.pretty_generate(
|
|
103
|
-
exit 1
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
json = JSON.parse(response.body);
|
|
94
|
+
puts JSON.pretty_generate(json)
|
|
95
|
+
exit 1
|
|
96
|
+
end
|
|
97
|
+
|
|
107
98
|
json[resp_title]
|
|
108
|
-
end
|
|
99
|
+
end
|
|
109
100
|
}
|
|
110
101
|
|
|
111
|
-
self.class_eval
|
|
102
|
+
self.class_eval(meta_method)
|
|
112
103
|
end
|
|
113
104
|
end
|
|
114
|
-
end
|
|
105
|
+
end
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
%w[ base64 cgi openssl uri digest/sha1 net/https net/http json
|
|
1
|
+
%w[ base64 cgi openssl uri digest/sha1 net/https net/http json ].each { |f| require f }
|
|
2
2
|
|
|
3
3
|
require 'cloudstack_ruby_client/version'
|
|
4
|
+
require 'cloudstack_ruby_client/help'
|
|
4
5
|
require 'cloudstack_ruby_client/client_helper'
|
|
5
6
|
|
|
6
|
-
Dir[File.join(File.dirname(__FILE__), 'cloudstack_ruby_client/api/*.rb')].sort.each { |lib| require lib
|
|
7
|
+
Dir[File.join(File.dirname(__FILE__), 'cloudstack_ruby_client/api/*.rb')].sort.each { |lib| require lib }
|
|
7
8
|
|
|
8
9
|
require 'cloudstack_ruby_client/base_client'
|
|
9
10
|
require 'cloudstack_ruby_client/client'
|
data/test/config.yml
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
cloudstack:
|
|
2
2
|
host: '10.1.192.92'
|
|
3
|
+
# host: 'localhost'
|
|
3
4
|
port: '8080'
|
|
4
5
|
admin_port: '8096'
|
|
5
|
-
api_key: '
|
|
6
|
-
secret_key: '
|
|
6
|
+
api_key: 'd460dbswlC6ApcirESZJOh-JDCFxCtwtmoRd_FHC9QYwHNkeHi1BjdDrvnfQQ0vwDOC9t4yPF46o5Kfpn5eFVg'
|
|
7
|
+
secret_key: 'sZchCmafeZU4ZKM2HkX5DzcoWFWAYp3eGIpYFdgsCoYtZiTIuXIgv48Ja5vD1sdkf_gFFbh534hepPayEfcfNQ'
|
data/test/unit/accounts_test.rb
CHANGED
|
@@ -191,6 +191,17 @@ class AccountsTest < Test::Unit::TestCase
|
|
|
191
191
|
assert_equal({}, @client.list_vpn_users)
|
|
192
192
|
end
|
|
193
193
|
|
|
194
|
+
def test_login
|
|
195
|
+
# @client.login 'username' => 'admin', 'domain' => '/', 'password' => 'password'
|
|
196
|
+
assert_raise(RuntimeError) do
|
|
197
|
+
@client.login
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def test_logout
|
|
202
|
+
assert_equal({"description" => "success"}, @client.logout)
|
|
203
|
+
end
|
|
204
|
+
|
|
194
205
|
### Limit Test ###
|
|
195
206
|
|
|
196
207
|
def test_update_resource_limit
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'yaml'
|
|
3
|
+
require_relative '../../lib/cloudstack_ruby_client'
|
|
4
|
+
|
|
5
|
+
class AsyncjobTest < Test::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
config = YAML.load_file("test/config.yml")
|
|
9
|
+
_host = config['cloudstack']['host']
|
|
10
|
+
_port = config['cloudstack']['port']
|
|
11
|
+
_admin_port = config['cloudstack']['admin_port']
|
|
12
|
+
_api_key = config['cloudstack']['api_key']
|
|
13
|
+
_secret_key = config['cloudstack']['secret_key']
|
|
14
|
+
@client = CloudstackRubyClient::Client.new \
|
|
15
|
+
"http://#{_host}:#{_port}/client/api",
|
|
16
|
+
"#{_api_key}",
|
|
17
|
+
"#{_secret_key}"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def teardown
|
|
21
|
+
# Do nothing here!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_list_async_jobs
|
|
25
|
+
assert_equal([], @client.list_async_jobs)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_query_async_job_result
|
|
29
|
+
assert_raise(ArgumentError) do
|
|
30
|
+
@client.query_async_job_result
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
metadata
CHANGED
|
@@ -1,33 +1,45 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cloudstack_ruby_client
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 0
|
|
7
|
+
- 2
|
|
8
|
+
- 0
|
|
9
|
+
version: 0.2.0
|
|
6
10
|
platform: ruby
|
|
7
|
-
authors:
|
|
11
|
+
authors:
|
|
8
12
|
- Chip Childers
|
|
9
13
|
autorequire:
|
|
10
14
|
bindir: bin
|
|
11
15
|
cert_chain: []
|
|
12
|
-
|
|
16
|
+
|
|
17
|
+
date: 2013-08-26 00:00:00 -04:00
|
|
18
|
+
default_executable:
|
|
13
19
|
dependencies: []
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
email:
|
|
20
|
+
|
|
21
|
+
description: A Ruby client for CloudStack's API, including a simple CLI.
|
|
22
|
+
email:
|
|
17
23
|
- chip.childers@gmail.com
|
|
18
|
-
executables:
|
|
24
|
+
executables:
|
|
25
|
+
- cloudstack_ruby_client
|
|
19
26
|
extensions: []
|
|
27
|
+
|
|
20
28
|
extra_rdoc_files: []
|
|
21
|
-
|
|
29
|
+
|
|
30
|
+
files:
|
|
22
31
|
- .gitignore
|
|
23
32
|
- Gemfile
|
|
24
33
|
- LICENSE
|
|
25
34
|
- NOTICE
|
|
26
35
|
- README.md
|
|
27
36
|
- Rakefile
|
|
37
|
+
- bin/cloudstack_ruby_client
|
|
28
38
|
- cloudstack_ruby_client.gemspec
|
|
29
39
|
- lib/cloudstack_ruby_client.rb
|
|
30
40
|
- lib/cloudstack_ruby_client/api/accounts_api.rb
|
|
41
|
+
- lib/cloudstack_ruby_client/api/apidiscovery_api.rb
|
|
42
|
+
- lib/cloudstack_ruby_client/api/asyncjob_api.rb
|
|
31
43
|
- lib/cloudstack_ruby_client/api/autoscale_api.rb
|
|
32
44
|
- lib/cloudstack_ruby_client/api/configuration_api.rb
|
|
33
45
|
- lib/cloudstack_ruby_client/api/firewall_api.rb
|
|
@@ -45,10 +57,12 @@ files:
|
|
|
45
57
|
- lib/cloudstack_ruby_client/base_client.rb
|
|
46
58
|
- lib/cloudstack_ruby_client/client.rb
|
|
47
59
|
- lib/cloudstack_ruby_client/client_helper.rb
|
|
60
|
+
- lib/cloudstack_ruby_client/help.rb
|
|
48
61
|
- lib/cloudstack_ruby_client/version.rb
|
|
49
62
|
- test/config.yml
|
|
50
63
|
- test/integration/client_test.rb
|
|
51
64
|
- test/unit/accounts_test.rb
|
|
65
|
+
- test/unit/asyncjob_test.rb
|
|
52
66
|
- test/unit/autoscale_test.rb
|
|
53
67
|
- test/unit/configuration_test.rb
|
|
54
68
|
- test/unit/firewall_test.rb
|
|
@@ -63,34 +77,41 @@ files:
|
|
|
63
77
|
- test/unit/template_test.rb
|
|
64
78
|
- test/unit/vm_test.rb
|
|
65
79
|
- test/unit/volume_test.rb
|
|
80
|
+
has_rdoc: true
|
|
66
81
|
homepage: http://chipchilders.github.io/cloudstack_ruby_client/
|
|
67
82
|
licenses: []
|
|
83
|
+
|
|
68
84
|
post_install_message:
|
|
69
85
|
rdoc_options: []
|
|
70
|
-
|
|
86
|
+
|
|
87
|
+
require_paths:
|
|
71
88
|
- lib
|
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
requirements:
|
|
81
|
-
- -
|
|
82
|
-
- !ruby/object:Gem::Version
|
|
83
|
-
|
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
segments:
|
|
94
|
+
- 0
|
|
95
|
+
version: "0"
|
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - ">="
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
segments:
|
|
101
|
+
- 0
|
|
102
|
+
version: "0"
|
|
84
103
|
requirements: []
|
|
104
|
+
|
|
85
105
|
rubyforge_project:
|
|
86
|
-
rubygems_version: 1.
|
|
106
|
+
rubygems_version: 1.3.6
|
|
87
107
|
signing_key:
|
|
88
108
|
specification_version: 3
|
|
89
109
|
summary: A Ruby client for CloudStack's API.
|
|
90
|
-
test_files:
|
|
110
|
+
test_files:
|
|
91
111
|
- test/config.yml
|
|
92
112
|
- test/integration/client_test.rb
|
|
93
113
|
- test/unit/accounts_test.rb
|
|
114
|
+
- test/unit/asyncjob_test.rb
|
|
94
115
|
- test/unit/autoscale_test.rb
|
|
95
116
|
- test/unit/configuration_test.rb
|
|
96
117
|
- test/unit/firewall_test.rb
|