kontena-plugin-vagrant 0.2.0.pre1 → 0.2.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTc0YThjZGFlYmE5Y2VkOTdjZDlkMmUxNzhiMWUzMWIzNDliMWY1MQ==
4
+ ZDQzN2Q5NjA0YTY4YzAyYTdhN2U0OGE0ZWNmMzlmOTE2YTNmNWMyYQ==
5
5
  data.tar.gz: !binary |-
6
- MGE2NmM1N2ZkMzkwOTk3MmUxMDk5ZGQxNDg3MmUyOTIzYzMyNjM0OQ==
6
+ ZGY0YWY4NmYwYmNhMWUyMWRlNmRiNWQ5Yjc3NjcwYWE2ZmJhNTFhZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDk3OTEwNWZkNzRiMGNiNDYxZDA4YmU5NDg4MmFhMmYyMzg1ODUxZTc1ZDNl
10
- YzFjZmE4MTY0MzRlM2U1Zjc1ZGMwMDIzZWE2MDE5NmVkODJkMjAyMzExMzY0
11
- ZDJiYzZiNTI2MWJmNjhiNjk3MzllMGFjZjNkZjZjZTc5ZTFjYzQ=
9
+ MDgzOWNiZWNmOTYyMGMyYjU2ZTAzMTE0MmExMDJhYmNkMmUxNDMxZjZhOGNk
10
+ N2ZhZmFmODgzYjQ0MWViYjUyMjNkZGU2NDQ2ODJjYTM1MzE4NjcxMTI3NGE5
11
+ NTJlMDc3NjIyMWM4ZWYwNDJjNmEyODc3YjUwYjVhOWM4OTQ1OTQ=
12
12
  data.tar.gz: !binary |-
13
- MzBjODY2NmJkZmI4NTViNmY5ZmRlOTIyOTZlN2VmZjMyMDgwNDI5ZTA3Y2M5
14
- ZGFiZjhlNzVlYTViMDQxNjllZGQzZDE5MTZiZjYzM2JhMWU4ZmE3YTZiZGM3
15
- OTgwMmQ3NzcyZDYwMzAyYjI1OGZhMGE5MmU4MzFlNzgyYjAwNGQ=
13
+ Nzg0MDY4NGU5ZTU4MjU5YmQ1ZWI2NTFkYWZkNzg4MmM0NzNhYTcwNjM5NmYz
14
+ YmJhNWNiZWE1Y2NkYThiMzE5N2MzOGM2ZDE0NmM3NmQ3Mjg1OWQxNzRiZjFi
15
+ YzU4NjRhMDZiNTY5MTdkNzBlNTYxZTlkMGI2Njg5MTY5YWU5MGU=
data/.travis.yml CHANGED
@@ -4,10 +4,15 @@ rvm:
4
4
  - 2.1.8
5
5
  - 2.2.3
6
6
  - 2.3.1
7
+ before_install:
8
+ - rvm @global do gem uninstall bundler -a -x
9
+ - rvm @global do gem install bundler -v 1.12.5
10
+ cache:
11
+ directories:
12
+ - vendor/
7
13
  env:
