kontena-plugin-cloud 1.0.0.pre3 → 1.0.0
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/lib/kontena/plugin/cloud.rb +5 -5
- data/lib/kontena/plugin/cloud/organization/list_command.rb +4 -2
- data/lib/kontena/plugin/cloud/organization/remove_command.rb +16 -0
- data/lib/kontena/plugin/cloud/organization_command.rb +4 -8
- data/lib/kontena/plugin/{platform → cloud/platform}/common.rb +4 -3
- data/lib/kontena/plugin/{platform → cloud/platform}/create_command.rb +2 -2
- data/lib/kontena/plugin/{platform → cloud/platform}/import_grid_command.rb +2 -2
- data/lib/kontena/plugin/{platform → cloud/platform}/list_command.rb +2 -2
- data/lib/kontena/plugin/{platform → cloud/platform}/remove_command.rb +2 -2
- data/lib/kontena/plugin/cloud/platform/show_command.rb +27 -0
- data/lib/kontena/plugin/{platform → cloud/platform}/use_command.rb +2 -2
- data/lib/kontena/plugin/{platform → cloud/platform}/user/add_command.rb +4 -2
- data/lib/kontena/plugin/{platform → cloud/platform}/user/list_command.rb +4 -3
- data/lib/kontena/plugin/{platform → cloud/platform}/user/remove_command.rb +4 -2
- data/lib/kontena/plugin/cloud/platform/user_command.rb +10 -0
- data/lib/kontena/plugin/cloud/platform_command.rb +12 -0
- data/lib/kontena/plugin/cloud/region_command.rb +1 -4
- data/lib/kontena/plugin/cloud_command.rb +2 -1
- data/lib/kontena_cli_plugin.rb +2 -5
- metadata +18 -23
- data/lib/kontena/plugin/platform/audit_log_command.rb +0 -33
- data/lib/kontena/plugin/platform/health_command.rb +0 -67
- data/lib/kontena/plugin/platform/show_command.rb +0 -58
- data/lib/kontena/plugin/platform/trusted_subnet/add_command.rb +0 -20
- data/lib/kontena/plugin/platform/trusted_subnet/list_command.rb +0 -51
- data/lib/kontena/plugin/platform/trusted_subnet/remove_command.rb +0 -27
- data/lib/kontena/plugin/platform/trusted_subnet_command.rb +0 -11
- data/lib/kontena/plugin/platform/user_command.rb +0 -14
- data/lib/kontena/plugin/platform_command.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f54f4efba0517f8af5aa2d10caae9f68f0bd18c9
|
4
|
+
data.tar.gz: 9948d9b7c0e3cb153cdad97139ed040297d9570a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 494db6387d932a046993756423a65e730f13c74d1241ecbef58e89aacd61262d31b60eaae87b632e307e5549555700cca054971ac4de30d5de4a8fdfe75617a1
|
7
|
+
data.tar.gz: 16d9f944fe522e868b1602527095e31ef027040b5a94bb6d284a57506178fbea3e83cbedf3206b822708a5f965faada5ab1a3a40485d2919ecc7df14c2496e0c
|
data/lib/kontena/plugin/cloud.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Kontena
|
2
2
|
module Plugin
|
3
3
|
module Cloud
|
4
|
-
VERSION = "1.0.0
|
4
|
+
VERSION = "1.0.0"
|
5
5
|
|
6
6
|
module Organization
|
7
7
|
module User; end
|
8
8
|
end
|
9
|
+
|
9
10
|
module Region; end
|
10
|
-
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
module Platform
|
13
|
+
module User; end
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
17
|
module Grid
|
@@ -9,14 +9,16 @@ class Kontena::Plugin::Cloud::Organization::ListCommand < Kontena::Command
|
|
9
9
|
print_table(organizations) do |row|
|
10
10
|
row.merge!(row['attributes'])
|
11
11
|
row['name'] = row['name']
|
12
|
+
row['account-status'] = row['account-status'] == 'active' ? pastel.green(row['account-status']) : row['account-status']
|
12
13
|
row['role'] = row['owner'] ? pastel.cyan('owner') : 'member'
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
17
|
def fields
|
17
18
|
{
|
18
|
-
name
|
19
|
-
'
|
19
|
+
'name' => 'name',
|
20
|
+
'account status' => 'account-status',
|
21
|
+
'your role' => 'role'
|
20
22
|
}
|
21
23
|
end
|
22
24
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Kontena::Plugin::Cloud::Organization::RemoveCommand < Kontena::Command
|
2
|
+
include Kontena::Cli::Common
|
3
|
+
|
4
|
+
parameter "NAME", "Organization name"
|
5
|
+
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
6
|
+
|
7
|
+
requires_current_account_token
|
8
|
+
|
9
|
+
def execute
|
10
|
+
confirm_command(name) unless forced?
|
11
|
+
|
12
|
+
spinner "Removing organization #{pastel.cyan(name)}" do
|
13
|
+
cloud_client.delete("/organizations/#{name}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,14 +1,10 @@
|
|
1
|
-
require_relative 'organization/list_command'
|
2
|
-
require_relative 'organization/show_command'
|
3
|
-
require_relative 'organization/user_command'
|
4
|
-
|
5
1
|
class Kontena::Plugin::Cloud::OrganizationCommand < Kontena::Command
|
6
|
-
include Kontena::Plugin::Cloud
|
7
2
|
|
8
|
-
subcommand ['list', 'ls'], 'List organizations',
|
9
|
-
subcommand 'show', 'Show organization details',
|
3
|
+
subcommand ['list', 'ls'], 'List organizations', load_subcommand('kontena/plugin/cloud/organization/list_command')
|
4
|
+
subcommand 'show', 'Show organization details', load_subcommand('kontena/plugin/cloud/organization/show_command')
|
5
|
+
subcommand ['remove', 'rm'], 'Remove organization', load_subcommand('kontena/plugin/cloud/organization/remove_command')
|
6
|
+
subcommand 'user', 'User management commands', load_subcommand('kontena/plugin/cloud/organization/user_command')
|
10
7
|
|
11
|
-
subcommand 'user', 'User management commands', Organization::UserCommand
|
12
8
|
def execute
|
13
9
|
end
|
14
10
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
-
require_relative '
|
2
|
-
require_relative '
|
1
|
+
require_relative '../../../cli/master_code_exchanger'
|
2
|
+
require_relative '../../../cli/models/platform'
|
3
|
+
|
4
|
+
module Kontena::Plugin::Cloud::Platform::Common
|
3
5
|
|
4
|
-
module Kontena::Plugin::Platform::Common
|
5
6
|
def fetch_platforms
|
6
7
|
all = []
|
7
8
|
organizations = cloud_client.get('/organizations')['data']
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative 'common'
|
2
|
-
class Kontena::Plugin::Platform::CreateCommand < Kontena::Command
|
2
|
+
class Kontena::Plugin::Cloud::Platform::CreateCommand < Kontena::Command
|
3
3
|
include Kontena::Cli::Common
|
4
|
-
include Kontena::Plugin::Platform::Common
|
4
|
+
include Kontena::Plugin::Cloud::Platform::Common
|
5
5
|
|
6
6
|
requires_current_account_token
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
class Kontena::Plugin::Platform::ImportGridCommand < Kontena::Command
|
1
|
+
class Kontena::Plugin::Cloud::Platform::ImportGridCommand < Kontena::Command
|
2
2
|
include Kontena::Cli::Common
|
3
3
|
|
4
|
-
banner "
|
4
|
+
banner "Bring your own grid to Kontena Cloud platform"
|
5
5
|
|
6
6
|
parameter "MASTER", "Kontena Master name in local config"
|
7
7
|
parameter "GRID", "Grid name"
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require_relative 'common'
|
2
2
|
|
3
|
-
class Kontena::Plugin::Platform::ListCommand < Kontena::Command
|
3
|
+
class Kontena::Plugin::Cloud::Platform::ListCommand < Kontena::Command
|
4
4
|
include Kontena::Cli::Common
|
5
5
|
include Kontena::Cli::TableGenerator::Helper
|
6
|
-
include Kontena::Plugin::Platform::Common
|
6
|
+
include Kontena::Plugin::Cloud::Platform::Common
|
7
7
|
|
8
8
|
requires_current_account_token
|
9
9
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require_relative 'common'
|
2
2
|
|
3
|
-
class Kontena::Plugin::Platform::RemoveCommand < Kontena::Command
|
3
|
+
class Kontena::Plugin::Cloud::Platform::RemoveCommand < Kontena::Command
|
4
4
|
include Kontena::Cli::Common
|
5
|
-
include Kontena::Plugin::Platform::Common
|
5
|
+
include Kontena::Plugin::Cloud::Platform::Common
|
6
6
|
|
7
7
|
requires_current_account_token
|
8
8
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'kontena/cli/grids/common'
|
2
|
+
require_relative 'common'
|
3
|
+
|
4
|
+
class Kontena::Plugin::Cloud::Platform::ShowCommand < Kontena::Command
|
5
|
+
include Kontena::Cli::Common
|
6
|
+
include Kontena::Plugin::Cloud::Platform::Common
|
7
|
+
include Kontena::Cli::Grids::Common
|
8
|
+
|
9
|
+
requires_current_account_token
|
10
|
+
|
11
|
+
parameter "NAME", "Platform name"
|
12
|
+
|
13
|
+
def execute
|
14
|
+
require_platform(name)
|
15
|
+
|
16
|
+
platform = find_platform_by_name(current_platform, current_organization)
|
17
|
+
|
18
|
+
puts "#{name}:"
|
19
|
+
puts " name: #{platform.name}"
|
20
|
+
puts " organization: #{current_organization}"
|
21
|
+
puts " state: #{platform.state}"
|
22
|
+
puts " region: #{platform.region || '-'}"
|
23
|
+
puts " initial_size: #{platform.initial_size}"
|
24
|
+
puts " master: #{platform.url}"
|
25
|
+
puts " grid: #{platform.grid_id}"
|
26
|
+
end
|
27
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require_relative 'common'
|
2
2
|
|
3
|
-
class Kontena::Plugin::Platform::UseCommand < Kontena::Command
|
3
|
+
class Kontena::Plugin::Cloud::Platform::UseCommand < Kontena::Command
|
4
4
|
include Kontena::Cli::Common
|
5
|
-
include Kontena::Plugin::Platform::Common
|
5
|
+
include Kontena::Plugin::Cloud::Platform::Common
|
6
6
|
|
7
7
|
requires_current_account_token
|
8
8
|
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
require_relative '../common'
|
2
|
+
|
3
|
+
class Kontena::Plugin::Cloud::Platform::User::AddCommand < Kontena::Command
|
2
4
|
include Kontena::Cli::Common
|
3
|
-
include Kontena::Plugin::Platform::Common
|
5
|
+
include Kontena::Plugin::Cloud::Platform::Common
|
4
6
|
|
5
7
|
requires_current_account_token
|
6
8
|
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
require_relative '../common'
|
2
|
+
|
3
|
+
class Kontena::Plugin::Cloud::Platform::User::ListCommand < Kontena::Command
|
2
4
|
include Kontena::Cli::Common
|
3
|
-
include Kontena::Plugin::Platform::Common
|
5
|
+
include Kontena::Plugin::Cloud::Platform::Common
|
4
6
|
include Kontena::Cli::TableGenerator::Helper
|
5
7
|
|
6
8
|
requires_current_account_token
|
@@ -13,7 +15,6 @@ class Kontena::Plugin::Platform::User::ListCommand < Kontena::Command
|
|
13
15
|
platform_users = cloud_client.get("/organizations/#{current_organization}/platforms/#{platform.id}/relationships/users")['data']
|
14
16
|
print_table(platform_users) do |row|
|
15
17
|
row.merge!(row['attributes'].merge(row['meta']))
|
16
|
-
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
require_relative '../common'
|
2
|
+
|
3
|
+
class Kontena::Plugin::Cloud::Platform::User::RemoveCommand < Kontena::Command
|
2
4
|
include Kontena::Cli::Common
|
3
|
-
include Kontena::Plugin::Platform::Common
|
5
|
+
include Kontena::Plugin::Cloud::Platform::Common
|
4
6
|
|
5
7
|
requires_current_account_token
|
6
8
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
class Kontena::Plugin::Cloud::Platform::UserCommand < Kontena::Command
|
3
|
+
|
4
|
+
subcommand ['list', 'ls'], 'List platform users', load_subcommand('kontena/plugin/cloud/platform/user/list_command')
|
5
|
+
subcommand 'add', 'Add users to platform', load_subcommand('kontena/plugin/cloud/platform/user/add_command')
|
6
|
+
subcommand ['remove', 'rm'], 'Remove users from platform', load_subcommand('kontena/plugin/cloud/platform/user/remove_command')
|
7
|
+
|
8
|
+
def execute
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Kontena::Plugin::Cloud::PlatformCommand < Kontena::Command
|
2
|
+
subcommand ['list', 'ls'], 'List platforms', load_subcommand('kontena/plugin/cloud/platform/list_command')
|
3
|
+
subcommand ['use', 'switch'], 'Use/switch local scope to platform', load_subcommand('kontena/plugin/cloud/platform/use_command')
|
4
|
+
subcommand 'show', 'Show platform details', load_subcommand('kontena/plugin/cloud/platform/show_command')
|
5
|
+
subcommand 'create', 'Create new platform', load_subcommand('kontena/plugin/cloud/platform/create_command')
|
6
|
+
subcommand ['remove', 'rm'], 'Remove platform', load_subcommand('kontena/plugin/cloud/platform/remove_command')
|
7
|
+
subcommand ['join', 'byo'], 'Join grid as Kontena Platform', load_subcommand('kontena/plugin/cloud/platform/import_grid_command')
|
8
|
+
subcommand 'user', 'User management commands', load_subcommand('kontena/plugin/cloud/platform/user_command')
|
9
|
+
|
10
|
+
def execute
|
11
|
+
end
|
12
|
+
end
|
@@ -1,9 +1,6 @@
|
|
1
|
-
require_relative 'region/list_command'
|
2
|
-
|
3
1
|
class Kontena::Plugin::Cloud::RegionCommand < Kontena::Command
|
4
|
-
include Kontena::Plugin::Cloud
|
5
2
|
|
6
|
-
subcommand ['list', 'ls'], 'List regions',
|
3
|
+
subcommand ['list', 'ls'], 'List regions', load_subcommand('kontena/plugin/cloud/region/list_command')
|
7
4
|
|
8
5
|
def execute
|
9
6
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class Kontena::Cli::CloudCommand < Kontena::Command
|
2
2
|
|
3
|
-
subcommand '
|
3
|
+
subcommand 'platform', 'Kontena platform specific commands', load_subcommand('kontena/plugin/cloud/platform_command')
|
4
|
+
subcommand ['organization', 'org'], 'Organization specific commands', load_subcommand('kontena/plugin/cloud/organization_command')
|
4
5
|
subcommand 'region', 'Region specific commands', load_subcommand('kontena/plugin/cloud/region_command')
|
5
6
|
|
6
7
|
def execute
|
data/lib/kontena_cli_plugin.rb
CHANGED
@@ -2,9 +2,6 @@ require 'kontena_cli'
|
|
2
2
|
require 'kontena/command'
|
3
3
|
require_relative 'kontena/plugin/cloud'
|
4
4
|
require_relative 'kontena/plugin/cloud_command'
|
5
|
-
require_relative 'kontena/plugin/platform_command'
|
6
|
-
|
7
|
-
Kontena::MainCommand.register("platform", "Platform specific commands", Kontena::Plugin::PlatformCommand)
|
8
5
|
|
9
6
|
module Kontena
|
10
7
|
module Cli
|
@@ -12,7 +9,7 @@ module Kontena
|
|
12
9
|
def self.included(base)
|
13
10
|
if base.respond_to?(:option)
|
14
11
|
|
15
|
-
base.option '--platform', 'PLATFORM', 'Specify platform to use' do |platform|
|
12
|
+
base.option '--platform', 'PLATFORM', 'Specify Kontena Cloud platform to use' do |platform|
|
16
13
|
config.current_master = platform
|
17
14
|
config.current_grid = platform.split('/')[1]
|
18
15
|
end
|
@@ -24,7 +21,7 @@ module Kontena
|
|
24
21
|
|
25
22
|
module CloudCommand
|
26
23
|
|
27
|
-
PLATFORM_NOT_SELECTED_ERROR = "Platform not selected, use 'kontena platform use' to select a platform"
|
24
|
+
PLATFORM_NOT_SELECTED_ERROR = "Platform not selected, use 'kontena cloud platform use' to select a platform"
|
28
25
|
|
29
26
|
def verify_current_master
|
30
27
|
super
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kontena-plugin-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kontena, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kontena-cli
|
@@ -73,33 +73,28 @@ files:
|
|
73
73
|
- lib/kontena/cli/models/platform.rb
|
74
74
|
- lib/kontena/plugin/cloud.rb
|
75
75
|
- lib/kontena/plugin/cloud/organization/list_command.rb
|
76
|
+
- lib/kontena/plugin/cloud/organization/remove_command.rb
|
76
77
|
- lib/kontena/plugin/cloud/organization/show_command.rb
|
77
78
|
- lib/kontena/plugin/cloud/organization/user/add_command.rb
|
78
79
|
- lib/kontena/plugin/cloud/organization/user/list_command.rb
|
79
80
|
- lib/kontena/plugin/cloud/organization/user/remove_command.rb
|
80
81
|
- lib/kontena/plugin/cloud/organization/user_command.rb
|
81
82
|
- lib/kontena/plugin/cloud/organization_command.rb
|
83
|
+
- lib/kontena/plugin/cloud/platform/common.rb
|
84
|
+
- lib/kontena/plugin/cloud/platform/create_command.rb
|
85
|
+
- lib/kontena/plugin/cloud/platform/import_grid_command.rb
|
86
|
+
- lib/kontena/plugin/cloud/platform/list_command.rb
|
87
|
+
- lib/kontena/plugin/cloud/platform/remove_command.rb
|
88
|
+
- lib/kontena/plugin/cloud/platform/show_command.rb
|
89
|
+
- lib/kontena/plugin/cloud/platform/use_command.rb
|
90
|
+
- lib/kontena/plugin/cloud/platform/user/add_command.rb
|
91
|
+
- lib/kontena/plugin/cloud/platform/user/list_command.rb
|
92
|
+
- lib/kontena/plugin/cloud/platform/user/remove_command.rb
|
93
|
+
- lib/kontena/plugin/cloud/platform/user_command.rb
|
94
|
+
- lib/kontena/plugin/cloud/platform_command.rb
|
82
95
|
- lib/kontena/plugin/cloud/region/list_command.rb
|
83
96
|
- lib/kontena/plugin/cloud/region_command.rb
|
84
97
|
- lib/kontena/plugin/cloud_command.rb
|
85
|
-
- lib/kontena/plugin/platform/audit_log_command.rb
|
86
|
-
- lib/kontena/plugin/platform/common.rb
|
87
|
-
- lib/kontena/plugin/platform/create_command.rb
|
88
|
-
- lib/kontena/plugin/platform/health_command.rb
|
89
|
-
- lib/kontena/plugin/platform/import_grid_command.rb
|
90
|
-
- lib/kontena/plugin/platform/list_command.rb
|
91
|
-
- lib/kontena/plugin/platform/remove_command.rb
|
92
|
-
- lib/kontena/plugin/platform/show_command.rb
|
93
|
-
- lib/kontena/plugin/platform/trusted_subnet/add_command.rb
|
94
|
-
- lib/kontena/plugin/platform/trusted_subnet/list_command.rb
|
95
|
-
- lib/kontena/plugin/platform/trusted_subnet/remove_command.rb
|
96
|
-
- lib/kontena/plugin/platform/trusted_subnet_command.rb
|
97
|
-
- lib/kontena/plugin/platform/use_command.rb
|
98
|
-
- lib/kontena/plugin/platform/user/add_command.rb
|
99
|
-
- lib/kontena/plugin/platform/user/list_command.rb
|
100
|
-
- lib/kontena/plugin/platform/user/remove_command.rb
|
101
|
-
- lib/kontena/plugin/platform/user_command.rb
|
102
|
-
- lib/kontena/plugin/platform_command.rb
|
103
98
|
- lib/kontena_cli_plugin.rb
|
104
99
|
homepage: https://kontena.io
|
105
100
|
licenses:
|
@@ -116,12 +111,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
111
|
version: '0'
|
117
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
113
|
requirements:
|
119
|
-
- - "
|
114
|
+
- - ">="
|
120
115
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
116
|
+
version: '0'
|
122
117
|
requirements: []
|
123
118
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.6.13
|
125
120
|
signing_key:
|
126
121
|
specification_version: 4
|
127
122
|
summary: Kontena Cloud management for Kontena CLI
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'kontena/cli/grids/audit_log_command'
|
2
|
-
require_relative 'common'
|
3
|
-
|
4
|
-
class Kontena::Plugin::Platform::AuditLogCommand < Kontena::Command
|
5
|
-
include Kontena::Cli::Common
|
6
|
-
include Kontena::Plugin::Platform::Common
|
7
|
-
include Kontena::Cli::TableGenerator::Helper
|
8
|
-
|
9
|
-
parameter "NAME", "Platform name"
|
10
|
-
|
11
|
-
option ["-l", "--lines"], "LINES", "Number of lines"
|
12
|
-
|
13
|
-
def execute
|
14
|
-
require_platform(name)
|
15
|
-
|
16
|
-
audit_logs = client.get("grids/#{current_grid}/audit_log", {limit: lines})['logs']
|
17
|
-
print_table(audit_logs) do |a|
|
18
|
-
a['user'] = a['user_identity']['email']
|
19
|
-
a['resource'] = a['resource_name'] ? "#{a['resource_type']}:#{a['resource_name']}" : a['resource_type']
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def fields
|
24
|
-
{
|
25
|
-
'time' => 'time',
|
26
|
-
'resource' => 'resource',
|
27
|
-
'event' => 'event_name',
|
28
|
-
'user' => 'user',
|
29
|
-
'source ip' => 'source_ip',
|
30
|
-
'user agent' => 'user_agent'
|
31
|
-
}
|
32
|
-
end
|
33
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'kontena/cli/grids/health_command'
|
2
|
-
require_relative 'common'
|
3
|
-
|
4
|
-
class Kontena::Plugin::Platform::HealthCommand < Kontena::Command
|
5
|
-
include Kontena::Cli::Common
|
6
|
-
include Kontena::Plugin::Platform::Common
|
7
|
-
include Kontena::Cli::Helpers::HealthHelper
|
8
|
-
|
9
|
-
parameter "NAME", "Platform name"
|
10
|
-
|
11
|
-
def execute
|
12
|
-
require_platform(name)
|
13
|
-
|
14
|
-
grid = client.get("grids/#{current_grid}")
|
15
|
-
grid_nodes = client.get("grids/#{current_grid}/nodes")
|
16
|
-
|
17
|
-
show_platform_health(grid, grid_nodes['nodes'])
|
18
|
-
end
|
19
|
-
|
20
|
-
# Validate grid/nodes configuration for grid operation
|
21
|
-
#
|
22
|
-
# @return [Boolean] false if unhealthy
|
23
|
-
def show_platform_health(grid, nodes)
|
24
|
-
initial_size = grid['initial_size']
|
25
|
-
minimum_size = grid['initial_size'] / 2 + 1 # a majority is required for etcd quorum
|
26
|
-
|
27
|
-
grid_health = grid_health(grid, nodes)
|
28
|
-
initial_nodes = nodes.select{|node| node['initial_member']}
|
29
|
-
online_nodes = initial_nodes.select{|node| node['connected']}
|
30
|
-
|
31
|
-
# configuration and status
|
32
|
-
if initial_nodes.length == 0
|
33
|
-
puts "#{health_icon :error} #{name} does not have any initial nodes and requires at least #{minimum_size} of #{initial_size} initial nodes for operation"
|
34
|
-
elsif online_nodes.empty?
|
35
|
-
puts "#{health_icon :error} #{name} does not have any initial nodes online and requires at least #{minimum_size} of #{initial_size} initial nodes for operation"
|
36
|
-
elsif initial_nodes.length < minimum_size
|
37
|
-
puts "#{health_icon :error} #{name} only has #{initial_nodes.length} initial nodes and requires at least #{minimum_size} of #{initial_size} initial nodes for operation"
|
38
|
-
elsif online_nodes.length < minimum_size
|
39
|
-
puts "#{health_icon :error} #{name} only has #{online_nodes.length} initial nodes online and requires at least #{minimum_size} of #{initial_size} initial nodes for operation"
|
40
|
-
elsif initial_nodes.length < initial_size
|
41
|
-
puts "#{health_icon :warning} #{name} only has #{initial_nodes.length} initial nodes of #{initial_size} required for high-availability"
|
42
|
-
elsif online_nodes.length < initial_size
|
43
|
-
puts "#{health_icon :warning} #{name} only has #{online_nodes.length} initial nodes online of #{initial_size} required for high-availability"
|
44
|
-
elsif initial_nodes.length == 2
|
45
|
-
puts "#{health_icon :warning} #{name} only has #{initial_nodes.length} initial nodes and is not high-availability"
|
46
|
-
elsif initial_nodes.length == 1
|
47
|
-
puts "#{health_icon :warning} #{name} only has #{initial_nodes.length} initial node and is not high-availability"
|
48
|
-
else
|
49
|
-
puts "#{health_icon :ok} #{name} has all #{online_nodes.length} of #{initial_size} initial nodes online"
|
50
|
-
end
|
51
|
-
|
52
|
-
nodes.each do |node|
|
53
|
-
node_health = node_health(node, grid_health)
|
54
|
-
|
55
|
-
if node['connected']
|
56
|
-
|
57
|
-
elsif node['initial_member']
|
58
|
-
puts "#{health_icon grid_health} Initial node #{node['name']} is offline"
|
59
|
-
else
|
60
|
-
puts "#{health_icon node_health} Grid node #{node['name']} is offline"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# operational if we have etcd quorum
|
65
|
-
online_nodes.length >= minimum_size
|
66
|
-
end
|
67
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'kontena/cli/grids/common'
|
2
|
-
require_relative 'common'
|
3
|
-
require_relative '../../cli/models/grid'
|
4
|
-
|
5
|
-
class Kontena::Plugin::Platform::ShowCommand < Kontena::Command
|
6
|
-
include Kontena::Cli::Common
|
7
|
-
include Kontena::Plugin::Platform::Common
|
8
|
-
include Kontena::Cli::Grids::Common
|
9
|
-
|
10
|
-
requires_current_account_token
|
11
|
-
|
12
|
-
parameter "NAME", "Platform name"
|
13
|
-
|
14
|
-
def execute
|
15
|
-
require_platform(name)
|
16
|
-
|
17
|
-
platform = find_platform_by_name(current_platform, current_organization)
|
18
|
-
|
19
|
-
puts "#{name}:"
|
20
|
-
puts " name: #{platform.name}"
|
21
|
-
puts " organization: #{current_organization}"
|
22
|
-
puts " state: #{platform.state}"
|
23
|
-
puts " region: #{platform.region || '-'}"
|
24
|
-
puts " initial_size: #{platform.initial_size}"
|
25
|
-
puts " master: #{platform.url}"
|
26
|
-
|
27
|
-
grid = nil
|
28
|
-
begin
|
29
|
-
data = client.get("grids/#{platform.grid_id}")
|
30
|
-
grid = Kontena::Cli::Models::Grid.new(data)
|
31
|
-
rescue Kontena::Errors::StandardError
|
32
|
-
exit_with_error "Cannot fetch grid information"
|
33
|
-
end
|
34
|
-
|
35
|
-
if grid.default_affinity?
|
36
|
-
puts " default_affinity: "
|
37
|
-
grid.default_affinity.to_a.each do |a|
|
38
|
-
puts " - #{a}"
|
39
|
-
end
|
40
|
-
else
|
41
|
-
puts " default_affinity: -"
|
42
|
-
end
|
43
|
-
puts " subnet: #{grid.subnet}"
|
44
|
-
puts " supernet: #{grid.supernet}"
|
45
|
-
if grid.stats.statsd?
|
46
|
-
statsd = grid.stats.statsd
|
47
|
-
puts " exports:"
|
48
|
-
puts " statsd: #{statsd.server}:#{statsd.port}"
|
49
|
-
end
|
50
|
-
if grid.logs.forwarder?
|
51
|
-
puts "logs:"
|
52
|
-
puts " forwarder: #{grid.logs.forwarder}"
|
53
|
-
grid.logs.opts.each do |k,v|
|
54
|
-
puts " #{k}: #{v}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative '../../../cli/models/grid'
|
2
|
-
require_relative '../common'
|
3
|
-
|
4
|
-
class Kontena::Plugin::Platform::TrustedSubnet::AddCommand < Kontena::Command
|
5
|
-
include Kontena::Cli::Common
|
6
|
-
include Kontena::Plugin::Platform::Common
|
7
|
-
|
8
|
-
parameter "NAME", "Platform name"
|
9
|
-
parameter "SUBNET", "Subnet"
|
10
|
-
|
11
|
-
def execute
|
12
|
-
require_platform(name)
|
13
|
-
|
14
|
-
grid = client.get("grids/#{current_grid}")
|
15
|
-
data = {trusted_subnets: grid['trusted_subnets'] + [self.subnet]}
|
16
|
-
spinner "Adding #{subnet.colorize(:cyan)} as a trusted subnet in #{current_grid.colorize(:cyan)} platform " do
|
17
|
-
client.put("grids/#{current_grid}", data)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require_relative '../../../cli/models/grid'
|
2
|
-
require_relative '../common'
|
3
|
-
require 'ipaddr'
|
4
|
-
|
5
|
-
class Kontena::Plugin::Platform::TrustedSubnet::ListCommand < Kontena::Command
|
6
|
-
include Kontena::Cli::Common
|
7
|
-
include Kontena::Plugin::Platform::Common
|
8
|
-
include Kontena::Cli::TableGenerator::Helper
|
9
|
-
|
10
|
-
parameter "NAME", "Platform name"
|
11
|
-
|
12
|
-
def execute
|
13
|
-
require_platform(name)
|
14
|
-
grid = Kontena::Cli::Models::Grid.new(client.get("grids/#{current_grid}"))
|
15
|
-
if grid.trusted_subnets.size > 0
|
16
|
-
nodes = client.get("grids/#{current_grid}/nodes")['nodes']
|
17
|
-
else
|
18
|
-
nodes = []
|
19
|
-
end
|
20
|
-
items = grid.trusted_subnets.map { |s|
|
21
|
-
item = {
|
22
|
-
'subnet' => s
|
23
|
-
}
|
24
|
-
subnet = IPAddr.new(s)
|
25
|
-
item['nodes'] = trusted_nodes(subnet, nodes).map { |n| n['name'] }.join(',')
|
26
|
-
|
27
|
-
item
|
28
|
-
}
|
29
|
-
|
30
|
-
print_table(items)
|
31
|
-
end
|
32
|
-
|
33
|
-
# @param [IPAddr] subnet
|
34
|
-
# @param [Array<Hash>] nodes
|
35
|
-
def trusted_nodes(subnet, nodes)
|
36
|
-
nodes.select { |n|
|
37
|
-
begin
|
38
|
-
n['private_ip'] && subnet.include?( IPAddr.new(n['private_ip']) )
|
39
|
-
rescue => exc
|
40
|
-
STDERR.puts "Failed to parse #{n['private_ip']} (#{n['name']}): #{exc.message}"
|
41
|
-
end
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
def fields
|
46
|
-
{
|
47
|
-
subnet: 'subnet',
|
48
|
-
nodes: 'nodes'
|
49
|
-
}
|
50
|
-
end
|
51
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative '../../../cli/models/grid'
|
2
|
-
require_relative '../common'
|
3
|
-
|
4
|
-
class Kontena::Plugin::Platform::TrustedSubnet::RemoveCommand < Kontena::Command
|
5
|
-
include Kontena::Cli::Common
|
6
|
-
include Kontena::Plugin::Platform::Common
|
7
|
-
|
8
|
-
parameter "NAME", "Platform name"
|
9
|
-
parameter "SUBNET", "Subnet"
|
10
|
-
|
11
|
-
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
12
|
-
|
13
|
-
def execute
|
14
|
-
require_platform(name)
|
15
|
-
|
16
|
-
grid = client.get("grids/#{current_grid}")
|
17
|
-
confirm_command(subnet) unless forced?
|
18
|
-
trusted_subnets = grid['trusted_subnets'] || []
|
19
|
-
unless trusted_subnets.delete(self.subnet)
|
20
|
-
exit_with_error("Platform #{name.colorize(:cyan)} does not have trusted subnet #{subnet.colorize(:cyan)}")
|
21
|
-
end
|
22
|
-
data = {trusted_subnets: trusted_subnets}
|
23
|
-
spinner "Removing trusted subnet #{subnet.colorize(:cyan)} from #{name.colorize(:cyan)} platform " do
|
24
|
-
client.put("grids/#{current_grid}", data)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require_relative 'common'
|
2
|
-
|
3
|
-
class Kontena::Plugin::Platform::TrustedSubnetCommand < Kontena::Command
|
4
|
-
|
5
|
-
subcommand ["list", "ls"], "List trusted subnets", load_subcommand('kontena/plugin/platform/trusted_subnet/list_command')
|
6
|
-
subcommand ["add"], "Add trusted subnet", load_subcommand('kontena/plugin/platform/trusted_subnet/add_command')
|
7
|
-
subcommand ["remove", "rm"], "Remove trusted subnet", load_subcommand('kontena/plugin/platform/trusted_subnet/remove_command')
|
8
|
-
|
9
|
-
def execute
|
10
|
-
end
|
11
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require_relative 'common'
|
2
|
-
|
3
|
-
require_relative 'user/list_command'
|
4
|
-
require_relative 'user/add_command'
|
5
|
-
require_relative 'user/remove_command'
|
6
|
-
class Kontena::Plugin::Platform::UserCommand < Kontena::Command
|
7
|
-
include Kontena::Plugin::Platform
|
8
|
-
subcommand ['list', 'ls'], 'List platform users', User::ListCommand
|
9
|
-
subcommand 'add', 'Add users to platform', User::AddCommand
|
10
|
-
subcommand ['remove', 'rm'], 'Remove users from platform', User::RemoveCommand
|
11
|
-
|
12
|
-
def execute
|
13
|
-
end
|
14
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative 'platform/user_command'
|
2
|
-
|
3
|
-
class Kontena::Plugin::PlatformCommand < Kontena::Command
|
4
|
-
include Kontena::Plugin::Platform
|
5
|
-
|
6
|
-
subcommand ['list', 'ls'], 'List platforms', load_subcommand('kontena/plugin/platform/list_command')
|
7
|
-
subcommand ['use', 'switch'], 'Use/switch local scope to platform', load_subcommand('kontena/plugin/platform/use_command')
|
8
|
-
subcommand 'show', 'Show platform details', load_subcommand('kontena/plugin/platform/show_command')
|
9
|
-
subcommand 'create', 'Create new platform', load_subcommand('kontena/plugin/platform/create_command')
|
10
|
-
subcommand ['remove', 'rm'], 'Remove platform', load_subcommand('kontena/plugin/platform/remove_command')
|
11
|
-
subcommand 'audit-log', 'Show platform audit logs', load_subcommand('kontena/plugin/platform/audit_log_command')
|
12
|
-
subcommand 'health', 'Show platform health', load_subcommand('kontena/plugin/platform/health_command')
|
13
|
-
subcommand 'trusted-subnet', 'Trusted subnet specific commands', load_subcommand('kontena/plugin/platform/trusted_subnet_command')
|
14
|
-
subcommand 'import-grid', 'Import grid as Kontena Platform', load_subcommand('kontena/plugin/platform/import_grid_command')
|
15
|
-
subcommand 'user', 'User management commands', UserCommand
|
16
|
-
|
17
|
-
def execute
|
18
|
-
end
|
19
|
-
end
|