cloudstack-cli 0.0.5 → 0.1.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/Gemfile.lock +1 -5
- data/README.md +6 -6
- data/cloudstack-cli.gemspec +0 -1
- data/lib/cloudstack-cli/base.rb +36 -0
- data/lib/cloudstack-cli/cli.rb +20 -19
- data/lib/cloudstack-cli/commands/account.rb +12 -5
- data/lib/cloudstack-cli/commands/capacity.rb +34 -0
- data/lib/cloudstack-cli/commands/domain.rb +6 -5
- data/lib/cloudstack-cli/commands/load_balancer.rb +24 -30
- data/lib/cloudstack-cli/commands/network.rb +28 -49
- data/lib/cloudstack-cli/commands/offering.rb +18 -29
- data/lib/cloudstack-cli/commands/project.rb +7 -5
- data/lib/cloudstack-cli/commands/publicip.rb +3 -4
- data/lib/cloudstack-cli/commands/router.rb +44 -62
- data/lib/cloudstack-cli/commands/server.rb +39 -32
- data/lib/cloudstack-cli/commands/stack.rb +3 -11
- data/lib/cloudstack-cli/commands/template.rb +10 -12
- data/lib/cloudstack-cli/commands/volume.rb +9 -10
- data/lib/cloudstack-cli/commands/zone.rb +6 -5
- data/lib/cloudstack-cli/helper.rb +8 -86
- data/lib/cloudstack-cli/version.rb +1 -1
- data/lib/cloudstack-client/client.rb +18 -11
- data/lib/cloudstack_cli.rb +2 -3
- metadata +23 -23
- checksums.yaml +0 -7
@@ -1,20 +1,19 @@
|
|
1
|
-
class Volume <
|
2
|
-
|
1
|
+
class Volume < CloudstackCli::Base
|
2
|
+
|
3
|
+
desc "list", "list networks"
|
3
4
|
option :project
|
4
5
|
def list
|
5
|
-
|
6
|
-
|
7
|
-
project = cs_cli.projects.select { |p| p['name'] == options[:project] }.first
|
8
|
-
raise "Project '#{options[:project]}' not found" unless project
|
9
|
-
end
|
10
|
-
|
11
|
-
networks = cs_cli.networks(project ? project['id'] : nil)
|
6
|
+
project = find_project if options[:project]
|
7
|
+
networks = client.list_networks(project ? project['id'] : nil)
|
12
8
|
if networks.size < 1
|
13
9
|
puts "No networks found"
|
14
10
|
else
|
11
|
+
table = [["Name", "Displaytext", "Default?"]]
|
15
12
|
networks.each do |network|
|
16
|
-
|
13
|
+
table << [network['name'], network['displaytext'], network['isdefault']]
|
17
14
|
end
|
15
|
+
print_table(table)
|
18
16
|
end
|
19
17
|
end
|
18
|
+
|
20
19
|
end
|
@@ -1,16 +1,17 @@
|
|
1
|
-
class Zone <
|
1
|
+
class Zone < CloudstackCli::Base
|
2
2
|
|
3
|
-
desc "
|
3
|
+
desc "list", "list zones"
|
4
4
|
def list
|
5
|
-
|
6
|
-
zones = cs_cli.zones
|
5
|
+
zones = client.list_zones
|
7
6
|
if zones.size < 1
|
8
7
|
puts "No projects found"
|
9
8
|
else
|
9
|
+
table = [["Name", "Description"]]
|
10
10
|
zones.each do |zone|
|
11
|
-
|
11
|
+
table << [zone['name'] ,zone['description']]
|
12
12
|
end
|
13
13
|
end
|
14
|
+
print_table(table)
|
14
15
|
end
|
15
16
|
|
16
17
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module CloudstackCli
|
2
2
|
class Helper
|
3
|
-
include CommandLineReporter
|
4
|
-
|
5
3
|
attr_reader :cs
|
6
4
|
|
7
5
|
def initialize(config_file)
|
@@ -13,8 +11,14 @@ module CloudstackCli
|
|
13
11
|
)
|
14
12
|
end
|
15
13
|
|
16
|
-
def
|
17
|
-
|
14
|
+
def options
|
15
|
+
@options ||= CloudstackClient::ConnectionHelper.load_configuration(@config_file)
|
16
|
+
end
|
17
|
+
|
18
|
+
def print_options(options, attr = 'name')
|
19
|
+
options.to_enum.with_index(1).each do |option, i|
|
20
|
+
puts "#{i}: #{option[attr]}"
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
def domains(name = nil)
|
@@ -24,18 +28,6 @@ module CloudstackCli
|
|
24
28
|
def server_offerings(domain = nil)
|
25
29
|
@server_offerings ||= @cs.list_service_offerings(domain)
|
26
30
|
end
|
27
|
-
|
28
|
-
def create_offering(params)
|
29
|
-
@cs.create_offering(params)
|
30
|
-
end
|
31
|
-
|
32
|
-
def delete_offering(id)
|
33
|
-
@cs.delete_offering(id)
|
34
|
-
end
|
35
|
-
|
36
|
-
def update_offering(args)
|
37
|
-
@cs.update_offering(args)
|
38
|
-
end
|
39
31
|
|
40
32
|
def templates(type = 'featured', project_id = -1)
|
41
33
|
@templates ||= @cs.list_templates(type, project_id)
|
@@ -53,9 +45,6 @@ module CloudstackCli
|
|
53
45
|
@cs.list_networks(project_id)
|
54
46
|
end
|
55
47
|
|
56
|
-
def physical_networks
|
57
|
-
@cs.list_physical_networks
|
58
|
-
end
|
59
48
|
|
60
49
|
def volumes(project_id = nil)
|
61
50
|
@cs.list_volumes(project_id)
|
@@ -64,31 +53,6 @@ module CloudstackCli
|
|
64
53
|
def virtual_machines(options = {})
|
65
54
|
@cs.list_servers(options)
|
66
55
|
end
|
67
|
-
|
68
|
-
def virtual_machines_table(vms)
|
69
|
-
table(border: true) do
|
70
|
-
row do
|
71
|
-
column 'Name', width: 20
|
72
|
-
column 'State'
|
73
|
-
column 'Offering', align: 'right'
|
74
|
-
column 'Template', align: 'right', width: 30
|
75
|
-
column 'IP\'s', width: 14
|
76
|
-
column 'Project'
|
77
|
-
column 'Account'
|
78
|
-
end
|
79
|
-
vms.each do |vm|
|
80
|
-
row do
|
81
|
-
column vm['name']
|
82
|
-
column vm['state']
|
83
|
-
column vm['serviceofferingname']
|
84
|
-
column vm['templatename']
|
85
|
-
column vm['nic'].map { |nic| nic['ipaddress']}.join(" ")
|
86
|
-
column vm['project']
|
87
|
-
column vm['account']
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
56
|
|
93
57
|
def bootstrap_server(name, zone, template, offering, networks, pf_rules = [], project = nil)
|
94
58
|
puts "Create server #{name}...".color(:yellow)
|
@@ -128,18 +92,6 @@ module CloudstackCli
|
|
128
92
|
puts "Complete!".color(:green)
|
129
93
|
end
|
130
94
|
|
131
|
-
def stop_server(name)
|
132
|
-
@cs.stop_server(name)
|
133
|
-
end
|
134
|
-
|
135
|
-
def start_server(name)
|
136
|
-
@cs.start_server(name)
|
137
|
-
end
|
138
|
-
|
139
|
-
def reboot_server(name)
|
140
|
-
@cs.reboot_server(name)
|
141
|
-
end
|
142
|
-
|
143
95
|
def list_accounts(name = nil)
|
144
96
|
@cs.list_accounts({ name: name })
|
145
97
|
end
|
@@ -164,36 +116,6 @@ module CloudstackCli
|
|
164
116
|
end
|
165
117
|
end
|
166
118
|
|
167
|
-
def list_routers(args, redundant_state = nil)
|
168
|
-
routers = @cs.list_routers(args)
|
169
|
-
if redundant_state
|
170
|
-
return routers.select {|r| r['redundantstate'].downcase == redundant_state.downcase }
|
171
|
-
end
|
172
|
-
routers
|
173
|
-
end
|
174
|
-
|
175
|
-
def destroy_router(id)
|
176
|
-
@cs.destroy_router(id)
|
177
|
-
end
|
178
|
-
|
179
|
-
def start_router(id)
|
180
|
-
@cs.start_router(id)
|
181
|
-
end
|
182
|
-
|
183
|
-
def stop_router(id)
|
184
|
-
@cs.stop_router(id)
|
185
|
-
end
|
186
|
-
|
187
|
-
def options
|
188
|
-
@options ||= CloudstackClient::ConnectionHelper.load_configuration(@config_file)
|
189
|
-
end
|
190
|
-
|
191
|
-
def print_options(options, attr = 'name')
|
192
|
-
options.to_enum.with_index(1).each do |option, i|
|
193
|
-
puts "#{i}: #{option[attr]}"
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
119
|
def bootstrap_server_interactive
|
198
120
|
ARGV.clear
|
199
121
|
puts
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# cloudstack-client by Nik Wolfgramm (<nik.wolfgramm@gmail.com.ch>) based on
|
2
2
|
# knife-cloudstack by Ryan Holmes (<rholmes@edmunds.com>), KC Braunschweig (<kcbraunschweig@gmail.com>)
|
3
3
|
#
|
4
4
|
# License:: Apache License, Version 2.0
|
@@ -16,7 +16,6 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'rubygems'
|
20
19
|
require 'base64'
|
21
20
|
require 'openssl'
|
22
21
|
require 'uri'
|
@@ -127,12 +126,8 @@ module CloudstackClient
|
|
127
126
|
def list_servers(options = {})
|
128
127
|
params = {
|
129
128
|
'command' => 'listVirtualMachines',
|
129
|
+
'listAll' => true
|
130
130
|
}
|
131
|
-
if options[:listall]
|
132
|
-
params['listAll'] = true
|
133
|
-
params['projectId'] = -1
|
134
|
-
options[:account] = nil
|
135
|
-
end
|
136
131
|
params['projectid'] = options[:project_id] if options[:project_id]
|
137
132
|
if options[:account]
|
138
133
|
params['domainid'] = list_accounts({name: options[:account]}).first["domainid"]
|
@@ -668,14 +663,14 @@ module CloudstackClient
|
|
668
663
|
##
|
669
664
|
# List loadbalancer rules
|
670
665
|
|
671
|
-
def list_load_balancer_rules(
|
666
|
+
def list_load_balancer_rules(options = {})
|
672
667
|
params = {
|
673
668
|
'command' => 'listLoadBalancerRules',
|
674
669
|
}
|
675
|
-
params['name'] = name if name
|
670
|
+
params['name'] = options[:name] if options[:name]
|
676
671
|
|
677
|
-
if project_name
|
678
|
-
project = get_project(project_name)
|
672
|
+
if options[:project_name]
|
673
|
+
project = get_project(options[:project_name])
|
679
674
|
params['projectid'] = project['id']
|
680
675
|
end
|
681
676
|
|
@@ -816,6 +811,18 @@ module CloudstackClient
|
|
816
811
|
json['domain'] || []
|
817
812
|
end
|
818
813
|
|
814
|
+
##
|
815
|
+
# List capacity.
|
816
|
+
|
817
|
+
def list_capacity(args = {})
|
818
|
+
params = {
|
819
|
+
'command' => 'listCapacity',
|
820
|
+
}
|
821
|
+
|
822
|
+
json = send_request(params)
|
823
|
+
json['capacity'] || []
|
824
|
+
end
|
825
|
+
|
819
826
|
##
|
820
827
|
# Sends a synchronous request to the CloudStack API and returns the response as a Hash.
|
821
828
|
#
|
data/lib/cloudstack_cli.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'rainbow'
|
3
3
|
require "thor"
|
4
|
-
require 'command_line_reporter'
|
5
4
|
|
6
5
|
require "cloudstack-cli/version"
|
6
|
+
require "cloudstack-cli/helper"
|
7
|
+
require "cloudstack-cli/base"
|
7
8
|
|
8
9
|
# require subcommands
|
9
10
|
Dir[File.dirname(__FILE__) + '/../lib/cloudstack-cli/commands/*.rb'].each do |file|
|
10
11
|
require file
|
11
12
|
end
|
12
|
-
|
13
|
-
require "cloudstack-cli/helper"
|
14
13
|
require "cloudstack-cli/cli"
|
metadata
CHANGED
@@ -1,32 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudstack-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Nik Wolfgramm
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-25 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rdoc
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: thor
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: net-ssh
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ~>
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rainbow
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ~>
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,24 +86,11 @@ dependencies:
|
|
76
86
|
type: :runtime
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - ~>
|
81
92
|
- !ruby/object:Gem::Version
|
82
93
|
version: 1.1.4
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: command_line_reporter
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 3.2.1
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ~>
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 3.2.1
|
97
94
|
description: cloudstack-cli is a CloudStack API client written in Ruby.
|
98
95
|
email:
|
99
96
|
- nik.wolfgramm@gmail.com
|
@@ -110,8 +107,10 @@ files:
|
|
110
107
|
- bin/cs
|
111
108
|
- cloudstack-cli.gemspec
|
112
109
|
- config/cloudstack.example.yml
|
110
|
+
- lib/cloudstack-cli/base.rb
|
113
111
|
- lib/cloudstack-cli/cli.rb
|
114
112
|
- lib/cloudstack-cli/commands/account.rb
|
113
|
+
- lib/cloudstack-cli/commands/capacity.rb
|
115
114
|
- lib/cloudstack-cli/commands/domain.rb
|
116
115
|
- lib/cloudstack-cli/commands/load_balancer.rb
|
117
116
|
- lib/cloudstack-cli/commands/network.rb
|
@@ -133,7 +132,6 @@ files:
|
|
133
132
|
- lib/cloudstack_client.rb
|
134
133
|
homepage: https://bitbucket.org/swisstxt/cloudstack-cli
|
135
134
|
licenses: []
|
136
|
-
metadata: {}
|
137
135
|
post_install_message:
|
138
136
|
rdoc_options:
|
139
137
|
- --line-numbers
|
@@ -141,19 +139,21 @@ rdoc_options:
|
|
141
139
|
require_paths:
|
142
140
|
- lib
|
143
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
144
143
|
requirements:
|
145
|
-
- - '>='
|
144
|
+
- - ! '>='
|
146
145
|
- !ruby/object:Gem::Version
|
147
146
|
version: 1.9.3
|
148
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
149
|
requirements:
|
150
|
-
- - '>='
|
150
|
+
- - ! '>='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
154
|
rubyforge_project:
|
155
|
-
rubygems_version:
|
155
|
+
rubygems_version: 1.8.23
|
156
156
|
signing_key:
|
157
|
-
specification_version:
|
157
|
+
specification_version: 3
|
158
158
|
summary: cloudstack-cli CloudStack API client
|
159
159
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 93104eb717133f717c8c4ca3cd7eca4f1bd004f2
|
4
|
-
data.tar.gz: 1107b76a9e396b694f6cacfb81d83febaf60aa70
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 9ab5e2a02a20bc047bf5d04635c82c8981914f21f0d6f50597f37f39fe92c7dbcf24c27bc9d0b5c38471bcf9d96fe0bc1f09622abb8e58900ca2424f561b5faa
|
7
|
-
data.tar.gz: 57652bbf3d82fc448836ac61e33a747b996c7908fee1f2f7a0f32c4679f9d711a88c435e4b474b8303828d809b0d222571b4d08a2534f47deba48741bb77ed71
|