kontena-cli 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/kontena +64 -2
  4. data/kontena-cli.gemspec +4 -2
  5. data/lib/kontena/cli/app_command.rb +20 -0
  6. data/lib/kontena/cli/apps/common.rb +53 -0
  7. data/lib/kontena/cli/{stacks/stacks.rb → apps/deploy_command.rb} +17 -31
  8. data/lib/kontena/cli/apps/init_command.rb +101 -0
  9. data/lib/kontena/cli/apps/list_command.rb +41 -0
  10. data/lib/kontena/cli/apps/logs_command.rb +58 -0
  11. data/lib/kontena/cli/apps/remove_command.rb +64 -0
  12. data/lib/kontena/cli/apps/start_command.rb +38 -0
  13. data/lib/kontena/cli/apps/stop_command.rb +38 -0
  14. data/lib/kontena/cli/container_command.rb +9 -0
  15. data/lib/kontena/cli/containers/{containers.rb → exec_command.rb} +5 -5
  16. data/lib/kontena/cli/deploy_command.rb +159 -0
  17. data/lib/kontena/cli/external_registries/add_command.rb +22 -0
  18. data/lib/kontena/cli/external_registries/delete_command.rb +13 -0
  19. data/lib/kontena/cli/external_registries/list_command.rb +16 -0
  20. data/lib/kontena/cli/external_registry_command.rb +14 -0
  21. data/lib/kontena/cli/forgot_password_command.rb +13 -0
  22. data/lib/kontena/cli/grid_command.rb +27 -0
  23. data/lib/kontena/cli/grids/add_user_command.rb +17 -0
  24. data/lib/kontena/cli/grids/{audit_log.rb → audit_log_command.rb} +7 -6
  25. data/lib/kontena/cli/grids/common.rb +24 -0
  26. data/lib/kontena/cli/grids/create_command.rb +26 -0
  27. data/lib/kontena/cli/grids/current_command.rb +18 -0
  28. data/lib/kontena/cli/grids/list_command.rb +26 -0
  29. data/lib/kontena/cli/grids/list_users_command.rb +18 -0
  30. data/lib/kontena/cli/grids/remove_command.rb +26 -0
  31. data/lib/kontena/cli/grids/remove_user_command.rb +16 -0
  32. data/lib/kontena/cli/grids/show_command.rb +19 -0
  33. data/lib/kontena/cli/grids/use_command.rb +21 -0
  34. data/lib/kontena/cli/invite_command.rb +13 -0
  35. data/lib/kontena/cli/login_command.rb +114 -0
  36. data/lib/kontena/cli/logout_command.rb +8 -0
  37. data/lib/kontena/cli/node_command.rb +21 -0
  38. data/lib/kontena/cli/nodes/digital_ocean/create_command.rb +31 -0
  39. data/lib/kontena/cli/nodes/digital_ocean/restart_command.rb +26 -0
  40. data/lib/kontena/cli/nodes/digital_ocean/terminate_command.rb +18 -0
  41. data/lib/kontena/cli/nodes/digital_ocean_command.rb +15 -0
  42. data/lib/kontena/cli/nodes/list_command.rb +28 -0
  43. data/lib/kontena/cli/nodes/remove_command.rb +15 -0
  44. data/lib/kontena/cli/nodes/show_command.rb +31 -0
  45. data/lib/kontena/cli/nodes/update_command.rb +18 -0
  46. data/lib/kontena/cli/nodes/vagrant/create_command.rb +26 -0
  47. data/lib/kontena/cli/nodes/vagrant/restart_command.rb +25 -0
  48. data/lib/kontena/cli/nodes/vagrant/ssh_command.rb +20 -0
  49. data/lib/kontena/cli/nodes/vagrant/start_command.rb +25 -0
  50. data/lib/kontena/cli/nodes/vagrant/stop_command.rb +25 -0
  51. data/lib/kontena/cli/nodes/vagrant/terminate_command.rb +16 -0
  52. data/lib/kontena/cli/nodes/vagrant_command.rb +21 -0
  53. data/lib/kontena/cli/register_command.rb +21 -0
  54. data/lib/kontena/cli/{grids/registry.rb → registry/create_command.rb} +32 -35
  55. data/lib/kontena/cli/registry/delete_command.rb +15 -0
  56. data/lib/kontena/cli/registry_command.rb +11 -0
  57. data/lib/kontena/cli/reset_password_command.rb +17 -0
  58. data/lib/kontena/cli/service_command.rb +33 -0
  59. data/lib/kontena/cli/services/container_command.rb +9 -0
  60. data/lib/kontena/cli/services/containers_command.rb +31 -0
  61. data/lib/kontena/cli/services/create_command.rb +62 -0
  62. data/lib/kontena/cli/services/delete_command.rb +17 -0
  63. data/lib/kontena/cli/services/deploy_command.rb +23 -0
  64. data/lib/kontena/cli/services/list_command.rb +20 -0
  65. data/lib/kontena/cli/services/logs_command.rb +51 -0
  66. data/lib/kontena/cli/services/restart_command.rb +16 -0
  67. data/lib/kontena/cli/services/scale_command.rb +20 -0
  68. data/lib/kontena/cli/services/services_helper.rb +94 -0
  69. data/lib/kontena/cli/services/show_command.rb +17 -0
  70. data/lib/kontena/cli/services/start_command.rb +16 -0
  71. data/lib/kontena/cli/services/{stats.rb → stats_command.rb} +11 -10
  72. data/lib/kontena/cli/services/stop_command.rb +16 -0
  73. data/lib/kontena/cli/services/update_command.rb +51 -0
  74. data/lib/kontena/cli/verify_account_command.rb +13 -0
  75. data/lib/kontena/cli/version_command.rb +8 -0
  76. data/lib/kontena/cli/vpn/config_command.rb +12 -0
  77. data/lib/kontena/cli/{grids/vpn.rb → vpn/create_command.rb} +12 -29
  78. data/lib/kontena/cli/vpn/delete_command.rb +15 -0
  79. data/lib/kontena/cli/vpn_command.rb +13 -0
  80. data/lib/kontena/cli/whoami_command.rb +19 -0
  81. data/lib/kontena/client.rb +14 -11
  82. data/lib/kontena/machine/common.rb +17 -0
  83. data/lib/kontena/machine/digital_ocean.rb +11 -0
  84. data/lib/kontena/machine/digital_ocean/cloudinit.yml +66 -0
  85. data/lib/kontena/machine/digital_ocean/node_destroyer.rb +38 -0
  86. data/lib/kontena/machine/digital_ocean/node_provisioner.rb +74 -0
  87. data/lib/kontena/machine/random_name.rb +42 -0
  88. data/lib/kontena/machine/vagrant.rb +10 -0
  89. data/lib/kontena/machine/vagrant/Vagrantfile.coreos.rb.erb +32 -0
  90. data/lib/kontena/machine/vagrant/cloudinit.yml +65 -0
  91. data/lib/kontena/machine/vagrant/node_destroyer.rb +36 -0
  92. data/lib/kontena/machine/vagrant/node_provisioner.rb +68 -0
  93. data/lib/kontena/scripts/completer +5 -5
  94. data/spec/kontena/cli/app/deploy_command_spec.rb +227 -0
  95. data/spec/kontena/cli/deploy_command_spec.rb +213 -0
  96. data/spec/kontena/cli/login_command_spec.rb +22 -0
  97. data/spec/kontena/cli/register_command_spec.rb +57 -0
  98. data/spec/spec_helper.rb +5 -1
  99. metadata +132 -36
  100. data/lib/kontena/cli/commands.rb +0 -20
  101. data/lib/kontena/cli/containers/commands.rb +0 -12
  102. data/lib/kontena/cli/grids/commands.rb +0 -169
  103. data/lib/kontena/cli/grids/external_registries.rb +0 -40
  104. data/lib/kontena/cli/grids/grids.rb +0 -108
  105. data/lib/kontena/cli/grids/users.rb +0 -32
  106. data/lib/kontena/cli/nodes/commands.rb +0 -27
  107. data/lib/kontena/cli/nodes/nodes.rb +0 -64
  108. data/lib/kontena/cli/server/commands.rb +0 -69
  109. data/lib/kontena/cli/server/server.rb +0 -45
  110. data/lib/kontena/cli/server/user.rb +0 -174
  111. data/lib/kontena/cli/services/commands.rb +0 -138
  112. data/lib/kontena/cli/services/containers.rb +0 -24
  113. data/lib/kontena/cli/services/logs.rb +0 -44
  114. data/lib/kontena/cli/services/services.rb +0 -175
  115. data/lib/kontena/cli/stacks/commands.rb +0 -13
  116. data/spec/kontena/cli/server/user_spec.rb +0 -59
  117. data/spec/kontena/cli/stacks/stacks_spec.rb +0 -212
