cloudstack-cli 1.5.2 → 1.5.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ccb77e0ffb661b126a24d49267c01e7ee5d8475
4
- data.tar.gz: f148f87197bafa1c1e627ff73311b9e1a04feb2b
3
+ metadata.gz: 6b75da05246b3ab3ac85f5ca8e93a28db01f8968
4
+ data.tar.gz: fc2d98e9c509876350509db6da5b5e7ab3b900b2
5
5
  SHA512:
6
- metadata.gz: f3f6c49400185cc0f198a1a9f3e7ca33d82eded1102bbfaeaf3290e107c25ba282db5eca0d11f4242a7590b3017256c0be46b646d0ee6d69aed8708fb96ff2bd
7
- data.tar.gz: 3fbdeac646beb0d2e50219e50a2874f9d482ccc3a0380f45c09548933021da6a27ab06b6d95da37771e1c3e65ccb1cebbdbe1b59c39f41a05aecb119717bbee5
6
+ metadata.gz: 573c55dfed55ed68409424ef04562a9cd0dca835d23a458ce031c3f5fc0653fc87326f05cfd45c18e76ccbdb409dba6a90a1a5098f4c779ff81065514d50c804
7
+ data.tar.gz: 22dd3887d463b7b3e08792b1396ec08002ba65bf1a94d9bec2090f72776a64a6b03630cd4dc6c5dd363281d195550cceb991e1677c11b2bf6fe02935c2e6a982
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: ../cloudstack_client/
3
3
  specs:
4
- cloudstack_client (1.4.0)
4
+ cloudstack_client (1.4.1)
5
5
 
6
6
  PATH
7
7
  remote: .
8
8
  specs:
9
- cloudstack-cli (1.5.2)
9
+ cloudstack-cli (1.5.3)
10
10
  cloudstack_client (~> 1.4)
11
11
  thor (~> 0.19)
12
12
 
@@ -25,4 +25,4 @@ DEPENDENCIES
25
25
  rake (~> 11.1)
26
26
 
27
27
  BUNDLED WITH
28
- 1.11.2
28
+ 1.12.0
data/README.md CHANGED
@@ -121,24 +121,23 @@ CloudStack CLI does support stack files in YAML or JSON.
121
121
  group: "my_web_stack"
122
122
  keypair: "mykeypair"
123
123
  servers:
124
- -
125
- name: "web-d1, web-d2"
126
- description: "Web nodes"
124
+ - name: "web-d1, web-d2"
125
+ description: "web node"
127
126
  template: "CentOS-7-x64"
128
127
  offering: "1cpu_1gb"
129
128
  networks: "server_network"
130
129
  port_rules: ":80, :443"
131
- -
132
- name: "db-01"
130
+ - name: "db-01"
133
131
  description: "PostgreSQL Master"
134
132
  iso: "CentOS-7-x64"
135
133
  disk_offering: "Perf Storage"
136
134
  disk_size: "5"
137
135
  offering: "2cpu_4gb"
138
- ip_address: 10.100.1.25
139
- networks:
140
- - "server_network"
141
- - "storage_network"
136
+ ip_network_list:
137
+ - name: FrontendNetwork
138
+ ip: 10.101.64.42
139
+ - name: BackendNetwork
140
+ ip: 10.102.1.11
142
141
  ```
143
142
 
144
143
  *Create the stack of servers from the definition above:
@@ -163,15 +162,16 @@ Completed: 2/3 (15.4s)
163
162
  ### Example: Sort computing offerings
164
163
 
165
164
  *Sort all computing offerings by CPU and Memory grouped by domain:*
165
+ (root admin privileges needed)
166
166
 
167
167
  ```bash
168
- $ cloudstack-cli offering sort
168
+ $ cloudstack-cli compute_offer sort
169
169
  ```
170
170
 
171
171
  ### Example: Stop all backup routers of a given project
172
172
 
173
173
  *Stop all virtual routers of project named Demo (you could filter by zone too):*
174
- (This command is helpful if you have to deploy new versions of CloudStack when using redundant routers)
174
+ (this command is helpful if you have to deploy new major release of CloudStack when using redundant routers)
175
175
 
176
176
  ```bash
177
177
  $ cloudstack-cli router list --project Demo --status running --redundant-state BACKUP --command STOP
@@ -72,7 +72,7 @@ module CloudstackCli
72
72
  end
73
73
 
74
74
  unless config.key?(:url) && config.key?(:api_key) && config.key?(:secret_key)
75
- say "The environment #{env || '\'-\''} contains no valid data.", :red
75
+ say "The environment #{env || '\'-\''} does not contain all required keys.", :red
76
76
  say "Please check with 'cloudstack-cli environment list' and set a valid default environment."
