morpheus-cli 6.1.0 → 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.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/api_client.rb +8 -0
- data/lib/morpheus/api/cypher_interface.rb +11 -5
- data/lib/morpheus/api/load_balancer_pool_nodes_interface.rb +8 -0
- data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
- data/lib/morpheus/api/load_balancer_pools_secondary_interface.rb +9 -0
- data/lib/morpheus/api/roles_interface.rb +8 -8
- data/lib/morpheus/cli/commands/load_balancer_pool_nodes.rb +87 -0
- data/lib/morpheus/cli/commands/load_balancer_pools.rb +7 -4
- data/lib/morpheus/cli/commands/roles.rb +403 -586
- data/lib/morpheus/cli/commands/users.rb +46 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +6 -6
- data/lib/morpheus/cli/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cf8719e8fbab69a6e0de10b9d2920b0394bb55d4928ba4266b82c9430f53658
|
4
|
+
data.tar.gz: a518e58f7b2adc050e786ca6f29e0f7832787e5c294c495d5599960f7232aacc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30263a5621c68dc42d8bb1093c67c21a27eab9c440bd12848a345ddee7200d45d8744531418dd9b936529405623a7c464d44b957503903ac0fc1e2bb462b431a
|
7
|
+
data.tar.gz: 2bc5e8dc185195a1dc470394d487b1c970c1c8626701803636441ae84a6f138352dcafd07481d39a151c24911a05526dfa8748882ee7b1b48f57c02bba584e54
|
data/Dockerfile
CHANGED
@@ -492,6 +492,10 @@ class Morpheus::APIClient
|
|
492
492
|
Morpheus::LoadBalancerPoolsInterface.new(common_interface_options).setopts(@options)
|
493
493
|
end
|
494
494
|
|
495
|
+
def load_balancer_pools_secondary
|
496
|
+
Morpheus::LoadBalancerPoolsSecondaryInterface.new(common_interface_options).setopts(@options)
|
497
|
+
end
|
498
|
+
|
495
499
|
def load_balancer_profiles
|
496
500
|
Morpheus::LoadBalancerProfilesInterface.new(common_interface_options).setopts(@options)
|
497
501
|
end
|
@@ -500,6 +504,10 @@ class Morpheus::APIClient
|
|
500
504
|
Morpheus::LoadBalancerMonitorsInterface.new(common_interface_options).setopts(@options)
|
501
505
|
end
|
502
506
|
|
507
|
+
def load_balancer_pool_nodes
|
508
|
+
Morpheus::LoadBalancerPoolNodesInterface.new(common_interface_options).setopts(@options)
|
509
|
+
end
|
510
|
+
|
503
511
|
def tasks
|
504
512
|
Morpheus::TasksInterface.new(common_interface_options).setopts(@options)
|
505
513
|
end
|
@@ -9,7 +9,7 @@ class Morpheus::CypherInterface < Morpheus::APIClient
|
|
9
9
|
|
10
10
|
def get(item_key, params={})
|
11
11
|
raise "#{self.class}.get() passed a blank item_key!" if item_key.to_s == ''
|
12
|
-
url = "#{@base_url}#{base_path}/#{item_key}"
|
12
|
+
url = "#{@base_url}#{base_path}/#{escape_item_key(item_key)}"
|
13
13
|
headers = { :params => params, :authorization => "Bearer #{@access_token}" }
|
14
14
|
execute({method: :get, url: url, headers: headers})
|
15
15
|
end
|
@@ -17,29 +17,35 @@ class Morpheus::CypherInterface < Morpheus::APIClient
|
|
17
17
|
# list url is the same as get but uses $itemKey/?list=true
|
18
18
|
# method: 'LIST' would be neat though
|
19
19
|
def list(item_key=nil, params={})
|
20
|
-
url = item_key ? "#{@base_url}#{base_path}/#{item_key}" : "#{@base_url}#{base_path}"
|
20
|
+
url = item_key ? "#{@base_url}#{base_path}/#{escape_item_key(item_key)}" : "#{@base_url}#{base_path}"
|
21
21
|
params.merge!({list:'true'}) # ditch this probably
|
22
22
|
headers = { :params => params, :authorization => "Bearer #{@access_token}" }
|
23
23
|
execute({method: :get, url: url, headers: headers})
|
24
24
|
end
|
25
25
|
|
26
26
|
def create(item_key, params={}, payload={})
|
27
|
-
url = "#{@base_url}#{base_path}/#{item_key}"
|
27
|
+
url = "#{@base_url}#{base_path}/#{escape_item_key(item_key)}"
|
28
28
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
29
29
|
execute({method: :post, url: url, headers: headers, payload: payload.to_json})
|
30
30
|
end
|
31
31
|
|
32
32
|
# update is not even needed I don't think, same as POST
|
33
33
|
def update(item_key, params={}, payload={})
|
34
|
-
url = "#{@base_url}#{base_path}/#{item_key}"
|
34
|
+
url = "#{@base_url}#{base_path}/#{escape_item_key(item_key)}"
|
35
35
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
36
36
|
execute({method: :put, url: url, headers: headers, payload: payload.to_json})
|
37
37
|
end
|
38
38
|
|
39
39
|
def destroy(item_key, params={})
|
40
|
-
url = "#{@base_url}#{base_path}/#{item_key}"
|
40
|
+
url = "#{@base_url}#{base_path}/#{escape_item_key(item_key)}"
|
41
41
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
42
42
|
execute({method: :delete, url: url, headers: headers})
|
43
43
|
end
|
44
44
|
|
45
|
+
protected
|
46
|
+
|
47
|
+
def escape_item_key(item_key)
|
48
|
+
item_key.to_s.split("/").collect {|i| CGI::escape(i.to_s) }.join("/")
|
49
|
+
end
|
50
|
+
|
45
51
|
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
|
@@ -2,10 +2,10 @@ require 'morpheus/api/api_client'
|
|
2
2
|
|
3
3
|
class Morpheus::RolesInterface < Morpheus::APIClient
|
4
4
|
|
5
|
-
def get(account_id, id)
|
5
|
+
def get(account_id, id, params={})
|
6
6
|
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
7
7
|
url = build_url(account_id, id)
|
8
|
-
headers = { params:
|
8
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
9
9
|
execute(method: :get, url: url, headers: headers)
|
10
10
|
end
|
11
11
|
|
@@ -21,24 +21,24 @@ class Morpheus::RolesInterface < Morpheus::APIClient
|
|
21
21
|
execute(method: :get, url: url, headers: headers)
|
22
22
|
end
|
23
23
|
|
24
|
-
def create(account_id, options)
|
24
|
+
def create(account_id, options, params={})
|
25
25
|
url = build_url(account_id)
|
26
26
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
27
27
|
payload = options
|
28
|
-
execute(method: :post, url: url, headers: headers, payload: payload.to_json)
|
28
|
+
execute(method: :post, url: url, headers: headers, payload: payload.to_json, params: params)
|
29
29
|
end
|
30
30
|
|
31
|
-
def update(account_id, id, options)
|
31
|
+
def update(account_id, id, options, params={})
|
32
32
|
url = build_url(account_id, id)
|
33
33
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
34
34
|
payload = options
|
35
|
-
execute(method: :put, url: url, headers: headers, payload: payload.to_json)
|
35
|
+
execute(method: :put, url: url, headers: headers, payload: payload.to_json, params: params)
|
36
36
|
end
|
37
37
|
|
38
|
-
def destroy(account_id, id)
|
38
|
+
def destroy(account_id, id, params={})
|
39
39
|
url = build_url(account_id, id)
|
40
40
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
41
|
-
execute(method: :delete, url: url, headers: headers)
|
41
|
+
execute(method: :delete, url: url, headers: headers, params: params)
|
42
42
|
end
|
43
43
|
|
44
44
|
def update_permission(account_id, id, options)
|
@@ -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}"
|