@@ -0,0 +1,15 @@
1
+ module Kontena::Cli::Registry
2
+ class DeleteCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ def execute
6
+ require_api_url
7
+ token = require_token
8
+
9
+ registry = client(token).get("services/#{current_grid}/registry") rescue nil
10
+ abort("Docker Registry service does not exist") if registry.nil?
11
+
12
+ client(token).delete("services/#{current_grid}/registry")
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require_relative 'registry/create_command'
2
+ require_relative 'registry/delete_command'
3
+
4
+ class Kontena::Cli::RegistryCommand < Clamp::Command
5
+
6
+ subcommand "create", "Create Docker image registry service", Kontena::Cli::Registry::CreateCommand
7
+ subcommand "delete", "Delete Docker image registry service", Kontena::Cli::Registry::DeleteCommand
8
+
9
+ def execute
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ class Kontena::Cli::ResetPasswordCommand < Clamp::Command
2
+ include Kontena::Cli::Common
3
+
4
+ parameter "TOKEN", "Password reset token"
5
+
6
+ def execute
7
+ require_api_url
8
+ password = password("Password: ")
9
+ password2 = password("Password again: ")
10
+ if password != password2
11
+ abort("Passwords don't match")
12
+ end
13
+ params = {token: token, password: password}
14
+ client.put('user/password_reset', params)
15
+ puts 'Password is now changed. To login with the new password, please run: kontena login'
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ require_relative 'services/list_command'
2
+ require_relative 'services/show_command'
3
+ require_relative 'services/update_command'
4
+ require_relative 'services/deploy_command'
5
+ require_relative 'services/stop_command'
6
+ require_relative 'services/start_command'
7
+ require_relative 'services/restart_command'
8
+ require_relative 'services/create_command'
9
+ require_relative 'services/scale_command'
10
+ require_relative 'services/delete_command'
11
+ require_relative 'services/containers_command'
12
+ require_relative 'services/logs_command'
13
+ require_relative 'services/stats_command'
14
+
15
+ class Kontena::Cli::ServiceCommand < Clamp::Command
16
+
17
+ subcommand "list", "List services", Kontena::Cli::Services::ListCommand
18
+ subcommand "create", "Create a new service", Kontena::Cli::Services::CreateCommand
19
+ subcommand "show", "Show service details", Kontena::Cli::Services::ShowCommand
20
+ subcommand "update", "Update service configuration", Kontena::Cli::Services::UpdateCommand
21
+ subcommand "deploy", "Deploy service", Kontena::Cli::Services::DeployCommand
22
+ subcommand "stop", "Stop service", Kontena::Cli::Services::StopCommand
23
+ subcommand "start", "Start service", Kontena::Cli::Services::StartCommand
24
+ subcommand "restart", "Restart service", Kontena::Cli::Services::RestartCommand
25
+ subcommand "scale", "Scale service", Kontena::Cli::Services::ScaleCommand
26
+ subcommand "delete", "Delete service", Kontena::Cli::Services::DeleteCommand
27
+ subcommand "containers", "List service containers", Kontena::Cli::Services::ContainersCommand
28
+ subcommand "logs", "Show service logs", Kontena::Cli::Services::LogsCommand
29
+ subcommand "stats", "Show service statistics", Kontena::Cli::Services::StatsCommand
30
+
31
+ def execute
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ require_relative 'containers/exec_command'
2
+
3
+ class Kontena::Cli::ContainerCommand < Clamp::Command
4
+
5
+ subcommand "exec", "Execute command inside a container", Kontena::Cli::Containers::ExecCommand
6
+
7
+ def execute
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class ContainersCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+
10
+ def execute
11
+ require_api_url
12
+ token = require_token
13
+
14
+ result = client(token).get("services/#{current_grid}/#{name}/containers")
15
+ result['containers'].each do |container|
16
+ puts "#{container['id']}:"
17
+ puts " rev: #{container['deploy_rev']}"
18
+ puts " node: #{container['node']['name']}"
19
+ puts " dns: #{container['name']}.#{current_grid}.kontena.local"
20
+ puts " ip: #{container['overlay_cidr'].split('/')[0]}"
21
+ puts " public ip: #{container['node']['public_ip']}"
22
+ if container['status'] == 'unknown'
23
+ puts " status: #{container['status'].colorize(:yellow)}"
24
+ else
25
+ puts " status: #{container['status']}"
26
+ end
27
+ puts ""
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,62 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class CreateCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+ parameter "IMAGE", "Service image (example: redis:3.0)"
10
+
11
+ option ["-p", "--ports"], "PORTS", "Publish a service's port to the host", multivalued: true
12
+ option ["-e", "--env"], "ENV", "Set environment variables", multivalued: true
13
+ option ["-l", "--link"], "LINK", "Add link to another service in the form of name:alias", multivalued: true
14
+ option ["-v", "--volume"], "VOLUME", "Add a volume or bind mount it from the host", multivalued: true
15
+ option "--volumes-from", "VOLUMES_FROM", "Mount volumes from another container", multivalued: true
16
+ option ["-a", "--affinity"], "AFFINITY", "Set service affinity", multivalued: true
17
+ option ["-c", "--cpu-shares"], "CPU_SHARES", "CPU shares (relative weight)"
18
+ option ["-m", "--memory"], "MEMORY", "Memory limit (format: <number><optional unit>, where unit = b, k, m or g)"
19
+ option ["--memory-swap"], "MEMORY_SWAP", "Total memory usage (memory + swap), set \'-1\' to disable swap (format: <number><optional unit>, where unit = b, k, m or g)"
20
+ option "--cmd", "CMD", "Command to execute"
21
+ option "--instances", "INSTANCES", "How many instances should be deployed"
22
+ option ["-u", "--user"], "USER", "Username who executes first process inside container"
23
+ option "--stateful", :flag, "Set service as stateful", default: false
24
+ option "--cap-add", "CAP_ADD", "Add capabitilies", multivalued: true
25
+ option "--cap-drop", "CAP_DROP", "Drop capabitilies", multivalued: true
26
+
27
+ def execute
28
+ require_api_url
29
+ token = require_token
30
+ data = {
31
+ name: name,
32
+ image: image,
33
+ stateful: stateful?
34
+ }
35
+ data.merge!(parse_service_data_from_options)
36
+ create_service(token, current_grid, data)
37
+ end
38
+
39
+ ##
40
+ # parse given options to hash
41
+ # @return [Hash]
42
+ def parse_service_data_from_options
43
+ data = {}
44
+ data[:ports] = parse_ports(ports_list) if ports_list
45
+ data[:links] = parse_links(link_list) if link_list
46
+ data[:volumes] = volume_list if volume_list
47
+ data[:volumes_from] = volumes_from_list if volumes_from_list
48
+ data[:memory] = parse_memory(memory) if memory
49
+ data[:memory_swap] = parse_memory(memory_swap) if memory_swap
50
+ data[:cpu_shares] = cpu_shares if cpu_shares
51
+ data[:affinity] = affinity_list if affinity_list
52
+ data[:env] = env_list if env_list
53
+ data[:container_count] = instances if instances
54
+ data[:cmd] = cmd.split(" ") if cmd
55
+ data[:user] = user if user
56
+ data[:image] = image if image
57
+ data[:cap_add] = cap_add_list if cap_add_list
58
+ data[:cap_drop] = cap_drop_list if cap_drop_list
59
+ data
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,17 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class DeleteCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+
10
+ def execute
11
+ require_api_url
12
+ token = require_token
13
+
14
+ result = client(token).delete("services/#{parse_service_id(name)}")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class DeployCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+ option '--strategy', 'STRATEGY', 'Define deploy strategy (ha / random)'
10
+ option '--wait-for-port', 'WAIT_FOR_PORT', 'Wait for given container port to open before deploying next container'
11
+
12
+ def execute
13
+ require_api_url
14
+ token = require_token
15
+ service_id = name
16
+ data = {}
17
+ data[:strategy] = strategy if strategy
18
+ data[:wait_for_port] = wait_for_port if wait_for_port
19
+ deploy_service(token, service_id, data)
20
+ show_service(token, service_id)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class ListCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ def execute
9
+ require_api_url
10
+ token = require_token
11
+
12
+ grids = client(token).get("grids/#{current_grid}/services")
13
+ puts "%-30.30s %-40.40s %-10s %-8s" % ['NAME', 'IMAGE', 'INSTANCES', 'STATEFUL']
14
+ grids['services'].each do |service|
15
+ state = service['stateful'] ? 'yes' : 'no'
16
+ puts "%-30.30s %-40.40s %-10.10s %-8s" % [service['name'], service['image'], service['container_count'], state]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class LogsCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+ option ["-f", "--follow"], :flag, "Follow (tail) logs", default: false
10
+ option ["-s", "--search"], "SEARCH", "Search from logs"
11
+ option ["-c", "--container"], "CONTAINER", "Show only specified container logs"
12
+
13
+ def execute
14
+ require_api_url
15
+ token = require_token
16
+ last_id = nil
17
+ loop do
18
+ query_params = []
19
+ query_params << "from=#{last_id}" unless last_id.nil?
20
+ query_params << "search=#{search}" if search
21
+ query_params << "container=#{container}" if container
22
+
23
+ result = client(token).get("services/#{current_grid}/#{name}/container_logs?#{query_params.join('&')}")
24
+ result['logs'].each do |log|
25
+ color = color_for_container(log['name'])
26
+ puts "#{log['name'].colorize(color)} | #{log['data']}"
27
+ last_id = log['id']
28
+ end
29
+ break unless follow?
30
+ sleep(2)
31
+ end
32
+ end
33
+
34
+ def color_for_container(container_id)
35
+ color_maps[container_id] = colors.shift unless color_maps[container_id]
36
+ color_maps[container_id].to_sym
37
+ end
38
+
39
+ def color_maps
40
+ @color_maps ||= {}
41
+ end
42
+
43
+ def colors
44
+ if(@colors.nil? || @colors.size == 0)
45
+ @colors = [:green, :yellow, :magenta, :cyan, :red,
46
+ :light_green, :light_yellow, :ligh_magenta, :light_cyan, :light_red]
47
+ end
48
+ @colors
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class RestartCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+
10
+ def execute
11
+ require_api_url
12
+ token = require_token
13
+ result = client(token).post("services/#{parse_service_id(name)}/restart", {})
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class ScaleCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+ parameter "INSTANCES", "Scales service to given number of instances"
10
+ option '--strategy', 'STRATEGY', 'Define deploy strategy (ha / random)'
11
+
12
+ def execute
13
+ token = require_token
14
+ client(token).put("services/#{parse_service_id(name)}", {container_count: instances})
15
+ opts = {}
16
+ opts[:strategy] = strategy if strategy
17
+ deploy_service(token, name, opts)
18
+ end
19
+ end
20
+ end
@@ -29,6 +29,79 @@ module Kontena
29
29
  client(token).get("services/#{param}")
