kontena-plugin-packet 0.2.0.pre1 → 0.2.0

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
- OTE0NzVkM2EzYzQxMDEyNTE5YTUxMzEwZWYyYTZiYWRjYzZhOTJlOA==
4
+ MGQwYzI5OTg5MTkwZDM5NDQyNzZlMzE3MzFkYzBhZmI5ZmYxMWM4Mw==
5
5
  data.tar.gz: !binary |-
6
- MzcxYjQ1ZDM5ZTIzNzdkNDQ0NmJmODQwYTZlZmQwNmJkMGEwOTI1Yw==
6
+ OWIzNDcwMWYwODY2YjI5ZTVlMjgyMTgyZjA4ZDE5ZDM0YWNiNzFhNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODM5OTNkMTE1NDk4NDY1Y2U4YTQwZTdiOTIxN2U0MmI3NjRmZGM3NmI2MzUx
10
- ZjEzODYyNzU0YWVkMGYxYWRmYmQxZjlmNjZkMmNlZjgyZWVjOTM3NjdlMGVm
11
- OTVmMDk1YTc1M2FiYzRkMTc4NDg5MTQyNDc4MDgwYjk2NWRlOWE=
9
+ YjM0MzkwZTU0M2YzYzYxZTc0ZDEwMDA5MDBmMGFmZDdhYWE0NTg1ZTA0MTBl
10
+ Y2EwMGEyMTQyMTNmZDk0MWRlYWEzMzJjZmNiZGY3MzZmNGNjOTU3YTAzMDRl
11
+ NzhkMzM1NmM2YzAzYTczM2FiNGI1YmUxMmNlYTJhNDI1NTYzNzY=
12
12
  data.tar.gz: !binary |-
13
- YjFjNjAwNzg5NTFkZTI2MzIwY2ZkNTkyZDZiZTJiODc0ZTRhODJmZjk2MWFk
14
- Y2I5NWI1ZWE1ZDM2MGVjN2IzODJiYmRkNDI3YjBjM2UyNTgwNDAzYjA3NzM2
15
- MDAxYzZkYzhhMzczYWYzNmZmYmQyZGJjZjI4NGYzYTU5ZDc0NzI=
13
+ MGQ5MTY0MmQxMjgzZDc4MjJlNjE0MjA3MTIwMGMwYjc0YWE5NzIxMjAxZWM1
14
+ MjMyMTE4MWQ4NzI3NTc5YTM0Y2QzMTNjZTgyZjg1Nzc3NzM2MzYwZmJiNDdi
15
+ MTNjZjlmYWE2YTA2ZWM4NTQwMTdjMjdiYTNlYmNhYmZhYTA3Mjc=
@@ -18,7 +18,7 @@ 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_runtime_dependency 'packethost', '>= 0.0.6'
21
+ spec.add_runtime_dependency 'packethost', '>= 0.0.8'
22
22
  spec.add_development_dependency "bundler", "~> 1.11"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  end
@@ -28,6 +28,16 @@ write_files:
28
28
  nameserver 8.8.4.4
29
29
  coreos:
30
30
  units:
31
+ - name: etcd2.service
32
+ command: start
33
+ enable: true
34
+ content: |
35
+ Description=etcd 2.0
36
+ After=docker.service
37
+ [Service]
38
+ Restart=always
39
+ RestartSec=5
40
+ ExecStart=/usr/bin/docker logs --tail=10 -f kontena-etcd
31
41
  - name: 10-weave.network
32
42
  runtime: false
33
43
  content: |
@@ -88,11 +88,11 @@ coreos:
88
88
  --link kontena-server-mongo:mongodb \
89
89
  -e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
90
90
  <% end -%>
91
- <% if server_name %>
92
- -e KONTENA_SERVER_NAME=<%= server_name %> \
91
+ <% if server_name -%>
92
+ -e SERVER_NAME=<%= server_name %> \
93
93
  <% end -%>
94
- <% if initial_admin_code %>
95
- -e KONTENA_INITIAL_ADMIN_CODE=<%= initial_admin_code %> \
94
+ <% if initial_admin_code -%>
95
+ -e INITIAL_ADMIN_CODE=<%= initial_admin_code %> \
96
96
  <% end -%>
