vagrant-service-manager 1.0.2 → 1.1.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ Feature: Command output from env command
2
+ service-manager should return the correct output from env commands
3
+
4
+ @env
5
+ Scenario Outline: Boot and execute env commands
6
+ Given box is <box>
7
+ And provider is <provider>
8
+ And a file named "Vagrantfile" with:
9
+ """
10
+ require 'vagrant-libvirt'
11
+
12
+ Vagrant.configure('2') do |config|
13
+ config.vm.box = '<box>'
14
+ config.vm.box_url = 'file://../boxes/<box>-<provider>.box'
15
+ config.vm.network :private_network, ip: '<ip>'
16
+ config.vm.synced_folder '.', '/vagrant', disabled: true
17
+ config.servicemanager.services = 'docker'
18
+ end
19
+ """
20
+
21
+ When I successfully run `bundle exec vagrant up --provider <provider>`
22
+ And I successfully run `bundle exec vagrant service-manager env`
23
+ Then stdout from "bundle exec vagrant service-manager env" should be evaluable in a shell
24
+
25
+ When I successfully run `bundle exec vagrant service-manager env --script-readable`
26
+ Then stdout from "bundle exec vagrant service-manager env --script-readable" should be script readable
27
+
28
+ When I successfully run `bundle exec vagrant service-manager env docker`
29
+ Then stdout from "bundle exec vagrant service-manager env docker" should be evaluable in a shell
30
+ And stdout from "bundle exec vagrant service-manager env docker" should contain "export DOCKER_HOST=tcp://<ip>:2376"
31
+ And stdout from "bundle exec vagrant service-manager env docker" should match /export DOCKER_CERT_PATH=.*\/.vagrant\/machines\/cdk\/virtualbox\/docker/
32
+ And stdout from "bundle exec vagrant service-manager env docker" should contain "export DOCKER_TLS_VERIFY=1"
33
+ And stdout from "bundle exec vagrant service-manager env docker" should contain "export DOCKER_API_VERSION=1.21"
34
+ And stdout from "bundle exec vagrant service-manager env docker" should match /# eval "\$\(vagrant service-manager env docker\)"/
35
+
36
+ When I successfully run `bundle exec vagrant service-manager env docker --script-readable`
37
+ Then stdout from "bundle exec vagrant service-manager env docker --script-readable" should be script readable
38
+
39
+ When I run `bundle exec vagrant service-manager env openshift`
40
+ Then the exit status should be 126
41
+ And stderr from "bundle exec vagrant service-manager env openshift" should contain:
42
+ """
43
+ # OpenShift service is not running in the vagrant box.
44
+ """
45
+
46
+ Examples:
47
+ | box | provider | ip |
48
+ | cdk | virtualbox | 10.10.10.42 |
49
+ | adb | virtualbox | 10.10.10.42 |
50
+ | cdk | libvirt | 10.10.10.42 |
51
+ | adb | libvirt | 10.10.10.42 |
@@ -0,0 +1,86 @@
1
+ Feature: Command output from help command
2
+ service-manager should return the correct output from its help commands
3
+
4
+ @help
5
+ Scenario Outline: Boot and execute help commands
6
+ Given box is <box>
7
+ And provider is <provider>
8
+ And a file named "Vagrantfile" with:
9
+ """
10
+ require 'vagrant-libvirt'
11
+
12
+ Vagrant.configure('2') do |config|
13
+ config.vm.box = '<box>'
14
+ config.vm.box_url = 'file://../boxes/<box>-<provider>.box'
15
+ config.vm.network :private_network, ip: '<ip>'
16
+ config.vm.synced_folder '.', '/vagrant', disabled: true
17
+ config.servicemanager.services = 'docker'
18
+ end
19
+ """
20
+
21
+ When I successfully run `bundle exec vagrant up --provider <provider>`
22
+ And I successfully run `bundle exec vagrant service-manager --help`
23
+ Then stdout from "bundle exec vagrant service-manager --help" should contain:
24
+ """
25
+ Usage: vagrant service-manager <command> [options]
26
+
27
+ Commands:
28
+ env displays connection information for services in the box
29
+ box displays box related information like version, release, IP etc
30
+ restart restarts the given service in the box
31
+ start starts the given service in the box
32
+ stop stops the given service in the box
33
+ status list services and their running state
34
+
35
+ Options:
36
+ -h, --help print this help
37
+
38
+ For help on any individual command run `vagrant service-manager COMMAND -h`
39
+ """
40
+
41
+ When I successfully run `bundle exec vagrant service-manager -h`
42
+ Then stdout from "bundle exec vagrant service-manager -h" should contain:
43
+ """
44
+ Usage: vagrant service-manager <command> [options]
45
+
46
+ Commands:
47
+ env displays connection information for services in the box
48
+ box displays box related information like version, release, IP etc
49
+ restart restarts the given service in the box
50
+ start starts the given service in the box
51
+ stop stops the given service in the box
52
+ status list services and their running state
53
+
54
+ Options:
55
+ -h, --help print this help
56
+
57
+ For help on any individual command run `vagrant service-manager COMMAND -h`
58
+ """
59
+
60
+ When I run `bundle exec vagrant service-manager`
61
+ Then the exit status should be 1
62
+ And stdout from "bundle exec vagrant service-manager -h" should contain:
63
+ """
64
+ Usage: vagrant service-manager <command> [options]
65
+
66
+ Commands:
67
+ env displays connection information for services in the box
68
+ box displays box related information like version, release, IP etc
69
+ restart restarts the given service in the box
70
+ start starts the given service in the box
71
+ stop stops the given service in the box
72
+ status list services and their running state
73
+
74
+ Options:
75
+ -h, --help print this help
76
+
77
+ For help on any individual command run `vagrant service-manager COMMAND -h`
78
+ """
79
+
80
+ Examples:
81
+ | box | provider | ip |
82
+ | cdk | virtualbox | 10.10.10.42 |
83
+ | adb | virtualbox | 10.10.10.42 |
84
+ | cdk | libvirt | 10.10.10.42 |
85
+ | adb | libvirt | 10.10.10.42 |
86
+
@@ -0,0 +1,51 @@
1
+ Feature: Command output from various OpenShift related commands
2
+ service-manager should return the correct output from commands affecting OpenShift
3
+
4
+ @openshift
5
+ Scenario Outline: Boot and execute commands
6
+ Given box is <box>
7
+ And provider is <provider>
8
+ And a file named "Vagrantfile" with:
9
+ """
10
+ require 'vagrant-libvirt'
11
+
12
+ Vagrant.configure('2') do |config|
13
+ config.vm.box = '<box>'
14
+ config.vm.box_url = 'file://../boxes/<box>-<provider>.box'
15
+ config.vm.network :private_network, ip: '<ip>'
16
+ config.vm.synced_folder '.', '/vagrant', disabled: true
17
+ config.servicemanager.services = 'docker'
18
+ config.vm.provision "shell", inline: <<-SHELL
19
+ systemctl enable openshift 2>&1
20
+ systemctl start openshift | true
21
+ SHELL
22
+ end
23
+ """
24
+
25
+ When I successfully run `bundle exec vagrant up --provider <provider>`
26
+ # TODO, for some reason I can not use 'successfully' here. Seems the exit code is not 0 in this case!?
27
+ And I run `bundle exec vagrant service-manager env openshift`
28
+ Then stdout from "bundle exec vagrant service-manager env openshift" should be evaluable in a shell
29
+ And stdout from "bundle exec vagrant service-manager env openshift" should contain:
30
+ """
31
+ # You can access the OpenShift console on: https://<ip>:8443/console
32
+ # To use OpenShift CLI, run: oc login https://<ip>:8443
33
+ export OPENSHIFT_URL=https://<ip>:8443
34
+ export OPENSHIFT_WEB_CONSOLE=https://<ip>:8443/console
35
+
36
+ # run following command to configure your shell:
37
+ # eval "$(vagrant service-manager env openshift)"
38
+ """
39
+
40
+ When I successfully run `bundle exec vagrant service-manager env openshift --script-readable`
41
+ Then stdout from "bundle exec vagrant service-manager env openshift --script-readable" should be script readable
42
+ And stdout from "bundle exec vagrant service-manager env openshift --script-readable" should contain:
43
+ """
44
+ OPENSHIFT_URL=https://<ip>:8443
45
+ OPENSHIFT_WEB_CONSOLE=https://<ip>:8443/console
46
+ """
47
+
48
+ Examples:
49
+ | box | provider | ip |
50
+ | cdk | virtualbox | 10.10.10.42 |
51
+ | cdk | libvirt | 10.10.10.42 |
@@ -0,0 +1,40 @@
1
+ Feature: Command output from service operations like stop/start/restart
2
+ service-manager should return the correct exit code from stop/start/restart command
3
+
4
+ @operation
5
+ Scenario Outline: Boot and execute service operations like stop/start/restart
6
+ Given box is <box>
7
+ And provider is <provider>
8
+ And a file named "Vagrantfile" with:
9
+ """
10
+ require 'vagrant-libvirt'
11
+
12
+ Vagrant.configure('2') do |config|
13
+ config.vm.box = '<box>'
14
+ config.vm.box_url = 'file://../boxes/<box>-<provider>.box'
15
+ config.vm.network :private_network, ip: '<ip>'
16
+ config.vm.synced_folder '.', '/vagrant', disabled: true
17
+ config.servicemanager.services = 'docker'
18
+ end
19
+ """
20
+
21
+ When I successfully run `bundle exec vagrant up --provider <provider>`
22
+ And the "docker" service is running
23
+ And I successfully run `bundle exec vagrant service-manager stop docker`
24
+ Then the service "docker" should be stopped
25
+
26
+ When the "docker" service is not running
27
+ And I successfully run `bundle exec vagrant service-manager start docker`
28
+ Then the service "docker" should be running
29
+
30
+ When the "docker" service is running
31
+ And I successfully run `bundle exec vagrant service-manager restart docker`
32
+ Then the service "docker" should be running
33
+ And have a new pid for "docker" service
34
+
35
+ Examples:
36
+ | box | provider | ip |
37
+ | cdk | virtualbox | 10.10.10.42 |
38
+ | adb | virtualbox | 10.10.10.42 |
39
+ | cdk | libvirt | 10.10.10.42 |
40
+ | adb | libvirt | 10.10.10.42 |
@@ -0,0 +1,31 @@
1
+ Feature: Command output from status command
2
+ service-manager should return the correct output from status command
3
+
4
+ @status
5
+ Scenario Outline: Boot and execute status command
6
+ Given box is <box>
7
+ And provider is <provider>
8
+ And a file named "Vagrantfile" with:
9
+ """
10
+ require 'vagrant-libvirt'
11
+
12
+ Vagrant.configure('2') do |config|
13
+ config.vm.box = '<box>'
14
+ config.vm.box_url = 'file://../boxes/<box>-<provider>.box'
15
+ config.vm.network :private_network, ip: '<ip>'
16
+ config.vm.synced_folder '.', '/vagrant', disabled: true
17
+ config.servicemanager.services = 'docker'
18
+ end
19
+ """
20
+
21
+ When I successfully run `bundle exec vagrant up --provider <provider>`
22
+ And I successfully run `bundle exec vagrant service-manager status`
23
+ Then stdout from "bundle exec vagrant service-manager status" should contain "docker - running"
24
+ Then stdout from "bundle exec vagrant service-manager status" should contain "openshift - stopped"
25
+
26
+ Examples:
27
+ | box | provider | ip |
28
+ | cdk | virtualbox | 10.10.10.42 |
29
+ | adb | virtualbox | 10.10.10.42 |
30
+ | cdk | libvirt | 10.10.10.42 |
31
+ | adb | libvirt | 10.10.10.42 |
@@ -0,0 +1,138 @@
1
+ require 'aruba/cucumber'
2
+ require 'komenda'
3
+
4
+ ###############################################################################
5
+ # Aruba config and Cucumber hooks
6
+ ###############################################################################
7
+
8
+ Aruba.configure do |config|
9
+ config.exit_timeout = 300
10
+ config.activate_announcer_on_command_failure = [:stdout, :stderr]
11
+ config.working_directory = 'build/aruba'
12
+ end
13
+
14
+ After do |_scenario|
15
+ if File.exist?(File.join(aruba.config.working_directory, 'Vagrantfile'))
16
+ Komenda.run('bundle exec vagrant destroy -f', cwd: aruba.config.working_directory, fail_on_fail: true)
17
+ if ENV.has_key?('CUCUMBER_RUN_PROVIDER')
18
+ # if we have more than one provider we need to wait between scenarios in order to allow for proper cleanup/shutdown
19
+ # of virtualization framework
20
+ sleep 10
21
+ end
22
+ end
23
+ end
24
+
25
+ Before do |scenario|
26
+ @scenario_name = scenario.name
27
+ end
28
+
29
+ ###############################################################################
30
+ # Some helper functions
31
+ ###############################################################################
32
+ # When running Vagrant from within a plugin development environment, Vagrant
33
+ # prints a warning which we can ignore
34
+ def stdout_without_plugin_context(raw_stdout)
35
+ raw_stdout.lines.to_a[6..-1].join
36
+ end
37
+
38
+ def output_is_evaluable(raw_stdout)
39
+ console_out = stdout_without_plugin_context(raw_stdout)
40
+ console_out.each_line do |line|
41
+ expect(line).to match(/^#.*|^export [a-zA-Z_]+=.*|^\n/)
42
+ end
43
+ end
44
+
45
+ def output_is_script_readable(raw_stdout)
46
+ console_out = stdout_without_plugin_context(raw_stdout)
47
+ console_out.each_line do |line|
48
+ expect(line).to match(/^[a-zA-Z_]+=.*$/)
49
+ end
50
+ end
51
+
52
+ def extract_process_id(data)
53
+ tokens = data.scan(/Main PID: ([0-9]+) \(/)
54
+ tokens.last.first.to_i unless tokens.empty?
55
+ end
56
+
57
+ ###############################################################################
58
+ # Some shared step definitions
59
+ ##############################################################################
60
+ Given /provider is (.*)/ do |current_provider|
61
+ requested_provider = ENV.has_key?('PROVIDER') ? ENV['PROVIDER']: 'virtualbox'
62
+
63
+ unless requested_provider.include?(current_provider)
64
+ #puts "Skipping scenario '#{@scenario_name}' for provider '#{current_provider}', since this provider is not explicitly enabled via environment variable 'PROVIDER'"
65
+ skip_this_scenario
66
+ end
67
+ end
68
+
69
+ Given /box is (.*)/ do |current_box|
70
+ requested_box = ENV.has_key?('BOX') ? ENV['BOX']: 'adb'
71
+
72
+ unless requested_box.include?(current_box)
73
+ #puts "Skipping scenario '#{@scenario_name}' for box '#{current_box}', since this box is not explicitly enabled via environment variable 'BOX'"
74
+ skip_this_scenario
75
+ end
76
+ end
77
+
78
+ Then(/^stdout from "([^"]*)" should be evaluable in a shell$/) do |cmd|
79
+ output_is_evaluable(aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)).send(:stdout))
80
+ end
81
+
82
+ Then(/^stdout from "([^"]*)" should be script readable$/) do |cmd|
83
+ output_is_script_readable(aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)).send(:stdout))
84
+ end
85
+
86
+ Then(/^stdout from "([^"]*)" should match \/(.*)\/$/) do |cmd, regexp|
87
+ aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd)).send(:stdout) =~ /#{regexp}/
88
+ end
89
+
90
+ # track service process ID
91
+ @service_current_process_id = -1
92
+
93
+ # Note: Only for services supported through systemctl. Not for 'kubernetes'.
94
+ Then(/^the service "([^"]*)" should be ([^"]*)$/) do |service, operation|
95
+ run("vagrant ssh -c \"sudo systemctl status #{service}\"")
96
+
97
+ if ['running', 'restarted'].include? operation
98
+ exit_code = 0
99
+ regexp = /Active: active \(running\)/
100
+ elsif operation == 'stopped'
101
+ exit_code = 3
102
+ regexp = /Active: inactive\(dead\)/
103
+ end
104
+
105
+ expect(last_command_started).to have_exit_status(exit_code)
106
+ aruba.command_monitor.find(Aruba.platform.detect_ruby(last_command_started)).send(:stdout) =~ regexp
107
+ end
108
+
109
+ # Note: Only for services supported through systemctl. Not for 'kubernetes'.
110
+ When(/^the "([^"]*)" service is( not)? running$/) do |service, negated|
111
+ run("vagrant ssh -c \"sudo systemctl status #{service}\"")
112
+
113
+ if negated
114
+ expect(last_command_started).to have_exit_status(3)
115
+ else
116
+ expect(last_command_started).to have_exit_status(0)
117
+ stdout = aruba.command_monitor.find(Aruba.platform.detect_ruby(last_command_started)).send(:stdout)
118
+ @service_current_process_id = extract_process_id(stdout)
119
+ end
120
+ end
121
+
122
+ # Note: Only for services supported through systemctl. Not for 'kubernetes'.
123
+ When(/^the "([^"]*)" service is \*not\* running$/) do |service|
124
+ # Stop the service
125
+ run("vagrant ssh -c \"sudo systemctl stop #{service}\"")
126
+
127
+ expect(last_command_started).to have_exit_status(0)
128
+ step "the \"docker\" service is not running"
129
+ end
130
+
131
+ # Note: Only for services supported through systemctl. Not for 'kubernetes'.
132
+ Then(/^have a new pid for "([^"]*)" service$/) do |service|
133
+ run("vagrant ssh -c \"sudo systemctl status #{service}\"")
134
+
135
+ expect(last_command_started).to have_exit_status(0)
136
+ stdout = aruba.command_monitor.find(Aruba.platform.detect_ruby(last_command_started)).send(:stdout)
137
+ expect(@service_current_process_id).not_to eq(extract_process_id(stdout))
138
+ end
@@ -1,4 +1,4 @@
1
- module Vagrant
1
+ module VagrantPlugins
2
2
  module ServiceManager