8
14
  - secure: "AKXU+TV7xK0tZdtKq7ONJyLrrJfBNaPDMLvARHYPQlgHc0LDCaYSC3r+RZwIWMNBWYrAsT0A4wmLviUXex1gPvIJ9ej9bhUE0ch6xnFP1LUQG7UF1HjregG6zZqrPuxJ7fqJx3dATy2vV13BiIUmjkxRKeN76fQI/ISIkDhv2GHLGp8uuRxKBmxKFCX0azYzNOZtz8vSSF5iWmRbHjbc6XEP6s3OwkSU1FUCvXh5o+mVxA+yHufCoZnCZbGsw1Y+0+l/kIq+dypJrHBGrvu6xH5zJDddtwcJ9TS1Q4W7+XUTag5MrLDYlLoSBKDSXUkeGZ9Pv7fRhw0FZssOy8mBWVvM2Np2r7/p5yWqCoKQ9rvnhy1xAMVpwA6BzKzp47UV8DeSXywABO8rqtFDfimrh2FWViiEkLbMTH8YtykD1+OB6HLr/qPwogtBHAKdPhW3vHV4SM7+QzIUVHzzxYZES5lZGHiYZ9HGp4cGNtBQ0dwoCO11zeAVJXasjXzzBCn/TtlFAgS+xsephygk8YGzNvUBSwiMAd7vPt1ikm5R9RN4Vp8WEC0QyTNNVvG+Z8fuYC8x2KR16TYKOBFcYfBVMdDtoDJX45gIVxjGiLa9Dm2SCbyyeovI8o+6ryjSaSPE23ajxP7Xxx9nQXRGn14MyxDLndxpiZIMDoc18On+t9E="
9
- cache: bundler
10
- script: bundle install && bundle exec rspec spec/
15
+ script: bundle install --path vendor/bundle && bundle exec rspec spec/
11
16
  deploy:
12
17
  provider: rubygems
13
18
  api_key: $GEM_TOKEN
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ group :development do
7
7
  gem "kontena-cli", "~> 0.16.0.pre2"
8
8
  gem "listen", "~> 3.0.8"
9
9
  gem "rspec"
10
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", tag: "v1.8.4"
10
11
  end
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_runtime_dependency 'kontena-cli', '>= 0.16.0.pre2'
21
- spec.add_development_dependency "bundler", "~> 1.11"
21
+ spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  end
@@ -69,8 +69,8 @@ coreos:
69
69
  --link kontena-server-mongo:mongodb \
70
70
  -e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
71
71
  -e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
72
- <% if server_name %>-e KONTENA_SERVER_NAME=<%= server_name %><% end %> \
73
- <% if initial_admin_code %>-e KONTENA_INITIAL_ADMIN_CODE=<%= initial_admin_code %><% end %> \
72
+ <% if server_name %>-e SERVER_NAME=<%= server_name %><% end %> \
73
+ <% if initial_admin_code %>-e INITIAL_ADMIN_CODE=<%= initial_admin_code %><% end %> \
74
74
  -p 8080:9292 \
75
75
  kontena/server:${KONTENA_VERSION}
76
76
  ExecStop=/usr/bin/docker stop kontena-server-api
@@ -90,7 +90,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
90
90
  end
91
91
 
92
92
  config.vm.define "<%= name %>" do |docker|
93
- docker.vm.box = "coreos-stable"
93
+ docker.vm.box = "coreos-<%= coreos_channel %>"
94
94
  docker.vm.box_url = "http://stable.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json"
95
95
  docker.vm.network "private_network", ip: "192.168.66.100"
96
96
  docker.vm.hostname = "<%= name %>"
@@ -15,7 +15,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
15
15
  end
16
16
 
17
17
  config.vm.define "<%= name %>" do |docker|
18
- docker.vm.box = "coreos-stable"
18
+ docker.vm.box = "coreos-<%= coreos_channel %>"
19
19
  docker.vm.box_url = "http://stable.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json"
20
20
  docker.vm.network "private_network", type: "dhcp"
21
21
  docker.vm.hostname = "<%= name %>"
@@ -7,13 +7,6 @@ module Kontena
7
7
 
8
8
  include Kontena::Cli::ShellSpinner
9
9
 
10
- attr_reader :client, :api_client
11
-
12
- # @param [Kontena::Client] api_client Kontena api client
13
- def initialize(api_client)
14
- @api_client = api_client
15
- end
16
-
17
10
  def run!
18
11
  vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
19
12
  Dir.chdir(vagrant_path) do
@@ -8,6 +8,7 @@ module Kontena
8
8
  class MasterProvisioner
9
9
  include RandomName
