vagrant-linode 0.1.3 → 0.2.0

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rspec +4 -0
  4. data/.rubocop.yml +1 -0
  5. data/.rubocop_todo.yml +164 -0
  6. data/Gemfile +9 -6
  7. data/README.md +21 -9
  8. data/Rakefile +21 -1
  9. data/Vagrantfile.multi +18 -0
  10. data/box/linode-debian-7.5.box +0 -0
  11. data/box/linode.box +0 -0
  12. data/box/metadata-debian-7.5.json +12 -0
  13. data/box/metadata.json +2 -2
  14. data/features/provision.feature +34 -0
  15. data/features/steps/sdk_steps.rb +13 -0
  16. data/features/steps/server_steps.rb +25 -0
  17. data/features/support/env.rb +34 -0
  18. data/features/support/fog_mock.rb +16 -0
  19. data/features/vagrant-linode.feature +68 -0
  20. data/lib/vagrant-linode.rb +44 -5
  21. data/lib/vagrant-linode/actions.rb +201 -87
  22. data/lib/vagrant-linode/actions/connect_linode.rb +36 -0
  23. data/lib/vagrant-linode/actions/create.rb +9 -9
  24. data/lib/vagrant-linode/actions/create_image.rb +23 -0
  25. data/lib/vagrant-linode/actions/destroy.rb +1 -3
  26. data/lib/vagrant-linode/actions/halt.rb +29 -0
  27. data/lib/vagrant-linode/actions/is_created.rb +16 -0
  28. data/lib/vagrant-linode/actions/is_stopped.rb +17 -0
  29. data/lib/vagrant-linode/actions/list_datacenters.rb +20 -0
  30. data/lib/vagrant-linode/actions/list_distributions.rb +20 -0
  31. data/lib/vagrant-linode/actions/list_images.rb +20 -0
  32. data/lib/vagrant-linode/actions/list_plans.rb +20 -0
  33. data/lib/vagrant-linode/actions/list_servers.rb +20 -0
  34. data/lib/vagrant-linode/actions/message_already_active.rb +16 -0
  35. data/lib/vagrant-linode/actions/message_already_off.rb +16 -0
  36. data/lib/vagrant-linode/actions/message_not_created.rb +16 -0
  37. data/lib/vagrant-linode/actions/message_off.rb +16 -0
  38. data/lib/vagrant-linode/actions/power_off.rb +4 -3
  39. data/lib/vagrant-linode/actions/power_on.rb +3 -2
  40. data/lib/vagrant-linode/actions/read_ssh_info.rb +48 -0
  41. data/lib/vagrant-linode/actions/read_state.rb +38 -0
  42. data/lib/vagrant-linode/actions/rebuild.rb +3 -2
  43. data/lib/vagrant-linode/actions/reload.rb +3 -2
  44. data/lib/vagrant-linode/commands/create_image.rb +21 -0
  45. data/lib/vagrant-linode/commands/datacenters.rb +21 -0
  46. data/lib/vagrant-linode/commands/distributions.rb +21 -0
  47. data/lib/vagrant-linode/commands/images.rb +59 -0
  48. data/lib/vagrant-linode/commands/list_images.rb +21 -0
  49. data/lib/vagrant-linode/commands/networks.rb +21 -0
  50. data/lib/vagrant-linode/commands/plans.rb +21 -0
  51. data/lib/vagrant-linode/commands/root.rb +81 -0
  52. data/lib/vagrant-linode/commands/servers.rb +21 -0
  53. data/lib/vagrant-linode/config.rb +11 -3
  54. data/lib/vagrant-linode/helpers/client.rb +21 -79
  55. data/lib/vagrant-linode/helpers/waiter.rb +21 -0
  56. data/lib/vagrant-linode/plugin.rb +20 -0
  57. data/lib/vagrant-linode/provider.rb +27 -32
  58. data/lib/vagrant-linode/version.rb +1 -1
  59. data/locales/en.yml +17 -1
  60. data/spec/spec_helper.rb +20 -0
  61. data/spec/vagrant-linode/actions/list_distributions_spec.rb +47 -0
  62. data/spec/vagrant-linode/actions/list_plans_spec.rb +47 -0
  63. data/spec/vagrant-linode/config_spec.rb +189 -0
  64. data/test/Vagrantfile +4 -9
  65. data/vagrant-linode.gemspec +1 -1
  66. metadata +70 -20
  67. data/lib/vagrant-linode/actions/check_state.rb +0 -19
  68. data/lib/vagrant-linode/actions/setup_key.rb +0 -52
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10e005fdd16d23255cbc89613cf419a133fb729e
4
- data.tar.gz: 035816e2ee03ce0698b0de6ab6c1dc0a09cd0a13
3
+ metadata.gz: 2c0b56e45b965f16f865dbd480b823f1c568eca1
4
+ data.tar.gz: cb62e7ce8e9482621d273e3f28e9b76678b2c365
5
5
  SHA512:
6
- metadata.gz: d415ef59813703bdba199ff25eabaf39296ada14651591c07c3b207186de626671d19470b48abc47e02c3711a237a8c02e780e4c5636757574b358400cc5bd57
7
- data.tar.gz: 4961ed7a4f26c6e0ccf640c0b296df80104e7cc742c9661c410715dd8533b52ad73de435753ef0b98cf10e0a445f1e218658d8ed18fd6e69b4e84e8fe24f260f
6
+ metadata.gz: ac6a357b79d595d347ecf7a022f220b38ea9b4e9a5f9fadf219fa31a959c7899b33c6e0c8b06c988345dbefad8247ae6ac6f3ec15f9d2f68ad556421a0360001
7
+ data.tar.gz: 69ef3bddf8194c4369d533e7c05ae74feaa207f251f4390e108933bafd6100831b357253c420834e542a023cd0a4964fb5b34402590fe76338a129a5f25c7dc5
data/.gitignore CHANGED
@@ -19,3 +19,6 @@ test/tmp
19
19
  test/version_tmp
20
20
  test/.vagrant
21
21
  tmp
22
+ vendor
23
+ *.un~
24
+ *.orig
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format
2
+ d
3
+ --colour
4
+ --backtrace
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,164 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-12-02 23:23:38 -0500 using RuboCop version 0.27.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ # Configuration parameters: AlignWith, SupportedStyles.
10
+ Lint/EndAlignment:
11
+ Enabled: false
12
+
13
+ # Offense count: 12
14
+ Lint/ParenthesesAsGroupedExpression:
15
+ Enabled: false
16
+
17
+ # Offense count: 3
18
+ Lint/ShadowingOuterLocalVariable:
19
+ Enabled: false
20
+
21
+ # Offense count: 1
22
+ Lint/UnderscorePrefixedVariableName:
23
+ Enabled: false
24
+
25
+ # Offense count: 1
26
+ Lint/UnreachableCode:
27
+ Enabled: false
28
+
29
+ # Offense count: 14
30
+ Lint/UselessAssignment:
31
+ Enabled: false
32
+
33
+ # Offense count: 18
34
+ Metrics/AbcSize:
35
+ Max: 200
36
+
37
+ # Offense count: 1
38
+ # Configuration parameters: CountComments.
39
+ Metrics/ClassLength:
40
+ Max: 139
41
+
42
+ # Offense count: 4
43
+ Metrics/CyclomaticComplexity:
44
+ Max: 27
45
+
46
+ # Offense count: 66
47
+ # Configuration parameters: AllowURI, URISchemes.
48
+ Metrics/LineLength:
49
+ Max: 138
50
+
51
+ # Offense count: 26
52
+ # Configuration parameters: CountComments.
53
+ Metrics/MethodLength:
54
+ Max: 120
55
+
56
+ # Offense count: 4
57
+ Metrics/PerceivedComplexity:
58
+ Max: 33
59
+
60
+ # Offense count: 1
61
+ Style/AccessorMethodName:
62
+ Enabled: false
63
+
64
+ # Offense count: 2
65
+ # Configuration parameters: Keywords.
66
+ Style/CommentAnnotation:
67
+ Enabled: false
68
+
69
+ # Offense count: 51
70
+ Style/Documentation:
71
+ Enabled: false
72
+
73
+ # Offense count: 1
74
+ # Cop supports --auto-correct.
75
+ Style/ElseAlignment:
76
+ Enabled: false
77
+
78
+ # Offense count: 1
79
+ # Configuration parameters: Exclude.
80
+ Style/FileName:
81
+ Enabled: false
82
+
83
+ # Offense count: 16
84
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
85
+ Style/FormatString:
86
+ Enabled: false
87
+
88
+ # Offense count: 1
89
+ # Configuration parameters: MinBodyLength.
90
+ Style/GuardClause:
91
+ Enabled: false
92
+
93
+ # Offense count: 4
94
+ # Cop supports --auto-correct.
95
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
96
+ Style/HashSyntax:
97
+ Enabled: false
98
+
99
+ # Offense count: 2
100
+ # Configuration parameters: MaxLineLength.
101
+ Style/IfUnlessModifier:
102
+ Enabled: false
103
+
104
+ # Offense count: 42
105
+ # Cop supports --auto-correct.
106
+ Style/IndentationConsistency:
107
+ Enabled: false
108
+
109
+ # Offense count: 3
110
+ # Cop supports --auto-correct.
111
+ # Configuration parameters: Width.
112
+ Style/IndentationWidth:
113
+ Enabled: false
114
+
115
+ # Offense count: 2
116
+ Style/Lambda:
117
+ Enabled: false
118
+
119
+ # Offense count: 2
120
+ # Cop supports --auto-correct.
121
+ Style/LeadingCommentSpace:
122
+ Enabled: false
123
+
124
+ # Offense count: 3
125
+ # Cop supports --auto-correct.
126
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
127
+ Style/MultilineOperationIndentation:
128
+ Enabled: false
129
+
130
+ # Offense count: 1
131
+ # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
132
+ Style/Next:
133
+ Enabled: false
134
+
135
+ # Offense count: 2
136
+ # Configuration parameters: MaxSlashes.
137
+ Style/RegexpLiteral:
138
+ Enabled: false
139
+
140
+ # Offense count: 2
141
+ Style/SelfAssignment:
142
+ Enabled: false
143
+
144
+ # Offense count: 5
145
+ # Cop supports --auto-correct.
146
+ Style/SpaceInsideParens:
147
+ Enabled: false
148
+
149
+ # Offense count: 4
150
+ # Cop supports --auto-correct.
151
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
152
+ Style/StringLiterals:
153
+ Enabled: false
154
+
155
+ # Offense count: 10
156
+ # Cop supports --auto-correct.
157
+ Style/Tab:
158
+ Enabled: false
159
+
160
+ # Offense count: 1
161
+ # Cop supports --auto-correct.
162
+ # Configuration parameters: WordRegex.
163
+ Style/WordArray:
164
+ MinSize: 5
data/Gemfile CHANGED
@@ -1,11 +1,14 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.7.2'
4
- gem 'vagrant-omnibus'
5
- gem 'rake'
6
-
7
3
  group :plugins do
