vagrant-service-manager 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9070fa23f07f07325ec792a696c40845b1dc03d5
4
- data.tar.gz: c14f7fdad39e74f9e6845fe136b35d5d37344b5a
3
+ metadata.gz: dc29eabc39c834f0e04c2edfc3efe61179e88085
4
+ data.tar.gz: fc8f1062197a8cb676a88449839721c6a836dcc8
5
5
  SHA512:
6
- metadata.gz: 7bfa1be7abe7a5510474d4bb9d049d3caf1dee84662e3bde346f38d02818c470302ba1557b8977c3bdc9c21eb44e0a0903d4c3204fe1c11fba68d1d630bc3dc6
7
- data.tar.gz: b7e5916946a877a765ca304a38de86c16bee28c97b046bf69216edfcb801bd35e89d21cc5e72e73d1dab99743ee63f880ee5f7647e13cd99083b21edea114ffd
6
+ metadata.gz: ce3218c6d2edefe64db604656e494cb65eaa8b3dc154243b26f029b435eca8ca17c07c326e41f5166265c4665f3079a5fb1f16d3073d3d7909b1743df7846f15
7
+ data.tar.gz: 2ec3abebad4070c80af5bcfe078977ec1fe49b650271a544163cf04ca77f85e4f4b447ece26706addcfe1662204b5066b540376c4fcc53620f56cb797c04d46b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.0.4 Mar 14, 2016
4
+ - Fix #101: vagrant-service-manager version 0.0.4 release @navidshaikh
5
+ - Remove manually scp for TLS keys and use machine.communicate.download @bexelbie
6
+ - Fix #87 #83: Supports starting OpenShift service as part of config @budhrg @bexelbie @navidshaikh
7
+ - Fix #95: Update hook code to call other middleware first @bexelbie
8
+ - Fix #94: Do not exit if box is not supported @navidshaikh
9
+ - Fixed missing word for plugin installation in README @budhrg
10
+ - Fix #91: Renaming the method name flavor to os_variant @lalatendumohanty
11
+ - Fix links, typos, formatting in CONTRIBUTING.md @budhrg
12
+ - Fix #16 and #72: Enable private networking for VirtualBox if not set @budhrg
13
+
3
14
  ## v0.0.3 Mar 01, 2016
4
15
  - Fix #74: vagrant-service-manager plugin version 0.0.3 release @navidshaikh
5
16
  - Fix #12 and #21: Restart docker service on 'vagrant up' @budhrg
data/CONTRIBUTING.md CHANGED
@@ -1,16 +1,15 @@
1
1
  # Contributing to vagrant-service-manager Plugin
2
2
 
3
3
  The following is a set of guidelines for contributing to the