10
10
  include Kontena::Machine::Common
11
+ include Kontena::Cli::Common
11
12
  include Kontena::Cli::ShellSpinner
12
13
 
13
14
  API_URL = 'http://192.168.66.100:8080'
@@ -24,6 +25,7 @@ module Kontena
24
25
  vault_secret = opts[:vault_secret]
25
26
  vault_iv = opts[:vault_iv]
26
27
  initial_admin_code = opts[:initial_admin_code]
28
+ coreos_channel = opts[:coreos_channel]
27
29
  vagrant_path = "#{Dir.home}/.kontena/vagrant_master/"
28
30
  if Dir.exist?(vagrant_path)
29
31
  puts "Oops... cannot create Kontena Master because installation path already exists."
@@ -42,6 +44,7 @@ module Kontena
42
44
  vault_secret: vault_secret,
43
45
  initial_admin_code: initial_admin_code,
44
46
  vault_iv: vault_iv,
47
+ coreos_channel: coreos_channel,
45
48
  cloudinit: "#{vagrant_path}/cloudinit.yml"
46
49
  }
47
50
  vagrant_data = erb(File.read(template), vars)
@@ -61,10 +64,7 @@ module Kontena
61
64
  spinner "Waiting for #{name.colorize(:cyan)} to start " do
62
65
  sleep 1 until master_running?
63
66
  end
64
-
65
- puts
66
- puts "Kontena Master is now running at #{API_URL}".colorize(:green)
67
- puts
67
+ vspinner "Kontena Master is now running at #{API_URL}"
68
68
 
69
69
  {
70
70
  name: name.sub('kontena-master-', ''),
@@ -35,6 +35,7 @@ module Kontena
35
35
  memory: opts[:memory] || 1024,
36
36
  master_uri: opts[:master_uri],
37
37
  grid_token: opts[:grid_token],
38
+ coreos_channel: opts[:coreos_channel],
38
39
  cloudinit: "#{vagrant_path}/cloudinit.yml"
39
40
  }
40
41
  vagrant_data = erb(File.read(template), vars)
@@ -51,7 +52,7 @@ module Kontena
51
52
  end
52
53
  end
53
54
  spinner "Waiting for node #{name.colorize(:cyan)} join to grid #{grid.colorize(:cyan)} " do
54
- sleep 1 until node_exists_in_grid?(grid, name)
55
+ sleep 1 until node = node_exists_in_grid?(grid, name)
55
56
  end
56
57
  end
