vagrant-service-manager 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/CONTRIBUTING.md +52 -7
- data/MAINTAINERS +14 -0
- data/README.md +58 -92
- data/lib/vagrant-service-manager/command.rb +89 -180
- data/lib/vagrant-service-manager/plugin_util.rb +98 -1
- data/lib/vagrant-service-manager/services/docker.rb +56 -9
- data/lib/vagrant-service-manager/services/kubernetes.rb +22 -0
- data/lib/vagrant-service-manager/services/open_shift.rb +30 -8
- data/lib/vagrant-service-manager/version.rb +1 -1
- data/locales/en.yml +52 -14
- data/plugins/guests/redhat/cap/box_version.rb +25 -0
- data/plugins/guests/redhat/cap/machine_ip.rb +17 -0
- data/plugins/guests/redhat/cap/{osvariant.rb → os_variant.rb} +3 -3
- data/plugins/guests/redhat/cap/sha_id.rb +1 -1
- data/plugins/guests/redhat/plugin.rb +13 -1
- data/vagrant-service-manager.spec +17 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 931ed28213feec845263c099a965a747c85891ae
|
4
|
+
data.tar.gz: bf8447ff4ce1f42b9a0b460db37bff7d561cc468
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 072cfd5bf2882444c43eaa9bc869954117d141228d6997d049e618a5aab38640b8322bba26771a68641167399fc9897bb1c2a6559041c36f04bb7da3567885f8
|
7
|
+
data.tar.gz: 23c23b006585fc65760762f49823474bebc637419a2b4aecfdec17cb8db4eb81703749b59aa7e6c3c60e54d0ffcb2ad8567e6dd1df4023f193c1a7f37f6e2d61
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,21 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## v1.0.2 May 09, 2016
|
6
|
+
- Add --script-readable to env and env docker @bexelbie
|
7
|
+
- Fix #178: Add status command and separate status from env @bexelbie
|
8
|
+
- Fix#173: Shows if kubernetes services is running in the box @navidshaikh
|
9
|
+
- Fix #169: Adds command for displaying box routable IP address @navidshaikh
|
10
|
+
- Fix message for box command on default help @budhrg
|
11
|
+
- Fix #184: Make env headers comments for vagrant service-manager env @bexelbie
|
12
|
+
- Fix #135: Refactor command.rb to make commands easier to add/maintain @budhrg
|
13
|
+
- Adds @budhrg as co-maintainer for the plugin @navidshaikh
|
14
|
+
- Fix #191: 'vagrant service-manager restart' not handled correctly @budhrg
|
15
|
+
- Fixes #187, Updated commands in the Available Commands section @preeticp
|
16
|
+
- Fix #200: Simplify the eval hint for `vagrant service-manager env` command @budhrg
|
17
|
+
- Add environment variables for Openshift env output @bexelbie
|
18
|
+
- Fix #181: vagrant-service-manager version 1.0.2 release @navidshaikh
|
19
|
+
|
5
20
|
## v1.0.1 Apr 12, 2016
|
6
21
|
- Updated SPEC (v1.0.0) for url, date and format @budhrg
|
7
22
|
- Added Table of Contents for README @bexelbie
|
data/CONTRIBUTING.md
CHANGED
@@ -1,26 +1,32 @@
|
|
1
1
|
# Contributing to vagrant-service-manager Plugin
|
2
2
|
|
3
3
|
The following is a set of guidelines for contributing to the
|
4
|
-
|
5
|
-
Organization
|
4
|
+
vagrant-service-manager plugin, which is hosted in the [Project Atomic
|
5
|
+
Organization](https://github.com/projectatomic) on GitHub.
|
6
6
|
|
7
7
|
These are just guidelines, please use your best judgement and feel free
|
8
8
|
to propose changes to this document in a pull request.
|
9
9
|
|
10
10
|
At this point, this document is not complete, but as decisions are made on the
|
11
|
-
[
|
11
|
+
[container-tools@redhat.com](https://www.redhat.com/mailman/listinfo/container-tools)
|
12
12
|
mailing list they will be added to this document.
|
13
13
|
|
14
|
-
|
14
|
+
|
15
|
+
## Submitting Issues
|
16
|
+
|
17
|
+
You can submit issues with respect to the vagrant-service-manager plugin [here](https://github.com/projectatomic/vagrant-service-manager/issues/new).Make sure you include all the relevant details pertaining the issue.
|
18
|
+
|
19
|
+
Before submitting new issues, it is suggested to check [all existing issues](https://github.com/projectatomic/vagrant-service-manager/issues) in order to avoid duplication.The vagrant-service-manager plugin works closely with the [ADB](https://github.com/projectatomic/adb-atomic-developer-bundle/issues) and the [adb-utils](https://github.com/projectatomic/adb-utils/issues) RPM. You may wish to review the issues in both the repositories as well.
|
20
|
+
|
21
|
+
|
22
|
+
## Submitting Pull Requests
|
15
23
|
|
16
24
|
* All changes will be made by pull request (PR), even from core
|
17
25
|
committers/maintainers.
|
18
26
|
|
19
27
|
* All changes must include appropriate documentation updates.
|
20
28
|
|
21
|
-
* All changes must include an entry in the
|
22
|
-
*unreleased* section describing the change. Your new entry should be
|
23
|
-
the first entry after *unreleased.*
|
29
|
+
* All changes must include an entry in the [Changelog document](https://github.com/projectatomic/vagrant-service-manager/blob/master/CHANGELOG.md) in the *Unreleased* section describing the change. Your new entry should be the last entry in the *Unreleased* section and should include your GitHub userid.
|
24
30
|
|
25
31
|
* All changes need at least 2 ACKs from maintainers before they will be merged. If
|
26
32
|
the author of the PR is a maintainer, their submission is considered
|
@@ -30,3 +36,42 @@ mailing list they will be added to this document.
|
|
30
36
|
By "2 ACKs" we mean that two maintainers must acknowledge that the change
|
31
37
|
is a good one. The 2<sup>nd</sup> person to ACK the PR should merge the PR with
|
32
38
|
a comment including their agreement.
|
39
|
+
|
40
|
+
|
41
|
+
## How to Develop/Test
|
42
|
+
|
43
|
+
1. Install the Atomic Developer Bundle (ADB), as
|
44
|
+
[documented](https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/docs/installing.rst)
|
45
|
+
in the ADB project. Do not start the box yet.
|
46
|
+
|
47
|
+
2. Fork and clone the vagrant-service-manager repository
|
48
|
+
|
49
|
+
git clone https://github.com/projectatomic/vagrant-service-manager
|
50
|
+
|
51
|
+
3. Change the directory to vagrant-service-manager `cd vagrant-service-manager`
|
52
|
+
|
53
|
+
4. Run `bundle install`
|
54
|
+
|
55
|
+
5. Start the box with `bundle exec vagrant up
|
56
|
+
|
57
|
+
6. Develop the plugin and test by running `bundle exec vagrant service-manager`
|
58
|
+
|
59
|
+
7. When you are ready to build the release, get one of the [repository maintainers](https://github.com/projectatomic/vagrant-service-manager/blob/master/MAINTAINERS) to release the plugin.
|
60
|
+
|
61
|
+
|
62
|
+
### How to build the Vagrant plugin using Bundler
|
63
|
+
|
64
|
+
You can also use Bundler to build the plugin and install it manually in
|
65
|
+
your Vagrant environment
|
66
|
+
|
67
|
+
1. Run the commands below inside of the repository:
|
68
|
+
|
69
|
+
```
|
70
|
+
$ bundle install
|
71
|
+
$ bundle exec rake build
|
72
|
+
````
|
73
|
+
|
74
|
+
2. Install the plugin using:
|
75
|
+
|
76
|
+
vagrant plugin install pkg/<gem name>
|
77
|
+
|
data/MAINTAINERS
CHANGED
@@ -1,3 +1,17 @@
|
|
1
1
|
Brian Exelbierd <bexelbie@redhat.com> @bexelbie
|
2
2
|
Navid Shaikh <nshaikh@redhat.com> @navidshaikh
|
3
3
|
Lalatendu Mohanty <lmohanty@redhat.com> @LalatenduMohanty
|
4
|
+
Budh Ram Gurung <bgurung@redhat.com> @budhrg
|
5
|
+
|
6
|
+
## How to release the vagrant-service-manager plugin
|
7
|
+
|
8
|
+
1. Create gemfile in `pkg` directory by running `rake build`
|
9
|
+
|
10
|
+
2. Increment the Version Number.
|
11
|
+
|
12
|
+
3. Release the plugin by running `rake release`
|
13
|
+
|
14
|
+
4. Tag the release commit with a vX.Y.Z tag.
|
15
|
+
|
16
|
+
5. Create a Github release.
|
17
|
+
|
data/README.md
CHANGED
@@ -1,154 +1,120 @@
|
|
1
1
|
# vagrant-service-manager
|
2
2
|
|
3
3
|
* [Objective](#objective)
|
4
|
-
* [
|
4
|
+
* [Example Execution of the Plugin](#example_execution)
|
5
|
+
* [Available Commands](#commands)
|
5
6
|
* [Exit codes](#exit_codes)
|
6
7
|
* [IP Address Detection](#ip_addr)
|
7
|
-
* [
|
8
|
-
* [How to Develop/Test](#develop)
|
9
|
-
* [How to build the Vagrant plugin using Bundler](#bundler)
|
8
|
+
* [Getting Involved with the Project](#Contributing)
|
10
9
|
* [Builds](#builds)
|
11
10
|
|
12
|
-
This plugin provides setup information, including environment variables and certificates, required to access services provided by an [Atomic Developer Bundle (ADB)](https://github.com/projectatomic/adb-atomic-developer-bundle). This plugin makes it easier to use the ADB with host-based tools such as Eclipse and the docker and kubernetes CLI commands. Details on this usage pattern can be found in the [ADB Documentation](https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/docs/using.rst).
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
* To provide the user a CLI to configure the
|
17
|
-
[ADB](https://github.com/projectatomic/adb-atomic-developer-bundle)
|
18
|
-
for different use cases and to provide glue between ADB and the user's
|
19
|
-
development environment.
|
20
|
-
|
21
|
-
* Provide users a tool to control and configure the ADB from the
|
22
|
-
developer's workstation without having to `ssh` into it.
|
12
|
+
The vagrant-service-manager plugin is designed to enable easier access to the features and services provided by the [Atomic Developer Bundle (ADB)](https://github.com/projectatomic/adb-atomic-developer-bundle). It provides setup information, including environment variables and certificates, required to access services provided by the ADB and is a must have for most ADB users.
|
23
13
|
|
24
|
-
|
25
|
-
Bundle](https://github.com/projectatomic/adb-atomic-developer-bundle)
|
26
|
-
is Vagrant box that provides a ready-to-use development environment
|
27
|
-
for container applications. With ADB, developers can dive right into
|
28
|
-
producing complex, multi-container applications.
|
14
|
+
This plugin makes it easier to use the ADB with host-based tools such as Eclipse and the docker and kubernetes CLI commands. Details on how to use ADB with this plugin can be found in the [ADB Documentation](https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/docs/using.rst).
|
29
15
|
|
30
|
-
## Quick Start <a name="quick_start"></a>
|
31
|
-
|
32
|
-
1. Install `vagrant-service-manager` plugin:
|
33
|
-
|
34
|
-
vagrant plugin install vagrant-service-manager
|
35
16
|
|
36
|
-
|
37
|
-
[Atomic Developer Bundle (ADB)](https://github.com/projectatomic/adb-atomic-developer-bundle) should download a [Vagrantfile from the repository](https://github.com/projectatomic/adb-atomic-developer-bundle/tree/master/components).
|
38
|
-
|
39
|
-
3. Enable your desired service(s) in [Vagrantfile](Vagrantfile) as:
|
40
|
-
|
41
|
-
config.servicemanager.services = 'openshift'
|
17
|
+
## Objective <a name="objective"></a>
|
42
18
|
|
43
|
-
|
19
|
+
The [ADB](https://github.com/projectatomic/adb-atomic-developer-bundle) provides a ready-to-use development environment for container applications. With ADB, developers can dive right into producing complex, multi-container applications.
|
44
20
|
|
45
|
-
|
46
|
-
* Enable multiple services as comma separated list. Eg: 'docker, openshift'
|
21
|
+
The vagrant-service-manager provides the user with:
|
47
22
|
|
48
|
-
|
23
|
+
* A CLI to configure the ADB for different use cases and to provide an interface between ADB and the user's development environment.
|
24
|
+
* A tool to control and configure the ADB from the
|
25
|
+
developer's workstation without having to `ssh` directly into the ADB virtual machine.
|
49
26
|
|
50
|
-
* OpenShift
|
51
27
|
|
52
|
-
|
28
|
+
## Example Execution of the Plugin <a name="example_execution"></a>
|
53
29
|
|
54
|
-
|
55
|
-
|
56
|
-
|
30
|
+
1. Install vagrant-service-manager plugin:
|
31
|
+
|
32
|
+
vagrant plugin install vagrant-service-manager
|
57
33
|
|
34
|
+
2. Download the relevant Vagrantfile for your [ADB](https://github.com/projectatomic/adb-atomic-developer-bundle) vagrant box, from the [repository](https://github.com/projectatomic/adb-atomic-developer-bundle/tree/master/components/centos). For further details on the usage of custom Vagrantfiles designed for specific use cases, refer to the [Usage Documentation](https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/docs/using.rst).
|
58
35
|
|
59
|
-
|
60
|
-
[Installation Documentation](https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/docs/installing.rst).
|
36
|
+
3. Start the ADB vagrant box using `vagrant up`. For detailed instructions consult the [Installation Documentation](https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/docs/installing.rst).
|
61
37
|
|
62
|
-
|
38
|
+
**Note:** When the vagrant-service-manager plugin is loaded and a box is started using the VirtualBox provider, the user needs to add a routable non NAT network interface declaration in the Vagrantfile. If the user does not provide a network declaration in the Vagrantfile, a private DHCP network is added by default and a warning is displayed.
|
63
39
|
|
64
|
-
|
40
|
+
4. Run the plugin to get environment variables and certificates:
|
65
41
|
|
66
|
-
|
42
|
+
$ vagrant service-manager env docker
|
67
43
|
# Set the following environment variables to enable access to the
|
68
44
|
# docker daemon running inside of the vagrant virtual machine:
|
69
45
|
export DOCKER_HOST=tcp://172.28.128.4:2376
|
70
|
-
export DOCKER_CERT_PATH=/
|
46
|
+
export DOCKER_CERT_PATH=/foo/bar/.vagrant/machines/default/virtualbox/docker
|
71
47
|
export DOCKER_TLS_VERIFY=1
|
72
|
-
export
|
48
|
+
export DOCKER_API_VERSION=1.21
|
73
49
|
# run following command to configure your shell:
|
74
50
|
# eval "$(vagrant service-manager env docker)"
|
75
51
|
|
76
|
-
|
52
|
+
**Note:** The required TLS certificates are copied to the host machine at the time of `vagrant up` itself. Every run of `vagrant service-manager env docker` checks for the validity of the certificates on the host machine by matching the certificates inside the box. If the certificates on the host machine are invalid, this command will also re-download the certificates onto the host machine.
|
77
53
|
|
78
|
-
## Exit codes <a name="exit_codes"></a>
|
79
54
|
|
80
|
-
|
55
|
+
## Available Commands <a name="commands"></a>
|
81
56
|
|
82
|
-
|
83
|
-
--------------- |-------------------------------------------------------------------------
|
84
|
-
0 | No error
|
85
|
-
1 | Catch all for general errors / Wrong sub-command or option given
|
86
|
-
3 | Vagrant box is not running and must be before this command can succeed
|
87
|
-
126 | A service inside the box is not running / Command invoked cannot execute
|
57
|
+
The following section lists the available commands for the plugin and their explanation:
|
88
58
|
|
89
|
-
|
59
|
+
1. `vagrant service-manager env [service] [--script-readable]`
|
90
60
|
|
91
|
-
|
92
|
-
This code uses the last IPv4 address available from the set of configured
|
93
|
-
addresses that are *up*. i.e. if eth0, eth1, and eth2 are all up and
|
94
|
-
have IPv4 addresses, the address on eth2 is used.
|
61
|
+
Displays connection information for all active services in the box in a manner that can be evaluated in a shell. If a `service` is specified, only the information for that service is displayed. When `--script-readable` is specified the output is in `key=value` format. The supported services are: Docker; OpenShift.
|
95
62
|
|
96
|
-
|
63
|
+
2. `vagrant service-manager box [command]`
|
97
64
|
|
98
|
-
|
99
|
-
|
65
|
+
Displays box related information like release version, IP etc.
|
66
|
+
|
67
|
+
3. `vagrant service-manager box version [--script-readable]`
|
100
68
|
|
101
|
-
|
69
|
+
Displays the version and release information of the running VM. When `--script-readable` is specified the output is in `key=value` format.
|
102
70
|
|
103
|
-
|
104
|
-
[documented](https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/docs/installing.rst)
|
105
|
-
in the ADB project. Do not start the box yet.
|
71
|
+
4. `vagrant service-manager box ip`
|
106
72
|
|
107
|
-
|
73
|
+
Displays the routable IP address of the running VM.
|
108
74
|
|
109
|
-
|
75
|
+
5. `vagrant service-manager status [service]`
|
110
76
|
|
111
|
-
|
77
|
+
Lists services and their running state. If a `service` is specified only the status of that service is displayed. If no service is provided then only supported orchestrators are reported.
|
112
78
|
|
113
|
-
|
79
|
+
6. `vagrant service-manager restart [service]`
|
114
80
|
|
115
|
-
|
81
|
+
Restarts the given service in the box.
|
116
82
|
|
117
|
-
|
83
|
+
7. `vagrant service-manager [command] [--help | -h]`
|
118
84
|
|
119
|
-
|
85
|
+
Displays the possible commands, options and other relevant information for the vagrant-service-manager plugin. If a `command` is specified, only the help relevant to that command is displayed.
|
120
86
|
|
121
|
-
8. When you are ready to build the release, get a repo maintainer to:
|
122
87
|
|
123
|
-
1. Put the gemfile in pkg/ with `rake build`
|
124
88
|
|
125
|
-
|
89
|
+
## Exit codes <a name="exit_codes"></a>
|
126
90
|
|
127
|
-
|
91
|
+
The following table lists the plugin's exit codes and their meaning:
|
128
92
|
|
129
|
-
|
93
|
+
Exit Code Number | Meaning
|
94
|
+
-------------------|-------------------------------------------------------------------------
|
95
|
+
`0` | No error
|
96
|
+
`1` | Catch all for general errors / Wrong sub-command or option given
|
97
|
+
`3` | Vagrant box is not running and should be running for this command to succeed
|
98
|
+
`126` | A service inside the box is not running / Command invoked cannot execute
|
130
99
|
|
131
|
-
5. Create a Github release
|
132
100
|
|
133
|
-
|
101
|
+
## IP Address Detection <a name="ip_addr"></a>
|
134
102
|
|
135
|
-
|
136
|
-
|
103
|
+
There is no standardized way of detecting Vagrant box IP addresses.
|
104
|
+
This code uses the last IPv4 address available from the set of configured addresses that are *up*. i.e. if eth0, eth1, and eth2 are all up and have IPv4 addresses, the address on eth2 is used.
|
137
105
|
|
138
|
-
Run the commands below inside of the repository:
|
139
106
|
|
140
|
-
|
141
|
-
$ bundle install
|
142
|
-
$ bundle exec rake build
|
143
|
-
````
|
107
|
+
## Getting Involved with the Project <a name="Contributing"></a>
|
144
108
|
|
145
|
-
|
109
|
+
We welcome your input. You can submit issues or pull requests with respect to the vagrant-service-manager plugin. Refer to the [contributing guidelines](https://github.com/projectatomic/vagrant-service-manager/blob/master/CONTRIBUTING.md) for detailed information on how to contribute to this plugin.
|
146
110
|
|
147
|
-
|
111
|
+
You can contact us on:
|
112
|
+
* IRC: #atomic and #nulecule on freenode
|
113
|
+
* Mailing List: container-tools@redhat.com
|
148
114
|
|
149
115
|
|
150
116
|
## Builds <a name="builds"></a>
|
151
117
|
|
152
|
-
-
|
118
|
+
- Gem: https://rubygems.org/gems/vagrant-service-manager
|
153
119
|
|
154
|
-
-
|
120
|
+
- Copr build: https://copr.fedorainfracloud.org/coprs/nshaikh/vagrant-service-manager/builds/
|
@@ -1,11 +1,23 @@
|
|
1
1
|
require_relative 'os'
|
2
2
|
require 'digest'
|
3
|
+
require_relative 'plugin_util'
|
3
4
|
|
4
5
|
module Vagrant
|
5
6
|
module ServiceManager
|
6
7
|
DOCKER_PATH = '/home/vagrant/.docker'
|
7
8
|
SUPPORTED_SERVICES = ['docker', 'openshift', 'kubernetes']
|
8
9
|
SCCLI_SERVICES = ['openshift', 'k8s']
|
10
|
+
KUBE_NAMES = ['kubernetes', 'k8s']
|
11
|
+
KUBE_SERVICES = [
|
12
|
+
'etcd', 'kube-apiserver', 'kube-controller-manager', 'kube-scheduler',
|
13
|
+
'kubelet', 'kube-proxy', 'docker'
|
14
|
+
]
|
15
|
+
# NOTE: SERVICES_MAP[<service>] will give fully-qualified service class name
|
16
|
+
# Eg: SERVICES_MAP['docker'] gives Vagrant::ServiceManager::Docker
|
17
|
+
SERVICES_MAP = {
|
18
|
+
'docker' => Docker, 'openshift' => OpenShift,
|
19
|
+
'kubernetes' => Kubernetes
|
20
|
+
}
|
9
21
|
|
10
22
|
class Command < Vagrant.plugin(2, :command)
|
11
23
|
OS_RELEASE_FILE = '/etc/os-release'
|
@@ -16,8 +28,8 @@ module Vagrant
|
|
16
28
|
|
17
29
|
def exit_if_machine_not_running
|
18
30
|
# Exit from plugin with status 3 if machine is not running
|
19
|
-
with_target_vms(nil,
|
20
|
-
if machine.state.id != :running
|
31
|
+
with_target_vms(nil, single_target: true) do |machine|
|
32
|
+
if machine.state.id != :running
|
21
33
|
@env.ui.error I18n.t('servicemanager.machine_should_running')
|
22
34
|
exit 3
|
23
35
|
end
|
@@ -31,21 +43,12 @@ module Vagrant
|
|
31
43
|
when 'env'
|
32
44
|
exit_if_machine_not_running
|
33
45
|
case subcommand
|
34
|
-
when 'docker'
|
46
|
+
when 'docker', 'openshift'
|
35
47
|
case option
|
36
48
|
when nil
|
37
|
-
|
38
|
-
when '--help', '-h'
|
39
|
-
print_help(type: command)
|
40
|
-
else
|
41
|
-
print_help(type: command, exit_status: 1)
|
42
|
-
end
|
43
|
-
when 'openshift'
|
44
|
-
case option
|
45
|
-
when nil
|
46
|
-
execute_openshift_info
|
49
|
+
execute_service(subcommand)
|
47
50
|
when '--script-readable'
|
48
|
-
|
51
|
+
execute_service(subcommand, script_readable: true)
|
49
52
|
when '--help', '-h'
|
50
53
|
print_help(type: command)
|
51
54
|
else
|
@@ -54,11 +57,23 @@ module Vagrant
|
|
54
57
|
when nil
|
55
58
|
# display information about all the providers inside ADB/CDK
|
56
59
|
print_all_provider_info
|
60
|
+
when '--script-readable'
|
61
|
+
print_all_provider_info(script_readable: true)
|
57
62
|
when '--help', '-h'
|
58
63
|
print_help(type: command)
|
59
64
|
else
|
60
65
|
print_help(type: command, exit_status: 1)
|
61
66
|
end
|
67
|
+
when 'status'
|
68
|
+
exit_if_machine_not_running
|
69
|
+
case subcommand
|
70
|
+
when nil
|
71
|
+
execute_status_display
|
72
|
+
when '--help', '-h'
|
73
|
+
print_help(type: command)
|
74
|
+
else
|
75
|
+
execute_status_display(subcommand)
|
76
|
+
end
|
62
77
|
when 'box'
|
63
78
|
exit_if_machine_not_running
|
64
79
|
case subcommand
|
@@ -68,6 +83,17 @@ module Vagrant
|
|
68
83
|
print_vagrant_box_version
|
69
84
|
when '--script-readable'
|
70
85
|
print_vagrant_box_version(true)
|
86
|
+
when '--help', '-h'
|
87
|
+
print_help(type: command)
|
88
|
+
else
|
89
|
+
print_help(type: command, exit_status: 1)
|
90
|
+
end
|
91
|
+
when 'ip'
|
92
|
+
case option
|
93
|
+
when nil
|
94
|
+
display_box_ip
|
95
|
+
when '--help', '-h'
|
96
|
+
print_help(type: command)
|
71
97
|
else
|
72
98
|
print_help(type: command, exit_status: 1)
|
73
99
|
end
|
@@ -76,23 +102,27 @@ module Vagrant
|
|
76
102
|
else
|
77
103
|
print_help(type: command, exit_status: 1)
|
78
104
|
end
|
79
|
-
when '
|
80
|
-
|
81
|
-
when "restart"
|
82
|
-
self.exit_if_machine_not_running
|
105
|
+
when 'restart'
|
106
|
+
exit_if_machine_not_running
|
83
107
|
case subcommand
|
84
108
|
when '--help', '-h'
|
85
109
|
print_help(type: command)
|
86
110
|
else
|
87
111
|
restart_service(subcommand)
|
88
112
|
end
|
89
|
-
when
|
90
|
-
|
113
|
+
when '--help', '-h', 'help'
|
114
|
+
print_help
|
91
115
|
else
|
92
116
|
print_help(exit_status: 1)
|
93
117
|
end
|
94
118
|
end
|
95
119
|
|
120
|
+
def execute_service(name, options = {})
|
121
|
+
with_target_vms(nil, single_target: true) do |machine|
|
122
|
+
PluginUtil.service_class(name).info(machine, @env.ui, options)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
96
126
|
def print_help(config = {})
|
97
127
|
config[:type] ||= 'default'
|
98
128
|
config[:exit_status] ||= 0
|
@@ -101,192 +131,71 @@ module Vagrant
|
|
101
131
|
exit config[:exit_status]
|
102
132
|
end
|
103
133
|
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
running_services = []
|
115
|
-
SUPPORTED_SERVICES.each do |service|
|
116
|
-
status = if check_if_a_service_is_running?(service)
|
117
|
-
running_services << service
|
118
|
-
I18n.t('servicemanager.commands.env.status.running')
|
119
|
-
else
|
120
|
-
I18n.t('servicemanager.commands.env.status.stopped')
|
121
|
-
end
|
122
|
-
@env.ui.info("#{service} - #{status}")
|
123
|
-
end
|
124
|
-
|
125
|
-
running_services.each do |e|
|
126
|
-
@env.ui.info("\n#{e} env:")
|
127
|
-
public_send("execute_#{e}_info")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def execute_openshift_info(script_readable = false)
|
132
|
-
@@OPENSHIFT_PORT = 8443
|
133
|
-
if self.check_if_a_service_is_running?("openshift") then
|
134
|
-
# Find the guest IP
|
135
|
-
guest_ip = self.find_machine_ip
|
136
|
-
openshift_url = "https://#{guest_ip}:#@@OPENSHIFT_PORT"
|
137
|
-
openshift_console_url = "#{openshift_url}/console"
|
138
|
-
self.print_openshift_info(
|
139
|
-
openshift_url,
|
140
|
-
openshift_console_url,
|
141
|
-
script_readable)
|
142
|
-
else
|
143
|
-
@env.ui.error I18n.t('servicemanager.commands.env.service_not_running',
|
144
|
-
name: 'OpenShift')
|
145
|
-
exit 126
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def print_openshift_info(url, console_url, script_readable = false)
|
150
|
-
if script_readable
|
151
|
-
message = I18n.t('servicemanager.commands.env.openshift.script_readable',
|
152
|
-
openshift_url: url, openshift_console_url: console_url)
|
153
|
-
else
|
154
|
-
message = I18n.t('servicemanager.commands.env.openshift.default',
|
155
|
-
openshift_url: url, openshift_console_url: console_url)
|
156
|
-
end
|
157
|
-
|
158
|
-
@env.ui.info(message)
|
159
|
-
end
|
160
|
-
|
161
|
-
def find_machine_ip
|
162
|
-
with_target_vms(nil, {:single_target=>true}) do |machine|
|
163
|
-
# Find the guest IP
|
164
|
-
command = "ip -o -4 addr show up |egrep -v ': docker|: lo' |tail -1 | awk '{print $4}' |cut -f1 -d\/"
|
165
|
-
guest_ip = ""
|
166
|
-
machine.communicate.execute(command) do |type, data|
|
167
|
-
guest_ip << data.chomp if type == :stdout
|
134
|
+
def execute_status_display(service = nil)
|
135
|
+
with_target_vms(nil, single_target: true) do |machine|
|
136
|
+
if service
|
137
|
+
PluginUtil.service_class(service).status(machine, @env.ui, service)
|
138
|
+
else
|
139
|
+
@env.ui.info I18n.t('servicemanager.commands.status.nil')
|
140
|
+
SUPPORTED_SERVICES.each do |s|
|
141
|
+
PluginUtil.service_class(s).status(machine, @env.ui, s)
|
142
|
+
end
|
168
143
|
end
|
169
|
-
return guest_ip
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
def sha_id(file_data)
|
174
|
-
Digest::SHA256.hexdigest file_data
|
175
|
-
end
|
176
|
-
|
177
|
-
def certs_present_and_valid?(path, machine)
|
178
|
-
return false if Dir["#{path}/*"].empty?
|
179
|
-
|
180
|
-
# check validity of certs
|
181
|
-
Dir[path + "/*"].each do |f|
|
182
|
-
guest_file_path = "#{DOCKER_PATH}/#{File.basename(f)}"
|
183
|
-
guest_sha = machine.guest.capability(:sha_id, guest_file_path)
|
184
|
-
return false if sha_id(File.read(f)) != guest_sha
|
185
144
|
end
|
186
|
-
|
187
|
-
true
|
188
145
|
end
|
189
146
|
|
190
|
-
def
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
# Hard Code the Docker port because it is fixed on the VM
|
195
|
-
# This also makes it easier for the plugin to be cross-provider
|
196
|
-
port = 2376
|
197
|
-
|
198
|
-
# Verify valid certs and copy if invalid
|
199
|
-
unless certs_present_and_valid?(secrets_path, machine)
|
200
|
-
# Log the message prefixed by #
|
201
|
-
PluginUtil.copy_certs_to_host(machine, secrets_path, @env.ui, true)
|
202
|
-
end
|
203
|
-
|
204
|
-
api_version = ""
|
205
|
-
docker_api_version = "docker version --format '{{.Server.APIVersion}}'"
|
206
|
-
unless machine.communicate.test(docker_api_version)
|
207
|
-
# fix for issue #152: Fallback to older Docker version (< 1.9.1)
|
208
|
-
docker_api_version.gsub!(/APIVersion/, 'ApiVersion')
|
209
|
-
end
|
147
|
+
def print_all_provider_info(options = {})
|
148
|
+
with_target_vms(nil, single_target: true) do |machine|
|
149
|
+
options[:all] = true # flag to mark all providers
|
150
|
+
running_service_classes = PluginUtil.running_services(machine, class: true)
|
210
151
|
|
211
|
-
|
212
|
-
|
152
|
+
running_service_classes.each do |service_class|
|
153
|
+
service = service_class.to_s.split('::').last.downcase
|
154
|
+
unless options[:script_readable] || KUBE_NAMES.include?(service)
|
155
|
+
@env.ui.info("\n# #{service} env:")
|
156
|
+
end
|
157
|
+
# since we do not have feature to show the Kube connection information
|
158
|
+
unless KUBE_NAMES.include? service
|
159
|
+
service_class.info(machine, @env.ui, options)
|
160
|
+
end
|
213
161
|
end
|
214
162
|
|
215
|
-
|
216
|
-
self.print_docker_env_info(find_machine_ip, port, secrets_path, api_version)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
def print_docker_env_info(guest_ip, port, secrets_path, api_version)
|
221
|
-
# Print configuration information for accesing the docker daemon
|
222
|
-
|
223
|
-
if !OS.windows? then
|
224
|
-
message = I18n.t('servicemanager.commands.env.docker.non_windows',
|
225
|
-
ip: guest_ip, port: port, path: secrets_path,
|
226
|
-
api_version: api_version)
|
227
|
-
@env.ui.info(message)
|
228
|
-
elsif OS.windows_cygwin? then
|
229
|
-
# replace / with \ for path in Cygwin Windows - which uses export
|
230
|
-
secrets_path = secrets_path.split('/').join('\\') + '\\'
|
231
|
-
message = I18n.t('servicemanager.commands.env.docker.windows_cygwin',
|
232
|
-
ip: guest_ip, port: port, path: secrets_path,
|
233
|
-
api_version: api_version)
|
234
|
-
@env.ui.info(message)
|
235
|
-
else
|
236
|
-
# replace / with \ for path in Windows
|
237
|
-
secrets_path = secrets_path.split('/').join('\\') + '\\'
|
238
|
-
message = I18n.t('servicemanager.commands.env.docker.windows',
|
239
|
-
ip: guest_ip, port: port, path: secrets_path,
|
240
|
-
api_version: api_version)
|
241
|
-
# puts is used here to escape and render the back slashes in Windows path
|
242
|
-
@env.ui.info(puts(message))
|
163
|
+
PluginUtil.print_shell_configure_info(@env.ui) unless options[:script_readable]
|
243
164
|
end
|
244
165
|
end
|
245
166
|
|
246
167
|
def print_vagrant_box_version(script_readable = false)
|
247
|
-
|
248
|
-
|
249
|
-
command = "cat #{OS_RELEASE_FILE} | grep VARIANT"
|
250
|
-
|
251
|
-
machine.communicate.execute(command) do |type, data|
|
252
|
-
if type == :stderr
|
253
|
-
@env.ui.error(data)
|
254
|
-
exit 126
|
255
|
-
end
|
256
|
-
|
257
|
-
if !script_readable
|
258
|
-
info = Hash[data.gsub('"', '').split("\n").map {|e| e.split("=") }]
|
259
|
-
version = "#{info['VARIANT']} #{info['VARIANT_VERSION']}"
|
260
|
-
@env.ui.info(version)
|
261
|
-
else
|
262
|
-
@env.ui.info(data.chomp)
|
263
|
-
end
|
264
|
-
end
|
168
|
+
with_target_vms(nil, single_target: true) do |machine|
|
169
|
+
@env.ui.info machine.guest.capability(:box_version, script_readable)
|
265
170
|
end
|
266
171
|
end
|
267
172
|
|
268
173
|
def restart_service(service)
|
269
|
-
|
174
|
+
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)
|
178
|
+
exit 126
|
179
|
+
end
|
180
|
+
|
270
181
|
command = if SCCLI_SERVICES.include? service
|
271
182
|
# TODO : Handle the case where user wants to pass extra arguments
|
272
183
|
# to OpenShift service
|
273
184
|
"sccli #{service}"
|
274
185
|
else
|
275
186
|
"systemctl restart #{service}"
|
276
|
-
|
187
|
+
end
|
277
188
|
|
278
189
|
with_target_vms(nil, single_target: true) do |machine|
|
279
|
-
|
280
|
-
errors << error if type == :stderr
|
281
|
-
end
|
282
|
-
unless exit_code.zero?
|
283
|
-
@env.ui.error errors.join("\n")
|
284
|
-
exit exit_code
|
285
|
-
end
|
286
|
-
exit_code
|
190
|
+
PluginUtil.execute_and_exit_on_fail(machine, @env.ui, command)
|
287
191
|
end
|
288
192
|
end
|
289
193
|
|
194
|
+
def display_box_ip
|
195
|
+
with_target_vms(nil, single_target: true) do |machine|
|
196
|
+
@env.ui.info machine.guest.capability(:machine_ip)
|
197
|
+
end
|
198
|
+
end
|
290
199
|
end
|
291
200
|
end
|
292
201
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Vagrant
|
2
2
|
module ServiceManager
|
3
3
|
module PluginUtil
|
4
|
+
def self.service_class(service)
|
5
|
+
SERVICES_MAP[service]
|
6
|
+
end
|
7
|
+
|
4
8
|
def self.copy_certs_to_host(machine, path, ui, commented_message = false)
|
5
9
|
Dir.mkdir(path) unless Dir.exist?(path)
|
6
10
|
|
@@ -15,7 +19,100 @@ module Vagrant
|
|
15
19
|
|
16
20
|
def self.host_docker_path(machine)
|
17
21
|
# Path to the private_key and where we will store the TLS Certificates
|
18
|
-
File.expand_path(
|
22
|
+
File.expand_path('docker', machine.data_dir)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.machine_ip(machine)
|
26
|
+
machine.guest.capability(:machine_ip)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.sha_id(file_data)
|
30
|
+
Digest::SHA256.hexdigest file_data
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.certs_present_and_valid?(path, machine)
|
34
|
+
return false if Dir["#{path}/*"].empty?
|
35
|
+
|
36
|
+
# check validity of certs
|
37
|
+
Dir[path + "/*"].each do |f|
|
38
|
+
guest_file_path = "#{DOCKER_PATH}/#{File.basename(f)}"
|
39
|
+
guest_sha = machine.guest.capability(:sha_id, guest_file_path)
|
40
|
+
return false if sha_id(File.read(f)) != guest_sha
|
41
|
+
end
|
42
|
+
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.print_service_status(ui, machine, service)
|
47
|
+
status = I18n.t('servicemanager.commands.status.status.stopped')
|
48
|
+
if service_running?(machine, service)
|
49
|
+
status = I18n.t('servicemanager.commands.status.status.running')
|
50
|
+
end
|
51
|
+
ui.info("#{service} - #{status}")
|
52
|
+
end
|
53
|
+
|
54
|
+
# If 'class' option is true then return the class name of running services
|
55
|
+
def self.running_services(machine, options = {})
|
56
|
+
running_services = []
|
57
|
+
|
58
|
+
SUPPORTED_SERVICES.each do |service|
|
59
|
+
next unless service_running?(machine, service)
|
60
|
+
running_services << (options[:class] ? SERVICES_MAP[service] : service)
|
61
|
+
end
|
62
|
+
running_services
|
63
|
+
end
|
64
|
+
|
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
|
+
def self.service_running?(machine, service)
|
73
|
+
return kube_running?(machine) if KUBE_NAMES.include? service
|
74
|
+
command = "systemctl status #{service}"
|
75
|
+
machine.communicate.test(command)
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.windows_path(path)
|
79
|
+
# Replace / with \ for path in Windows
|
80
|
+
path.split('/').join('\\') + '\\'
|
81
|
+
end
|
82
|
+
|
83
|
+
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
|
86
|
+
end
|
87
|
+
unless exit_code.zero?
|
88
|
+
ui.error errors.join("\n")
|
89
|
+
exit exit_code
|
90
|
+
end
|
91
|
+
exit_code
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.print_shell_configure_info(ui, command = '')
|
95
|
+
label = if OS.unix?
|
96
|
+
'unix_configure_info'
|
97
|
+
elsif OS.windows_cygwin?
|
98
|
+
'windows_cygwin_configure_info'
|
99
|
+
end
|
100
|
+
|
101
|
+
unless label.nil?
|
102
|
+
ui.info "\n" + I18n.t("servicemanager.commands.env.#{label}", command: command)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.env_label(script_readable)
|
107
|
+
if script_readable
|
108
|
+
'script_readable'
|
109
|
+
elsif OS.unix?
|
110
|
+
'non_windows'
|
111
|
+
elsif OS.windows_cygwin?
|
112
|
+
'windows_cygwin'
|
113
|
+
else
|
114
|
+
'windows'
|
115
|
+
end
|
19
116
|
end
|
20
117
|
end
|
21
118
|
end
|
@@ -1,25 +1,72 @@
|
|
1
|
-
require_relative '../plugin_util'
|
2
|
-
|
3
1
|
module Vagrant
|
4
2
|
module ServiceManager
|
5
3
|
class Docker
|
4
|
+
# Hard Code the Docker port because it is fixed on the VM
|
5
|
+
# This also makes it easier for the plugin to be cross-provider
|
6
|
+
PORT = 2376
|
7
|
+
|
6
8
|
def initialize(machine, ui)
|
7
9
|
@machine = machine
|
8
10
|
@ui = ui
|
9
11
|
end
|
10
12
|
|
11
13
|
def execute
|
12
|
-
command =
|
14
|
+
command = 'sudo rm /etc/docker/ca.pem && sudo systemctl restart docker'
|
15
|
+
|
16
|
+
exit_code = PluginUtil.execute_and_exit_on_fail(@machine, @ui, command)
|
17
|
+
# Copy certs on command execution success
|
18
|
+
if exit_code
|
19
|
+
secrets_path = PluginUtil.host_docker_path(@machine)
|
20
|
+
PluginUtil.copy_certs_to_host(@machine, secrets_path, @ui)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.status(machine, ui, service)
|
25
|
+
PluginUtil.print_service_status(ui, machine, service)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.info(machine, ui, options = {})
|
29
|
+
if PluginUtil.service_running?(machine, 'docker')
|
30
|
+
options[:secrets_path] = PluginUtil.host_docker_path(machine)
|
31
|
+
options[:guest_ip] = PluginUtil.machine_ip(machine)
|
13
32
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
33
|
+
# Verify valid certs and copy if invalid
|
34
|
+
unless PluginUtil.certs_present_and_valid?(options[:secrets_path], machine)
|
35
|
+
# Log the message prefixed by #
|
36
|
+
PluginUtil.copy_certs_to_host(machine, options[:secrets_path], ui, true)
|
18
37
|
end
|
38
|
+
|
39
|
+
docker_api_version_cmd = "docker version --format '{{.Server.APIVersion}}'"
|
40
|
+
unless machine.communicate.test(docker_api_version_cmd)
|
41
|
+
# fix for issue #152: Fallback to older Docker version (< 1.9.1)
|
42
|
+
docker_api_version_cmd.gsub!(/APIVersion/, 'ApiVersion')
|
43
|
+
end
|
44
|
+
|
45
|
+
machine.communicate.execute(docker_api_version_cmd) do |type, data|
|
46
|
+
options[:api_version] = data.chomp if type == :stdout
|
47
|
+
end
|
48
|
+
|
49
|
+
# Display the information, irrespective of the copy operation
|
50
|
+
print_env_info(ui, options)
|
51
|
+
else
|
52
|
+
ui.error I18n.t('servicemanager.commands.env.service_not_running',
|
53
|
+
name: 'Docker')
|
54
|
+
exit 126
|
19
55
|
end
|
56
|
+
end
|
20
57
|
|
21
|
-
|
22
|
-
PluginUtil.
|
58
|
+
def self.print_env_info(ui, options)
|
59
|
+
label = PluginUtil.env_label(options[:script_readable])
|
60
|
+
options[:secrets_path] = PluginUtil.windows_path(options[:secrets_path]) unless OS.unix?
|
61
|
+
message = I18n.t("servicemanager.commands.env.docker.#{label}",
|
62
|
+
ip: options[:guest_ip], port: PORT, path: options[:secrets_path],
|
63
|
+
api_version: options[:api_version])
|
64
|
+
# Puts is used to escape and render the back slashes in Windows path
|
65
|
+
message = puts(message) if OS.windows?
|
66
|
+
ui.info(message)
|
67
|
+
unless options[:script_readable] || options[:all]
|
68
|
+
PluginUtil.print_shell_configure_info(ui, ' docker')
|
69
|
+
end
|
23
70
|
end
|
24
71
|
end
|
25
72
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module ServiceManager
|
3
|
+
class Kubernetes
|
4
|
+
def initialize(machine, ui)
|
5
|
+
@machine = machine
|
6
|
+
@ui = ui
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute
|
10
|
+
# TODO: Implement execute method
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.status(machine, ui, service)
|
14
|
+
PluginUtil.print_service_status(ui, machine, service)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.info(machine, ui, options = {})
|
18
|
+
# TODO: Implement info method
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Vagrant
|
2
2
|
module ServiceManager
|
3
3
|
class OpenShift
|
4
|
+
OPENSHIFT_PORT = 8443
|
5
|
+
|
4
6
|
def initialize(machine, ui)
|
5
7
|
@machine = machine
|
6
8
|
@ui = ui
|
@@ -8,17 +10,37 @@ module Vagrant
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def execute
|
11
|
-
|
12
|
-
|
13
|
+
command = "#{@extra_cmd} sccli openshift"
|
14
|
+
Plugin.execute_and_exit_on_fail(@machine, @ui, command)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.status(machine, ui, service)
|
18
|
+
PluginUtil.print_service_status(ui, machine, service)
|
19
|
+
end
|
13
20
|
|
14
|
-
|
15
|
-
|
21
|
+
def self.info(machine, ui, options = {})
|
22
|
+
options[:script_readable] ||= false
|
23
|
+
|
24
|
+
if PluginUtil.service_running?(machine, 'openshift')
|
25
|
+
options[:url] = "https://#{PluginUtil.machine_ip(machine)}:#{OPENSHIFT_PORT}"
|
26
|
+
options[:console_url] = "#{options[:url]}/console"
|
27
|
+
print_info(ui, options)
|
28
|
+
else
|
29
|
+
ui.error I18n.t('servicemanager.commands.env.service_not_running',
|
30
|
+
name: 'OpenShift')
|
31
|
+
exit 126
|
16
32
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.print_info(ui, options)
|
36
|
+
label = PluginUtil.env_label(options[:script_readable])
|
37
|
+
message = I18n.t("servicemanager.commands.env.openshift.#{label}",
|
38
|
+
openshift_url: options[:url],
|
39
|
+
openshift_console_url: options[:console_url])
|
40
|
+
ui.info(message)
|
41
|
+
unless options[:script_readable] || options[:all]
|
42
|
+
PluginUtil.print_shell_configure_info(ui, ' openshift')
|
20
43
|
end
|
21
|
-
exit_code
|
22
44
|
end
|
23
45
|
|
24
46
|
private
|
data/locales/en.yml
CHANGED
@@ -23,8 +23,9 @@ en:
|
|
23
23
|
|
24
24
|
Commands:
|
25
25
|
env displays connection information for services in the box
|
26
|
-
box displays
|
26
|
+
box displays box related information like version, release, IP etc
|
27
27
|
restart restarts the given systemd service in the box
|
28
|
+
status list services and their running state
|
28
29
|
|
29
30
|
Options:
|
30
31
|
-h, --help print this help
|
@@ -37,30 +38,44 @@ en:
|
|
37
38
|
docker display information and environment variables for docker
|
38
39
|
openshift display information and environment variables for openshift
|
39
40
|
|
40
|
-
If OBJECT is ommitted, display the
|
41
|
-
for all active services
|
41
|
+
If OBJECT is ommitted, display the information for all active services
|
42
42
|
|
43
43
|
Options:
|
44
44
|
--script-readable display information in a script readable format.
|
45
|
-
Only supported by the openshift object.
|
46
45
|
-h, --help print this help
|
47
46
|
box: |-
|
48
47
|
Usage: vagrant service-manager box <sub-command> [options]
|
49
48
|
|
50
49
|
Sub-Command:
|
51
50
|
version display version and release information about the running VM
|
51
|
+
ip display routable IP address of the running VM
|
52
52
|
|
53
53
|
Options:
|
54
54
|
--script-readable display information in a script readable format
|
55
55
|
-h, --help print this help
|
56
56
|
|
57
|
+
status: |-
|
58
|
+
Usage: vagrant service-manager status [service] [options]
|
59
|
+
|
60
|
+
Options:
|
61
|
+
-h, --help print this help
|
62
|
+
|
63
|
+
If a service is provided, only that service is reported.
|
64
|
+
If no service is provided only supported orchestrators are reported.
|
65
|
+
|
66
|
+
Examples:
|
67
|
+
vagrant service-manager box version
|
68
|
+
vagrant service-manager box ip
|
69
|
+
vagrant service-manager box version --script-readable
|
70
|
+
|
57
71
|
restart: |-
|
58
72
|
Restarts the service
|
59
73
|
|
60
|
-
Usage: vagrant service-manager restart <
|
74
|
+
Usage: vagrant service-manager restart <service> [options]
|
61
75
|
|
62
|
-
|
63
|
-
|
76
|
+
Service:
|
77
|
+
A service provided by sccli or systemd. For example:
|
78
|
+
docker, k8s, or openshift etc.
|
64
79
|
|
65
80
|
Options:
|
66
81
|
-h, --help print this help
|
@@ -84,8 +99,6 @@ en:
|
|
84
99
|
export DOCKER_CERT_PATH=%{path}
|
85
100
|
export DOCKER_TLS_VERIFY=1
|
86
101
|
export DOCKER_API_VERSION=%{api_version}
|
87
|
-
# run following command to configure your shell:
|
88
|
-
# eval "$(vagrant service-manager env docker)"
|
89
102
|
windows_cygwin: |-
|
90
103
|
# Set the following environment variables to enable access to the
|
91
104
|
# docker daemon running inside of the vagrant virtual machine:
|
@@ -93,17 +106,42 @@ en:
|
|
93
106
|
export DOCKER_CERT_PATH='%{path}'
|
94
107
|
export DOCKER_TLS_VERIFY=1
|
95
108
|
export DOCKER_API_VERSION=%{api_version}
|
96
|
-
|
97
|
-
|
109
|
+
script_readable: |-
|
110
|
+
DOCKER_HOST=tcp://%{ip}:%{port}
|
111
|
+
DOCKER_CERT_PATH='%{path}'
|
112
|
+
DOCKER_TLS_VERIFY=1
|
113
|
+
DOCKER_API_VERSION=%{api_version}
|
98
114
|
openshift:
|
99
|
-
|
100
|
-
You can access the OpenShift console on: %{openshift_console_url}
|
101
|
-
To use OpenShift CLI, run: oc login %{openshift_url}
|
115
|
+
windows: |-
|
116
|
+
# You can access the OpenShift console on: %{openshift_console_url}
|
117
|
+
# To use OpenShift CLI, run: oc login %{openshift_url}
|
118
|
+
setx OPENSHIFT_URL %{openshift_url}
|
119
|
+
setx OPENSHIFT_WEB_CONSOLE %{openshift_console_url}
|
120
|
+
non_windows: |-
|
121
|
+
# You can access the OpenShift console on: %{openshift_console_url}
|
122
|
+
# To use OpenShift CLI, run: oc login %{openshift_url}
|
123
|
+
export OPENSHIFT_URL=%{openshift_url}
|
124
|
+
export OPENSHIFT_WEB_CONSOLE=%{openshift_console_url}
|
125
|
+
windows_cygwin: |-
|
126
|
+
# You can access the OpenShift console on: %{openshift_console_url}
|
127
|
+
# To use OpenShift CLI, run: oc login %{openshift_url}
|
128
|
+
export OPENSHIFT_URL=%{openshift_url}
|
129
|
+
export OPENSHIFT_WEB_CONSOLE=%{openshift_console_url}
|
102
130
|
script_readable: |-
|
103
131
|
OPENSHIFT_URL=%{openshift_url}
|
104
132
|
OPENSHIFT_WEB_CONSOLE=%{openshift_console_url}
|
133
|
+
windows_cygwin_configure_info: |-
|
134
|
+
# run following command to configure your shell:
|
135
|
+
# eval "$(VAGRANT_NO_COLOR=1 vagrant service-manager env%{command} | tr -d '\r')"
|
136
|
+
unix_configure_info: |-
|
137
|
+
# run following command to configure your shell:
|
138
|
+
# eval "$(vagrant service-manager env%{command})"
|
105
139
|
service_not_running: |-
|
106
140
|
# %{name} service is not running in the vagrant box.
|
141
|
+
restart:
|
142
|
+
service_missing: 'Service name missing'
|
143
|
+
|
144
|
+
status:
|
107
145
|
nil: |-
|
108
146
|
Configured services:
|
109
147
|
status:
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestRedHat
|
3
|
+
module Cap
|
4
|
+
class BoxVersion
|
5
|
+
# Prints the version of the vagrant box, parses /etc/os-release for version
|
6
|
+
def self.box_version(machine, script_readable)
|
7
|
+
command = "cat #{OS_RELEASE_FILE} | grep VARIANT"
|
8
|
+
# TODO: execute efficient command to solve this
|
9
|
+
if machine.communicate.test(command) # test if command is exits with code 0
|
10
|
+
machine.communicate.execute(command) do |type, data|
|
11
|
+
if type == :stderr
|
12
|
+
@env.ui.error(data)
|
13
|
+
exit 126
|
14
|
+
end
|
15
|
+
|
16
|
+
return data.chomp if script_readable
|
17
|
+
info = Hash[data.delete('"').split("\n").map { |e| e.split('=') }]
|
18
|
+
return "#{info['VARIANT']} #{info['VARIANT_VERSION']}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestRedHat
|
3
|
+
module Cap
|
4
|
+
class MachineIP
|
5
|
+
def self.machine_ip(machine)
|
6
|
+
# Find the guest IP
|
7
|
+
command = "ip -o -4 addr show up |egrep -v ': docker|: lo' |tail -1 | awk '{print $4}' |cut -f1 -d\/"
|
8
|
+
ip = ''
|
9
|
+
machine.communicate.execute(command) do |type, data|
|
10
|
+
ip << data.chomp if type == :stdout
|
11
|
+
end
|
12
|
+
ip
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -3,11 +3,11 @@ module VagrantPlugins
|
|
3
3
|
module Cap
|
4
4
|
class OsVariant
|
5
5
|
def self.os_variant(machine)
|
6
|
-
command = "grep VARIANT_ID
|
6
|
+
command = "grep VARIANT_ID #{OS_RELEASE_FILE}"
|
7
7
|
# TODO: execute efficient command to solve this
|
8
8
|
if machine.communicate.test(command) # test if command is exits with code 0
|
9
|
-
machine.communicate.execute(command) do |
|
10
|
-
return data.chomp.
|
9
|
+
machine.communicate.execute(command) do |_, data|
|
10
|
+
return data.chomp.delete('"').split('=').last
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -6,7 +6,7 @@ module VagrantPlugins
|
|
6
6
|
command = "sha256sum #{path}"
|
7
7
|
|
8
8
|
if machine.communicate.test(command)
|
9
|
-
machine.communicate.execute(command) do |
|
9
|
+
machine.communicate.execute(command) do |_, data|
|
10
10
|
# sha256sum results in "sha_id path"
|
11
11
|
return data.split.first
|
12
12
|
end
|
@@ -1,17 +1,29 @@
|
|
1
1
|
require 'vagrant'
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
|
+
OS_RELEASE_FILE = '/etc/os-release'
|
5
|
+
|
4
6
|
module GuestRedHat
|
5
7
|
class Plugin < Vagrant.plugin('2')
|
6
8
|
guest_capability('redhat', 'os_variant') do
|
7
|
-
require_relative 'cap/
|
9
|
+
require_relative 'cap/os_variant'
|
8
10
|
Cap::OsVariant
|
9
11
|
end
|
10
12
|
|
13
|
+
guest_capability('redhat', 'box_version') do
|
14
|
+
require_relative 'cap/box_version'
|
15
|
+
Cap::BoxVersion
|
16
|
+
end
|
17
|
+
|
11
18
|
guest_capability('redhat', 'sha_id') do
|
12
19
|
require_relative 'cap/sha_id'
|
13
20
|
Cap::ShaID
|
14
21
|
end
|
22
|
+
|
23
|
+
guest_capability('redhat', 'machine_ip') do
|
24
|
+
require_relative 'cap/machine_ip'
|
25
|
+
Cap::MachineIP
|
26
|
+
end
|
15
27
|
end
|
16
28
|
end
|
17
29
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
%global vagrant_plugin_name vagrant-service-manager
|
3
3
|
|
4
4
|
Name: %{vagrant_plugin_name}
|
5
|
-
Version: 1.0.
|
5
|
+
Version: 1.0.2
|
6
6
|
Release: 1%{?dist}
|
7
7
|
Summary: To provide the user a CLI to configure the ADB/CDK for different use cases and to provide glue between ADB/CDK and the user's developer environment.
|
8
8
|
Group: Development/Languages
|
@@ -88,6 +88,22 @@ popd
|
|
88
88
|
%{vagrant_plugin_instdir}/.gitattributes
|
89
89
|
|
90
90
|
%changelog
|
91
|
+
* Mon May 09 2016 Navid Shaikh - 1.0.2-1
|
92
|
+
- Add --script-readable to env and env docker @bexelbie
|
93
|
+
- Fix #178: Add status command and separate status from env @bexelbie
|
94
|
+
- Fix#173: Shows if kubernetes services is running in the box @navidshaikh
|
95
|
+
- Fix #169: Adds command for displaying box routable IP address @navidshaikh
|
96
|
+
- Fix message for box command on default help @budhrg
|
97
|
+
- Fix #184: Make env headers comments for vagrant service-manager env @bexelbie
|
98
|
+
- Fix #135: Refactor command.rb to make commands easier to add/maintain @budhrg
|
99
|
+
- Adds @budhrg as co-maintainer for the plugin @navidshaikh
|
100
|
+
- Fix #191: 'vagrant service-manager restart' not handled correctly @budhrg
|
101
|
+
- Fixes #187, Updated commands in the Available Commands section @preeticp
|
102
|
+
- Fix #200: Simplify the eval hint for `vagrant service-manager env` command @budhrg
|
103
|
+
- Add environment variables for Openshift env output @bexelbie
|
104
|
+
- Fix #181: vagrant-service-manager version 1.0.2 release @navidshaikh
|
105
|
+
|
106
|
+
|
91
107
|
* Tue Apr 12 2016 Navid Shaikh - 1.0.1-1
|
92
108
|
- Updated SPEC (v1.0.0) for url, date and format @budhrg
|
93
109
|
- Added Table of Contents for README @bexelbie
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-service-manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Exelbierd
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Provides setup information, including environment variables and certificates,
|
15
15
|
required to access services provided by ADB/CDK.
|
@@ -40,10 +40,13 @@ files:
|
|
40
40
|
- lib/vagrant-service-manager/plugin_util.rb
|
41
41
|
- lib/vagrant-service-manager/service.rb
|
42
42
|
- lib/vagrant-service-manager/services/docker.rb
|
43
|
+
- lib/vagrant-service-manager/services/kubernetes.rb
|
43
44
|
- lib/vagrant-service-manager/services/open_shift.rb
|
44
45
|
- lib/vagrant-service-manager/version.rb
|
45
46
|
- locales/en.yml
|
46
|
-
- plugins/guests/redhat/cap/
|
47
|
+
- plugins/guests/redhat/cap/box_version.rb
|
48
|
+
- plugins/guests/redhat/cap/machine_ip.rb
|
49
|
+
- plugins/guests/redhat/cap/os_variant.rb
|
47
50
|
- plugins/guests/redhat/cap/sha_id.rb
|
48
51
|
- plugins/guests/redhat/plugin.rb
|
49
52
|
- vagrant-service-manager.gemspec
|