77
77
  exit 1
78
78
  end
@@ -134,5 +134,6 @@ module CloudstackCli
134
134
  end
135
135
  end
136
136
  end
137
- end
138
- end
137
+
138
+ end # class
139
+ end # module
@@ -63,15 +63,12 @@ class VirtualMachine < CloudstackCli::Base
63
63
  option :project
64
64
  def show(name)
65
65
  resolve_project
66
- options[:name] = name
67
- unless virtual_machine = client.list_virtual_machines({list_all: true}.merge options).first
68
- puts "No virtual machine found."
69
- else
70
- table = virtual_machine.map do |key, value|
71
- [ set_color("#{key}:", :yellow), "#{value}" ]
72
- end
73
- print_table table
66
+ options[:virtual_machine] = name
67
+ virtual_machine = resolve_virtual_machine(true)
68
+ table = virtual_machine.map do |key, value|
69
+ [ set_color("#{key}:", :yellow), "#{value}" ]
74
70
  end
71
+ print_table table
75
72
  end
76
73
 
77
74
  desc "create NAME [NAME2 ...]", "create virtual machine(s)"
@@ -149,14 +146,13 @@ class VirtualMachine < CloudstackCli::Base
149
146
  say "Please provide at least one virtual machine name.", :yellow
150
147
  exit 1
151
148
  end
152
-
153
149
  resolve_project
154
150
  names.each do |name|
155
- unless virtual_machine = client.list_virtual_machines(options.merge(name: name, listall: true)).first
151
+ unless virtual_machine = find_vm_by_name(name)
156
152
  say "Virtual machine #{name} not found.", :red
157
153
  else
158
154
  action = options[:expunge] ? "Expunge" : "Destroy"
159
- ask = "#{action} #{name} (#{virtual_machine['state']})? [y/N]:"
155
+ ask = "#{action} #{virtual_machine['name']} (#{virtual_machine['state']})? [y/N]:"
160
156
  if options[:force] || yes?(ask, :yellow)
161
157
  say "destroying #{name} "