3
3
  module Action
4
4
  class SetupNetwork
@@ -1,13 +1,12 @@
1
1
  require_relative 'os'
2
2
  require 'digest'
3
3
  require_relative 'plugin_util'
4
+ require_relative 'plugin_logger'
4
5
 
5
- module Vagrant
6
+ module VagrantPlugins
6
7
  module ServiceManager
7
8
  DOCKER_PATH = '/home/vagrant/.docker'
8
9
  SUPPORTED_SERVICES = ['docker', 'openshift', 'kubernetes']
9
- SCCLI_SERVICES = ['openshift', 'k8s']
10
- KUBE_NAMES = ['kubernetes', 'k8s']
11
10
  KUBE_SERVICES = [
12
11
  'etcd', 'kube-apiserver', 'kube-controller-manager', 'kube-scheduler',
13
12
  'kubelet', 'kube-proxy', 'docker'
@@ -29,6 +28,7 @@ module Vagrant
29
28
  def exit_if_machine_not_running
30
29
  # Exit from plugin with status 3 if machine is not running
31
30
  with_target_vms(nil, single_target: true) do |machine|
31
+ PluginLogger.debug("machine state - #{machine.state.id || 'nil'}")
32
32
  if machine.state.id != :running
33
33
  @env.ui.error I18n.t('servicemanager.machine_should_running')
34
34
  exit 3
@@ -37,8 +37,16 @@ module Vagrant
37
37
  end
38
38
 
39
39
  def execute
40
- command, subcommand, option = ARGV[1..ARGV.length]
40
+ argv = ARGV.dup
41
+ # Don't propagate --debug argument to case operation
42
+ if ARGV.include? '--debug'
43
+ PluginLogger.enable_debug_mode
44
+ PluginLogger.set_logger(@logger)
45
+ argv.delete('--debug')
46
+ end
41
47
 
48
+ # Remove first argument i.e plugin name
49
+ command, subcommand, option = argv.drop(1)
42
50
  case command
43
51
  when 'env'
44
52
  exit_if_machine_not_running
@@ -102,13 +110,13 @@ module Vagrant
102
110
  else
103
111
  print_help(type: command, exit_status: 1)
104
112
  end
105
- when 'restart'
113
+ when 'restart', 'start', 'stop'
106
114
  exit_if_machine_not_running
107
115
  case subcommand
108
116
  when '--help', '-h'
109
- print_help(type: command)
117
+ print_help(type: 'operation', operation: command)
110
118
  else
111
- restart_service(subcommand)
119
+ perform_service(command, subcommand)
112
120
  end
113
121
  when '--help', '-h', 'help'
114
122
  print_help
@@ -127,7 +135,7 @@ module Vagrant
127
135
  config[:type] ||= 'default'
128
136
  config[:exit_status] ||= 0
129
137
 
130
- @env.ui.info(I18n.t("servicemanager.commands.help.#{config[:type]}"))
138
+ @env.ui.info(I18n.t("servicemanager.commands.help.#{config[:type]}", operation: config[:operation]))
131
139
  exit config[:exit_status]
132
140
  end
133
141
 
@@ -151,11 +159,11 @@ module Vagrant
151
159
 
152
160
  running_service_classes.each do |service_class|
153
161
  service = service_class.to_s.split('::').last.downcase
154
- unless options[:script_readable] || KUBE_NAMES.include?(service)
162
+ unless options[:script_readable] || service == 'kubernetes'
155
163
  @env.ui.info("\n# #{service} env:")
156
164
  end
157
165
  # since we do not have feature to show the Kube connection information
158
- unless KUBE_NAMES.include? service
166
+ unless service == 'kubernetes'
159
167
  service_class.info(machine, @env.ui, options)
160
168
  end
161
169
  end
@@ -165,25 +173,28 @@ module Vagrant
165
173
  end
166
174
 
167
175
  def print_vagrant_box_version(script_readable = false)
176
+ options = { script_readable: script_readable }
177
+
168
178
  with_target_vms(nil, single_target: true) do |machine|
169
- @env.ui.info machine.guest.capability(:box_version, script_readable)
179
+ @env.ui.info machine.guest.capability(:box_version, options)
170
180
  end
171
181
  end
172
182
 
173
- def restart_service(service)
183
+ def perform_service(operation, service)
174
184
  if service.nil?
175
- help_msg = I18n.t('servicemanager.commands.help.restart')
176
- service_missing_msg = I18n.t('servicemanager.commands.restart.service_missing')
177
- @env.ui.error help_msg.gsub(/Restarts the service/, service_missing_msg)
185
+ help_msg = I18n.t('servicemanager.commands.help.operation', operation: operation)
186
+ service_missing_msg = I18n.t('servicemanager.commands.operation.service_missing')
187
+ @env.ui.error help_msg.gsub(/#{operation}s the service/, service_missing_msg)
178
188
  exit 126
179
189
  end
180
190
 
181
- command = if SCCLI_SERVICES.include? service
191
+ command = if SUPPORTED_SERVICES.include? service
182
192
  # TODO : Handle the case where user wants to pass extra arguments
183
193
  # to OpenShift service
184
- "sccli #{service}"
194
+ "sccli #{service} #{operation}"
185
195
  else
186
- "systemctl restart #{service}"
196
+ @env.ui.error I18n.t('servicemanager.commands.operation.sccli_only_support')
197
+ exit 126
187
198
  end
188
199
 
189
200
  with_target_vms(nil, single_target: true) do |machine|
@@ -1,6 +1,6 @@
1
1
  require 'set'
2
2
 
3
- module Vagrant
3
+ module VagrantPlugins
4
4
  module ServiceManager
5
5
  SERVICES = ['docker', 'openshift']
6
6
  CONFIG_KEYS = [
@@ -2,7 +2,7 @@
2
2
  Dir["#{File.dirname(__FILE__)}/action/*.rb"].each { |f| require_relative f }
3
3
  require_relative 'service'
4
4
 
5
- module Vagrant
5
+ module VagrantPlugins
6
6
  module ServiceManager
7
7
  class Plugin < Vagrant.plugin('2')
8
8
  name "service-manager"
@@ -0,0 +1,32 @@
1
+ module VagrantPlugins
2
+ module PluginLogger
3
+ @debug = false
4
+
5
+ def self.debug_mode?
6
+ @debug
7
+ end
8
+
9
+ def self.logger
10
+ @logger
11
+ end
12
+
13
+ def self.enable_debug_mode
14
+ @debug = true
15
+ end
16
+
17
+ def self.set_logger(logger)
18
+ @logger = logger
19
+ end
20
+
21
+ def self.command
22
+ (ARGV.drop(1) - ['--debug', '--script-readable']).join(' ')
23
+ end
24
+
25
+ def self.debug(message = nil)
26
+ if debug_mode?
27
+ message = "#{command}" if message.nil?
28
+ logger.debug "[ service-manager: #{message} ]"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,6 +1,7 @@
1
- module Vagrant
1
+ module VagrantPlugins
2
2
  module ServiceManager
3
3
  module PluginUtil
4
+
4
5
  def self.service_class(service)
5
6
  SERVICES_MAP[service]
6
7
  end
@@ -62,16 +63,8 @@ module Vagrant
62
63
  running_services
63
64
  end
64
65
 
65
- def self.kube_running?(machine)
66
- KUBE_SERVICES.each do |service|
67
- return false unless service_running?(machine, service)
68
- end
69
- true
70
- end
71
-
72
66
  def self.service_running?(machine, service)
73
- return kube_running?(machine) if KUBE_NAMES.include? service
74
- command = "systemctl status #{service}"
67
+ command = "sudo sccli #{service} status"
75
68
  machine.communicate.test(command)
76
69
  end
77
70
 
@@ -81,14 +74,24 @@ module Vagrant
81
74
  end
82
75
 
83
76
  def self.execute_and_exit_on_fail(machine, ui, command)
84
- exit_code = machine.communicate.sudo(command) do |type, error|
85
- errors << error if type == :stderr
77
+ errors = []
78
+ logged = false # Log one time only
79
+
80
+ exit_code = machine.communicate.sudo(command) do |type, data|
81
+ PluginLogger.debug unless logged
82
+ errors << data if type == :stderr
83
+ logged = true
86
84
  end
85
+
87
86
  unless exit_code.zero?
88
87
  ui.error errors.join("\n")
88
+ PluginLogger.debug("#{command} exited with code #{exit_code}")
89
89
  exit exit_code
90
90
  end
91
+
91
92
  exit_code
93
+ rescue StandardError => e
94
+ ui.error e.message.squeeze
92
95
  end
93
96
 
94
97
  def self.print_shell_configure_info(ui, command = '')
@@ -1,7 +1,7 @@
1
1
  # Loads all services
2
2
  Dir["#{File.dirname(__FILE__)}/services/*.rb"].each { |f| require_relative f }
3
3
 
4
- module Vagrant
4
+ module VagrantPlugins
5
5
  module ServiceManager
6
6
  SUPPORTED_BOXES = ['adb', 'cdk']
7
7
 
@@ -30,6 +30,8 @@ module Vagrant
30
30
  @openshift_hook.execute
31
31
  end
32
32
  end
33
+ rescue Vagrant::Errors::GuestCapabilityNotFound
34
+ # Do nothing if supported box variant not found
33
35
  end
34
36
  end
35
37
  end
@@ -1,4 +1,4 @@
1
- module Vagrant
1
+ module VagrantPlugins
2
2
  module ServiceManager
3
3
  class Docker
4
4
  # Hard Code the Docker port because it is fixed on the VM
@@ -42,6 +42,7 @@ module Vagrant
42
42
  docker_api_version_cmd.gsub!(/APIVersion/, 'ApiVersion')
43
43
  end
44
44
 
45
+ PluginLogger.debug
45
46
  machine.communicate.execute(docker_api_version_cmd) do |type, data|
46
47
  options[:api_version] = data.chomp if type == :stdout
47
48
  end
@@ -56,6 +57,8 @@ module Vagrant
56
57
  end
57
58
 
58
59
  def self.print_env_info(ui, options)
60
+ PluginLogger.debug("script_readable: #{options[:script_readable] || false}")
61
+
59
62
  label = PluginUtil.env_label(options[:script_readable])
60
63
  options[:secrets_path] = PluginUtil.windows_path(options[:secrets_path]) unless OS.unix?
61
64
  message = I18n.t("servicemanager.commands.env.docker.#{label}",