97
97
  -e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
98
98
  kontena/server:${KONTENA_VERSION}
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Kontena
2
4
  module Machine
3
5
  module Packet
@@ -5,7 +7,7 @@ module Kontena
5
7
  include RandomName
6
8
  include Machine::CertHelper
7
9
  include PacketCommon
8
- include Kontena::Cli::ShellSpinner
10
+ include Kontena::Cli::Common
9
11
 
10
12
  attr_reader :client, :http_client
11
13
 
@@ -26,7 +28,7 @@ module Kontena
26
28
  abort('Invalid ssl cert') unless File.exists?(File.expand_path(opts[:ssl_cert]))
27
29
  ssl_cert = File.read(File.expand_path(opts[:ssl_cert]))
28
30
  else
29
- spinner "Generating self-signed SSL certificate" do
31
+ spinner "Generating a self-signed SSL certificate" do
30
32
  ssl_cert = generate_self_signed_cert
31
33
  end
32
34
  end
@@ -48,7 +50,7 @@ module Kontena
48
50
  userdata: user_data(userdata_vars, 'cloudinit_master.yml')
49
51
  )
50
52
 
51
- spinner "Creating Packet device #{device.hostname.colorize(:cyan)} " do
53
+ spinner "Creating a Packet device #{device.hostname.colorize(:cyan)} " do
52
54
  api_retry "Packet API reported an error, please try again" do
53
55
  response = client.create_device(device)
54
56
  raise response.body unless response.success?
@@ -70,14 +72,19 @@ module Kontena
70
72
  sleep 0.5 until master_running?
71
73
  end
72
74
 
73
- puts
74
- puts "Kontena Master is now running at #{master_url}".colorize(:green)
75
- puts
75
+ master_version = nil
76
+ spinner "Retrieving Kontena Master version" do
77
+ master_version = JSON.parse(http_client.get(path: '/').body)["version"] rescue nil
78
+ end
79
+
80
+ spinner "Kontena Master #{master_version} is now running at #{master_url}".colorize(:green)
76
81
 
77
82
  {
78
83
  name: name.sub('kontena-master-', ''),
79
84
  public_ip: public_ip['address'],
80
- code: opts[:initial_admin_code]
85
+ code: opts[:initial_admin_code],
86
+ provider: 'packet',
87
+ version: master_version
81
88
  }
82
89
  end
83
90
 
@@ -1,7 +1,7 @@
1
1
  module Kontena
2
2
  module Plugin
3
3
  module Packet
4
- VERSION = "0.2.0.pre1"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,43 @@
1
+ module Kontena::Plugin::Packet
2
+ module FacilityOption
3
+
4
+ def self.included(base)
5
+ base.option "--facility", "CODE", "Packet facility"
6
+ base.class_eval do
7
+ def default_facility
8
+ require 'packet'
9
+ client = Packet::Client.new(self.token || (self.respond_to?(:default_token) && self.default_token))
10
+
11
+ facilities = []
12
+ spinner "Retrieving a list of available facilities at Packet" do
13
+ facilities = client.list_facilities
14
+ end
15
+
16
+ case facilities.size
17
+ when 0
18
+ abort 'You do not have access to any facilities on Packet'
19
+ when 1
20
+ unless Kontena.prompt.yes?("You have access to facility '#{facilities.first.name}'. Use?")
21
+ abort 'Aborted'
22
+ end
23
+ facilities.first.code
24
+ else
25
+ Kontena.prompt.select "Packet facility:" do |menu|
26
+ facilities.each do |facility|
27
+ if facility.features.empty?
28
+ feats = ""
29
+ else
30
+ feats = "(#{facility.features.join(',')})"
31
+ end
32
+ menu.choice "#{facility.name} #{feats}", facility.code
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+
@@ -1,17 +1,21 @@
1
1
  require 'securerandom'
2
+ require_relative '../token_option'
3
+ require_relative '../project_option'
4
+ require_relative '../type_option'
5
+ require_relative '../facility_option'
2
6
 
3
7
  module Kontena::Plugin::Packet::Master