4
- vagrant-service-manager plugin, which is hosted in the `Project Atomic
5
- Organization <https://github.com/projectatomic>`_ on GitHub.
4
+ `vagrant-service-manager` plugin, which is hosted in the [`Project Atomic
5
+ Organization`](https://github.com/projectatomic) on GitHub.
6
6
 
7
- These are just guidelines, please use your best judgment and feel free
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
- At this point, this document is not complete, but
11
- as decisions are made on `container-tools@redhat.com
12
- <https://www.redhat.com/mailman/listinfo/container-tools>`_ mailing list
13
- they will be added to this document.
10
+ At this point, this document is not complete, but as decisions are made on the
11
+ [`container-tools@redhat.com`](https://www.redhat.com/mailman/listinfo/container-tools)
12
+ mailing list they will be added to this document.
14
13
 
15
14
  ## Pull Requests
16
15
 
@@ -22,11 +21,11 @@ they will be added to this document.
22
21
  * All changes must include an entry in the `CHANGELOG.md` in the
23
22
  *unreleased* section describing the change
24
23
 
25
- * All changes need 2 ACKs from maintainers before they will be merged. If
24
+ * All changes need at least 2 ACKs from maintainers before they will be merged. If
26
25
  the author of the PR is a maintainer, their submission is considered
27
- to be the first ACK. Therefore PRs from maintainers only need one
26
+ to be the first ACK. Therefore, PRs from maintainers only need one
28
27
  additional ACK.
29
28
 
30
- By "2 ACKs" we mean that 2 maintainers must acknowledge that the change
31
- is a good one. The 2nd person to ACK the PR should merge the PR with
29
+ By "2 ACKs" we mean that two maintainers must acknowledge that the change
30
+ is a good one. The 2<sup>nd</sup> person to ACK the PR should merge the PR with
32
31
  a comment including their agreement.
data/README.md CHANGED
@@ -36,6 +36,17 @@ producing complex, multi-container applications.
36
36
  * `docker` is default service and does not require above configuration.
37
37
  * Enable multiple services as comma separated list. Eg: 'docker, openshift'
38
38
 
39
+ 4. Enable any specific options for the services you have selected:
40
+
41
+ * OpenShift
42
+
43
+ Specific versions can be specified using the following variables:
44
+
45
+ `config.servicemanager.openshift_docker_registry = "docker.io"` - What registry should be pulled from
46
+ `config.servicemanager.openshift_image_name = "openshift/origin"` - What image should be used
47
+ `config.servicemanager.openshift_image_tag = "v1.1.1"` - What image version should be used
48
+
49
+
39
50
  5. Start the ADB using `vagrant up`. Users of the ADB may wish to consult the
40
51
  [Installation Documentation](https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/docs/installing.rst).
41
52
 
@@ -118,7 +129,7 @@ $ bundle exec rake build
118
129
 
119
130
  Install the plugin using:
120
131
 
121
- vagrant install pkg/<gem name>
132
+ vagrant plugin install pkg/<gem name>
122
133
 
123
134
 
124
135
  ## Builds
data/Vagrantfile CHANGED
@@ -13,11 +13,14 @@ Vagrant.configure(2) do |config|
13
13
 
14
14
  config.vm.box = "projectatomic/adb"
15
15
 
16
- config.vm.network "private_network", type: "dhcp"
17
-
18
16
  # This is the default setup
19
17
  # config.servicemanager.services = 'docker'
20
18
 
21
19
  # Enable multiple services as comma separated list.
22
20
  # config.servicemanager.services = 'docker, openshift'
21
+
22
+ # Specific versions can be specified using the following variables for OpenShift service:
23
+ # config.servicemanager.openshift_docker_registry = "docker.io"
24
+ # config.servicemanager.openshift_image_name = "openshift/origin"
25
+ # config.servicemanager.openshift_image_tag = "v1.1.1"
23
26
  end
@@ -0,0 +1,38 @@
1
+ module Vagrant
2
+ module ServiceManager
3
+ module Action
4
+ class SetupNetwork
5
+
6
+ def initialize(app, env)
7
+ @app = app
8
+ @machine = env[:machine]
9
+ @ui = env[:ui]
10
+ end
11
+
12
+ def call(env)
13
+ add_private_network if virtualbox? && default_network_exists?
14
+ @app.call(env)
15
+ end
16
+
17
+ private
18
+
19
+ def virtualbox?
20
+ @machine.provider.instance_of?(VagrantPlugins::ProviderVirtualBox::Provider)
21
+ end
22
+
23
+ def default_network_exists?
24
+ @machine.config.vm.networks.length == 1
25
+ end
26
+
27
+ def add_private_network
28
+ @ui.info <<-MSG
29
+ When using virtualbox, a non-NAT network interface is required.
30
+ Adding a private network using DHCP
31
+ MSG
32
+ @machine.config.vm.network :private_network, type: :dhcp
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,8 +1,5 @@
1
1
  require_relative 'os'
2
2
 
3
- require 'net/scp'
4
- require 'net/ssh'
5
-
6
3
  module Vagrant
7
4
  module ServiceManager
8
5
  class Command < Vagrant.plugin(2, :command)
@@ -100,20 +97,6 @@ Verb:
100
97
  exit exit_status
101
98
  end
102
99
 
103
- def copy_from_box(hIP, hport, husername, hprivate_key_path, source, destination)
104
- # This method should be extended to take an option 'if recursive'
105
-
106
- # read the private key
107
- fp = File.open(hprivate_key_path)
108
- pk_data = [fp.read]
109
- fp.close
110
-
111
- # create the ssh session
112
- Net::SSH.start(hIP, husername, :port => hport, :key_data => pk_data, :keys_only => TRUE) do |ssh|
113
- ssh.scp.download(source, destination, :recursive => TRUE)
114
- end
115
- end
116
-
117
100
  def check_if_a_service_is_running?(service)
118
101
  command = "systemctl status #{service}"
119
102
  with_target_vms(nil, {:single_target=>true}) do |machine|
@@ -192,14 +175,14 @@ Verb:
192
175
  # First, get the TLS Certificates, if needed
193
176
  if !File.directory?(secrets_path) then
194
177
 
195
- # Get the private key
196
- hprivate_key_path = machine.ssh_info[:private_key_path][0]
178
+ # Create the directory
179
+ Dir.mkdir(secrets_path)
197
180
 
198
181
  # copy the required client side certs from inside the box to host machine
199
182
  @env.ui.info("# Copying TLS certificates to #{secrets_path}")
200
- self.copy_from_box(hIP, hport, husername, hprivate_key_path, "/home/vagrant/.docker/ca.pem", "#{secrets_path}")
201
- self.copy_from_box(hIP, hport, husername, hprivate_key_path, "/home/vagrant/.docker/cert.pem", "#{secrets_path}")
202
- self.copy_from_box(hIP, hport, husername, hprivate_key_path, "/home/vagrant/.docker/key.pem", "#{secrets_path}")
183
+ machine.communicate.download("/home/vagrant/.docker/ca.pem", "#{secrets_path}")
184
+ machine.communicate.download("/home/vagrant/.docker/cert.pem", "#{secrets_path}")
185
+ machine.communicate.download("/home/vagrant/.docker/key.pem", "#{secrets_path}")
203
186
  end
204
187
 
205
188
  # display the information, irrespective of the copy operation
@@ -3,9 +3,13 @@ require 'set'
3
3
  module Vagrant
4
4
  module ServiceManager
5
5
  SERVICES = ['docker', 'openshift']
6
+ CONFIG_KEYS = [
7
+ :services, :openshift_docker_registry,
8
+ :openshift_image_name, :openshift_image_tag
9
+ ]
6
10
 
7
11
  class Config < Vagrant.plugin('2', :config)
8
- attr_accessor :services
12
+ attr_accessor(*CONFIG_KEYS)
9
13
 
10
14
  DEFAULTS = {
11
15
  services: 'docker'
@@ -1,5 +1,6 @@
1
- # Loads all services
2
- Dir["#{File.dirname(__FILE__)}/services/*.rb"].each { |f| require_relative f }
1
+ # Loads all actions
2
+ Dir["#{File.dirname(__FILE__)}/action/*.rb"].each { |f| require_relative f }
3
+ require_relative 'service'
3
4
 
4
5
  module Vagrant
5
6
  module ServiceManager
@@ -18,7 +19,14 @@ module Vagrant
18
19
  end
19
20
 
20
21
  action_hook(:servicemanager, :machine_action_up) do |hook|
21
- hook.append(Service::Docker)
22
+ hook.before(VagrantPlugins::ProviderVirtualBox::Action::Network, setup_network)
23
+ hook.after(Vagrant::Action::Builtin::SyncedFolders, Service)
24
+ end
25
+
26
+ def self.setup_network
27
+ Vagrant::Action::Builder.new.tap do |b|
28
+ b.use Action::SetupNetwork
29
+ end
22
30
  end
23
31
  end
24
32
  end
@@ -0,0 +1,36 @@
1
+ # Loads all services
2
+ Dir["#{File.dirname(__FILE__)}/services/*.rb"].each { |f| require_relative f }
3
+
4
+ module Vagrant
5
+ module ServiceManager
6
+ SUPPORTED_BOXES = ['adb', 'cdk']
7
+
8
+ class Service
9
+ def initialize(app, env)
10
+ @app = app
11
+ @machine = env[:machine]
12
+ @ui = env[:ui]
13
+ @services = @machine.config.servicemanager.services.split(',').map(&:strip)
14
+ @docker_hook = Docker.new(@machine, @ui)
15
+ @openshift_hook = OpenShift.new(@machine, @ui)
16
+ end
17
+
18
+ def call(env)
19
+ @app.call(env)
20
+
21
+ if SUPPORTED_BOXES.include? @machine.guest.capability(:os_variant)
22
+ @docker_hook.execute
23
+
24
+ if @machine.guest.capability(:os_variant) == "cdk" and @services.length == 0
25
+ # openshift to be started by default for CDK
26
+ @openshift_hook.execute
27
+ end
28
+ if @services.include? "openshift"
29
+ # Start OpenShift service if it is configured in Vagrantfile
30
+ @openshift_hook.execute
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,27 +1,18 @@
1
1
  module Vagrant
2
2
  module ServiceManager
3
- SUPPORTED_BOXES = ['adb', 'cdk']
4
-
5
- module Service
6
- class Docker
7
- def initialize(app, env)
8
- @app = app
9
- @machine = env[:machine]
10
- @ui = env[:ui]
11
- end
3
+ class Docker
4
+ def initialize(machine, ui)
5
+ @machine = machine
6
+ @ui = ui
7
+ end
12
8
 
13
- def call(env)
14
- if SUPPORTED_BOXES.include? @machine.guest.capability(:flavor)
15
- command = "sudo rm /etc/docker/ca.pem && sudo systemctl restart docker"
16
- @machine.communicate.execute(command) do |type, data|
17
- if type == :stderr
18
- @ui.error(data)
19
- exit 126
20
- end
21
- end
9
+ def execute
10
+ command = "sudo rm /etc/docker/ca.pem && sudo systemctl restart docker"
11
+ @machine.communicate.execute(command) do |type, data|
12
+ if type == :stderr
13
+ @ui.error(data)
14
+ exit 126
22
15
  end
23
-
24
- @app.call(env)
25
16
  end
26
17
  end
27
18
  end
@@ -0,0 +1,35 @@
1
+ module Vagrant
2
+ module ServiceManager
3
+ class OpenShift
4
+ def initialize(machine, ui)
5
+ @machine = machine
6
+ @ui = ui
7
+ @extra_cmd = build_extra_command
8
+ end
9
+
10
+ def execute
11
+ full_cmd = "#{@extra_cmd} sccli openshift"
12
+
13
+ @machine.communicate.sudo(full_cmd) do |type, data|
14
+ if type == :stderr
15
+ @ui.error(data)
16
+ exit 126
17
+ end
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def build_extra_command
24
+ cmd = ''
25
+ CONFIG_KEYS.select {|e| e[/^openshift_/] }.each do |key|
26
+ unless @machine.config.servicemanager.send(key).nil?
27
+ env_name = key.to_s.gsub(/openshift_/,'').upcase
28
+ cmd += "#{env_name}='#{@machine.config.servicemanager.send(key)}' "
29
+ end
30
+ end
31
+ cmd.chop
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module ServiceManager
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -0,0 +1,17 @@
1
+ module VagrantPlugins
2
+ module GuestRedHat
3
+ module Cap
4
+ class OsVariant
5
+ def self.os_variant(machine)
6
+ command = "grep VARIANT_ID /etc/os-release"
7
+ # TODO: execute efficient command to solve this
8
+ if machine.communicate.test(command) # test if command is exits with code 0
9
+ machine.communicate.execute(command) do |type, data|
10
+ return data.chomp.gsub(/"/, '').split("=").last
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,9 +3,9 @@ require 'vagrant'
3
3
  module VagrantPlugins
4
4
  module GuestRedHat
5
5
  class Plugin < Vagrant.plugin('2')
6
- guest_capability('redhat', 'flavor') do
7
- require_relative 'cap/flavor'
8
- Cap::Flavor
6
+ guest_capability('redhat', 'os_variant') do
7
+ require_relative 'cap/osvariant'
8
+ Cap::OsVariant
9
9
  end
10
10
  end
11
11
  end
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: 0.0.3
4
+ version: 0.0.4
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-03-01 00:00:00.000000000 Z
12
+ date: 2016-03-15 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.
@@ -31,13 +31,16 @@ files:
31
31
  - TODO
32
32
  - Vagrantfile
33
33
  - lib/vagrant-service-manager.rb
34
+ - lib/vagrant-service-manager/action/setup_network.rb
34
35
  - lib/vagrant-service-manager/command.rb
35
36
  - lib/vagrant-service-manager/config.rb
36
37
  - lib/vagrant-service-manager/os.rb
37
38
  - lib/vagrant-service-manager/plugin.rb
39
+ - lib/vagrant-service-manager/service.rb
38
40
  - lib/vagrant-service-manager/services/docker.rb
41
+ - lib/vagrant-service-manager/services/open_shift.rb
39
42
  - lib/vagrant-service-manager/version.rb
40
- - plugins/guests/redhat/cap/flavor.rb
43
+ - plugins/guests/redhat/cap/osvariant.rb
41
44
  - plugins/guests/redhat/plugin.rb
42
45
  - vagrant-service-manager.gemspec
43
46
  - vagrant-service-manager.spec
@@ -1,17 +0,0 @@
1
- module VagrantPlugins
2
- module GuestRedHat
3
- module Cap
4
- class Flavor
5
- def self.flavor(machine)
6
- machine.communicate.sudo("grep VARIANT_ID /etc/os-release") do |type, data|
7
- if type == :stderr
8
- @env.ui.error(data)
9
- exit 126
10
- end
11
- return data.chomp.gsub(/"/, '').split("=").last
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end