8
- gem 'vagrant-linode', path: '.'
4
+ gemspec
9
5
  end
10
6
 
11
- gemspec
7
+ group :development do
8
+ # We depend on Vagrant for development, but we don't add it as a
9
+ # gem dependency because we expect to be installed within the
10
+ # Vagrant environment itself using `vagrant plugin`.
11
+ gem 'vagrant', git: 'https://github.com/mitchellh/vagrant'
12
+ gem 'coveralls', require: false
13
+ gem 'pry'
14
+ end
data/README.md CHANGED
@@ -55,7 +55,7 @@ Vagrant.configure('2') do |config|
55
55
  override.vm.box = 'linode'
56
56
  override.vm.box_url = "https://github.com/displague/vagrant-linode/raw/master/box/linode.box"
57
57
 
58
- provider.token = 'API_KEY'
58
+ provider.api_key = 'API_KEY'
59
59
  provider.distribution = 'Ubuntu 14.04 LTS'
60
60
  provider.datacenter = 'newark'
61
61
  provider.plan = 'Linode 1024'
@@ -86,16 +86,15 @@ Please note the following:
86
86
 
87
87
  The following attributes are available to further configure the provider:
88
88
  - `provider.distribution` - A string representing the distribution to use when
89
- creating a new linode (e.g. `Debian 7.5`). The available options may
90
- be found on Linode's new linode [form](https://www.linode.com/distributions).
89
+ creating a new linode (e.g. `Debian 8.1`). The available options may
90
+ be found on [Linode's Supported Distributions](https://www.linode.com/distributions) page.
91
91
  It defaults to `Ubuntu 14.04 LTS`.
92
- - `provider.datacenter` - A string representing the region to create the new
93
- linode in. It defaults to `newark`.
92
+ - `provider.datacenter` - A string representing the datacenter to create the new
93
+ linode in. It defaults to `dallas`.
94
94
  - `provider.plan` - A string representing the size to use when creating a
95
95
  new linode (e.g. `Linode 2048`). It defaults to `Linode 1024`.
96
96
  - `provider.private_networking` - A boolean flag indicating whether to enable
97
- a private network interface (if the region supports private networking). It
98
- defaults to `false`.
97
+ a private network interface. It defaults to `false`.
99
98
  - `provider.ssh_key_name` - A string representing the name to use when creating
100
99
  a Linode SSH key for linode authentication. It defaults to `Vagrant`.
101
100
  - `provider.setup` - A boolean flag indicating whether to setup a new user
@@ -128,6 +127,12 @@ Current Plan-ID table follows:
128
127
  | 10 | 64GB Plan (Linode 65536) |
129
128
  | 12 | 96GB Plan (Linode 98304) |
130
129
 
130
+ This can be obtained through vagrant with:
131
+ ```
132
+ vagrant linode datacenters
133
+ ```
134
+
135
+ Or using curl:
131
136
  ```
132
137
  curl -X POST "https://api.linode.com/?api_action=avail.plans" \
133
138
  --data-ascii api_key="$LINODE_API_KEY" \
@@ -151,9 +156,14 @@ Current Region-ID table is:
151
156
  | 8 | tokyo | Tokyo, JP |
152
157
  | 9 | singapore | Singapore, SGP |
153
158
 
154
- You can find latest datacenter ID number using Linode API call.
159
+ You can find latest datacenter ID number using Vagrant subcommands:
160
+
161
+ ```
162
+ vagrant linode datacenters
163
+ ```
164
+
165
+ Or directly through the API:
155
166
 
156
- - example call.
157
167
 
158
168
  ```
159
169
  curl -X POST "https://api.linode.com/?api_action=avail.datacenters" \
@@ -204,6 +214,8 @@ The provider supports the following Vagrant sub-commands:
204
214
  same IP address which was previously assigned.
205
215
  - `vagrant status` - Outputs the status (active, off, not created) for the
206
216
  linode instance.
217
+ - `vagrant linode` - Offers Linode resource listing options for datacenters,
218
+ distributions, images, networks, plans, and servers
207
219
 
208
220
 
209
221
  More Docs and Tools
data/Rakefile CHANGED
@@ -1,9 +1,29 @@
1
- require 'bundler/gem_helper'
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
2
4
 
5
+ # Immediately sync all stdout so that tools like buildbot can
6
+ # immediately load in the output.
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ # Change to the directory of this file.
11
+ Dir.chdir(File.expand_path('../', __FILE__))
12
+
13
+ # This installs the tasks that help with gem creation and
14
+ # publishing.
3
15
  namespace :gem do
4
16
  Bundler::GemHelper.install_tasks
5
17
  end
6
18
 
19
+ # Install the `spec` task so that we can run tests.
20
+ RSpec::Core::RakeTask.new
21
+
22
+ # Default task is to run the unit tests
23
+ task default: 'spec'
24
+
25
+ # require 'bundler/gem_helper'
26
+
7
27
  task :test do
8
28
  result = sh 'bash test/test.sh'
9
29
 
data/Vagrantfile.multi ADDED
@@ -0,0 +1,18 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ DATACENTERS = [:newark, :dallas, :atlanta]
8
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
9
+ Vagrant.require_plugin "vagrant-linode"
10
+
11
+ DATACENTERS.each do |datacenter|
12
+ config.vm.define datacenter do |machine|
13
+ machine.vm.provider :linode do |provider|
14
+ provider.api_key = ENV['LINODE_API_KEY']
15
+ end
16
+ end
17
+ end
18
+ end
Binary file
data/box/linode.box CHANGED
Binary file
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "displague/debian-7.5",
3
+ "description": "This box creates Debian 7.5 on a Linode",
4
+ "versions": [{
5
+ "version": "0.1.0",
6
+ "providers": [{
7
+ "name": "linode",
8
+ "url": "https://github.com/displague/vagrant-linode/raw/master/box/linode.box",
9
+ "distribution": "debian 7.5"
10
+ }]
11
+ }]
12
+ }
data/box/metadata.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "provider": "linode"
3
- }
2
+ provider: 'linode'
3
+ }
@@ -0,0 +1,34 @@
1
+ @announce
2
+ @vagrant-linode
3
+ Feature: vagrant-linode fog tests
4
+
5
+ Background:
6
+ Given I have Linode credentials available
7
+ And I have a "fog_mock.rb" file
8
+
9
+ Scenario: Create a single server (with provisioning)
10
+ Given a file named "Vagrantfile" with:
11
+ """
12
+ Vagrant.configure("2") do |config|
13
+ Vagrant.require_plugin "vagrant-linode"
14
+
15
+ config.vm.box = "dummy"
16
+ config.ssh.private_key_path = "~/.ssh/id_rsa"
17
+
18
+
19
+ config.vm.provider :linode do |provider|
20
+ provider.server_name = 'vagrant-provisioned-server'
21
+ provider.api_key = ENV['LINODE_API_KEY']
22
+ provider.datacenter = 'dallas'
23
+ provider.plan = /Linode 1024/
24
+ provider.distribution = /Ubuntu/
25
+ provider.public_key_path = "~/.ssh/id_rsa.pub"
26
+ end
27
+
28
+ config.vm.provision :shell, :inline => "echo Hello, World"
29
+ end
30
+ """
31
+ When I successfully run `bundle exec vagrant up --provider linode`
32
+ # I want to capture the ID like I do in tests for other tools, but Vagrant doesn't print it!
33
+ # And I get the server from "Instance ID:"
34
+ Then the server "vagrant-provisioned-server" should be active
@@ -0,0 +1,13 @@
1
+ Given(/^I have Linode credentials available$/) do
2
+ fail unless ENV['LINODE_API_KEY']
3
+ end
4
+
5
+ Given(/^I have a "fog_mock.rb" file$/) do
6
+ script = File.open('features/support/fog_mock.rb').read
7
+ steps %(
8
+ Given a file named "fog_mock.rb" with:
9
+ """
10
+ #{script}
11
+ """
12
+ )
13
+ end
@@ -0,0 +1,25 @@
1
+ When(/^I get the server from "(.*?)"$/) do |label|
2
+ @server_id = all_output.match(/#{label}\s([\w-]*)/)[1]
3
+ puts "Server: #{@server_id}"
4
+ end
5
+
6
+ When(/^I load the server$/) do
7
+ @server_id = all_output.strip.lines.to_a.last
8
+ puts "Server: #{@server_id}"
9
+ end
10
+
11
+ Then(/^the server should be active$/) do
12
+ unless Fog.mock? # unfortunately we can't assert this with Fog.mock!, since mocked objects do not persist from the subprocess
13
+ assert_active @server_id
14
+ end
15
+ end
16
+
17
+ Then(/^the server "(.+)" should be active$/) do |server_name|
18
+ server = @compute.servers.all.find { |s| s.name == server_name }
19
+ assert_active server.id
20
+ end
21
+
22
+ def assert_active(server_id)
23
+ server = @compute.servers.get server_id
24
+ server.state.should == 'ACTIVE'
25
+ end
@@ -0,0 +1,34 @@
1
+ require 'fog'
2
+ require 'aruba/cucumber'
3
+
4
+ Fog.mock! if ENV['LINODE_MOCK'] == 'true'
5
+
6
+ Before do | scenario |
7
+ @aruba_timeout_seconds = 600
8
+ @scenario = File.basename(scenario.file)
9
+ ENV['CASSETTE'] = @scenario
10
+
11
+ proxy_options = {
12
+ connection_options: {
13
+ proxy: ENV['https_proxy'],
14
+ ssl_verify_peer: false
15
+ }
16
+ }
17
+
18
+ connect_options = {
19
+ provider: 'linode',
20
+ linode_api_key: ENV['LINODE_API_KEY'],
21
+ }
22
+ connect_options.merge!(proxy_options) unless ENV['https_proxy'].nil?
23
+ @compute = Fog::Compute.new(connect_options)
24
+ end
25
+
26
+ Around do | _scenario, block |
27
+ Bundler.with_clean_env do
28
+ block.call
29
+ end
30
+ end
31
+
32
+ After('@creates_server') do
33
+ @compute.servers.delete @server_id
34
+ end