30
30
  end
31
31
 
32
+ # @param [String] token
33
+ # @param [String] service_id
34
+ def show_service(token, service_id)
35
+ service = get_service(token, service_id)
36
+ grid = service['id'].split('/')[0]
37
+ puts "#{service['id']}:"
38
+ puts " status: #{service['state'] }"
39
+ puts " stateful: #{service['stateful'] == true ? 'yes' : 'no' }"
40
+ puts " scaling: #{service['container_count'] }"
41
+ puts " image: #{service['image']}"
42
+ puts " dns: #{service['name']}.#{grid}.kontena.local"
43
+
44
+ puts " affinity: "
45
+ service['affinity'].to_a.each do |a|
46
+ puts " - #{a}"
47
+ end
48
+
49
+ if service['cmd']
50
+ puts " cmd: #{service['cmd'].join(' ')}"
51
+ else
52
+ puts " cmd: "
53
+ end
54
+
55
+ puts " env: "
56
+ service['env'].to_a.each{|e| puts " - #{e}"}
57
+
58
+ puts " ports:"
59
+ service['ports'].to_a.each do |p|
60
+ puts " - #{p['node_port']}:#{p['container_port']}/#{p['protocol']}"
61
+ end
62
+
63
+ puts " volumes:"
64
+ service['volumes'].to_a.each do |v|
65
+ puts " - #{v}"
66
+ end
67
+
68
+ puts " volumes_from:"
69
+ service['volumes_from'].to_a.each do |v|
70
+ puts " - #{v}"
71
+ end
72
+
73
+ puts " links: "
74
+ service['links'].to_a.each do |l|
75
+ puts " - #{l['alias']}"
76
+ end
77
+
78
+ puts " cap_add:"
79
+ service['cap_add'].to_a.each do |c|
80
+ puts " - #{c}"
81
+ end
82
+
83
+ puts " cap_drop:"
84
+ service['cap_drop'].to_a.each do |c|
85
+ puts " - #{c}"
86
+ end
87
+
88
+ puts " containers:"
89
+ result = client(token).get("services/#{parse_service_id(service_id)}/containers")
90
+ result['containers'].each do |container|
91
+ puts " #{container['name']}:"
92
+ puts " rev: #{container['deploy_rev']}"
93
+ puts " node: #{container['node']['name']}"
94
+ puts " dns: #{container['name']}.#{grid}.kontena.local"
95
+ puts " ip: #{container['overlay_cidr'].split('/')[0]}"
96
+ puts " public ip: #{container['node']['public_ip']}"
97
+ if container['status'] == 'unknown'
98
+ puts " status: #{container['status'].colorize(:yellow)}"
99
+ else
100
+ puts " status: #{container['status']}"
101
+ end
102
+ end
103
+ end
104
+
32
105
  # @param [String] token
33
106
  # @param [String] service_id
34
107
  # @param [Hash] data
@@ -44,6 +117,27 @@ module Kontena
44
117
  puts ''
45
118
  end
46
119
 
120
+ # @param [String] token
121
+ # @param [String] service_id
122
+ def start_service(token, service_id)
123
+ param = parse_service_id(service_id)
124
+ client(token).post("services/#{param}/start", {})
125
+ end
126
+
127
+ # @param [String] token
128
+ # @param [String] service_id
129
+ def stop_service(token, service_id)
130
+ param = parse_service_id(service_id)
131
+ client(token).post("services/#{param}/stop", {})
132
+ end
133
+
134
+ # @param [String] token
135
+ # @param [String] service_id
136
+ def delete_service(token, service_id)
137
+ param = parse_service_id(service_id)
138
+ client(token).delete("services/#{param}")
139
+ end
140
+
47
141
  # @param [String] service_id
48
142
  # @return [String]
49
143
  def parse_service_id(service_id)