4
8
  class CreateCommand < Kontena::Command
5
9
  include Kontena::Cli::Common
10
+ include Kontena::Plugin::Packet::TokenOption
11
+ include Kontena::Plugin::Packet::ProjectOption
12
+ include Kontena::Plugin::Packet::TypeOption
13
+ include Kontena::Plugin::Packet::FacilityOption
6
14
 
7
15
  option "--name", "[NAME]", "Set master name"
8
- option "--token", "TOKEN", "Packet API token", required: true
9
- option "--project", "PROJECT ID", "Packet project id", required: true
10
16
  option "--ssl-cert", "PATH", "SSL certificate file (optional)"
11
- option "--type", "TYPE", "Server type (baremetal_0, baremetal_1, ..)", default: 'baremetal_0', attribute_name: :plan
12
- option "--facility", "FACILITY CODE", "Facility", default: 'ams1'
13
17
  option "--billing", "BILLING", "Billing cycle", default: 'hourly'
14
- option "--ssh-key", "PATH", "Path to ssh public key (optional)"
18
+ option "--ssh-key", "PATH", "Path to ssh public key", default: File.join(Dir.home, '.ssh', 'id_rsa.pub')
15
19
  option "--vault-secret", "VAULT_SECRET", "Secret key for Vault (optional)"
16
20
  option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (optional)"
17
21
  option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
@@ -1,15 +1,21 @@
1
+ require_relative '../token_option'
2
+ require_relative '../project_option'
3
+ require_relative '../type_option'
4
+ require_relative '../facility_option'
5
+
1
6
  module Kontena::Plugin::Packet::Nodes
2
7
  class CreateCommand < Kontena::Command
3
8
  include Kontena::Cli::Common
4
9
  include Kontena::Cli::GridOptions
10
+ include Kontena::Plugin::Packet::TokenOption
11
+ include Kontena::Plugin::Packet::ProjectOption
12
+ include Kontena::Plugin::Packet::TypeOption
13
+ include Kontena::Plugin::Packet::FacilityOption
5
14
 
6
15
  parameter "[NAME]", "Node name"
7
- option "--token", "TOKEN", "Packet API token", required: true
8
- option "--project", "PROJECT ID", "Packet project id", required: true
9
- option "--type", "TYPE", "Server type (baremetal_0, baremetal_1, ..)", default: 'baremetal_0', attribute_name: :plan
10
- option "--facility", "FACILITY CODE", "Facility", default: 'ams1'
16
+
11
17
  option "--billing", "BILLING", "Billing cycle", default: 'hourly'
12
- option "--ssh-key", "PATH", "Path to ssh public key (optional)"
18
+ option "--ssh-key", "PATH", "Path to ssh public key", default: File.join(Dir.home, '.ssh', 'id_rsa.pub')
13
19
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
14
20
 
15
21
  def execute
@@ -18,7 +24,7 @@ module Kontena::Plugin::Packet::Nodes
18
24
 
19
25
  require_relative '../../../machine/packet'
20
26
  grid = fetch_grid