162
158
  client.destroy_virtual_machine(
@@ -179,13 +175,12 @@ class VirtualMachine < CloudstackCli::Base
179
175
  option :force
180
176
  def stop(name)
181
177
  resolve_project
182
- options[:name] = name
183
- options[:listall] = true
184
- exit unless options[:force] || yes?("Stop virtual machine #{name}? [y/N]:", :magenta)
185
- unless virtual_machine = client.list_virtual_machines(options).first
178
+ unless virtual_machine = find_vm_by_name(name)
186
179
  say "Virtual machine #{name} not found.", :red
187
180
  exit 1
188
181
  end
182
+ exit unless options[:force] ||
183
+ yes?("Stop virtual machine #{virtual_machine['name']}? [y/N]:", :magenta)
189
184
  client.stop_virtual_machine(id: virtual_machine['id'])
190
185
  puts
191
186
  end
@@ -194,13 +189,11 @@ class VirtualMachine < CloudstackCli::Base
194
189
  option :project
195
190
  def start(name)
196
191
  resolve_project
197
- options[:name] = name
198
- options[:listall] = true
199
- unless virtual_machine = client.list_virtual_machines(options).first
192
+ unless virtual_machine = find_vm_by_name(name)
200
193
  say "Virtual machine #{name} not found.", :red
201
194
  exit 1
202
195
  end
203
- say("Starting virtual machine #{name}", :magenta)
196
+ say("Starting virtual machine #{virtual_machine['name']}", :magenta)
204
197
  client.start_virtual_machine(id: virtual_machine['id'])
205
198
  puts
206
199
  end
@@ -210,13 +203,11 @@ class VirtualMachine < CloudstackCli::Base
210
203
  option :force
211
204
  def reboot(name)
212
205
  resolve_project
213
- options[:name] = name
214
- options[:listall] = true
215
- unless virtual_machine = client.list_virtual_machines(options).first
206
+ unless virtual_machine = find_vm_by_name(name)
216
207
  say "Virtual machine #{name} not found.", :red
217
208
  exit 1
218
209
  end
219
- exit unless options[:force] || yes?("Reboot virtual_machine #{name}? [y/N]:", :magenta)
210
+ exit unless options[:force] || yes?("Reboot virtual_machine #{virtual_machine["name"]}? [y/N]:", :magenta)
220
211
  client.reboot_virtual_machine(id: virtual_machine['id'])
221
212
  puts
222
213
  end
@@ -248,30 +239,22 @@ class VirtualMachine < CloudstackCli::Base
248
239
  desc: "optional binary data that can be sent to the virtual machine upon a successful deployment."
249
240
  def update(name)
250
241
  resolve_project
251
-
252
- unless vm = client.list_virtual_machines(
253
- name: name, project_id: options[:project_id], listall: true
254
- ).first
242
+ unless vm = find_vm_by_name(name)
255
243
  say "Virtual machine #{name} not found.", :red
256
244
  exit 1
257
245
  end
258
-
259
246
  unless vm["state"].downcase == "stopped"
260
247
  say "Virtual machine #{name} (#{vm["state"]}) must be in a stopped state.", :red
261
248
  exit 1
262
249
  end
263
-
264
250
  unless options[:force] || yes?("Update virtual_machine #{name}? [y/N]:", :magenta)
265
251
  exit
266
252
  end
267
-
268
253
  if options[:user_data]
269
254
  # base64 encode user_data
270
255
  options[:user_data] = [options[:user_data]].pack("m")
271
256
  end
272
-
273
257
  vm = client.update_virtual_machine(options.merge(id: vm['id']))
274
-
275
258
  say "Virtual machine \"#{name}\" has been updated:", :green
276
259
 
277
260
  table = vm.select do |k, _|
@@ -284,6 +267,14 @@ class VirtualMachine < CloudstackCli::Base
284
267
 
285
268
  no_commands do
286
269
 
270
+ def find_vm_by_name(name)
271
+ client.list_virtual_machines(
272
+ name: options[:virtual_machine],
273
+ listall: true,
274
+ project_id: options[:project_id]
275
+ ).find {|vm| vm["name"] == name }
276
+ end
277
+
287
278
  def print_virtual_machines(virtual_machines)
288
279
  case options[:format].to_sym
289
280
  when :yaml
@@ -113,7 +113,7 @@ class Volume < CloudstackCli::Base
113
113
 
114
114
  desc "attach NAME", "attach volume to VM"
115
115
  option :project, desc: 'project of volume'
116
- option :virtual_machine, desc: 'virtual machine of volume'
116
+ option :virtual_machine, desc: 'virtual machine of volume', required: true
117
117
  def attach(name)
118
118
  resolve_project
119
119
  resolve_virtual_machine
@@ -142,6 +142,7 @@ class Volume < CloudstackCli::Base
142
142
 
143
143
  desc "detach NAME", "detach volume from VM"
144
144
  option :project, desc: 'project of volume'
145
+ option :force
145
146
  def detach(name)
146
147
  resolve_project
147
148
 
@@ -158,7 +159,8 @@ class Volume < CloudstackCli::Base
158
159
  say "Error: Volume #{name} currently not attached to any VM.", :red
159
160
  exit 1
160
161
  end
161
-
162
+ exit unless options[:force] ||
163
+ yes?("Detach volume #{name} from virtual_machine #{volume["vmname"]}? [y/N]:", :magenta)
162
164
  say "Detach volume #{name} from VM #{volume["vmname"]} "
163
165
  client.detach_volume id: volume['id']
164
166
  say " OK.", :green
@@ -232,7 +232,7 @@ module CloudstackCli
232
232
  print_options(server_offerings)
233
233
  service_offering = ask_number("Offering Nr.: ")
234
234
 
235
- templates = client.list_templates(project_id: project_id, zone_id: zones[zone]["id"], template_filter: "all")
235
+ templates = client.list_templates(project_id: project_id, zone_id: zones[zone]["id"], template_filter: "executable")
236
236
  say "Select a template:", :yellow
237
237
  print_options(templates)
238
238
  template = ask_number("Template Nr.: ")
@@ -195,15 +195,22 @@ module CloudstackCli
195
195
  options
196
196
  end
197
197
 
198
- def resolve_virtual_machine
198
+ def resolve_virtual_machine(return_vm = false)
199
199
  if options[:virtual_machine]
200
- args = { name: options[:virtual_machine], listall: true }
201
- args[:project_id] = options[:project_id]
202
- unless vm = client.list_virtual_machines(args).first
200
+ unless vm = client.list_virtual_machines(
201
+ name: options[:virtual_machine],
202
+ listall: true,
203
+ project_id: options[:project_id]
204
+ ).find {|vm| vm["name"] == options[:virtual_machine] }
203
205
  say "Error: VM '#{options[:virtual_machine]}' not found.", :red
204
206
  exit 1
205
207
  end
206
- options[:virtual_machine_id] = vm['id']
208
+
209
+ if return_vm
210
+ return vm
211
+ else
212
+ options[:virtual_machine_id] = vm["id"]
213
+ end
207
214
  end
208
215
  options
209
216
  end
@@ -1,3 +1,3 @@
1
1
  module CloudstackCli
2
- VERSION = "1.5.2"
2
+ VERSION = "1.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstack-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nik Wolfgramm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake