vagrant-linode 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e16e4d4758bf63cfd92415d81520f83db8f353c3
4
- data.tar.gz: 6bc13afd6403044f06b2b8cb1d1e2be04d5d2e56
3
+ metadata.gz: 18251b22d7c4b04762d22da9cb2d724604345a71
4
+ data.tar.gz: a4b9cd21684c90388fb3f81a745bc3a911bb643e
5
5
  SHA512:
6
- metadata.gz: 4b996b315d58e433ae27434d50b2e8974f15a6fe751ad5f8e6598774673c042ef76aac85b9392e530134d5917a2006e86c76b0a5afe35656c1a5a98217538fd0
7
- data.tar.gz: d7a18739c9a870e5f4e5affa6c1b1be7da1b67cc819768d4e82f9546ca4c7c20a2f2679c5f027916fa33a5e22651e7484523f140c3ae6e5da32e9fa7d9955e95
6
+ metadata.gz: 16753c736f94bbbe79f16f15f6d9274b0dc76f5f86549ecedf96ec847447f2e95b47e6ea3e20a8a7b35c82028ac56fd7b68dfb4fd2655742486e7422c605cb62
7
+ data.tar.gz: a26d05de5eea17ae1d966590d588ea8116643744900cba9c74be9d8b29e44989b9bea1414a5be10a7d2063441ed6c10369aab9ef06e81822a168f5b4d55c4d17
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
-
4
+ v0.2.2 fixed provision on startup
data/README.md CHANGED
@@ -29,7 +29,7 @@ Configure
29
29
  ---------
30
30
  Once the provider has been installed, you will need to configure your project
31
31
  to use it. The most basic `Vagrantfile` to create a linode on Linode
32
- is shown below:
32
+ is shown below (with most of the available options included but commented out):
33
33
 
34
34
  ```ruby
35
35
  Vagrant.configure('2') do |config|
@@ -51,8 +51,8 @@ Vagrant.configure('2') do |config|
51
51
  # provider.kernel = <string>
52
52
  # provider.kernelid = <int>
53
53
  # provider.private_networking = <boolean>
54
- # provider.stackscript = <string>
55
- # provider.stackscriptid = <int>
54
+ # provider.stackscript = <string> # Not Supported Yet
55
+ # provider.stackscriptid = <int> # Not Supported Yet
56
56
  # provider.distributionid = <int>
57
57
  end
58
58
  end
@@ -113,17 +113,17 @@ Current Plan-ID table follows:
113
113
 
114
114
  This can be obtained through vagrant with:
115
115
  ```
116
- vagrant linode datacenters
116
+ vagrant linode plans
117
117
  ```
118
118
 
119
119
  Or using curl:
120
120
  ```
121
- curl -X POST "https://api.linode.com/?api_action=avail.plans" \
121
+ curl -X POST "https://api.linode.com/?api_action=avail.linodeplans" \
122
122
  --data-ascii api_key="$LINODE_API_KEY" \
123
123
  2>/dev/null | jq '.DATA [] | .PLANID,.LABEL'
124
124
  ```
125
125
 
126
- More detail: [Linode API - Plans](https://www.linode.com/api/utility/avail.plans)
126
+ More detail: [Linode API - Plans](https://www.linode.com/api/utility/avail.linodeplans)
127
127
 
128
128
  ### provider.datacenter
129
129
 
@@ -139,6 +139,7 @@ Current Region-ID table is:
139
139
  | 6 | newark | Newark, NJ, USA |
140
140
  | 8 | tokyo | Tokyo, JP |
141
141
  | 9 | singapore | Singapore, SGP |
142
+ | 10 | frankfurt | Frankfurt, DE |
142
143
 
143
144
  You can find latest datacenter ID number using Vagrant subcommands:
144
145
 
@@ -38,6 +38,20 @@ module VagrantPlugins
38
38
  distribution_id = @machine.provider_config.distributionid
39
39
  end
40
40
 
41
+ if @machine.provider_config.imageid
42
+ distribution_id = nil
43
+ images = @client.image.list
44
+ image = images.find { |i| i.imageid == @machine.provider_config.imageid }
45
+ fail Errors::ImageMatch, image: @machine.provider_config.imageid.to_s if image.nil?
46
+ image_id = image.imageid || nil
47
+ elsif @machine.provider_config.image
48
+ distribution_id = nil
49
+ images = @client.image.list
50
+ image = images.find { |i| i.label.downcase.include? @machine.provider_config.image.downcase }
51
+ fail Errors::ImageMatch, image: @machine.provider_config.image.to_s if image.nil?
52
+ image_id = image.imageid || nil
53
+ end
54
+
41
55
  if @machine.provider_config.kernel
42
56
  kernels = @client.avail.kernels
43
57
  kernel = kernels.find { |k| k.label.downcase.include? @machine.provider_config.kernel.downcase }
@@ -50,17 +64,24 @@ module VagrantPlugins
50
64
  if @machine.provider_config.datacenter
51
65
  datacenters = @client.avail.datacenters
52
66
  datacenter = datacenters.find { |d| d.abbr == @machine.provider_config.datacenter }
53
- datacenter_id = datacenter.datacenterid || nil # @todo throw if not found
67
+ fail Errors::DatacenterMatch, datacenter: @machine.provider_config.datacenter if datacenter.nil?
68
+ datacenter_id = datacenter.datacenterid
54
69
  else
55
- datacenter_id = @machine.provider_config.datacenterid
70
+ datacenters = @client.avail.datacenters
71
+ datacenter = datacenters.find { |d| d.datacenterid == @machine.provider_config.datacenterid }
72
+ fail Errors::DatacenterMatch, datacenter: @machine.provider_config.datacenter if datacenter.nil?
73
+ datacenter_id = datacenter.datacenterid
56
74
  end
57
75
 
58
76
  if @machine.provider_config.plan
59
77
  plans = @client.avail.linodeplans
60
78
  plan = plans.find { |p| p.label.include? @machine.provider_config.plan }
61
79
  fail Errors::PlanID, plan: @machine.provider_config.plan if plan.nil?
62
- plan_id = plan.planid || nil
80
+ plan_id = plan.planid
63
81
  else
82
+ plans = @client.avail.linodeplans
83
+ plan = plans.find { |p| p.planid == @machine.provider_config.planid }
84
+ fail Errors::PlanID, plan: @machine.provider_config.plan if plan.nil?
64
85
  plan_id = @machine.provider_config.planid
65
86
  end
66
87
 
@@ -114,6 +135,7 @@ module VagrantPlugins
114
135
  disk = @client.linode.disk.createfromimage(
115
136
  linodeid: result['linodeid'],
116
137
  imageid: image_id,
138
+ label: 'Vagrant Disk Image (' + image_id.to_s + ') for ' + result['linodeid'].to_s,
117
139
  size: xvda_size,
118
140
  rootsshkey: pubkey,
119
141
  rootpass: root_pass
@@ -197,7 +219,7 @@ module VagrantPlugins
197
219
 
198
220
  # generate a random name if server name is empty
199
221
  def get_server_name
200
- server_name = "vagrant_linode-#{rand.to_s.split('.')[1]}"
222
+ "vagrant_linode-#{rand.to_s.split('.')[1]}"
201
223
  end
202
224
 
203
225
  def terminate(env)
@@ -17,9 +17,8 @@ module VagrantPlugins
17
17
  def read_state(_linode, machine)
18
18
  return :not_created if machine.id.nil?
19
19
  server = Provider.linode(machine)
20
-
21
20
  return :not_created if server.nil?
22
- status = server.status
21
+ status = server[:status]
23
22
  return :not_created if status.nil?
24
23
  states = {
25
24
  '' => :not_created,
@@ -111,22 +111,22 @@ module VagrantPlugins
111
111
  if env[:result]
112
112
  b.use Call, IsStopped do |env2, b2|
113
113
  if env2[:result]
114
+ b2.use Provision
114
115
  b2.use MessageOff
115
116
  b2.use ConnectLinode
116
117
  b2.use PowerOn
117
- b2.use Provision
118
118
  else
119
119
  b2.use MessageAlreadyActive
120
120
  end
121
121
  end
122
122
  else
123
+ b.use Provision
123
124
  b.use MessageNotCreated
124
125
  b.use ConnectLinode
125
126
  b.use Create
126
127
  b.use SetupSudo
127
128
  b.use SetupUser
128
129
  b.use SetupHostname
129
- b.use Provision
130
130
  end
131
131
  end
132
132
  end
@@ -4,8 +4,13 @@ module VagrantPlugins
4
4
  attr_accessor :token # deprecated
5
5
  attr_accessor :api_key
6
6
  attr_accessor :api_url
7
+ attr_accessor :distributionid
7
8
  attr_accessor :distribution
9
+ attr_accessor :imageid
10
+ attr_accessor :image
11
+ attr_accessor :datacenterid
8
12
  attr_accessor :datacenter
13
+ attr_accessor :planid
9
14
  attr_accessor :plan
10
15
  attr_accessor :paymentterm
11
16
  attr_accessor :private_networking
@@ -14,7 +19,7 @@ module VagrantPlugins
14
19
  attr_accessor :setup
15
20
  attr_accessor :xvda_size
16
21
  attr_accessor :swap_size
17
- attr_accessor :kernel_id
22
+ attr_accessor :kernelid
18
23
  attr_accessor :kernel
19
24
  attr_accessor :label
20
25
  attr_accessor :group
@@ -27,8 +32,13 @@ module VagrantPlugins
27
32
  @token = UNSET_VALUE
28
33
  @api_key = UNSET_VALUE
29
34
  @api_url = UNSET_VALUE
35
+ @distributionid = UNSET_VALUE
30
36
  @distribution = UNSET_VALUE
37
+ @imageid = UNSET_VALUE
38
+ @image = UNSET_VALUE
39
+ @datacenterid = UNSET_VALUE
31
40
  @datacenter = UNSET_VALUE
41
+ @planid = UNSET_VALUE
32
42
  @plan = UNSET_VALUE
33
43
  @paymentterm = UNSET_VALUE
34
44
  @private_networking = UNSET_VALUE
@@ -37,7 +47,7 @@ module VagrantPlugins
37
47
  @setup = UNSET_VALUE
38
48
  @xvda_size = UNSET_VALUE
39
49
  @swap_size = UNSET_VALUE
40
- @kernel_id = UNSET_VALUE
50
+ @kernelid = UNSET_VALUE
41
51
  @kernel = UNSET_VALUE
42
52
  @label = UNSET_VALUE
43
53
  @group = UNSET_VALUE
@@ -48,9 +58,17 @@ module VagrantPlugins
48
58
  @token = ENV['LINODE_TOKEN'] if @token == UNSET_VALUE
49
59
  @api_key = @token if ((@api_key == nil) and (@token != nil))
50
60
  @api_url = ENV['LINODE_URL'] if @api_url == UNSET_VALUE
51
- @distribution = 'Ubuntu 14.04 LTS' if @distribution == UNSET_VALUE
52
- @datacenter = 'dallas' if @datacenter == UNSET_VALUE
53
- @plan = 'Linode 1024' if @plan == UNSET_VALUE
61
+ @imageid = nil if @imageid == UNSET_VALUE
62
+ @image = nil if @image == UNSET_VALUE
63
+ @distributionid = nil if @distributionid == UNSET_VALUE
64
+ @distribution = nil if @distribution == UNSET_VALUE
65
+ @distribution = 'Ubuntu 14.04 LTS' if @distribution.nil? and @distributionid.nil? and @imageid.nil? and @image.nil?
66
+ @datacenterid = nil if @datacenterid == UNSET_VALUE
67
+ @datacenter = nil if @datacenter == UNSET_VALUE
68
+ @datacenter = 'dallas' if @datacenter.nil? and @datacenterid.nil?
69
+ @planid = nil if @planid == UNSET_VALUE
70
+ @plan = nil if @plan == UNSET_VALUE
71
+ @plan = 'Linode 1024' if @plan.nil? and @planid.nil?
54
72
  @paymentterm = '1' if @paymentterm == UNSET_VALUE
55
73
  @private_networking = false if @private_networking == UNSET_VALUE
56
74
  @ca_path = nil if @ca_path == UNSET_VALUE
@@ -58,7 +76,9 @@ module VagrantPlugins
58
76
  @setup = true if @setup == UNSET_VALUE
59
77
  @xvda_size = true if @xvda_size == UNSET_VALUE
60
78
  @swap_size = '256' if @swap_size == UNSET_VALUE
61
- @kernel = 'Latest 64 bit' if @kernel == UNSET_VALUE and @kernel_id == UNSET_VALUE
79
+ @kernelid = nil if @kernelid == UNSET_VALUE
80
+ @kernel = nil if @kernel == UNSET_VALUE
81
+ @kernel = 'Latest 64 bit' if @kernel.nil? and @kernelid.nil?
62
82
  @label = false if @label == UNSET_VALUE
63
83
  @group = false if @group == UNSET_VALUE
64
84
  end
@@ -77,6 +97,30 @@ module VagrantPlugins
77
97
  errors << I18n.t('vagrant_linode.config.public_key', key: "#{key}.pub")
78
98
  end
79
99
 
100
+ if @distributionid and @distribution
101
+ errors << I18n.t('vagrant_linode.config.distributionid_or_distribution')
102
+ end
103
+
104
+ if @datacenterid and @datacenter
105
+ errors << I18n.t('vagrant_linode.config.datacenterid_or_datacenter')
106
+ end
107
+
108
+ if @kernelid and @kernel
109
+ errors << I18n.t('vagrant_linode.config.kernelid_or_kernel')
110
+ end
111
+
112
+ if @planid and @plan
113
+ errors << I18n.t('vagrant_linode.config.planid_or_plan')
114
+ end
115
+
116
+ if @imageid and @image
117
+ errors << I18n.t('vagrant_linode.config.imageid_or_image')
118
+ end
119
+
120
+ if (@distribution or @distributionid) and (@imageid or @image)
121
+ errors << I18n.t('vagrant_linode.config.distribution_or_image')
122
+ end
123
+
80
124
  { 'Linode Provider' => errors }
81
125
  end
82
126
  end
@@ -16,7 +16,15 @@ module VagrantPlugins
16
16
  class DistroMatch < LinodeError
17
17
  error_key(:distro_match)
18
18
  end
19
+
20
+ class DatacenterMatch < LinodeError
21
+ error_key(:datacenter_match)
22
+ end
19
23
 
24
+ class ImageMatch < LinodeError
25
+ error_key(:image_match)
26
+ end
27
+
20
28
  class KernelMatch < LinodeError
21
29
  error_key(:kernel_match)
22
30
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Linode
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -44,6 +44,12 @@ en:
44
44
  private_key: "SSH private key path is required"
45
45
  public_key: "SSH public key not found: %{key}"
46
46
  disk_too_large: "Disk Images use more drive space than plan allocates"
47
+ planid_or_plan: "Use either planid or plan, not both"
48
+ distributionid_or_distribution: "Use either distributionid or distribution, not both"
49
+ datacenterid_or_datacenter: "Use either datacenterid or datacenter, not both"
50
+ kernelid_or_kernel: "Use either kernelid or kernel, not both"
51
+ imageid_or_image: "Use either imageid or image, not both"
52
+ distribution_or_image: "Distribution can not be specified with Image options"
47
53
  errors:
48
54
  public_key: |-
49
55
  There was an issue reading the public key at:
@@ -102,11 +108,17 @@ en:
102
108
  certs.
103
109
  local_ip: |-
104
110
  The Linode provider was unable to determine the host's IP.
111
+ datacenter_match: !-
112
+ The provider does not support your configurations chosen Datacenter ( %{datacenter} ).
113
+ Supported datacenters can be found at the following url - https://www.linode.com/api/utility/avail.datacenters
105
114
  distro_match: !-
106
- The provider does not support your configurations chosen Distribution %{distro}.
115
+ The provider does not support your configurations chosen Distribution ( %{distro} ).
107
116
  Supported distributions can be found at the following url - https://www.linode.com/distributions
117
+ image_match: !-
118
+ The provider does not support your configurations chosen Image ( %{image} ).
119
+ Available images can be found at https://manager.linode.com/images/ or with "vagrant linode image list"
108
120
  kernel_match: !-
109
- The provider does not support your configurations chosen Kernel %{kernel}.
121
+ The provider does not support your configurations chosen Kernel ( %{kernel} ).
110
122
  Supported kernels can be found at the following url - https://www.linode.com/kernels
111
123
  disk_size: !-
112
124
  The space which you have specified for your Disk Images is too large for your
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-linode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marques Johansson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-22 00:00:00.000000000 Z
12
+ date: 2015-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: linodeapi
@@ -129,7 +129,6 @@ files:
129
129
  - lib/vagrant-linode/actions/create.rb
130
130
  - lib/vagrant-linode/actions/create_image.rb
131
131
  - lib/vagrant-linode/actions/destroy.rb
132
- - lib/vagrant-linode/actions/halt.rb
133
132
  - lib/vagrant-linode/actions/is_created.rb
134
133
  - lib/vagrant-linode/actions/is_stopped.rb
135
134
  - lib/vagrant-linode/actions/list_datacenters.rb
@@ -1,29 +0,0 @@
1
- require 'vagrant-linode/helpers/client'
2
- require 'vagrant-linode/helpers/waiter'
3
-
4
- module VagrantPlugins
5
- module Linode
6
- module Actions
7
-
8
- class Reload
9
- include Helpers::Waiter
10
- def initialize(app, env)
11
- @app = app
12
- @machine = env[:machine]
13
- @logger = Log4r::Logger.new('vagrant::linode::reload')
14
- end
15
-
16
- def call(env)
17
- @client = env[:linode_api]
18
- # submit reboot linode request
19
- result = @client.linode.reboot(linodeid: @machine.id)
20
-
21
- # wait for request to complete
22
- env[:ui].info I18n.t('vagrant_linode.info.reloading')
23
- wait_for_event(env, result['jobid'])
24
- @app.call(env)
25
- end
26
- end
27
- end
28
- end
29
- end