kontena-cli 0.7.3 → 0.8.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/VERSION +1 -1
- data/bin/kontena +64 -2
- data/kontena-cli.gemspec +4 -2
- data/lib/kontena/cli/app_command.rb +20 -0
- data/lib/kontena/cli/apps/common.rb +53 -0
- data/lib/kontena/cli/{stacks/stacks.rb → apps/deploy_command.rb} +17 -31
- data/lib/kontena/cli/apps/init_command.rb +101 -0
- data/lib/kontena/cli/apps/list_command.rb +41 -0
- data/lib/kontena/cli/apps/logs_command.rb +58 -0
- data/lib/kontena/cli/apps/remove_command.rb +64 -0
- data/lib/kontena/cli/apps/start_command.rb +38 -0
- data/lib/kontena/cli/apps/stop_command.rb +38 -0
- data/lib/kontena/cli/container_command.rb +9 -0
- data/lib/kontena/cli/containers/{containers.rb → exec_command.rb} +5 -5
- data/lib/kontena/cli/deploy_command.rb +159 -0
- data/lib/kontena/cli/external_registries/add_command.rb +22 -0
- data/lib/kontena/cli/external_registries/delete_command.rb +13 -0
- data/lib/kontena/cli/external_registries/list_command.rb +16 -0
- data/lib/kontena/cli/external_registry_command.rb +14 -0
- data/lib/kontena/cli/forgot_password_command.rb +13 -0
- data/lib/kontena/cli/grid_command.rb +27 -0
- data/lib/kontena/cli/grids/add_user_command.rb +17 -0
- data/lib/kontena/cli/grids/{audit_log.rb → audit_log_command.rb} +7 -6
- data/lib/kontena/cli/grids/common.rb +24 -0
- data/lib/kontena/cli/grids/create_command.rb +26 -0
- data/lib/kontena/cli/grids/current_command.rb +18 -0
- data/lib/kontena/cli/grids/list_command.rb +26 -0
- data/lib/kontena/cli/grids/list_users_command.rb +18 -0
- data/lib/kontena/cli/grids/remove_command.rb +26 -0
- data/lib/kontena/cli/grids/remove_user_command.rb +16 -0
- data/lib/kontena/cli/grids/show_command.rb +19 -0
- data/lib/kontena/cli/grids/use_command.rb +21 -0
- data/lib/kontena/cli/invite_command.rb +13 -0
- data/lib/kontena/cli/login_command.rb +114 -0
- data/lib/kontena/cli/logout_command.rb +8 -0
- data/lib/kontena/cli/node_command.rb +21 -0
- data/lib/kontena/cli/nodes/digital_ocean/create_command.rb +31 -0
- data/lib/kontena/cli/nodes/digital_ocean/restart_command.rb +26 -0
- data/lib/kontena/cli/nodes/digital_ocean/terminate_command.rb +18 -0
- data/lib/kontena/cli/nodes/digital_ocean_command.rb +15 -0
- data/lib/kontena/cli/nodes/list_command.rb +28 -0
- data/lib/kontena/cli/nodes/remove_command.rb +15 -0
- data/lib/kontena/cli/nodes/show_command.rb +31 -0
- data/lib/kontena/cli/nodes/update_command.rb +18 -0
- data/lib/kontena/cli/nodes/vagrant/create_command.rb +26 -0
- data/lib/kontena/cli/nodes/vagrant/restart_command.rb +25 -0
- data/lib/kontena/cli/nodes/vagrant/ssh_command.rb +20 -0
- data/lib/kontena/cli/nodes/vagrant/start_command.rb +25 -0
- data/lib/kontena/cli/nodes/vagrant/stop_command.rb +25 -0
- data/lib/kontena/cli/nodes/vagrant/terminate_command.rb +16 -0
- data/lib/kontena/cli/nodes/vagrant_command.rb +21 -0
- data/lib/kontena/cli/register_command.rb +21 -0
- data/lib/kontena/cli/{grids/registry.rb → registry/create_command.rb} +32 -35
- data/lib/kontena/cli/registry/delete_command.rb +15 -0
- data/lib/kontena/cli/registry_command.rb +11 -0
- data/lib/kontena/cli/reset_password_command.rb +17 -0
- data/lib/kontena/cli/service_command.rb +33 -0
- data/lib/kontena/cli/services/container_command.rb +9 -0
- data/lib/kontena/cli/services/containers_command.rb +31 -0
- data/lib/kontena/cli/services/create_command.rb +62 -0
- data/lib/kontena/cli/services/delete_command.rb +17 -0
- data/lib/kontena/cli/services/deploy_command.rb +23 -0
- data/lib/kontena/cli/services/list_command.rb +20 -0
- data/lib/kontena/cli/services/logs_command.rb +51 -0
- data/lib/kontena/cli/services/restart_command.rb +16 -0
- data/lib/kontena/cli/services/scale_command.rb +20 -0
- data/lib/kontena/cli/services/services_helper.rb +94 -0
- data/lib/kontena/cli/services/show_command.rb +17 -0
- data/lib/kontena/cli/services/start_command.rb +16 -0
- data/lib/kontena/cli/services/{stats.rb → stats_command.rb} +11 -10
- data/lib/kontena/cli/services/stop_command.rb +16 -0
- data/lib/kontena/cli/services/update_command.rb +51 -0
- data/lib/kontena/cli/verify_account_command.rb +13 -0
- data/lib/kontena/cli/version_command.rb +8 -0
- data/lib/kontena/cli/vpn/config_command.rb +12 -0
- data/lib/kontena/cli/{grids/vpn.rb → vpn/create_command.rb} +12 -29
- data/lib/kontena/cli/vpn/delete_command.rb +15 -0
- data/lib/kontena/cli/vpn_command.rb +13 -0
- data/lib/kontena/cli/whoami_command.rb +19 -0
- data/lib/kontena/client.rb +14 -11
- data/lib/kontena/machine/common.rb +17 -0
- data/lib/kontena/machine/digital_ocean.rb +11 -0
- data/lib/kontena/machine/digital_ocean/cloudinit.yml +66 -0
- data/lib/kontena/machine/digital_ocean/node_destroyer.rb +38 -0
- data/lib/kontena/machine/digital_ocean/node_provisioner.rb +74 -0
- data/lib/kontena/machine/random_name.rb +42 -0
- data/lib/kontena/machine/vagrant.rb +10 -0
- data/lib/kontena/machine/vagrant/Vagrantfile.coreos.rb.erb +32 -0
- data/lib/kontena/machine/vagrant/cloudinit.yml +65 -0
- data/lib/kontena/machine/vagrant/node_destroyer.rb +36 -0
- data/lib/kontena/machine/vagrant/node_provisioner.rb +68 -0
- data/lib/kontena/scripts/completer +5 -5
- data/spec/kontena/cli/app/deploy_command_spec.rb +227 -0
- data/spec/kontena/cli/deploy_command_spec.rb +213 -0
- data/spec/kontena/cli/login_command_spec.rb +22 -0
- data/spec/kontena/cli/register_command_spec.rb +57 -0
- data/spec/spec_helper.rb +5 -1
- metadata +132 -36
- data/lib/kontena/cli/commands.rb +0 -20
- data/lib/kontena/cli/containers/commands.rb +0 -12
- data/lib/kontena/cli/grids/commands.rb +0 -169
- data/lib/kontena/cli/grids/external_registries.rb +0 -40
- data/lib/kontena/cli/grids/grids.rb +0 -108
- data/lib/kontena/cli/grids/users.rb +0 -32
- data/lib/kontena/cli/nodes/commands.rb +0 -27
- data/lib/kontena/cli/nodes/nodes.rb +0 -64
- data/lib/kontena/cli/server/commands.rb +0 -69
- data/lib/kontena/cli/server/server.rb +0 -45
- data/lib/kontena/cli/server/user.rb +0 -174
- data/lib/kontena/cli/services/commands.rb +0 -138
- data/lib/kontena/cli/services/containers.rb +0 -24
- data/lib/kontena/cli/services/logs.rb +0 -44
- data/lib/kontena/cli/services/services.rb +0 -175
- data/lib/kontena/cli/stacks/commands.rb +0 -13
- data/spec/kontena/cli/server/user_spec.rb +0 -59
- data/spec/kontena/cli/stacks/stacks_spec.rb +0 -212
data/lib/kontena/cli/commands.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'kontena/cli/version'
|
|
2
|
-
|
|
3
|
-
module Kontena::Cli; end;
|
|
4
|
-
|
|
5
|
-
program :name, 'kontena'
|
|
6
|
-
program :version, Kontena::Cli::VERSION
|
|
7
|
-
program :description, 'Command line interface for Kontena.'
|
|
8
|
-
program :int_block do
|
|
9
|
-
exit 1
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
default_command :help
|
|
13
|
-
never_trace!
|
|
14
|
-
|
|
15
|
-
require_relative 'server/commands'
|
|
16
|
-
require_relative 'containers/commands'
|
|
17
|
-
require_relative 'grids/commands'
|
|
18
|
-
require_relative 'nodes/commands'
|
|
19
|
-
require_relative 'services/commands'
|
|
20
|
-
require_relative 'stacks/commands'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Kontena::Cli::Containers; end;
|
|
2
|
-
|
|
3
|
-
require_relative 'containers'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
command 'container exec' do |c|
|
|
7
|
-
c.syntax = 'kontena container exec <container_id> <cmd>'
|
|
8
|
-
c.description = 'Execute command inside container'
|
|
9
|
-
c.action do |args, options|
|
|
10
|
-
Kontena::Cli::Containers::Containers.new.exec(args[0], args[1])
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
module Kontena::Cli::Grids; end;
|
|
2
|
-
|
|
3
|
-
require_relative 'grids'
|
|
4
|
-
require_relative 'users'
|
|
5
|
-
require_relative 'audit_log'
|
|
6
|
-
require_relative 'vpn'
|
|
7
|
-
require_relative 'registry'
|
|
8
|
-
require_relative 'external_registries'
|
|
9
|
-
|
|
10
|
-
command 'grid list' do |c|
|
|
11
|
-
c.syntax = 'kontena grid list'
|
|
12
|
-
c.description = 'List all grids'
|
|
13
|
-
c.action do |args, options|
|
|
14
|
-
Kontena::Cli::Grids::Grids.new.list
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
command 'grid use' do |c|
|
|
19
|
-
c.syntax = 'kontena grid use <name>'
|
|
20
|
-
c.description = 'Switch to use specific grid'
|
|
21
|
-
c.action do |args, options|
|
|
22
|
-
raise ArgumentError.new('grid name is required. For a list of existing grids please run: kontena grid list') if args[0].nil?
|
|
23
|
-
Kontena::Cli::Grids::Grids.new.use(args[0])
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
command 'grid show' do |c|
|
|
28
|
-
c.syntax = 'kontena grid show <name>'
|
|
29
|
-
c.description = 'Show grid details'
|
|
30
|
-
c.action do |args, options|
|
|
31
|
-
raise ArgumentError.new('grid name is required. For a list of existing grids please run: kontena grid list') if args[0].nil?
|
|
32
|
-
Kontena::Cli::Grids::Grids.new.show(args[0])
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
command 'grid current' do |c|
|
|
37
|
-
c.syntax = 'kontena grid current'
|
|
38
|
-
c.description = 'Show current grid details'
|
|
39
|
-
c.action do |args, options|
|
|
40
|
-
Kontena::Cli::Grids::Grids.new.current
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
command 'grid audit-log' do |c|
|
|
45
|
-
c.syntax = 'kontena grid audit-log'
|
|
46
|
-
c.description = 'Show audit log of the current grid'
|
|
47
|
-
c.option '-l', '--limit INTEGER', Integer, 'Number of lines'
|
|
48
|
-
c.action do |args, options|
|
|
49
|
-
Kontena::Cli::Grids::AuditLog.new.show(options)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
command 'grid create' do |c|
|
|
54
|
-
c.syntax = 'kontena grid create <name>'
|
|
55
|
-
c.description = 'Create a new grid'
|
|
56
|
-
c.option '--initial-size INTEGER', Integer, 'Initial number of nodes'
|
|
57
|
-
c.action do |args, options|
|
|
58
|
-
Kontena::Cli::Grids::Grids.new.create(args[0], options)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
command 'grid remove' do |c|
|
|
63
|
-
c.syntax = 'kontena grid remove <name>'
|
|
64
|
-
c.description = 'Removes grid'
|
|
65
|
-
c.action do |args, options|
|
|
66
|
-
Kontena::Cli::Grids::Grids.new.destroy(args[0])
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
command 'grid list-users' do |c|
|
|
71
|
-
c.syntax = 'kontena grid list-users'
|
|
72
|
-
c.description = 'Show grid users'
|
|
73
|
-
c.action do |args, options|
|
|
74
|
-
Kontena::Cli::Grids::Users.new.list
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
command 'grid add-user' do |c|
|
|
79
|
-
c.syntax = 'kontena grid add-user <email>'
|
|
80
|
-
c.description = 'Assign user to grid'
|
|
81
|
-
c.action do |args, options|
|
|
82
|
-
Kontena::Cli::Grids::Users.new.add(args[0])
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
command 'grid remove-user' do |c|
|
|
87
|
-
c.syntax = 'kontena grid remove-user <email>'
|
|
88
|
-
c.description = 'Unassign user from grid'
|
|
89
|
-
c.action do |args, options|
|
|
90
|
-
Kontena::Cli::Grids::Users.new.remove(args[0])
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
command 'vpn create' do |c|
|
|
96
|
-
c.syntax = 'kontena vpn create'
|
|
97
|
-
c.description = 'Create vpn service'
|
|
98
|
-
c.option '--node STRING', String, 'Node name'
|
|
99
|
-
c.option '--ip STRING', String, 'Node ip'
|
|
100
|
-
c.action do |args, options|
|
|
101
|
-
Kontena::Cli::Grids::Vpn.new.create(options)
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
command 'vpn delete' do |c|
|
|
106
|
-
c.syntax = 'kontena vpn delete'
|
|
107
|
-
c.description = 'Delete vpn service'
|
|
108
|
-
c.action do |args, options|
|
|
109
|
-
Kontena::Cli::Grids::Vpn.new.delete
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
command 'vpn config' do |c|
|
|
114
|
-
c.syntax = 'kontena vpn config'
|
|
115
|
-
c.description = 'Show vpn client config'
|
|
116
|
-
c.action do |args, options|
|
|
117
|
-
Kontena::Cli::Grids::Vpn.new.config
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
command 'registry create' do |c|
|
|
122
|
-
c.syntax = 'kontena registry create'
|
|
123
|
-
c.description = 'Create Docker Registry service'
|
|
124
|
-
c.option '--node STRING', String, 'Node name'
|
|
125
|
-
c.option '--s3-access-key STRING', String, 'S3 access key'
|
|
126
|
-
c.option '--s3-secret-key STRING', String, 'S3 secret key'
|
|
127
|
-
c.option '--s3-bucket STRING', String, 'S3 bucket'
|
|
128
|
-
c.option '--s3-region STRING', String, 'S3 region'
|
|
129
|
-
c.option '--s3-encrypt', 'S3 encrypt data'
|
|
130
|
-
c.option '--s3-secure', 'S3 use secure connection'
|
|
131
|
-
c.option '--azure-account-name STRING', String, 'Azure account name'
|
|
132
|
-
c.option '--azure-account-key STRING', String, 'Azure account key'
|
|
133
|
-
c.option '--azure-container-name STRING', String, 'Azure container name'
|
|
134
|
-
c.action do |args, options|
|
|
135
|
-
Kontena::Cli::Grids::Registry.new.create(options)
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
command 'registry delete' do |c|
|
|
140
|
-
c.syntax = 'kontena registry delete'
|
|
141
|
-
c.description = 'Delete Docker Registry service'
|
|
142
|
-
c.action do |args, options|
|
|
143
|
-
Kontena::Cli::Grids::Registry.new.delete
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
command 'external-registry add' do |c|
|
|
148
|
-
c.syntax = 'kontena external-registry add'
|
|
149
|
-
c.description = 'Add external private registry credentials'
|
|
150
|
-
c.action do |args, options|
|
|
151
|
-
Kontena::Cli::Grids::ExternalRegistries.new.add
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
command 'external-registry list' do |c|
|
|
156
|
-
c.syntax = 'kontena external-registry list'
|
|
157
|
-
c.description = 'List external private registries'
|
|
158
|
-
c.action do |args, options|
|
|
159
|
-
Kontena::Cli::Grids::ExternalRegistries.new.list
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
command 'external-registry delete' do |c|
|
|
164
|
-
c.syntax = 'kontena external-registry delete'
|
|
165
|
-
c.description = 'Delete external private registry'
|
|
166
|
-
c.action do |args, options|
|
|
167
|
-
Kontena::Cli::Grids::ExternalRegistries.new.destroy(args[0])
|
|
168
|
-
end
|
|
169
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
require 'kontena/client'
|
|
2
|
-
require_relative '../common'
|
|
3
|
-
|
|
4
|
-
module Kontena::Cli::Grids
|
|
5
|
-
class ExternalRegistries
|
|
6
|
-
include Kontena::Cli::Common
|
|
7
|
-
|
|
8
|
-
def add
|
|
9
|
-
default_url = 'https://index.docker.io/v1/'
|
|
10
|
-
require_api_url
|
|
11
|
-
require_current_grid
|
|
12
|
-
token = require_token
|
|
13
|
-
|
|
14
|
-
username = ask("Username: ")
|
|
15
|
-
password = password("Password: ")
|
|
16
|
-
email = ask("Email: ")
|
|
17
|
-
url = ask("URL [#{default_url}]: ")
|
|
18
|
-
url = default_url if url.strip == ''
|
|
19
|
-
data = { username: username, password: password, email: email, url: url }
|
|
20
|
-
client(token).post("grids/#{current_grid}/external_registries", data)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def destroy(name)
|
|
24
|
-
require_api_url
|
|
25
|
-
token = require_token
|
|
26
|
-
client(token).delete("external_registries/#{current_grid}/#{name}")
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def list
|
|
30
|
-
require_api_url
|
|
31
|
-
require_current_grid
|
|
32
|
-
token = require_token
|
|
33
|
-
result = client(token).get("grids/#{current_grid}/external_registries")
|
|
34
|
-
puts "%-30s %-20s %-30s" % ['Name', 'Username', 'Email']
|
|
35
|
-
result['external_registries'].each { |r|
|
|
36
|
-
puts "%-30.30s %-20.20s %-30.30s" % [r['name'], r['username'], r['email']]
|
|
37
|
-
}
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
require 'kontena/client'
|
|
2
|
-
require_relative '../common'
|
|
3
|
-
|
|
4
|
-
module Kontena::Cli::Grids
|
|
5
|
-
class Grids
|
|
6
|
-
include Kontena::Cli::Common
|
|
7
|
-
|
|
8
|
-
def list
|
|
9
|
-
require_api_url
|
|
10
|
-
|
|
11
|
-
if grids['grids'].size == 0
|
|
12
|
-
print color("You don't have any grids yet. Create first one with 'kontena grids create' command", :yellow)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
puts '%-30.30s %-8s %-12s %-10s' % ['Name', 'Nodes', 'Services', 'Users']
|
|
16
|
-
grids['grids'].each do |grid|
|
|
17
|
-
if grid['id'] == current_grid
|
|
18
|
-
name = "#{grid['name']} *"
|
|
19
|
-
else
|
|
20
|
-
name = grid['name']
|
|
21
|
-
end
|
|
22
|
-
puts '%-30.30s %-8s %-12s %-10s' % [name, grid['node_count'], grid['service_count'], grid['user_count']]
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def use(name)
|
|
27
|
-
require_api_url
|
|
28
|
-
|
|
29
|
-
grid = find_grid_by_name(name)
|
|
30
|
-
if !grid.nil?
|
|
31
|
-
self.current_grid = grid
|
|
32
|
-
puts "Using grid: #{grid['name'].cyan}"
|
|
33
|
-
else
|
|
34
|
-
print color('Could not resolve grid by name. For a list of existing grids please run: kontena grid list', :red)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def show(name)
|
|
40
|
-
require_api_url
|
|
41
|
-
|
|
42
|
-
grid = find_grid_by_name(name)
|
|
43
|
-
print_grid(grid)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def current
|
|
47
|
-
require_api_url
|
|
48
|
-
if current_grid.nil?
|
|
49
|
-
puts 'No grid selected. To select grid, please run: kontena grid use <grid name>'
|
|
50
|
-
else
|
|
51
|
-
grid = client(require_token).get("grids/#{current_grid}")
|
|
52
|
-
print_grid(grid)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def create(name = nil, opts)
|
|
57
|
-
require_api_url
|
|
58
|
-
|
|
59
|
-
token = require_token
|
|
60
|
-
payload = {
|
|
61
|
-
name: name
|
|
62
|
-
}
|
|
63
|
-
payload[:initial_size] = opts.initial_size if opts.initial_size
|
|
64
|
-
grid = client(token).post('grids', payload)
|
|
65
|
-
if grid
|
|
66
|
-
self.current_grid = grid
|
|
67
|
-
puts "Using grid: #{grid['name'].cyan}"
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def destroy(name)
|
|
72
|
-
require_api_url
|
|
73
|
-
token = require_token
|
|
74
|
-
grid = find_grid_by_name(name)
|
|
75
|
-
|
|
76
|
-
if !grid.nil?
|
|
77
|
-
response = client(token).delete("grids/#{grid['id']}")
|
|
78
|
-
if response
|
|
79
|
-
clear_current_grid if grid['id'] == current_grid
|
|
80
|
-
puts "removed #{grid['name'].cyan}"
|
|
81
|
-
end
|
|
82
|
-
else
|
|
83
|
-
print color('Could not resolve grid by name. For a list of existing grids please run: kontena grid list', :red)
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
private
|
|
88
|
-
|
|
89
|
-
##
|
|
90
|
-
# @param [Hash] grid
|
|
91
|
-
def print_grid(grid)
|
|
92
|
-
puts "#{grid['name']}:"
|
|
93
|
-
puts " token: #{grid['token']}"
|
|
94
|
-
puts " users: #{grid['user_count']}"
|
|
95
|
-
puts " nodes: #{grid['node_count']}"
|
|
96
|
-
puts " services: #{grid['service_count']}"
|
|
97
|
-
puts " containers: #{grid['container_count']}"
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def grids
|
|
101
|
-
@grids ||= client(require_token).get('grids')
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def find_grid_by_name(name)
|
|
105
|
-
grids['grids'].find {|grid| grid['name'] == name }
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
require 'kontena/client'
|
|
2
|
-
require_relative '../common'
|
|
3
|
-
|
|
4
|
-
module Kontena::Cli::Grids
|
|
5
|
-
class Users
|
|
6
|
-
include Kontena::Cli::Common
|
|
7
|
-
|
|
8
|
-
def add(email)
|
|
9
|
-
require_api_url
|
|
10
|
-
token = require_token
|
|
11
|
-
data = { email: email }
|
|
12
|
-
client(token).post("grids/#{current_grid}/users", data)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def remove(email)
|
|
16
|
-
require_api_url
|
|
17
|
-
token = require_token
|
|
18
|
-
result = client(token).delete("grids/#{current_grid}/users/#{email}")
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def list
|
|
22
|
-
require_api_url
|
|
23
|
-
token = require_token
|
|
24
|
-
result = client(token).get("grids/#{current_grid}/users")
|
|
25
|
-
puts "%-40s %-40s" % ['Email', 'Name']
|
|
26
|
-
result['users'].each { |user|
|
|
27
|
-
puts "%-40.40s %-40.40s" % [user['email'], user['name']]
|
|
28
|
-
}
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
module Kontena::Cli::Nodes; end;
|
|
2
|
-
|
|
3
|
-
require_relative 'nodes'
|
|
4
|
-
|
|
5
|
-
command 'node list' do |c|
|
|
6
|
-
c.syntax = 'kontena node list'
|
|
7
|
-
c.description = 'List all nodes'
|
|
8
|
-
c.action do |args, options|
|
|
9
|
-
Kontena::Cli::Nodes::Nodes.new.list
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
command 'node show' do |c|
|
|
14
|
-
c.syntax = 'kontena node show'
|
|
15
|
-
c.description = 'Show node details'
|
|
16
|
-
c.action do |args, options|
|
|
17
|
-
Kontena::Cli::Nodes::Nodes.new.show(args[0])
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
command 'node remove' do |c|
|
|
22
|
-
c.syntax = 'kontena node remove'
|
|
23
|
-
c.description = 'Remove node'
|
|
24
|
-
c.action do |args, options|
|
|
25
|
-
Kontena::Cli::Nodes::Nodes.new.destroy(args[0])
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
require 'kontena/client'
|
|
2
|
-
require_relative '../common'
|
|
3
|
-
|
|
4
|
-
module Kontena::Cli::Nodes
|
|
5
|
-
class Nodes
|
|
6
|
-
include Kontena::Cli::Common
|
|
7
|
-
|
|
8
|
-
def list
|
|
9
|
-
require_api_url
|
|
10
|
-
require_current_grid
|
|
11
|
-
token = require_token
|
|
12
|
-
|
|
13
|
-
grids = client(token).get("grids/#{current_grid}/nodes")
|
|
14
|
-
puts "%-30s %-40s %-15s %-30s %-10s" % ['Name', 'OS', 'Driver', 'Labels', 'Status']
|
|
15
|
-
grids['nodes'].each do |node|
|
|
16
|
-
if node['connected']
|
|
17
|
-
status = 'online'
|
|
18
|
-
else
|
|
19
|
-
status = 'offline'
|
|
20
|
-
end
|
|
21
|
-
puts "%-30.30s %-40.40s %-15s %-30.30s %-10s" % [
|
|
22
|
-
node['name'],
|
|
23
|
-
"#{node['os']} (#{node['kernel_version']})",
|
|
24
|
-
node['driver'],
|
|
25
|
-
(node['labels'] || ['-']).join(","),
|
|
26
|
-
status
|
|
27
|
-
]
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def show(id)
|
|
32
|
-
require_api_url
|
|
33
|
-
require_current_grid
|
|
34
|
-
token = require_token
|
|
35
|
-
|
|
36
|
-
node = client(token).get("grids/#{current_grid}/nodes/#{id}")
|
|
37
|
-
puts "#{node['name']}:"
|
|
38
|
-
puts " id: #{node['id']}"
|
|
39
|
-
puts " connected: #{node['connected'] ? 'yes': 'no'}"
|
|
40
|
-
puts " last connect: #{node['updated_at']}"
|
|
41
|
-
puts " public ip: #{node['public_ip']}"
|
|
42
|
-
puts " private ip: #{node['private_ip']}"
|
|
43
|
-
puts " overlay network: 10.81.#{node['node_number']}.0/24"
|
|
44
|
-
puts " os: #{node['os']}"
|
|
45
|
-
puts " driver: #{node['driver']}"
|
|
46
|
-
puts " kernel: #{node['kernel_version']}"
|
|
47
|
-
puts " cpus: #{node['cpus']}"
|
|
48
|
-
puts " memory: #{node['mem_total'] / 1024 / 1024}M"
|
|
49
|
-
puts " labels:"
|
|
50
|
-
if node['labels']
|
|
51
|
-
node['labels'].each{|l| puts " - #{l}"}
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def destroy(id)
|
|
56
|
-
require_api_url
|
|
57
|
-
require_current_grid
|
|
58
|
-
token = require_token
|
|
59
|
-
|
|
60
|
-
node = client(token).delete("grids/#{current_grid}/nodes/#{id}")
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
end
|
|
64
|
-
end
|