morpheus-cli 5.3.3 → 5.3.4
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 +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/api_client.rb +12 -0
- data/lib/morpheus/api/clouds_interface.rb +4 -11
- data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +10 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +4 -4
- data/lib/morpheus/api/network_routers_interface.rb +21 -0
- data/lib/morpheus/api/network_servers_interface.rb +42 -0
- data/lib/morpheus/api/rest_interface.rb +2 -1
- data/lib/morpheus/api/virtual_servers_interface.rb +9 -0
- data/lib/morpheus/cli/cli_command.rb +2 -1
- data/lib/morpheus/cli/cloud_resource_pools_command.rb +1 -1
- data/lib/morpheus/cli/clouds.rb +22 -40
- data/lib/morpheus/cli/hosts.rb +0 -1
- data/lib/morpheus/cli/instances.rb +111 -7
- data/lib/morpheus/cli/invoices_command.rb +42 -38
- data/lib/morpheus/cli/library_option_lists_command.rb +3 -3
- data/lib/morpheus/cli/load_balancer_pools.rb +111 -0
- data/lib/morpheus/cli/load_balancer_virtual_servers.rb +136 -0
- data/lib/morpheus/cli/load_balancers.rb +0 -155
- data/lib/morpheus/cli/mixins/load_balancers_helper.rb +2 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +32 -11
- data/lib/morpheus/cli/mixins/rest_command.rb +53 -37
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +488 -0
- data/lib/morpheus/cli/network_routers_command.rb +291 -7
- data/lib/morpheus/cli/network_scopes_command.rb +442 -0
- data/lib/morpheus/cli/networks_command.rb +2 -2
- data/lib/morpheus/cli/option_types.rb +20 -0
- data/lib/morpheus/cli/subnets_command.rb +7 -2
- data/lib/morpheus/cli/tasks.rb +25 -2
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +2 -0
- data/lib/morpheus/cli.rb +9 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e1172b58bb99b6348f15121c97f5c3d8db818c25fa977cd33835f7a3645da44
|
4
|
+
data.tar.gz: bd216d539aadf61f968cee0dabb6d36361bd79dbdd4ac86527a80872f64620ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24e82961eae144b2b9a00f555313ae653b6c1f844a9be549553481c7e91789011858075acfc76efabfeb3a503f211f4ddc76c79a8a33cff1d4bf07a355179753
|
7
|
+
data.tar.gz: 0cf97e82534466142e81d7a20ff7672578de00179cfab36a1e94e6900a24193090e1dd1c91d6c6d409000ac92623ed06ae9e6f5f346937c2912b42b5fedac561
|
data/Dockerfile
CHANGED
@@ -486,6 +486,10 @@ class Morpheus::APIClient
|
|
486
486
|
Morpheus::LoadBalancerPoolsInterface.new(common_interface_options).setopts(@options)
|
487
487
|
end
|
488
488
|
|
489
|
+
def virtual_servers
|
490
|
+
Morpheus::VirtualServersInterface.new(common_interface_options).setopts(@options)
|
491
|
+
end
|
492
|
+
|
489
493
|
def tasks
|
490
494
|
Morpheus::TasksInterface.new(common_interface_options).setopts(@options)
|
491
495
|
end
|
@@ -836,6 +840,14 @@ class Morpheus::APIClient
|
|
836
840
|
Morpheus::VdiGatewaysInterface.new(common_interface_options).setopts(@options)
|
837
841
|
end
|
838
842
|
|
843
|
+
def network_servers
|
844
|
+
Morpheus::NetworkServersInterface.new(common_interface_options).setopts(@options)
|
845
|
+
end
|
846
|
+
|
847
|
+
def rest(endpoint)
|
848
|
+
Morpheus::RestInterface.new(common_interface_options).setopts(@options.merge({base_path: "#{@base_url}/api/#{endpoint}"}))
|
849
|
+
end
|
850
|
+
|
839
851
|
# add new interfaces here
|
840
852
|
|
841
853
|
protected
|
@@ -24,17 +24,10 @@ class Morpheus::CloudsInterface < Morpheus::APIClient
|
|
24
24
|
execute(opts)
|
25
25
|
end
|
26
26
|
|
27
|
-
def get(params=
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
if params.is_a?(Hash)
|
32
|
-
headers[:params].merge!(params)
|
33
|
-
elsif params.is_a?(Numeric)
|
34
|
-
url = "#{@base_url}/api/zones/#{params}"
|
35
|
-
elsif params.is_a?(String)
|
36
|
-
headers[:params]['name'] = params
|
37
|
-
end
|
27
|
+
def get(id, params={})
|
28
|
+
validate_id!(id)
|
29
|
+
url = "#{@base_url}/api/zones/#{id}"
|
30
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
38
31
|
opts = {method: :get, url: url, headers: headers}
|
39
32
|
execute(opts)
|
40
33
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'morpheus/api/
|
1
|
+
require 'morpheus/api/rest_interface'
|
2
2
|
|
3
|
-
class Morpheus::LoadBalancerPoolsInterface < Morpheus::
|
3
|
+
class Morpheus::LoadBalancerPoolsInterface < Morpheus::RestInterface
|
4
4
|
|
5
|
-
def base_path
|
6
|
-
"/api/load-
|
5
|
+
def base_path
|
6
|
+
"/api/load-balancer-pools"
|
7
7
|
end
|
8
8
|
|
9
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'morpheus/api/
|
1
|
+
require 'morpheus/api/rest_interface'
|
2
2
|
|
3
|
-
class Morpheus::LoadBalancerVirtualServersInterface < Morpheus::
|
3
|
+
class Morpheus::LoadBalancerVirtualServersInterface < Morpheus::RestInterface
|
4
4
|
|
5
|
-
def base_path
|
6
|
-
"/api/load-
|
5
|
+
def base_path
|
6
|
+
"/api/load-balancer-virtual-servers"
|
7
7
|
end
|
8
8
|
|
9
9
|
end
|
@@ -143,6 +143,27 @@ class Morpheus::NetworkRoutersInterface < Morpheus::APIClient
|
|
143
143
|
execute(opts)
|
144
144
|
end
|
145
145
|
|
146
|
+
def create_bgp_neighbor(router_id, payload={})
|
147
|
+
url = "#{@base_url}/api/networks/routers/#{router_id}/bgp-neighbors"
|
148
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
149
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
150
|
+
execute(opts)
|
151
|
+
end
|
152
|
+
|
153
|
+
def update_bgp_neighbor(router_id, nat_id, payload={})
|
154
|
+
url = "#{@base_url}/api/networks/routers/#{router_id}/bgp-neighbors/#{nat_id}"
|
155
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
156
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
157
|
+
execute(opts)
|
158
|
+
end
|
159
|
+
|
160
|
+
def destroy_bgp_neighbor(router_id, nat_id, payload={})
|
161
|
+
url = "#{@base_url}/api/networks/routers/#{router_id}/bgp-neighbors/#{nat_id}"
|
162
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
163
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
164
|
+
execute(opts)
|
165
|
+
end
|
166
|
+
|
146
167
|
def update_permissions(router_id, payload)
|
147
168
|
url = "#{@base_url}/api/networks/routers/#{router_id}/permissions"
|
148
169
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::NetworkServersInterface < Morpheus::RestInterface
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"/api/networks/servers"
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_scopes(server_id, params={}, headers={})
|
10
|
+
validate_id!(server_id)
|
11
|
+
execute(method: :get, url: "#{base_path}/#{server_id}/scopes", params: params, headers: headers)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_scope(server_id, scope_id, params={}, headers={})
|
15
|
+
validate_id!(server_id)
|
16
|
+
validate_id!(scope_id)
|
17
|
+
execute(method: :get, url: "#{base_path}/#{server_id}/scopes/#{scope_id}", params: params, headers: headers)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_scope(server_id, payload, params={}, headers={})
|
21
|
+
validate_id!(server_id)
|
22
|
+
execute(method: :post, url: "#{base_path}/#{server_id}/scopes", params: params, payload: payload, headers: headers)
|
23
|
+
end
|
24
|
+
|
25
|
+
def update_scope(server_id, scope_id, payload, params={}, headers={})
|
26
|
+
validate_id!(server_id)
|
27
|
+
validate_id!(scope_id)
|
28
|
+
execute(method: :put, url: "#{base_path}/#{server_id}/scopes/#{scope_id}", params: params, payload: payload, headers: headers)
|
29
|
+
end
|
30
|
+
|
31
|
+
def destroy_scope(server_id, scope_id, params={}, headers={})
|
32
|
+
validate_id!(server_id)
|
33
|
+
validate_id!(scope_id)
|
34
|
+
execute(method: :delete, url: "#{base_path}/#{server_id}/scopes/#{scope_id}", params: params, headers: headers)
|
35
|
+
end
|
36
|
+
|
37
|
+
def update_scope_permissions(server_id, scope_id, payload, params={}, headers={})
|
38
|
+
validate_id!(server_id)
|
39
|
+
validate_id!(scope_id)
|
40
|
+
execute(method: :put, url: "#{base_path}/#{server_id}/scopes/#{scope_id}", payload: payload.to_json, params: params, headers: headers)
|
41
|
+
end
|
42
|
+
end
|
@@ -7,7 +7,8 @@ class Morpheus::RestInterface < Morpheus::APIClient
|
|
7
7
|
# subclasses should override in your interface
|
8
8
|
# Example: "/api/things"
|
9
9
|
def base_path
|
10
|
-
raise "#{self.class} has not defined base_path!"
|
10
|
+
raise "#{self.class} has not defined base_path!" if @options[:base_path].nil?
|
11
|
+
@options[:base_path]
|
11
12
|
end
|
12
13
|
|
13
14
|
def list(params={}, headers={})
|
@@ -215,7 +215,8 @@ module Morpheus
|
|
215
215
|
opts.on(arg1, arg2, description) do |val|
|
216
216
|
if option_type['type'] == 'checkbox'
|
217
217
|
val = (val.to_s != 'false' && val.to_s != 'off')
|
218
|
-
|
218
|
+
elsif option_type['dataType'] != 'string'
|
219
|
+
# 'dataType': 'string' added to cli to avoid auto conversion to JSON
|
219
220
|
# attempt to parse JSON, this allows blank arrays for multiSelect like --tenants []
|
220
221
|
if (val.to_s[0] == '{' && val.to_s[-1] == '}') || (val.to_s[0] == '[' && val.to_s[-1] == ']')
|
221
222
|
begin
|
@@ -819,7 +819,7 @@ class Morpheus::Cli::CloudResourcePoolsCommand
|
|
819
819
|
print_red_alert "Resource Pool not found by name #{name}"
|
820
820
|
return nil
|
821
821
|
elsif resource_pools.size > 1
|
822
|
-
matching_resource_pools =
|
822
|
+
matching_resource_pools = resource_pools.select { |it| name && (it['name'] == name || it['externalId'] == name) }
|
823
823
|
if matching_resource_pools.size == 1
|
824
824
|
return matching_resource_pools[0]
|
825
825
|
end
|
data/lib/morpheus/cli/clouds.rb
CHANGED
@@ -27,8 +27,6 @@ class Morpheus::Cli::Clouds
|
|
27
27
|
@clouds_interface = @api_client.clouds
|
28
28
|
@groups_interface = @api_client.groups
|
29
29
|
@active_group_id = Morpheus::Cli::Groups.active_groups[@appliance_name]
|
30
|
-
# preload stuff
|
31
|
-
get_available_cloud_types()
|
32
30
|
end
|
33
31
|
|
34
32
|
def handle(args)
|
@@ -134,38 +132,36 @@ class Morpheus::Cli::Clouds
|
|
134
132
|
|
135
133
|
def get(args)
|
136
134
|
options = {}
|
135
|
+
params = {}
|
137
136
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
138
137
|
opts.banner = subcommand_usage("[name]")
|
139
|
-
|
138
|
+
build_standard_list_options(opts, options)
|
140
139
|
opts.footer = "Get details about a cloud.\n" +
|
141
140
|
"[name] is required. This is the name or id of a cloud."
|
142
141
|
end
|
143
142
|
optparse.parse!(args)
|
144
|
-
|
145
|
-
puts optparse
|
146
|
-
exit 1
|
147
|
-
end
|
143
|
+
verify_args!(args:args, optparse:optparse, min:1)
|
148
144
|
connect(options)
|
145
|
+
params.merge!(parse_query_options(options))
|
149
146
|
id_list = parse_id_list(args)
|
150
147
|
return run_command_for_each_arg(id_list) do |arg|
|
151
|
-
_get(arg, options)
|
148
|
+
_get(arg, params, options)
|
152
149
|
end
|
153
150
|
end
|
154
151
|
|
155
|
-
def _get(
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
json_response = @clouds_interface.get(cloud['id'])
|
152
|
+
def _get(id, params, options={})
|
153
|
+
cloud = nil
|
154
|
+
if id.to_s !~ /\A\d{1,}\Z/
|
155
|
+
cloud = find_cloud_by_name_or_id(id)
|
156
|
+
id = cloud['id']
|
157
|
+
end
|
158
|
+
@clouds_interface.setopts(options)
|
159
|
+
if options[:dry_run]
|
160
|
+
print_dry_run @clouds_interface.dry.get(id.to_i, params)
|
161
|
+
return
|
162
|
+
end
|
163
|
+
json_response = @clouds_interface.get(id, params)
|
164
|
+
render_response(json_response, options, 'zone') do
|
169
165
|
cloud = json_response['zone']
|
170
166
|
cloud_stats = cloud['stats']
|
171
167
|
# serverCounts moved to zone.stats.serverCounts
|
@@ -175,17 +171,6 @@ class Morpheus::Cli::Clouds
|
|
175
171
|
else
|
176
172
|
server_counts = json_response['serverCounts'] # legacy
|
177
173
|
end
|
178
|
-
if options[:json]
|
179
|
-
puts as_json(json_response, options, 'zone')
|
180
|
-
return 0
|
181
|
-
elsif options[:yaml]
|
182
|
-
puts as_yaml(json_response, options, 'zone')
|
183
|
-
return 0
|
184
|
-
end
|
185
|
-
if options[:csv]
|
186
|
-
puts records_as_csv([json_response['zone']], options)
|
187
|
-
return 0
|
188
|
-
end
|
189
174
|
cloud_type = cloud_type_for_id(cloud['zoneTypeId'])
|
190
175
|
print_h1 "Cloud Details"
|
191
176
|
print cyan
|
@@ -195,6 +180,7 @@ class Morpheus::Cli::Clouds
|
|
195
180
|
"Type" => lambda {|it| cloud_type ? cloud_type['name'] : '' },
|
196
181
|
"Code" => 'code',
|
197
182
|
"Location" => 'location',
|
183
|
+
"Region Code" => 'regionCode',
|
198
184
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
199
185
|
"Groups" => lambda {|it| it['groups'].collect {|g| g.instance_of?(Hash) ? g['name'] : g.to_s }.join(', ') },
|
200
186
|
#"Owner" => lambda {|it| it['owner'].instance_of?(Hash) ? it['owner']['name'] : it['ownerId'] },
|
@@ -214,14 +200,9 @@ class Morpheus::Cli::Clouds
|
|
214
200
|
print "Unmanaged: #{server_counts['unmanaged']}".center(20)
|
215
201
|
print "\n"
|
216
202
|
end
|
217
|
-
|
218
203
|
print reset,"\n"
|
219
|
-
|
220
|
-
#puts instance
|
221
|
-
rescue RestClient::Exception => e
|
222
|
-
print_rest_exception(e, options)
|
223
|
-
exit 1
|
224
204
|
end
|
205
|
+
return 0, nil
|
225
206
|
end
|
226
207
|
|
227
208
|
def add(args)
|
@@ -954,13 +935,14 @@ class Morpheus::Cli::Clouds
|
|
954
935
|
name: cloud['name'],
|
955
936
|
type: cloud_type ? cloud_type['name'] : '',
|
956
937
|
location: cloud['location'],
|
938
|
+
"REGION CODE": cloud['regionCode'],
|
957
939
|
groups: (cloud['groups'] || []).collect {|it| it.instance_of?(Hash) ? it['name'] : it.to_s }.join(', '),
|
958
940
|
servers: cloud['serverCount'],
|
959
941
|
status: format_cloud_status(cloud)
|
960
942
|
}
|
961
943
|
end
|
962
944
|
columns = [
|
963
|
-
:id, :name, :type, :location, :groups, :servers, :status
|
945
|
+
:id, :name, :type, :location, "REGION CODE", :groups, :servers, :status
|
964
946
|
]
|
965
947
|
print as_pretty_table(rows, columns, opts)
|
966
948
|
end
|
data/lib/morpheus/cli/hosts.rb
CHANGED
@@ -553,7 +553,6 @@ class Morpheus::Cli::Hosts
|
|
553
553
|
server_columns.delete("Cost") if server['hourlyCost'].to_f == 0
|
554
554
|
server_columns.delete("Price") if server['hourlyPrice'].to_f == 0 || server['hourlyPrice'] == server['hourlyCost']
|
555
555
|
server_columns.delete("Labels") if server['labels'].nil? || server['labels'].empty?
|
556
|
-
server_columns.delete("Tags") if tags.nil? || tags.empty?
|
557
556
|
|
558
557
|
print_description_list(server_columns, server)
|
559
558
|
|
@@ -1365,7 +1365,6 @@ class Morpheus::Cli::Instances
|
|
1365
1365
|
"Status" => lambda {|it| format_instance_status(it) }
|
1366
1366
|
}
|
1367
1367
|
description_cols.delete("Labels") if labels.nil? || labels.empty?
|
1368
|
-
description_cols.delete("Tags") if tags.nil? || tags.empty?
|
1369
1368
|
description_cols.delete("Apps") if instance['apps'].nil? || instance['apps'].empty?
|
1370
1369
|
description_cols.delete("Power Schedule") if instance['powerSchedule'].nil?
|
1371
1370
|
description_cols.delete("Expire Date") if instance['expireDate'].nil?
|
@@ -1694,19 +1693,77 @@ class Morpheus::Cli::Instances
|
|
1694
1693
|
options = {:options => {}}
|
1695
1694
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
1696
1695
|
opts.banner = subcommand_usage("[instance] -g GROUP")
|
1697
|
-
opts.on('--name VALUE', String, "Name") do |val|
|
1698
|
-
options[:options]['name'] = val
|
1699
|
-
end
|
1700
1696
|
opts.on( '-g', '--group GROUP', "Group Name or ID for the new instance" ) do |val|
|
1701
1697
|
options[:group] = val
|
1702
1698
|
end
|
1703
1699
|
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID for the new instance" ) do |val|
|
1704
1700
|
options[:cloud] = val
|
1705
1701
|
end
|
1702
|
+
opts.on('--name VALUE', String, "Name") do |val|
|
1703
|
+
options[:options]['name'] = val
|
1704
|
+
end
|
1705
|
+
opts.on("--description [TEXT]", String, "Description") do |val|
|
1706
|
+
options[:description] = val.to_s
|
1707
|
+
end
|
1708
|
+
opts.on("--environment ENV", String, "Environment code") do |val|
|
1709
|
+
options[:environment] = val.to_s
|
1710
|
+
end
|
1711
|
+
opts.on('--tags LIST', String, "Metadata tags in the format 'ping=pong,flash=bang'") do |val|
|
1712
|
+
options[:metadata] = val
|
1713
|
+
end
|
1714
|
+
opts.on('--metadata LIST', String, "Metadata tags in the format 'ping=pong,flash=bang'") do |val|
|
1715
|
+
options[:metadata] = val
|
1716
|
+
end
|
1717
|
+
opts.add_hidden_option('--metadata')
|
1718
|
+
opts.on('--labels LIST', String, "Labels (keywords) in the format 'foo, bar'") do |val|
|
1719
|
+
options[:labels] = val.split(',').collect {|it| it.to_s.strip }.compact.uniq.join(',')
|
1720
|
+
end
|
1721
|
+
# opts.on("--copies NUMBER", Integer, "Number of copies to provision") do |val|
|
1722
|
+
# options[:copies] = val.to_i
|
1723
|
+
# end
|
1724
|
+
# opts.on("--layout-size NUMBER", Integer, "Apply a multiply factor of containers/vms within the instance") do |val|
|
1725
|
+
# options[:layout_size] = val.to_i
|
1726
|
+
# end
|
1727
|
+
# opts.on( '-l', '--layout LAYOUT', "Layout ID" ) do |val|
|
1728
|
+
# options[:layout] = val
|
1729
|
+
# end
|
1730
|
+
opts.on( '-p', '--plan PLAN', "Service plan ID") do |val|
|
1731
|
+
options[:service_plan] = val
|
1732
|
+
end
|
1733
|
+
opts.on( '--resource-pool ID', String, "Resource pool ID" ) do |val|
|
1734
|
+
options[:resource_pool] = val
|
1735
|
+
end
|
1736
|
+
opts.on("--workflow ID", String, "Automation: Workflow ID") do |val|
|
1737
|
+
options[:workflow_id] = val
|
1738
|
+
end
|
1739
|
+
opts.on("--ports ARRAY", String, "Exposed Ports, JSON formatted list of objects containing name and port") do |val|
|
1740
|
+
# expects format like --ports '[{"name":"web","port":8080}]'
|
1741
|
+
ports_array = JSON.parse(val)
|
1742
|
+
options[:ports] = ports_array
|
1743
|
+
options[:options]['ports'] = ports_array
|
1744
|
+
end
|
1745
|
+
# opts.on('-L', "--lb", "Enable Load Balancer") do
|
1746
|
+
# options[:enable_load_balancer] = true
|
1747
|
+
# end
|
1706
1748
|
opts.on("--create-user on|off", String, "User Config: Create Your User. Default is on") do |val|
|
1707
1749
|
options[:create_user] = !['false','off','0'].include?(val.to_s)
|
1708
1750
|
end
|
1709
|
-
|
1751
|
+
opts.on("--user-group USERGROUP", String, "User Config: User Group") do |val|
|
1752
|
+
options[:user_group_id] = val
|
1753
|
+
end
|
1754
|
+
opts.on("--shutdown-days DAYS", Integer, "Automation: Shutdown Days") do |val|
|
1755
|
+
options[:shutdown_days] = val.to_i
|
1756
|
+
end
|
1757
|
+
opts.on("--expire-days DAYS", Integer, "Automation: Expiration Days") do |val|
|
1758
|
+
options[:expire_days] = val.to_i
|
1759
|
+
end
|
1760
|
+
opts.on("--create-backup [on|off]", String, "Automation: Create Backups.") do |val|
|
1761
|
+
options[:create_backup] = ['on','true','1',''].include?(val.to_s.downcase) ? 'on' : 'off'
|
1762
|
+
end
|
1763
|
+
opts.on("--security-groups LIST", String, "Security Groups, comma separated list of security group IDs") do |val|
|
1764
|
+
options[:security_groups] = val.split(",").collect {|s| s.strip }.select {|s| !s.to_s.empty? }
|
1765
|
+
end
|
1766
|
+
build_standard_post_options(opts, options, [:auto_confirm])
|
1710
1767
|
end
|
1711
1768
|
optparse.parse!(args)
|
1712
1769
|
if args.count < 1 || args.count > 2
|
@@ -1724,12 +1781,20 @@ class Morpheus::Cli::Instances
|
|
1724
1781
|
|
1725
1782
|
# defaults derived from clone
|
1726
1783
|
options[:default_name] = instance['name'] + '-clone' if instance['name']
|
1784
|
+
options[:default_description] = instance['description'] if !instance['description'].to_s.empty?
|
1785
|
+
options[:default_environment] = instance['environment'] if instance['environment']
|
1727
1786
|
options[:default_group] = instance['group']['id'] if instance['group']
|
1728
1787
|
options[:default_cloud] = instance['cloud']['name'] if instance['cloud']
|
1729
1788
|
options[:default_plan] = instance['plan']['name'] if instance['plan']
|
1730
1789
|
options[:default_resource_pool] = instance['config']['resourcePoolId'] if instance['config']
|
1731
1790
|
options[:default_config] = instance['config']
|
1732
1791
|
options[:default_security_group] = instance['config']['securityGroups'][0]['id'] if instance['config'] && (instance['config']['securityGroups'] || []).count > 0
|
1792
|
+
if instance['labels'] && !instance['labels'].empty?
|
1793
|
+
options[:default_labels] = (instance['labels'] || []).join(',')
|
1794
|
+
end
|
1795
|
+
if instance['tags'] && !instance['tags'].empty?
|
1796
|
+
options[:current_tags] = instance['tags']
|
1797
|
+
end
|
1733
1798
|
|
1734
1799
|
# immutable derived from clone
|
1735
1800
|
options[:instance_type_code] = instance['instanceType']['code'] if instance['instanceType']
|
@@ -1767,13 +1832,52 @@ class Morpheus::Cli::Instances
|
|
1767
1832
|
payload.deep_merge!(passed_options)
|
1768
1833
|
end
|
1769
1834
|
|
1835
|
+
#payload['instance'] ||= {}
|
1836
|
+
# if options[:instance_name]
|
1837
|
+
# payload['instance']['name'] = options[:instance_name]
|
1838
|
+
# end
|
1839
|
+
# if options[:description] && !payload['instance']['description']
|
1840
|
+
# payload['instance']['description'] = options[:description]
|
1841
|
+
# end
|
1842
|
+
# if options[:environment] && !payload['instance']['instanceContext']
|
1843
|
+
# payload['instance']['instanceContext'] = options[:environment]
|
1844
|
+
# end
|
1845
|
+
|
1846
|
+
#payload[:copies] = options[:copies] if options[:copies] && options[:copies] > 0
|
1847
|
+
if options[:layout_size] && options[:layout_size] > 0 # aka Scale Factor
|
1848
|
+
payload[:layoutSize] = options[:layout_size]
|
1849
|
+
end
|
1850
|
+
if !options[:create_backup].nil?
|
1851
|
+
payload[:createBackup] = options[:create_backup]
|
1852
|
+
end
|
1853
|
+
if options[:expire_days]
|
1854
|
+
payload['instance'] ||= {}
|
1855
|
+
payload['instance']['expireDays'] = options[:expire_days]
|
1856
|
+
end
|
1857
|
+
if options[:shutdown_days]
|
1858
|
+
payload['instance'] ||= {}
|
1859
|
+
payload['shutdownDays'] = options[:shutdown_days]
|
1860
|
+
end
|
1770
1861
|
# JD: this actually fixed a customer problem
|
1771
1862
|
# It appears to be important to pass this... not sure if config.createUser is necessary...
|
1772
1863
|
if options[:create_user].nil?
|
1773
1864
|
options[:create_user] = true
|
1774
1865
|
end
|
1775
|
-
if options
|
1776
|
-
payload
|
1866
|
+
if options.key?(:create_user)
|
1867
|
+
payload['config'] ||= {}
|
1868
|
+
payload['config']['createUser'] = options[:create_user]
|
1869
|
+
payload['createUser'] = options[:create_user]
|
1870
|
+
end
|
1871
|
+
if options[:user_group_id]
|
1872
|
+
payload['instance'] ||= {}
|
1873
|
+
payload['instance']['userGroup'] = {'id' => options[:user_group_id] }
|
1874
|
+
end
|
1875
|
+
if options[:workflow_id]
|
1876
|
+
if options[:workflow_id].to_s =~ /\A\d{1,}\Z/
|
1877
|
+
payload['taskSetId'] = options[:workflow_id].to_i
|
1878
|
+
else
|
1879
|
+
payload['taskSetName'] = options[:workflow_id]
|
1880
|
+
end
|
1777
1881
|
end
|
1778
1882
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to clone the instance #{instance['name']} as '#{payload['name']}'?", options)
|
1779
1883
|
return 9, "aborted command"
|