cloudstack-cli 1.5.1 → 1.5.2
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ccb77e0ffb661b126a24d49267c01e7ee5d8475
|
|
4
|
+
data.tar.gz: f148f87197bafa1c1e627ff73311b9e1a04feb2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f3f6c49400185cc0f198a1a9f3e7ca33d82eded1102bbfaeaf3290e107c25ba282db5eca0d11f4242a7590b3017256c0be46b646d0ee6d69aed8708fb96ff2bd
|
|
7
|
+
data.tar.gz: 3fbdeac646beb0d2e50219e50a2874f9d482ccc3a0380f45c09548933021da6a27ab06b6d95da37771e1c3e65ccb1cebbdbe1b59c39f41a05aecb119717bbee5
|
data/Gemfile.lock
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
class Stack < CloudstackCli::Base
|
|
2
2
|
|
|
3
3
|
desc "create STACKFILE", "create a stack of VMs"
|
|
4
|
+
option :skip_forwarding_rules, default: false,
|
|
5
|
+
type: :boolean, aliases: '-s',
|
|
6
|
+
desc: "Skip creation of port forwarding rules."
|
|
4
7
|
def create(stackfile)
|
|
5
8
|
stack = parse_file(stackfile)
|
|
6
9
|
project_id = find_project_by_name(stack["project"])
|
|
@@ -34,7 +37,6 @@ class Stack < CloudstackCli::Base
|
|
|
34
37
|
keypair: instance["keypair"] || stack["keypair"],
|
|
35
38
|
ip_address: instance["ip_address"]
|
|
36
39
|
})
|
|
37
|
-
|
|
38
40
|
jobs << {
|
|
39
41
|
id: client.deploy_virtual_machine(
|
|
40
42
|
vm_options_to_params,
|
|
@@ -47,22 +49,25 @@ class Stack < CloudstackCli::Base
|
|
|
47
49
|
end
|
|
48
50
|
watch_jobs(jobs)
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
unless options[:skip_forwarding_rules]
|
|
53
|
+
say "Check for port forwarding rules...", :green
|
|
54
|
+
jobs = []
|
|
55
|
+
stack["servers"].each do |instance|
|
|
56
|
+
string_to_array(instance["name"]).each do |name|
|
|
57
|
+
if port_rules = string_to_array(instance["port_rules"])
|
|
58
|
+
server = client.list_virtual_machines(name: name, project_id: project_id).first
|
|
59
|
+
create_port_rules(server, port_rules, false).each_with_index do |job_id, index|
|
|
60
|
+
jobs << {
|
|
61
|
+
id: job_id,
|
|
62
|
+
name: "Create port forwarding rules (#{port_rules[index]}) for VM #{name}"
|
|
63
|
+
}
|
|
64
|
+
end
|
|
61
65
|
end
|
|
62
66
|
end
|
|
63
67
|
end
|
|
68
|
+
watch_jobs(jobs)
|
|
64
69
|
end
|
|
65
|
-
|
|
70
|
+
|
|
66
71
|
say "Finished.", :green
|
|
67
72
|
end
|
|
68
73
|
|
|
@@ -118,7 +123,8 @@ class Stack < CloudstackCli::Base
|
|
|
118
123
|
end
|
|
119
124
|
|
|
120
125
|
def load_string_or_array(item)
|
|
121
|
-
|
|
126
|
+
return nil if item == nil
|
|
127
|
+
item.is_a?(Array) ? item : [item]
|
|
122
128
|
end
|
|
123
129
|
|
|
124
130
|
def string_to_array(string)
|
|
@@ -91,9 +91,20 @@ class VirtualMachine < CloudstackCli::Base
|
|
|
91
91
|
option :group, desc: "group name"
|
|
92
92
|
option :account, desc: "account name"
|
|
93
93
|
option :ip_address, desc: "the ip address for default vm's network"
|
|
94
|
+
option :ip_network_list, desc: "ip_network_list (net1:ip net2:ip...)", type: :array
|
|
95
|
+
option :user_data,
|
|
96
|
+
desc: "optional binary data that can be sent to the virtual machine upon a successful deployment."
|
|
94
97
|
def create(*names)
|
|
95
|
-
|
|
98
|
+
if names.size == 0
|
|
99
|
+
say "Please provide at least one virtual machine name.", :yellow
|
|
100
|
+
exit 1
|
|
101
|
+
end
|
|
96
102
|
|
|
103
|
+
if options[:ip_network_list]
|
|
104
|
+
options[:ip_network_list] = array_to_network_list(options[:ip_network_list])
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
vm_options_to_params
|
|
97
108
|
say "Start deploying virtual machine#{ "s" if names.size > 1 }...", :green
|
|
98
109
|
jobs = names.map do |name|
|
|
99
110
|
if virtual_machine = client.list_virtual_machines(name: name, project_id: options[:project_id]).first
|
|
@@ -131,15 +142,21 @@ class VirtualMachine < CloudstackCli::Base
|
|
|
131
142
|
|
|
132
143
|
desc "destroy NAME [NAME2 ..]", "destroy virtual machine(s)"
|
|
133
144
|
option :project
|
|
134
|
-
option :force, desc: "destroy without
|
|
145
|
+
option :force, desc: "destroy without confirmation", type: :boolean, aliases: '-f'
|
|
135
146
|
option :expunge, desc: "expunge virtual machine immediately", type: :boolean, default: false, aliases: '-E'
|
|
136
147
|
def destroy(*names)
|
|
148
|
+
if names.size == 0
|
|
149
|
+
say "Please provide at least one virtual machine name.", :yellow
|
|
150
|
+
exit 1
|
|
151
|
+
end
|
|
152
|
+
|
|
137
153
|
resolve_project
|
|
138
154
|
names.each do |name|
|
|
139
155
|
unless virtual_machine = client.list_virtual_machines(options.merge(name: name, listall: true)).first
|
|
140
156
|
say "Virtual machine #{name} not found.", :red
|
|
141
157
|
else
|
|
142
|
-
|
|
158
|
+
action = options[:expunge] ? "Expunge" : "Destroy"
|
|
159
|
+
ask = "#{action} #{name} (#{virtual_machine['state']})? [y/N]:"
|
|
143
160
|
if options[:force] || yes?(ask, :yellow)
|
|
144
161
|
say "destroying #{name} "
|
|
145
162
|
client.destroy_virtual_machine(
|
|
@@ -228,7 +245,7 @@ class VirtualMachine < CloudstackCli::Base
|
|
|
228
245
|
option :ha_enable, enum: %w(true false),
|
|
229
246
|
desc: "true if high-availability is enabled for the virtual machine, false otherwise"
|
|
230
247
|
option :user_data,
|
|
231
|
-
desc: "
|
|
248
|
+
desc: "optional binary data that can be sent to the virtual machine upon a successful deployment."
|
|
232
249
|
def update(name)
|
|
233
250
|
resolve_project
|
|
234
251
|
|
|
@@ -315,6 +332,14 @@ class VirtualMachine < CloudstackCli::Base
|
|
|
315
332
|
run_background_jobs(jobs, "#{command}_virtual_machine")
|
|
316
333
|
end
|
|
317
334
|
|
|
335
|
+
def array_to_network_list(arr)
|
|
336
|
+
arr.each.map do |item|
|
|
337
|
+
name = item.split(':')[0]
|
|
338
|
+
ip = item.split(':')[1]
|
|
339
|
+
{"name" => name, "ip" => ip}
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
|
|
318
343
|
end # no_commands
|
|
319
344
|
|
|
320
345
|
end
|
|
@@ -109,11 +109,11 @@ module CloudstackCli
|
|
|
109
109
|
if options[:ip_network_list]
|
|
110
110
|
options[:ip_network_list].each do |item|
|
|
111
111
|
unless network = available_networks.find { |n| n['name'] == item["name"] }
|
|
112
|
-
say "Error: Network '#{name}' not found.", :red
|
|
112
|
+
say "Error: Network '#{item["name"]}' not found.", :red
|
|
113
113
|
exit 1
|
|
114
114
|
end
|
|
115
115
|
item.delete("name")
|
|
116
|
-
network_list << {networkid: network["id"]}.merge(item)
|
|
116
|
+
network_list << {networkid: network["id"]}.merge(item)
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
119
|
network_list.compact!
|
|
@@ -122,6 +122,7 @@ module CloudstackCli
|
|
|
122
122
|
exit 1
|
|
123
123
|
end
|
|
124
124
|
options[:ip_to_network_list] = network_list
|
|
125
|
+
[:network_ids, :ip_address].each { |k| options.delete(k) }
|
|
125
126
|
options
|
|
126
127
|
end
|
|
127
128
|
|
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.
|
|
4
|
+
version: 1.5.2
|
|
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-
|
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|