cloudstack-cli 0.3.11 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +3 -1
- data/bin/cs +1 -2
- data/cloudstack-cli.gemspec +1 -0
- data/lib/{cloudstack_cli.rb → cloudstack-cli.rb} +2 -0
- data/lib/cloudstack-cli/commands/router.rb +3 -1
- data/lib/cloudstack-cli/version.rb +1 -1
- metadata +24 -44
- data/lib/cloudstack-client/client.rb +0 -136
- data/lib/cloudstack-client/commands/account.rb +0 -22
- data/lib/cloudstack-client/commands/capacity.rb +0 -19
- data/lib/cloudstack-client/commands/cluster.rb +0 -19
- 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 -82
- data/lib/cloudstack-client/commands/iso.rb +0 -64
- 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 -128
- data/lib/cloudstack-client/commands/pod.rb +0 -19
- 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/router.rb +0 -89
- data/lib/cloudstack-client/commands/server.rb +0 -311
- data/lib/cloudstack-client/commands/service_offering.rb +0 -98
- data/lib/cloudstack-client/commands/snapshot.rb +0 -40
- data/lib/cloudstack-client/commands/ssh_key_pair.rb +0 -106
- 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 -20
- data/lib/cloudstack-client/commands/zone.rb +0 -57
- data/lib/cloudstack-client/version.rb +0 -3
- data/lib/cloudstack_client.rb +0 -2
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b11471c299adace0851b9aae26162928755ae80f
|
4
|
+
data.tar.gz: 09187a0c3bb5e5ffa504a9fc84811e8759d837c0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c50f031e9f05e41f419bcffcc27695b162680d43c54922fa7b20c3dc16c4a691bae62296c059c7869a702bf3bc2d45b9c19a128e5f3bb70af8b1834c5b8aecf6
|
7
|
+
data.tar.gz: ec8442e1444e4bca685896f0daf3f1f6d56710905c1d770ca86b919752daf58e82d7217ff9bd56530ea05951d959d3cad3f409c07b865d53ce3c089c5d02808b
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cloudstack-cli (0.
|
4
|
+
cloudstack-cli (0.4.0)
|
5
|
+
cloudstack_client (~> 0.2.10)
|
5
6
|
thor (~> 0.18.1)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
11
|
+
cloudstack_client (0.2.10)
|
10
12
|
json (1.8.1)
|
11
13
|
rake (10.0.4)
|
12
14
|
rdoc (4.0.1)
|
data/bin/cs
CHANGED
data/cloudstack-cli.gemspec
CHANGED
@@ -11,7 +11,9 @@ class Router < CloudstackCli::Base
|
|
11
11
|
option :command, desc: "command to execute for each router: START or STOP"
|
12
12
|
option :reverse, type: :boolean, default: false, desc: "reverse listing of routers"
|
13
13
|
def list
|
14
|
-
|
14
|
+
if options[:project]
|
15
|
+
projectid = options[:project] =~ /-1|all/ ? '-1' : find_project['id']
|
16
|
+
end
|
15
17
|
routers = client.list_routers(
|
16
18
|
{
|
17
19
|
account: options[:account],
|
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudstack-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Nik Wolfgramm
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rdoc
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: thor
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,11 +48,24 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 0.18.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cloudstack_client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.2.10
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.2.10
|
62
69
|
description: cloudstack-cli is a CloudStack API client written in Ruby.
|
63
70
|
email:
|
64
71
|
- nik.wolfgramm@gmail.com
|
@@ -74,6 +81,7 @@ files:
|
|
74
81
|
- README.md
|
75
82
|
- bin/cs
|
76
83
|
- cloudstack-cli.gemspec
|
84
|
+
- lib/cloudstack-cli.rb
|
77
85
|
- lib/cloudstack-cli/base.rb
|
78
86
|
- lib/cloudstack-cli/cli.rb
|
79
87
|
- lib/cloudstack-cli/commands/account.rb
|
@@ -103,37 +111,11 @@ files:
|
|
103
111
|
- lib/cloudstack-cli/commands/zone.rb
|
104
112
|
- lib/cloudstack-cli/helper.rb
|
105
113
|
- lib/cloudstack-cli/version.rb
|
106
|
-
- lib/cloudstack-client/client.rb
|
107
|
-
- lib/cloudstack-client/commands/account.rb
|
108
|
-
- lib/cloudstack-client/commands/capacity.rb
|
109
|
-
- lib/cloudstack-client/commands/cluster.rb
|
110
|
-
- lib/cloudstack-client/commands/disk_offering.rb
|
111
|
-
- lib/cloudstack-client/commands/domain.rb
|
112
|
-
- lib/cloudstack-client/commands/host.rb
|
113
|
-
- lib/cloudstack-client/commands/ip_address.rb
|
114
|
-
- lib/cloudstack-client/commands/iso.rb
|
115
|
-
- lib/cloudstack-client/commands/job.rb
|
116
|
-
- lib/cloudstack-client/commands/load_balancer_rule.rb
|
117
|
-
- lib/cloudstack-client/commands/network.rb
|
118
|
-
- lib/cloudstack-client/commands/pod.rb
|
119
|
-
- lib/cloudstack-client/commands/port_forwarding_rule.rb
|
120
|
-
- lib/cloudstack-client/commands/project.rb
|
121
|
-
- lib/cloudstack-client/commands/router.rb
|
122
|
-
- lib/cloudstack-client/commands/server.rb
|
123
|
-
- lib/cloudstack-client/commands/service_offering.rb
|
124
|
-
- lib/cloudstack-client/commands/snapshot.rb
|
125
|
-
- lib/cloudstack-client/commands/ssh_key_pair.rb
|
126
|
-
- lib/cloudstack-client/commands/template.rb
|
127
|
-
- lib/cloudstack-client/commands/user.rb
|
128
|
-
- lib/cloudstack-client/commands/volume.rb
|
129
|
-
- lib/cloudstack-client/commands/zone.rb
|
130
|
-
- lib/cloudstack-client/version.rb
|
131
|
-
- lib/cloudstack_cli.rb
|
132
|
-
- lib/cloudstack_client.rb
|
133
114
|
- test/stack_example.json
|
134
115
|
homepage: https://bitbucket.org/swisstxt/cloudstack-cli
|
135
116
|
licenses:
|
136
117
|
- MIT
|
118
|
+
metadata: {}
|
137
119
|
post_install_message:
|
138
120
|
rdoc_options:
|
139
121
|
- --line-numbers
|
@@ -141,22 +123,20 @@ rdoc_options:
|
|
141
123
|
require_paths:
|
142
124
|
- lib
|
143
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
-
none: false
|
145
126
|
requirements:
|
146
|
-
- -
|
127
|
+
- - '>='
|
147
128
|
- !ruby/object:Gem::Version
|
148
129
|
version: 1.9.3
|
149
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
-
none: false
|
151
131
|
requirements:
|
152
|
-
- -
|
132
|
+
- - '>='
|
153
133
|
- !ruby/object:Gem::Version
|
154
134
|
version: '0'
|
155
135
|
requirements: []
|
156
136
|
rubyforge_project:
|
157
|
-
rubygems_version:
|
137
|
+
rubygems_version: 2.0.3
|
158
138
|
signing_key:
|
159
|
-
specification_version:
|
139
|
+
specification_version: 4
|
160
140
|
summary: cloudstack-cli CloudStack API client
|
161
141
|
test_files:
|
162
142
|
- test/stack_example.json
|
@@ -1,136 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
require 'openssl'
|
3
|
-
require 'uri'
|
4
|
-
require 'cgi'
|
5
|
-
require 'net/http'
|
6
|
-
require 'net/https'
|
7
|
-
require 'json'
|
8
|
-
require 'yaml'
|
9
|
-
|
10
|
-
module CloudstackClient
|
11
|
-
class Connection
|
12
|
-
|
13
|
-
@@async_poll_interval = 2.0
|
14
|
-
@@async_timeout = 400
|
15
|
-
|
16
|
-
# include all commands
|
17
|
-
Dir.glob(File.dirname(__FILE__) + "/commands/*.rb").each do |file|
|
18
|
-
require file
|
19
|
-
module_name = File.basename(file, '.rb').split('_').map{|f| f.capitalize}.join
|
20
|
-
include Object.const_get("CloudstackClient").const_get(module_name)
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_accessor :verbose
|
24
|
-
|
25
|
-
def initialize(api_url, api_key, secret_key, opts = {})
|
26
|
-
@api_url = api_url
|
27
|
-
@api_key = api_key
|
28
|
-
@secret_key = secret_key
|
29
|
-
@use_ssl = api_url.start_with? "https"
|
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}"
|
57
|
-
|
58
|
-
uri = URI.parse(url)
|
59
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
60
|
-
http.use_ssl = @use_ssl
|
61
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
62
|
-
|
63
|
-
begin
|
64
|
-
response = http.request(Net::HTTP::Get.new(uri.request_uri))
|
65
|
-
rescue
|
66
|
-
puts "Error connecting to API:"
|
67
|
-
puts "#{@api_url} is not reachable"
|
68
|
-
exit 1
|
69
|
-
end
|
70
|
-
|
71
|
-
if !response.is_a?(Net::HTTPOK)
|
72
|
-
puts "Error #{response.code}: #{response.message}"
|
73
|
-
puts JSON.pretty_generate(JSON.parse(response.body))
|
74
|
-
puts "URL: #{url}"
|
75
|
-
exit 1
|
76
|
-
end
|
77
|
-
|
78
|
-
begin
|
79
|
-
json = JSON.parse(response.body)
|
80
|
-
rescue JSON::ParserError
|
81
|
-
puts "Error parsing response from server."
|
82
|
-
exit 1
|
83
|
-
end
|
84
|
-
json[params['command'].downcase + 'response']
|
85
|
-
end
|
86
|
-
|
87
|
-
##
|
88
|
-
# Sends an asynchronous request and waits for the response.
|
89
|
-
#
|
90
|
-
# The contents of the 'jobresult' element are returned upon completion of the command.
|
91
|
-
|
92
|
-
def send_async_request(params)
|
93
|
-
|
94
|
-
json = send_request(params)
|
95
|
-
|
96
|
-
params = {
|
97
|
-
'command' => 'queryAsyncJobResult',
|
98
|
-
'jobId' => json['jobid']
|
99
|
-
}
|
100
|
-
|
101
|
-
max_tries = (@@async_timeout / @@async_poll_interval).round
|
102
|
-
max_tries.times do
|
103
|
-
json = send_request(params)
|
104
|
-
status = json['jobstatus']
|
105
|
-
|
106
|
-
print "." if @verbose
|
107
|
-
|
108
|
-
if status == 1
|
109
|
-
return json['jobresult']
|
110
|
-
elsif status == 2
|
111
|
-
puts
|
112
|
-
puts "Request failed (#{json['jobresultcode']}): #{json['jobresult']}"
|
113
|
-
exit 1
|
114
|
-
end
|
115
|
-
|
116
|
-
STDOUT.flush
|
117
|
-
sleep @@async_poll_interval
|
118
|
-
end
|
119
|
-
|
120
|
-
print "\n"
|
121
|
-
puts "Error: Asynchronous request timed out"
|
122
|
-
exit 1
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
def debug_output(output, seperator = '-' * 80)
|
128
|
-
puts
|
129
|
-
puts seperator
|
130
|
-
puts output
|
131
|
-
puts seperator
|
132
|
-
puts
|
133
|
-
end
|
134
|
-
|
135
|
-
end # class
|
136
|
-
end
|
@@ -1,22 +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
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module DiskOffering
|
4
|
-
|
5
|
-
##
|
6
|
-
# Lists all available disk offerings.
|
7
|
-
|
8
|
-
def list_disk_offerings(domain = nil)
|
9
|
-
params = {
|
10
|
-
'command' => 'listDiskOfferings'
|
11
|
-
}
|
12
|
-
|
13
|
-
if domain
|
14
|
-
params['domainid'] = list_domains(domain).first["id"]
|
15
|
-
end
|
16
|
-
|
17
|
-
json = send_request(params)
|
18
|
-
json['diskoffering'] || []
|
19
|
-
end
|
20
|
-
|
21
|
-
##
|
22
|
-
# Get disk offering by name.
|
23
|
-
|
24
|
-
def get_disk_offering(name)
|
25
|
-
|
26
|
-
# TODO: use name parameter
|
27
|
-
# listServiceOfferings in CloudStack 2.2 doesn't seem to work
|
28
|
-
# when the name parameter is specified. When this is fixed,
|
29
|
-
# the name parameter should be added to the request.
|
30
|
-
params = {
|
31
|
-
'command' => 'listDiskOfferings'
|
32
|
-
}
|
33
|
-
json = send_request(params)
|
34
|
-
|
35
|
-
services = json['diskoffering']
|
36
|
-
return nil unless services
|
37
|
-
|
38
|
-
services.each { |s|
|
39
|
-
if s['name'] == name then
|
40
|
-
return s
|
41
|
-
end
|
42
|
-
}
|
43
|
-
nil
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|