57
58
  set_labels(
@@ -2,24 +2,41 @@ require 'securerandom'
2
2
 
3
3
  module Kontena::Plugin::Vagrant::Master
4
4
  class CreateCommand < Kontena::Command
5
+ include Kontena::Cli::Common
5
6
 
6
- option "--memory", "MEMORY", "How much memory node has", default: '512'
7
+ option "--name", "[NAME]", "Set master name"
8
+ option "--memory", "MEMORY", "How much memory node has"
7
9
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
8
10
  option "--vault-secret", "VAULT_SECRET", "Secret key for Vault"
9
11
  option "--vault-iv", "VAULT_IV", "Initialization vector for Vault"
10
12
  option "--name", "NAME", "Set Master name"
13
+ option "--coreos-channel", "CHANNEL", "CoreOS release channel", default: 'stable'
11
14
 
12
15
  def execute
13
16
  require_relative '../../../machine/vagrant'
17
+ mem = ask_instance_memory
14
18
  provisioner.run!(
15
- memory: memory,
19
+ memory: mem,
16
20
  version: version,
17
21
  vault_secret: vault_secret || SecureRandom.hex(24),
18
22
  vault_iv: vault_iv || SecureRandom.hex(24),
19
- initial_admin_code: SecureRandom.hex(16)
23
+ initial_admin_code: SecureRandom.hex(16),
24
+ coreos_channel: coreos_channel
20
25
  )
21
26
  end
22
27
 
28
+ def ask_instance_memory
29
+ if self.memory.nil?
30
+ prompt.select("Choose a size") do |menu|
31
+ %w(512 1024 2048).each do |mem|
32
+ menu.choice "#{mem}MB", mem
33
+ end
34
+ end
35
+ else
36
+ self.memory
37
+ end
38
+ end
39
+
23
40
  def provisioner
24
41
  Kontena::Machine::Vagrant::MasterProvisioner.new
25
42
  end
@@ -5,17 +5,9 @@ module Kontena::Plugin::Vagrant::Master
5
5
  option '--force', :flag, 'Force remove', default: false, attribute_name: :forced
6
6
 
7
7
  def execute
8
- require_api_url
9
-
10
8
  confirm unless forced?
11
-
12
9
  require_relative '../../../machine/vagrant'
13
- destroyer = destroyer(client(require_token))
14
- destroyer.run!
15
- end
16
-
17
- def destroyer(client)
18
- Kontena::Machine::Vagrant::MasterDestroyer.new(client)
10
+ Kontena::Machine::Vagrant::MasterDestroyer.new.run!
19
11
  end
20
12
  end
21
13
  end
@@ -4,19 +4,23 @@ module Kontena::Plugin::Vagrant::Nodes
4
4
  include Kontena::Cli::GridOptions
5
5
 
6
6
  parameter "[NAME]", "Node name"
7
- option "--instances", "AMOUNT", "How many nodes will be created", default: '1'
8
- option "--memory", "MEMORY", "How much memory node has", default: '1024'
7
+ option "--instances", "AMOUNT", "How many nodes will be created"
8
+ option "--memory", "MEMORY", "How much memory node has"
9
9
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
10
+ option "--coreos-channel", "CHANNEL", "CoreOS release channel", default: 'stable'
10
11
 
11
12
  def execute
12
13
  api_url = require_api_url
13
14
  require_current_grid
14
15
 
16
+ instance_count = ask_instances
17
+ instance_memory = ask_instance_memory
18
+
15
19
  require_relative '../../../machine/vagrant'
16
20
 
17
21
  grid = fetch_grid
18
22
  provisioner = provisioner(client(require_token))
19
- instances.to_i.times do |i|
23
+ instance_count.to_i.times do |i|
20
24
  provisioner.run!(
21
25
  master_uri: api_url,
22
26
  grid_token: grid['token'],
@@ -24,11 +28,32 @@ module Kontena::Plugin::Vagrant::Nodes
24
28
  name: name,
25
29
  instance_number: i + 1,
26
30
  memory: memory,
27
- version: version
31
+ version: version,
32
+ coreos_channel: coreos_channel
28
33
  )
29
34
  end
30
35
  end
31
36
 
37
+ def ask_instances
38
+ if self.instances.nil?
39
+ prompt.ask("How many nodes?: ", default: 1, in: '1..10')
40
+ else
41
+ self.instances
42
+ end
43
+ end
44
+
45
+ def ask_instance_memory
46
+ if self.memory.nil?
47
+ prompt.select("Choose a size ") do |menu|
48
+ %w(1024 2048 4096).each do |mem|
49
+ menu.choice "#{mem}MB", mem
50
+ end
51
+ end
52
+ else
53
+ self.memory
54
+ end
55
+ end
56
+
32
57
  # @param [Kontena::Client] client
33
58
  def provisioner(client)
34
59
  Kontena::Machine::Vagrant::NodeProvisioner.new(client)
@@ -1,7 +1,7 @@
1
1
  module Kontena
2
2
  module Plugin
3
3
  module Vagrant
4
- VERSION = "0.2.0.pre1"
4
+ VERSION = "0.2.0.pre2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-plugin-vagrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre1
4
+ version: 0.2.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-26 00:00:00.000000000 Z
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kontena-cli
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
- version: '1.11'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
- version: '1.11'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement