morpheus-cli 6.0.2 → 6.1.1

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.
@@ -0,0 +1,87 @@
1
+ require 'morpheus/cli/cli_command'
2
+
3
+ class Morpheus::Cli::LoadBalancerPoolNodes
4
+ include Morpheus::Cli::CliCommand
5
+ include Morpheus::Cli::RestCommand
6
+ include Morpheus::Cli::SecondaryRestCommand
7
+ include Morpheus::Cli::LoadBalancersHelper
8
+
9
+ set_command_description "View and manage load balancer pool member nodes."
10
+ set_command_name :'load-balancer-pool-nodes'
11
+
12
+ set_rest_key :load_balancer_node
13
+ set_rest_parent_name :load_balancer_pools
14
+ set_rest_option_context_map({'loadBalancerNode' => ''})
15
+
16
+ register_subcommands :list, :get, :add, :update, :remove
17
+ register_interfaces :load_balancer_types, :load_balancer_pools
18
+
19
+ protected
20
+
21
+ def load_balancer_node_list_column_definitions(options)
22
+ {
23
+ "ID" => 'id',
24
+ "Status" => 'status',
25
+ "Name" => 'name',
26
+ "IP Address" => 'ipAddress',
27
+ "Port" => 'port'
28
+ }
29
+ end
30
+
31
+ def load_balancer_node_column_definitions(options)
32
+ {
33
+ "ID" => 'id',
34
+ "Name" => 'name',
35
+ "Description" => 'description',
36
+ "State" => lambda {|it| it['config']['adminState']},
37
+ "IP Address" => 'ipAddress',
38
+ "Port" => 'port',
39
+ "Weight" => 'weight',
40
+ "Backup Member" => lambda {|it| format_boolean it['config']['backupMember']},
41
+ "Max Concurrent Connections" => lambda {|it| it['config']['maxConcurrentConnections']}
42
+ }
43
+ end
44
+
45
+ def load_balancer_node_object_key
46
+ 'loadBalancerNode'
47
+ end
48
+
49
+ def load_balancer_node_list_key
50
+ 'loadBalancerNodes'
51
+ end
52
+
53
+ def load_balancer_node_label
54
+ 'Load Balancer Node'
55
+ end
56
+
57
+ def load_balancer_node_label_plural
58
+ 'Load Balancer Nodes'
59
+ end
60
+
61
+ def format_load_balancer_pool_status(record, return_color=cyan)
62
+ out = ""
63
+ status_string = record['status']
64
+ if status_string.nil? || status_string.empty? || status_string == "unknown"
65
+ out << "#{white}UNKNOWN#{return_color}"
66
+ elsif status_string == 'ok'
67
+ out << "#{green}#{status_string.upcase}#{return_color}"
68
+ elsif status_string == 'warning'
69
+ out << "#{yellow}#{status_string.upcase}#{return_color}"
70
+ else
71
+ out << "#{red}#{status_string ? status_string.upcase : 'N/A'}#{record['statusMessage'] ? "#{return_color} - #{record['statusMessage']}" : ''}#{return_color}"
72
+ end
73
+ out
74
+ end
75
+
76
+ def load_option_types_for_load_balancer_node(type_record, parent_record)
77
+ load_balancer_pool = parent_record
78
+ load_balancer_type = find_by_id(:load_balancer_type, load_balancer_pool['loadBalancer']['type']['id'])
79
+ load_balancer_type['nodeOptionTypes']
80
+ end
81
+
82
+ def find_load_balancer_node_by_name_or_id(parent_id, val)
83
+ (@load_balancer_pool_nodes_interface.get(parent_id, val)['loadBalancerNode']) rescue nil
84
+ end
85
+ ## using CliCommand's generic find_by methods
86
+
87
+ end
@@ -8,12 +8,14 @@ class Morpheus::Cli::LoadBalancerPools
8
8
 
9
9
  set_command_description "View and manage load balancer pools."
10
10
  set_command_name :'load-balancer-pools'
11
- register_subcommands :list, :get, :add, :update, :remove
12
- register_interfaces :load_balancer_pools,
13
- :load_balancers, :load_balancer_types
14
11
 
12
+ set_rest_interface_name :load_balancer_pools_secondary
15
13
  set_rest_parent_name :load_balancers
16
14
 
15
+ register_subcommands :list, :get, :add, :update, :remove
16
+ register_interfaces :load_balancers, :load_balancer_types
17
+
18
+
17
19
  # set_rest_interface_name :load_balancer_pools
18
20
  # set_parent_rest_interface_name :load_balancers
19
21
 
@@ -30,6 +32,7 @@ class Morpheus::Cli::LoadBalancerPools
30
32
  "Name" => 'name',
31
33
  #"Load Balancer" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
32
34
  "Balancer Mode" => lambda {|it| it['vipBalance'] },
35
+ "Status" => lambda {|it| format_load_balancer_pool_status(it) }
33
36
  }
34
37
  end
35
38
 
@@ -68,7 +71,7 @@ class Morpheus::Cli::LoadBalancerPools
68
71
  status_string = record['status']
69
72
  if status_string.nil? || status_string.empty? || status_string == "unknown"
