vagrant-scaleway 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Scaleway
3
+ module Errors
4
+ class VagrantScalewayError < Vagrant::Errors::VagrantError
5
+ error_namespace('vagrant_scaleway.errors')
6
+ end
7
+
8
+ class FogError < VagrantScalewayError
9
+ error_key(:fog_error)
10
+ end
11
+
12
+ class InternalFogError < VagrantScalewayError
13
+ error_key(:internal_fog_error)
14
+ end
15
+
16
+ class ServerReadyTimeout < VagrantScalewayError
17
+ error_key(:server_ready_timeout)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,73 @@
1
+ begin
2
+ require 'vagrant'
3
+ rescue LoadError
4
+ raise 'The Scaleway provider must be run within Vagrant.'
5
+ end
6
+
7
+ # This is a sanity check to make sure no one is attempting to install
8
+ # this into an early Vagrant version.
9
+ if Vagrant::VERSION < '1.5.0'
10
+ raise 'Scaleway provider is only compatible with Vagrant 1.5+'
11
+ end
12
+
13
+ module VagrantPlugins
14
+ module Scaleway
15
+ class Plugin < Vagrant.plugin('2')
16
+ name 'Scaleway'
17
+ description <<-DESC
18
+ This plugin installs a provider that allows Vagrant to manage
19
+ machines in Scaleway.
20
+ DESC
21
+
22
+ config(:scaleway, :provider) do
23
+ require_relative 'config'
24
+ Config
25
+ end
26
+
27
+ provider(:scaleway, parallel: true, box_optional: true) do
28
+ # Setup logging and i18n
29
+ setup_logging
30
+ setup_i18n
31
+
32
+ # Return the provider
33
+ require_relative 'provider'
34
+ Provider
35
+ end
36
+
37
+ # This initializes the internationalization strings.
38
+ def self.setup_i18n
39
+ I18n.load_path << File.expand_path('locales/en.yml', Scaleway.source_root)
40
+ I18n.reload!
41
+ end
42
+
43
+ # This sets up our log level to be whatever VAGRANT_LOG is.
44
+ def self.setup_logging
45
+ require 'log4r'
46
+
47
+ level = nil
48
+ begin
49
+ level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
50
+ rescue NameError
51
+ # This means that the logging constant wasn't found,
52
+ # which is fine. We just keep `level` as `nil`. But
53
+ # we tell the user.
54
+ level = nil
55
+ end
56
+
57
+ # Some constants, such as "true" resolve to booleans, so the
58
+ # above error checking doesn't catch it. This will check to make
59
+ # sure that the log level is an integer, as Log4r requires.
60
+ level = nil unless level.is_a?(Integer)
61
+
62
+ # Set the logging level on all "vagrant" namespaced
63
+ # logs as long as we have a valid level.
64
+ if level
65
+ logger = Log4r::Logger.new('vagrant_scaleway')
66
+ logger.outputters = Log4r::Outputter.stderr
67
+ logger.level = level
68
+ logger = nil
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,47 @@
1
+ module VagrantPlugins
2
+ module Scaleway
3
+ class Provider < Vagrant.plugin('2', :provider)
4
+ def initialize(machine)
5
+ @machine = machine
6
+ end
7
+
8
+ def action(name)
9
+ # Attempt to get the action method from the Action class if it
10
+ # exists, otherwise return nil to show that we don't support the
11
+ # given action.
12
+ action_method = "action_#{name}"
13
+ return Action.send(action_method) if Action.respond_to?(action_method)
14
+ nil
15
+ end
16
+
17
+ def ssh_info
18
+ # Run a custom action called "read_ssh_info" which does what it
19
+ # says and puts the resulting SSH info into the `:machine_ssh_info`
20
+ # key in the environment.
21
+ env = @machine.action('read_ssh_info', lock: false)
22
+ env[:machine_ssh_info]
23
+ end
24
+
25
+ def state
26
+ # Run a custom action we define called "read_state" which does
27
+ # what it says. It puts the state in the `:machine_state_id`
28
+ # key in the environment.
29
+ env = @machine.action('read_state', lock: false)
30
+
31
+ state_id = env[:machine_state_id]
32
+
33
+ # Get the short and long description
34
+ short = I18n.t("vagrant_scaleway.states.short_#{state_id}")
35
+ long = I18n.t("vagrant_scaleway.states.long_#{state_id}")
36
+
37
+ # Return the MachineState object
38
+ Vagrant::MachineState.new(state_id, short, long)
39
+ end
40
+
41
+ def to_s
42
+ id = @machine.id.nil? ? 'new' : @machine.id
43
+ "Scaleway (#{id})"
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,17 @@
1
+ module VagrantPlugins
2
+ module Scaleway
3
+ module Util
4
+ class Timer
5
+ # A basic utility method that times the execution of the given
6
+ # block and returns it.
7
+ def self.time
8
+ start_time = Time.now.to_f
9
+ yield
10
+ end_time = Time.now.to_f
11
+
12
+ end_time - start_time
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Scaleway
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,81 @@
1
+ en:
2
+ vagrant_scaleway:
3
+ already_status: |-
4
+ The machine is already %{status}.
5
+
6
+ creating_server: |-
7
+ Creating a server with the following settings...
8
+ not_created: |-
9
+ Server is not created. Please run `vagrant up` first.
10
+ ready: |-
11
+ Machine is booted and ready for use!
12
+ starting: |-
13
+ Starting the server...
14
+ stopping: |-
15
+ Stopping the server...
16
+ destroying: |-
17
+ Destroying the server...
18
+ waiting_for_ready: |-
19
+ Waiting for server to become "ready"...
20
+ waiting_for_ssh: |-
21
+ Waiting for SSH to become available...
22
+ warn_networks: |-
23
+ Warning! The Scaleway provider doesn't support any of the Vagrant
24
+ high-level network configurations (`config.vm.network`). They
25
+ will be silently ignored.
26
+ will_not_destroy: |-
27
+ The server '%{name}' will not be destroyed, since the confirmation
28
+ was declined.
29
+
30
+ config:
31
+ organization_required: |-
32
+ A organization must be specified via "organization" option.
33
+ token_required: |-
34
+ A token must be specified via "token" option.
35
+
36
+ errors:
37
+ fog_error: |-
38
+ There was an error talking to Scaleway. The error message is shown
39
+ below:
40
+
41
+ %{message}
42
+ internal_fog_error: |-
43
+ There was an error talking to Scaleway. The error message is shown
44
+ below:
45
+
46
+ Error: %{error}
47
+ Response: %{response}
48
+ server_ready_timeout: |-
49
+ The server never became "ready" in Scaleway. The timeout currently
50
+ set waiting for the server to become ready is %{timeout} seconds.
51
+ Please verify that the machine properly boots. If you need more time
52
+ set the `server_ready_timeout` configuration on the Scaleway provider.
53
+
54
+ states:
55
+ short_not_created: |-
56
+ not created
57
+ long_not_created: |-
58
+ The server is not created. Run `vagrant up` to create it.
59
+
60
+ short_stopped: |-
61
+ stopped
62
+ long_stopped: |-
63
+ The server is stopped. Run `vagrant up` to start it.
64
+
65
+ short_stopping: |-
66
+ stopping
67
+ long_stopping: |-
68
+ The server is stopping. Wait until is completely stopped to
69
+ run `vagrant up` and start it.
70
+
71
+ short_starting: |-
72
+ starting
73
+ long_starting: |-
74
+ The server is starting. You must wait for this to
75
+ complete before you can access it.
76
+
77
+ short_running: |-
78
+ running
79
+ long_running: |-
80
+ The server is running. To stop this machine, you can run
81
+ `vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-scaleway/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'vagrant-scaleway'
8
+ spec.version = VagrantPlugins::Scaleway::VERSION
9
+ spec.authors = ['Satoshi Matsumoto']
10
+ spec.email = ['kaorimatz@gmail.com']
11
+
12
+ spec.summary = 'Vagrant provider plugin for Scaleway'
13
+ spec.description = 'Enables Vagrant to manage machines in Scaleway.'
14
+ spec.homepage = 'https://github.com/kaorimatz/vagrant-scaleway'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rubocop'
23
+
24
+ spec.add_dependency 'fog-scaleway', '~> 0.1'
25
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-scaleway
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Satoshi Matsumoto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fog-scaleway
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ description: Enables Vagrant to manage machines in Scaleway.
70
+ email:
71
+ - kaorimatz@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".ruby-version"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - dummy.box
83
+ - example_box/metadata.json
84
+ - lib/vagrant-scaleway.rb
85
+ - lib/vagrant-scaleway/action.rb
86
+ - lib/vagrant-scaleway/action/connect_scaleway.rb
87
+ - lib/vagrant-scaleway/action/create_server.rb
88
+ - lib/vagrant-scaleway/action/destroy_server.rb
89
+ - lib/vagrant-scaleway/action/is_created.rb
90
+ - lib/vagrant-scaleway/action/is_stopped.rb
91
+ - lib/vagrant-scaleway/action/message_already_created.rb
92
+ - lib/vagrant-scaleway/action/message_not_created.rb
93
+ - lib/vagrant-scaleway/action/message_will_not_destroy.rb
94
+ - lib/vagrant-scaleway/action/read_ssh_info.rb
95
+ - lib/vagrant-scaleway/action/read_state.rb
96
+ - lib/vagrant-scaleway/action/start_server.rb
97
+ - lib/vagrant-scaleway/action/stop_server.rb
98
+ - lib/vagrant-scaleway/action/warn_networks.rb
99
+ - lib/vagrant-scaleway/config.rb
100
+ - lib/vagrant-scaleway/errors.rb
101
+ - lib/vagrant-scaleway/plugin.rb
102
+ - lib/vagrant-scaleway/provider.rb
103
+ - lib/vagrant-scaleway/util/timer.rb
104
+ - lib/vagrant-scaleway/version.rb
105
+ - locales/en.yml
106
+ - vagrant-scaleway.gemspec
107
+ homepage: https://github.com/kaorimatz/vagrant-scaleway
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.6.6
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Vagrant provider plugin for Scaleway
131
+ test_files: []