vagrant-joyent 0.3.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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +201 -0
- data/README.md +30 -0
- data/Rakefile +1 -0
- data/dummy.box +0 -0
- data/example_box/README.md +13 -0
- data/example_box/Vagrantfile +8 -0
- data/example_box/metadata.json +3 -0
- data/lib/vagrant-joyent.rb +18 -0
- data/lib/vagrant-joyent/action.rb +111 -0
- data/lib/vagrant-joyent/action/connect_joyent.rb +33 -0
- data/lib/vagrant-joyent/action/is_created.rb +18 -0
- data/lib/vagrant-joyent/action/message_already_created.rb +16 -0
- data/lib/vagrant-joyent/action/message_not_created.rb +16 -0
- data/lib/vagrant-joyent/action/message_will_not_destroy.rb +16 -0
- data/lib/vagrant-joyent/action/read_ssh_info.rb +71 -0
- data/lib/vagrant-joyent/action/read_state.rb +38 -0
- data/lib/vagrant-joyent/action/run_instance.rb +114 -0
- data/lib/vagrant-joyent/action/sync_folders.rb +60 -0
- data/lib/vagrant-joyent/action/terminate_instance.rb +47 -0
- data/lib/vagrant-joyent/action/warn_networks.rb +19 -0
- data/lib/vagrant-joyent/config.rb +69 -0
- data/lib/vagrant-joyent/errors.rb +19 -0
- data/lib/vagrant-joyent/plugin.rb +73 -0
- data/lib/vagrant-joyent/provider.rb +50 -0
- data/lib/vagrant-joyent/util/timer.rb +17 -0
- data/lib/vagrant-joyent/version.rb +5 -0
- data/locales/en.yml +61 -0
- data/vagrant-joyent.gemspec +63 -0
- metadata +146 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Joyent
|
5
|
+
module Errors
|
6
|
+
class VagrantJoyentError < Vagrant::Errors::VagrantError
|
7
|
+
error_namespace("vagrant_joyent.errors")
|
8
|
+
end
|
9
|
+
|
10
|
+
class FogError < VagrantJoyentError
|
11
|
+
error_key(:fog_error)
|
12
|
+
end
|
13
|
+
|
14
|
+
class RsyncError < VagrantJoyentError
|
15
|
+
error_key(:rsync_error)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant Joyent 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.1.0"
|
10
|
+
raise "The Vagrant Joyent plugin is only compatible with Vagrant 1.1+"
|
11
|
+
end
|
12
|
+
|
13
|
+
module VagrantPlugins
|
14
|
+
module Joyent
|
15
|
+
class Plugin < Vagrant.plugin("2")
|
16
|
+
name "Joyent"
|
17
|
+
description <<-DESC
|
18
|
+
This plugin installs a provider that allows Vagrant to manage
|
19
|
+
machines in Joyent (Public Cloud/ SmartDatacenter).
|
20
|
+
DESC
|
21
|
+
|
22
|
+
config(:joyent, :provider) do
|
23
|
+
require_relative "config"
|
24
|
+
Config
|
25
|
+
end
|
26
|
+
|
27
|
+
provider(:joyent) 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", Joyent.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_joyent")
|
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 Joyent
|
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_joyent.states.short_#{state_id}")
|
38
|
+
long = I18n.t("vagrant_joyent.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
|
+
"Joyent (#{id})"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Joyent
|
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
|
data/locales/en.yml
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_joyent:
|
3
|
+
already_created: |-
|
4
|
+
The machine is already created.
|
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_folder: |-
|
12
|
+
Rsyncing folder: %{hostpath} => %{guestpath}
|
13
|
+
terminating: |-
|
14
|
+
Terminating the instance...
|
15
|
+
waiting_for_ready: |-
|
16
|
+
Waiting for instance to become "ready"...
|
17
|
+
waiting_for_ssh: |-
|
18
|
+
Waiting for SSH to become available...
|
19
|
+
will_not_destroy: |-
|
20
|
+
The instance '%{name}' will not be destroyed, since the confirmation
|
21
|
+
was declined.
|
22
|
+
|
23
|
+
config:
|
24
|
+
username_required: |-
|
25
|
+
A Joyent Username must be specified via "joyent.username"
|
26
|
+
keyname_required: |-
|
27
|
+
A Joyent Keyname must be specified via "joyent.keyname"
|
28
|
+
api_url_required: |-
|
29
|
+
A Joyent Datacenter API endpoint must be specified via "joyent.api_url"
|
30
|
+
dataset_required: |-
|
31
|
+
A Joyent Dataset must be specified via "joyent.dataset"
|
32
|
+
node_name_required: |-
|
33
|
+
A Node Name must be specified via "joyent.node_name"
|
34
|
+
ssh_username_required: |-
|
35
|
+
An SSH username must be specified via "joyent.ssh_username"
|
36
|
+
|
37
|
+
errors:
|
38
|
+
fog_error: |-
|
39
|
+
There was an error talking to Joyent. The error message is shown
|
40
|
+
below:
|
41
|
+
|
42
|
+
%{message}
|
43
|
+
rsync_error: |-
|
44
|
+
There was an error when attemping to rsync a share folder.
|
45
|
+
Please inspect the error message below for more info.
|
46
|
+
|
47
|
+
Host path: %{hostpath}
|
48
|
+
Guest path: %{guestpath}
|
49
|
+
Error: %{stderr}
|
50
|
+
|
51
|
+
states:
|
52
|
+
short_not_created: |-
|
53
|
+
not created
|
54
|
+
long_not_created: |-
|
55
|
+
The Joyent instance is not created. Run `vagrant up` to create it.
|
56
|
+
|
57
|
+
short_running: |-
|
58
|
+
running
|
59
|
+
long_running: |-
|
60
|
+
The Joyent instance is running. To stop this machine, you can run
|
61
|
+
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
|
@@ -0,0 +1,63 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "vagrant-joyent/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "vagrant-joyent"
|
6
|
+
s.version = VagrantPlugins::Joyent::VERSION
|
7
|
+
s.licenses = ['Apache-2.0']
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = "Sean OMeara"
|
10
|
+
s.email = "someara@opscode.com"
|
11
|
+
s.homepage = "http://www.vagrantup.com"
|
12
|
+
s.summary = "Enables Vagrant to manage machines in Joyent cloud and SDC"
|
13
|
+
s.description = <<-EOF
|
14
|
+
vagrant-joyent is a Vagrant provider for various Joyent services. It enables
|
15
|
+
Vagrant to manage machines in the Joyent cloud using standard commands like
|
16
|
+
'up', 'provision', and 'halt'.
|
17
|
+
EOF
|
18
|
+
|
19
|
+
s.required_rubygems_version = ">= 1.3.6"
|
20
|
+
s.rubyforge_project = "vagrant-joyent"
|
21
|
+
|
22
|
+
s.add_runtime_dependency "fog", "~> 1.12"
|
23
|
+
|
24
|
+
s.add_development_dependency "rake", "~> 10.1"
|
25
|
+
s.add_development_dependency "rspec-core", "~> 2.12"
|
26
|
+
s.add_development_dependency "rspec-expectations", "~> 2.12"
|
27
|
+
s.add_development_dependency "rspec-mocks", "~> 2.12"
|
28
|
+
|
29
|
+
# The following block of code determines the files that should be included
|
30
|
+
# in the gem. It does this by reading all the files in the directory where
|
31
|
+
# this gemspec is, and parsing out the ignored files from the gitignore.
|
32
|
+
# Note that the entire gitignore(5) syntax is not supported, specifically
|
33
|
+
# the "!" syntax, but it should mostly work correctly.
|
34
|
+
root_path = File.dirname(__FILE__)
|
35
|
+
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
|
36
|
+
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
|
37
|
+
gitignore_path = File.join(root_path, ".gitignore")
|
38
|
+
gitignore = File.readlines(gitignore_path)
|
39
|
+
gitignore.map! { |line| line.chomp.strip }
|
40
|
+
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
|
41
|
+
|
42
|
+
unignored_files = all_files.reject do |file|
|
43
|
+
# Ignore any directories, the gemspec only cares about files
|
44
|
+
next true if File.directory?(file)
|
45
|
+
|
46
|
+
# Ignore any paths that match anything in the gitignore. We do
|
47
|
+
# two tests here:
|
48
|
+
#
|
49
|
+
# - First, test to see if the entire path matches the gitignore.
|
50
|
+
# - Second, match if the basename does, this makes it so that things
|
51
|
+
# like '.DS_Store' will match sub-directories too (same behavior
|
52
|
+
# as git).
|
53
|
+
#
|
54
|
+
gitignore.any? do |ignore|
|
55
|
+
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
|
56
|
+
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
s.files = unignored_files
|
61
|
+
s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
|
62
|
+
s.require_path = 'lib'
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-joyent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sean OMeara
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fog
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-core
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-expectations
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-mocks
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.12'
|
83
|
+
description: |2
|
84
|
+
vagrant-joyent is a Vagrant provider for various Joyent services. It enables
|
85
|
+
Vagrant to manage machines in the Joyent cloud using standard commands like
|
86
|
+
'up', 'provision', and 'halt'.
|
87
|
+
email: someara@opscode.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- dummy.box
|
98
|
+
- example_box/README.md
|
99
|
+
- example_box/Vagrantfile
|
100
|
+
- example_box/metadata.json
|
101
|
+
- lib/vagrant-joyent.rb
|
102
|
+
- lib/vagrant-joyent/action.rb
|
103
|
+
- lib/vagrant-joyent/action/connect_joyent.rb
|
104
|
+
- lib/vagrant-joyent/action/is_created.rb
|
105
|
+
- lib/vagrant-joyent/action/message_already_created.rb
|
106
|
+
- lib/vagrant-joyent/action/message_not_created.rb
|
107
|
+
- lib/vagrant-joyent/action/message_will_not_destroy.rb
|
108
|
+
- lib/vagrant-joyent/action/read_ssh_info.rb
|
109
|
+
- lib/vagrant-joyent/action/read_state.rb
|
110
|
+
- lib/vagrant-joyent/action/run_instance.rb
|
111
|
+
- lib/vagrant-joyent/action/sync_folders.rb
|
112
|
+
- lib/vagrant-joyent/action/terminate_instance.rb
|
113
|
+
- lib/vagrant-joyent/action/warn_networks.rb
|
114
|
+
- lib/vagrant-joyent/config.rb
|
115
|
+
- lib/vagrant-joyent/errors.rb
|
116
|
+
- lib/vagrant-joyent/plugin.rb
|
117
|
+
- lib/vagrant-joyent/provider.rb
|
118
|
+
- lib/vagrant-joyent/util/timer.rb
|
119
|
+
- lib/vagrant-joyent/version.rb
|
120
|
+
- locales/en.yml
|
121
|
+
- vagrant-joyent.gemspec
|
122
|
+
homepage: http://www.vagrantup.com
|
123
|
+
licenses:
|
124
|
+
- Apache-2.0
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 1.3.6
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project: vagrant-joyent
|
142
|
+
rubygems_version: 2.2.2
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Enables Vagrant to manage machines in Joyent cloud and SDC
|
146
|
+
test_files: []
|