vagrant-aliyun 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +111 -0
- data/README.md +36 -0
- data/Rakefile +15 -0
- data/example_box/README.md +8 -0
- data/example_box/dummy_aliyun.box +0 -0
- data/example_box/metadata.json +3 -0
- data/lib/vagrant-aliyun/action/is_created.rb +18 -0
- data/lib/vagrant-aliyun/action/is_stopped.rb +18 -0
- data/lib/vagrant-aliyun/action/message_already_created.rb +16 -0
- data/lib/vagrant-aliyun/action/message_not_created.rb +16 -0
- data/lib/vagrant-aliyun/action/message_will_not_destroy.rb +16 -0
- data/lib/vagrant-aliyun/action/read_ssh_info.rb +38 -0
- data/lib/vagrant-aliyun/action/read_state.rb +47 -0
- data/lib/vagrant-aliyun/action/run_instance.rb +100 -0
- data/lib/vagrant-aliyun/action/start_instance.rb +90 -0
- data/lib/vagrant-aliyun/action/stop_instance.rb +52 -0
- data/lib/vagrant-aliyun/action/terminate_instance.rb +51 -0
- data/lib/vagrant-aliyun/action/wait_for_state.rb +41 -0
- data/lib/vagrant-aliyun/action/warn_networks.rb +19 -0
- data/lib/vagrant-aliyun/action.rb +182 -0
- data/lib/vagrant-aliyun/config.rb +55 -0
- data/lib/vagrant-aliyun/errors.rb +24 -0
- data/lib/vagrant-aliyun/plugin.rb +73 -0
- data/lib/vagrant-aliyun/provider.rb +50 -0
- data/lib/vagrant-aliyun/util/timer.rb +17 -0
- data/lib/vagrant-aliyun/version.rb +5 -0
- data/lib/vagrant-aliyun.rb +18 -0
- data/locales/en.yml +96 -0
- data/pkg/vagrant-aliyun-0.0.1.gem +0 -0
- data/pkg/vagrant-aliyun-0.0.2.gem +0 -0
- data/vagrant-aliyun.gemspec +52 -0
- metadata +76 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module AliyunECS
|
5
|
+
module Errors
|
6
|
+
class VagrantAliyunError < Vagrant::Errors::VagrantError
|
7
|
+
error_namespace("vagrant_aliyun.errors")
|
8
|
+
end
|
9
|
+
|
10
|
+
class InstanceReadyTimeout < VagrantAliyunError
|
11
|
+
error_key(:instance_ready_timeout)
|
12
|
+
end
|
13
|
+
|
14
|
+
class RsyncError < VagrantAliyunError
|
15
|
+
error_key(:rsync_error)
|
16
|
+
end
|
17
|
+
|
18
|
+
class MkdirError < VagrantAliyunError
|
19
|
+
error_key(:mkdir_error)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant Aliyun plugin 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.2.0"
|
10
|
+
raise "The Vagrant Aliyun plugin is only compatible with Vagrant 1.2+"
|
11
|
+
end
|
12
|
+
|
13
|
+
module VagrantPlugins
|
14
|
+
module AliyunECS
|
15
|
+
class Plugin < Vagrant.plugin("2")
|
16
|
+
name "AliyunECS"
|
17
|
+
description <<-DESC
|
18
|
+
This plugin installs a provider that allows Vagrant to manage
|
19
|
+
machines in Aliyun (ECS).
|
20
|
+
DESC
|
21
|
+
|
22
|
+
config(:aliyun, :provider) do
|
23
|
+
require_relative "config"
|
24
|
+
Config
|
25
|
+
end
|
26
|
+
|
27
|
+
provider(:aliyun, parallel: 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", AliyunECS.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 if !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_aliyun")
|
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,50 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "vagrant"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module AliyunECS
|
6
|
+
class Provider < Vagrant.plugin("2", :provider)
|
7
|
+
def initialize(machine)
|
8
|
+
@machine = machine
|
9
|
+
end
|
10
|
+
|
11
|
+
def action(name)
|
12
|
+
# Attempt to get the action method from the Action class if it
|
13
|
+
# exists, otherwise return nil to show that we don't support the
|
14
|
+
# given action.
|
15
|
+
action_method = "action_#{name}"
|
16
|
+
return Action.send(action_method) if Action.respond_to?(action_method)
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def ssh_info
|
21
|
+
# Run a custom action called "read_ssh_info" which does what it
|
22
|
+
# says and puts the resulting SSH info into the `:machine_ssh_info`
|
23
|
+
# key in the environment.
|
24
|
+
env = @machine.action("read_ssh_info")
|
25
|
+
env[:machine_ssh_info]
|
26
|
+
end
|
27
|
+
|
28
|
+
def state
|
29
|
+
# Run a custom action we define called "read_state" which does
|
30
|
+
# what it says. It puts the state in the `:machine_state_id`
|
31
|
+
# key in the environment.
|
32
|
+
env = @machine.action("read_state")
|
33
|
+
|
34
|
+
state_id = env[:machine_state_id]
|
35
|
+
|
36
|
+
# Get the short and long description
|
37
|
+
short = I18n.t("vagrant_aliyun.states.short_#{state_id}")
|
38
|
+
long = I18n.t("vagrant_aliyun.states.long_#{state_id}")
|
39
|
+
|
40
|
+
# Return the MachineState object
|
41
|
+
Vagrant::MachineState.new(state_id, short, long)
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
id = @machine.id.nil? ? "new" : @machine.id
|
46
|
+
"AliyunECS (#{id})"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module AliyunECS
|
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,18 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant-aliyun/plugin"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module AliyunECS
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-aliyun", __FILE__))
|
8
|
+
autoload :Action, lib_path.join("action")
|
9
|
+
autoload :Errors, lib_path.join("errors")
|
10
|
+
|
11
|
+
# This returns the path to the source of this plugin.
|
12
|
+
#
|
13
|
+
# @return [Pathname]
|
14
|
+
def self.source_root
|
15
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_aliyun:
|
3
|
+
already_status: |-
|
4
|
+
The machine is already %{status}.
|
5
|
+
launching_instance: |-
|
6
|
+
Launching an instance with the following settings...
|
7
|
+
not_created: |-
|
8
|
+
Instance is not created. Please run `vagrant up` first.
|
9
|
+
ready: |-
|
10
|
+
Machine is booted and ready for use!
|
11
|
+
rsync_not_found_warning: |-
|
12
|
+
Warning! Folder sync disabled because the rsync binary is missing in the %{side}.
|
13
|
+
Make sure rsync is installed and the binary can be found in the PATH.
|
14
|
+
rsync_folder: |-
|
15
|
+
Rsyncing folder: %{hostpath} => %{guestpath}
|
16
|
+
starting: |-
|
17
|
+
Starting the instance...
|
18
|
+
stopping: |-
|
19
|
+
Stopping the instance...
|
20
|
+
terminating: |-
|
21
|
+
Terminating the instance...
|
22
|
+
waiting_for_ready: |-
|
23
|
+
Waiting for instance to become "ready"...
|
24
|
+
waiting_for_ssh: |-
|
25
|
+
Waiting for SSH to become available...
|
26
|
+
warn_networks: |-
|
27
|
+
Warning! The Aliyun provider doesn't support any of the Vagrant
|
28
|
+
high-level network configurations (`config.vm.network`). They
|
29
|
+
will be silently ignored.
|
30
|
+
warn_ssh_access: |-
|
31
|
+
Warning! Vagrant might not be able to SSH into the instance.
|
32
|
+
Please check your security groups settings.
|
33
|
+
will_not_destroy: |-
|
34
|
+
The instance '%{name}' will not be destroyed, since the confirmation
|
35
|
+
was declined.
|
36
|
+
config:
|
37
|
+
access_key_id_required: |-
|
38
|
+
An access key ID must be specified via "access_key_id"
|
39
|
+
region_required: |-
|
40
|
+
A region must be specified via "region"
|
41
|
+
secret_access_key_required: |-
|
42
|
+
A secret access key is required via "secret_access_key"
|
43
|
+
errors:
|
44
|
+
fog_error: |-
|
45
|
+
There was an error talking to Aliyun. The error message is shown
|
46
|
+
below:
|
47
|
+
%{message}
|
48
|
+
internal_fog_error: |-
|
49
|
+
There was an error talking to Aliyun. The error message is shown
|
50
|
+
below:
|
51
|
+
Error: %{error}
|
52
|
+
Response: %{response}
|
53
|
+
instance_ready_timeout: |-
|
54
|
+
The instance never became "ready" in Aliyun. The timeout currently
|
55
|
+
set waiting for the instance to become ready is %{timeout} seconds.
|
56
|
+
Please verify that the machine properly boots. If you need more time
|
57
|
+
set the `instance_ready_timeout` configuration on the Aliyun provider.
|
58
|
+
rsync_error: |-
|
59
|
+
There was an error when attempting to rsync a shared folder.
|
60
|
+
Please inspect the error message below for more info.
|
61
|
+
Host path: %{hostpath}
|
62
|
+
Guest path: %{guestpath}
|
63
|
+
Error: %{stderr}
|
64
|
+
mkdir_error: |-
|
65
|
+
There was an error when attempting to create a shared host folder.
|
66
|
+
Please inspect the error message below for more info.
|
67
|
+
Host path: %{hostpath}
|
68
|
+
Error: %{err}
|
69
|
+
states:
|
70
|
+
short_not_created: |-
|
71
|
+
not created
|
72
|
+
long_not_created: |-
|
73
|
+
The ECS instance is not created. Run `vagrant up` to create it.
|
74
|
+
short_stopped: |-
|
75
|
+
stopped
|
76
|
+
long_stopped: |-
|
77
|
+
The ECS instance is stopped. Run `vagrant up` to start it.
|
78
|
+
short_stopping: |-
|
79
|
+
stopping
|
80
|
+
long_stopping: |-
|
81
|
+
The ECS instance is stopping. Wait until is completely stopped to
|
82
|
+
run `vagrant up` and start it.
|
83
|
+
short_pending: |-
|
84
|
+
pending
|
85
|
+
long_pending: |-
|
86
|
+
The ECS instance is pending a start (i.e. this is a transition state).
|
87
|
+
short_running: |-
|
88
|
+
running
|
89
|
+
long_running: |-
|
90
|
+
The ECS instance is running. To stop this machine, you can run
|
91
|
+
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
|
92
|
+
short_pending: |-
|
93
|
+
pending
|
94
|
+
long_pending: |-
|
95
|
+
The ECS instance is still being initialized. To destroy this machine,
|
96
|
+
you can run `vagrant destroy`.
|
Binary file
|
Binary file
|
@@ -0,0 +1,52 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "vagrant-aliyun/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "vagrant-aliyun"
|
6
|
+
s.version = VagrantPlugins::AliyunECS::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = "Taurus Cheung"
|
9
|
+
s.email = "tauruscheung@hotmail.com"
|
10
|
+
s.homepage = "https://github.com/lccheun2/vagrant-aliyun"
|
11
|
+
s.summary = "Enables Vagrant Provider for Aliyun VM"
|
12
|
+
s.description = "Enables Vagrant Provider for Aliyun VM"
|
13
|
+
s.license = "MIT"
|
14
|
+
|
15
|
+
s.required_rubygems_version = ">= 1.3.6"
|
16
|
+
s.rubyforge_project = "vagrant-aliyun"
|
17
|
+
|
18
|
+
# The following block of code determines the files that should be included
|
19
|
+
# in the gem. It does this by reading all the files in the directory where
|
20
|
+
# this gemspec is, and parsing out the ignored files from the gitignore.
|
21
|
+
# Note that the entire gitignore(5) syntax is not supported, specifically
|
22
|
+
# the "!" syntax, but it should mostly work correctly.
|
23
|
+
root_path = File.dirname(__FILE__)
|
24
|
+
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
|
25
|
+
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
|
26
|
+
gitignore_path = File.join(root_path, ".gitignore")
|
27
|
+
gitignore = File.readlines(gitignore_path)
|
28
|
+
gitignore.map! { |line| line.chomp.strip }
|
29
|
+
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
|
30
|
+
|
31
|
+
unignored_files = all_files.reject do |file|
|
32
|
+
# Ignore any directories, the gemspec only cares about files
|
33
|
+
next true if File.directory?(file)
|
34
|
+
|
35
|
+
# Ignore any paths that match anything in the gitignore. We do
|
36
|
+
# two tests here:
|
37
|
+
#
|
38
|
+
# - First, test to see if the entire path matches the gitignore.
|
39
|
+
# - Second, match if the basename does, this makes it so that things
|
40
|
+
# like '.DS_Store' will match sub-directories too (same behavior
|
41
|
+
# as git).
|
42
|
+
#
|
43
|
+
gitignore.any? do |ignore|
|
44
|
+
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
|
45
|
+
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
s.files = unignored_files
|
50
|
+
s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
|
51
|
+
s.require_path = 'lib'
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-aliyun
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Taurus Cheung
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Enables Vagrant Provider for Aliyun VM
|
14
|
+
email: tauruscheung@hotmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- example_box/dummy_aliyun.box
|
20
|
+
- example_box/metadata.json
|
21
|
+
- example_box/README.md
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
24
|
+
- lib/vagrant-aliyun/action/is_created.rb
|
25
|
+
- lib/vagrant-aliyun/action/is_stopped.rb
|
26
|
+
- lib/vagrant-aliyun/action/message_already_created.rb
|
27
|
+
- lib/vagrant-aliyun/action/message_not_created.rb
|
28
|
+
- lib/vagrant-aliyun/action/message_will_not_destroy.rb
|
29
|
+
- lib/vagrant-aliyun/action/read_ssh_info.rb
|
30
|
+
- lib/vagrant-aliyun/action/read_state.rb
|
31
|
+
- lib/vagrant-aliyun/action/run_instance.rb
|
32
|
+
- lib/vagrant-aliyun/action/start_instance.rb
|
33
|
+
- lib/vagrant-aliyun/action/stop_instance.rb
|
34
|
+
- lib/vagrant-aliyun/action/terminate_instance.rb
|
35
|
+
- lib/vagrant-aliyun/action/wait_for_state.rb
|
36
|
+
- lib/vagrant-aliyun/action/warn_networks.rb
|
37
|
+
- lib/vagrant-aliyun/action.rb
|
38
|
+
- lib/vagrant-aliyun/config.rb
|
39
|
+
- lib/vagrant-aliyun/errors.rb
|
40
|
+
- lib/vagrant-aliyun/plugin.rb
|
41
|
+
- lib/vagrant-aliyun/provider.rb
|
42
|
+
- lib/vagrant-aliyun/util/timer.rb
|
43
|
+
- lib/vagrant-aliyun/version.rb
|
44
|
+
- lib/vagrant-aliyun.rb
|
45
|
+
- locales/en.yml
|
46
|
+
- pkg/vagrant-aliyun-0.0.1.gem
|
47
|
+
- pkg/vagrant-aliyun-0.0.2.gem
|
48
|
+
- Rakefile
|
49
|
+
- README.md
|
50
|
+
- vagrant-aliyun.gemspec
|
51
|
+
- .gitignore
|
52
|
+
homepage: https://github.com/lccheun2/vagrant-aliyun
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.3.6
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project: vagrant-aliyun
|
72
|
+
rubygems_version: 2.0.14
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Enables Vagrant Provider for Aliyun VM
|
76
|
+
test_files: []
|