21
- provisioner = provisioner(client(require_token), token)
27
+ provisioner = provisioner(client, token)
22
28
  provisioner.run!(
23
29
  master_uri: api_url,
24
30
  grid_token: grid['token'],
@@ -40,7 +46,7 @@ module Kontena::Plugin::Packet::Nodes
40
46
 
41
47
  # @return [Hash]
42
48
  def fetch_grid
43
- client(require_token).get("grids/#{current_grid}")
49
+ client.get("grids/#{current_grid}")
44
50
  end
45
51
  end
46
52
  end
@@ -0,0 +1,37 @@
1
+ module Kontena::Plugin::Packet
2
+ module ProjectOption
3
+
4
+ def self.included(base)
5
+ base.option "--project", "PROJECT_ID", "Packet project ID", environment_variable: 'PACKET_PROJECT'
6
+ base.class_eval do
7
+ def default_project
8
+ require 'packet'
9
+
10
+ client = Packet::Client.new(self.token || (self.respond_to?(:default_token) && self.default_token))
11
+
12
+ projects = []
13
+ spinner "Retrieving a list of available projects on Packet" do
14
+ projects = client.list_projects
15
+ end
16
+
17
+ case projects.size
18
+ when 0
19
+ abort 'You do not have access to any projects on Packet'
20
+ when 1
21
+ unless Kontena.prompt.yes?("You have access to project '#{projects.first.name}'. Use?")
22
+ abort 'Aborted'
23
+ end
24
+ projects.first.id
25
+ else
26
+ Kontena.prompt.select "Packet project:" do |menu|
27
+ projects.each do |project|
28
+ menu.choice project.name, project.id
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,12 @@
1
+ module Kontena::Plugin::Packet
2
+ module TokenOption
3
+ def self.included(base)
4
+ base.option "--token", "TOKEN", "Packet API token", environment_variable: 'PACKET_TOKEN'
5
+ base.class_eval do
6
+ def default_token
7
+ Kontena.prompt.ask("Packet API token:")
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,47 @@
1
+ module Kontena::Plugin::Packet
2
+ module TypeOption
3
+
4
+ def self.included(base)
5
+ base.option "--type", "SLUG", "Packet server plan type", attribute_name: :plan
6
+ base.class_eval do
7
+ def default_project
8
+ require 'packet'
9
+
10
+ client = Packet::Client.new(self.token || (self.respond_to?(:default_token) && self.default_token))
11
+
12
+ plans = []
13
+ spinner "Retrieving a list of available plans at Packet" do
14
+ plans = client.list_plans
15
+ end
16
+
17
+ case plans.size
18
+ when 0
19
+ abort 'You do not have access to any plans on Packet'
20
+ when 1
21
+ unless Kontena.prompt.yes?("You have access to plan '#{plans.first.name}'. Use?")
22
+ abort 'Aborted'
23
+ end
24
+ plans.first.slug
25
+ else
26
+ puts
27
+ puts pastel.bright_blue("Packet plans:")
28
+ puts
29
+ plans.each do |plan|
30
+ puts pastel.green(" #{"%-11s" % "#{plan.name}:"}")
31
+ puts pastel.bright_blue(" #{plan.description}")
32
+ end
33
+ puts
34
+
35
+ Kontena.prompt.select "Packet plan:" do |menu|
36
+ plans.each do |plan|
37
+ menu.choice plan.name, plan.slug
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-plugin-packet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre1
4
+ version: 0.2.0
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-29 00:00:00.000000000 Z
11
+ date: 2016-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kontena-cli
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.6
33
+ version: 0.0.8
34
34
  type: :runtime
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: 0.0.6
40
+ version: 0.0.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -90,12 +90,16 @@ files:
90
90
  - lib/kontena/machine/packet/node_restarter.rb
91
91
  - lib/kontena/machine/packet/packet_common.rb
92
92
  - lib/kontena/plugin/packet.rb
93
+ - lib/kontena/plugin/packet/facility_option.rb
93
94
  - lib/kontena/plugin/packet/master/create_command.rb
94
95
  - lib/kontena/plugin/packet/master_command.rb
95
96
  - lib/kontena/plugin/packet/node_command.rb
96
97
  - lib/kontena/plugin/packet/nodes/create_command.rb
97
98
  - lib/kontena/plugin/packet/nodes/restart_command.rb
98
99
  - lib/kontena/plugin/packet/nodes/terminate_command.rb
100
+ - lib/kontena/plugin/packet/project_option.rb
101
+ - lib/kontena/plugin/packet/token_option.rb
102
+ - lib/kontena/plugin/packet/type_option.rb
99
103
  - lib/kontena/plugin/packet_command.rb
100
104
  - lib/kontena_cli_plugin.rb
101
105
  homepage: https://github.com/kontena/kontena-plugin-packet
@@ -113,9 +117,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
117
  version: '0'
114
118
  required_rubygems_version: !ruby/object:Gem::Requirement
115
119
  requirements:
116
- - - ! '>'
120
+ - - ! '>='
117
121
  - !ruby/object:Gem::Version
118
- version: 1.3.1
122
+ version: '0'
119
123
  requirements: []
120
124
  rubyforge_project:
121
125
  rubygems_version: 2.4.5