70
73
  out << "#{white}UNKNOWN#{return_color}"
71
- elsif status_string == 'ok'
74
+ elsif status_string == 'online' || status_string == 'ok'
72
75
  out << "#{green}#{status_string.upcase}#{return_color}"
73
76
  elsif status_string == 'syncing'
74
77
  out << "#{yellow}#{status_string.upcase}#{return_color}"
@@ -222,8 +222,10 @@ class Morpheus::Cli::NetworksCommand
222
222
  "Domain" => lambda {|it| it['networkDomain'] ? it['networkDomain']['name'] : '' },
223
223
  "Search Domains" => lambda {|it| it['searchDomains'] },
224
224
  "Pool" => lambda {|it| it['pool'] ? it['pool']['name'] : '' },
225
+ "IPv6 Pool" => lambda {|it| it['poolIPv6'] ? it['poolIPv6']['name'] : '' },
225
226
  "VPC" => lambda {|it| it['zonePool'] ? it['zonePool']['name'] : '' },
226
227
  "DHCP" => lambda {|it| it['dhcpServer'] ? 'Yes' : 'No' },
228
+ "IPv6 DHCP" => lambda {|it| it['dhcpServerIPv6'] ? 'Yes' : 'No' },
227
229
  "Active" => lambda {|it| format_boolean(it['active']) },
228
230
  "Allow IP Override" => lambda {|it| it['allowStaticOverride'] ? 'Yes' : 'No' },
229
231
  "Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
@@ -381,6 +383,12 @@ class Morpheus::Cli::NetworksCommand
381
383
  opts.on('--dhcp-server [on|off]', String, "DHCP Server") do |val|
382
384
  options['dhcpServer'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
383
385
  end
386
+ opts.on('--dhcp-serverIPv6 [on|off]', String, "IPv6 DHCP Server") do |val|
387
+ options['dhcpServerIPv6'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
388
+ end
389
+ opts.on('--dhcp-server-ipv6 [on|off]', String, "IPv6 DHCP Server") do |val|
390
+ options['dhcpServerIPv6'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
391
+ end
384
392
  opts.on('--allow-ip-override [on|off]', String, "Allow IP Override") do |val|
385
393
  options['allowStaticOverride'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
386
394
  end
@@ -723,6 +731,15 @@ class Morpheus::Cli::NetworksCommand
723
731
  v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'dnsSecondaryIPv6', 'fieldLabel' => 'IPv6 DNS Secondary', 'type' => 'text', 'required' => false, 'description' => ''}], options)
724
732
  payload['network']['dnsSecondaryIPv6'] = v_prompt['dnsSecondaryIPv6']
725
733
  end
734
+ end
735
+ # DHCP Server
736
+ if network_type['dhcpServerEditable'] && payload['network']['dhcpServerIPv6'].nil?
737
+ if options['dhcpServerIPv6'] != nil
738
+ payload['network']['dhcpServerIPv6'] = options['dhcpServerIPv6']
739
+ else
740
+ v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'dhcpServerIPv6', 'fieldLabel' => 'IPv6 DHCP Server', 'type' => 'checkbox', 'required' => false, 'description' => ''}], options)
741
+ payload['network']['dhcpServerIPv6'] = v_prompt['dhcpServerIPv6']
742
+ end
726
743
  end
727
744
  end
728
745
 
@@ -1003,6 +1020,12 @@ class Morpheus::Cli::NetworksCommand
1003
1020
  opts.on('--dhcp-server [on|off]', String, "DHCP Server") do |val|
1004
1021
  options['dhcpServer'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
1005
1022
  end
1023
+ opts.on('--dhcp-serverIPv6 [on|off]', String, "IPv6 DHCP Server") do |val|
1024
+ options['dhcpServerIPv6'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
1025
+ end
1026
+ opts.on('--dhcp-server-ipv6 [on|off]', String, "IPv6 DHCP Server") do |val|
1027
+ options['dhcpServerIPv6'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
1028
+ end
1006
1029
  opts.on('--allow-ip-override [on|off]', String, "Allow IP Override") do |val|
1007
1030
  options['allowStaticOverride'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
1008
1031
  end
@@ -1244,6 +1267,14 @@ class Morpheus::Cli::NetworksCommand
1244
1267
  # payload['network']['dhcpServer'] = v_prompt['dhcpServer']
1245
1268
  end
1246
1269
 
1270
+ # IPv6 DHCP Server
1271
+ if options['dhcpServerIPv6'] != nil
1272
+ payload['network']['dhcpServerIPv6'] = options['dhcpServerIPv6']
1273
+ else
1274
+ # v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'dhcpServerIPv6', 'fieldLabel' => 'IPv6 DHCP Server', 'type' => 'checkbox', 'required' => false, 'description' => ''}], options)
1275
+ # payload['network']['dhcpServerIPv6'] = v_prompt['dhcpServerIPv6']
1276
+ end
1277
+
1247
1278
  # Allow IP Override
1248
1279
  if options['allowStaticOverride'] != nil
1249
1280
  payload['network']['allowStaticOverride'] = options['allowStaticOverride']