vagrant-smartos 0.0.1alpha → 0.0.2pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +86 -16
- data/Vagrantfile +9 -27
- data/lib/vagrant-smartos.rb +2 -2
- data/lib/vagrant-smartos/action/connect_hypervisor.rb +45 -20
- data/lib/vagrant-smartos/action/read_state.rb +54 -16
- data/lib/vagrant-smartos/action/reload_instance.rb +29 -0
- data/lib/vagrant-smartos/action/run_instance.rb +10 -11
- data/lib/vagrant-smartos/action/sync_folders.rb +3 -8
- data/lib/vagrant-smartos/action/terminate_instance.rb +1 -1
- data/lib/vagrant-smartos/config.rb +5 -4
- data/lib/vagrant-smartos/errors.rb +16 -0
- data/lib/vagrant-smartos/plugin.rb +0 -1
- data/lib/vagrant-smartos/provider.rb +11 -0
- data/lib/vagrant-smartos/version.rb +1 -1
- data/locales/en.yml +29 -11
- data/vagrant-smartos.gemspec +1 -1
- metadata +39 -52
- data/LICENSE.txt +0 -22
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,29 +1,99 @@
|
|
1
|
-
# Vagrant
|
1
|
+
# Vagrant SmartOS Provider
|
2
2
|
|
3
|
-
|
3
|
+
Provision SmartOS zones using vagrant. For now, it only works with OS container zones.
|
4
|
+
|
5
|
+
## Notes
|
6
|
+
|
7
|
+
This has only been demonstrated to work against a SmartOS hypervisor running in a VMware Fusion image, but since it's only interacted with via SSH, there is no reason why this won't work against a physical SmartOS hypervisor.
|
8
|
+
|
9
|
+
This is purely a prototype / proof-of-concept hacked together. I make no apologies for the state of the code or the lack of tests. Feel free to fix and pull-request :-p
|
10
|
+
|
11
|
+
Also, right now it uses a dummy box to get vagrant to play ball, whilst requiring an `image_uuid` parameter in the Vagrantfile. It might be much tidier if we could package up SmartOS images into vagrant-boxes and use those.
|
4
12
|
|
5
13
|
## Installation
|
6
14
|
|
7
|
-
|
15
|
+
* Get Vagrant 1.2.0+ installed (see elsewhere - I've been building using version 1.2.2).
|
16
|
+
|
17
|
+
* Install the gem from RubyGems:
|
18
|
+
|
19
|
+
`vagrant plugin install --plugin-prerelease --plugin-source https://rubygems.org/ vagrant-smartos`
|
20
|
+
|
21
|
+
* Add the dummy box:
|
22
|
+
|
23
|
+
`vagrant box add smartos-dummy https://github.com/joshado/vagrant-smartos/raw/master/example_box/smartos.box`
|
24
|
+
|
25
|
+
* Boot a SmartOS hypervisor somewhere. It shouldn't matter if this is VMWare Fusion, VirtualBox or a dedicated machine, as long as you have SSH access to it.
|
26
|
+
|
27
|
+
* Ensure your local ssh key is in the roots `authorized_keys` file on the SmartOS box. The simple way to test this is to `ssh root@<hypervisor ip>` from your workstation, which should drop you straight into a root shell on the hypervisor.
|
28
|
+
|
29
|
+
* Write your `Vagrantfile`. See below for an example one and the options you can provide.
|
30
|
+
|
31
|
+
* Run your VMs:
|
32
|
+
|
33
|
+
`vagrant up --provider=smartos`
|
34
|
+
|
35
|
+
|
36
|
+
## Example Vagrantfile and options
|
37
|
+
|
38
|
+
There are two specific parameters required for the SmartOS provider (`hypervisor` and `image_uuid`) and a bunch of optional ones, you should be able to work it out:
|
39
|
+
|
40
|
+
Vagrant.require_plugin "vagrant-smartos"
|
41
|
+
|
42
|
+
Vagrant.configure("2") do |config|
|
43
|
+
|
44
|
+
# For the time being, use our dummy box
|
45
|
+
config.vm.box = "smartos-dummy"
|
46
|
+
|
47
|
+
config.vm.provider :smartos do |smartos, override|
|
48
|
+
# Required: This is which hypervisor to provision the VM on.
|
49
|
+
# The format must be "<username>@<ip or hostname>"
|
50
|
+
smartos.hypervisor = "root@172.16.251.129"
|
51
|
+
|
52
|
+
# Required: This is the UUID of the SmartOS image to use for the VMs.
|
53
|
+
# It must already be imported before running vagrant.
|
54
|
+
smartos.image_uuid = "cf7e2f40-9276-11e2-af9a-0bad2233fb0b" # this is base64:1.9.1
|
55
|
+
|
56
|
+
# Optional: The RAM allocation for the machine, defaults to the SmartOS default (256MB)
|
57
|
+
# smartos.ram = 512
|
8
58
|
|
9
|
-
|
59
|
+
# Optional: Disk quota for the machine, defaults to the SmartOS default (5G)
|
60
|
+
# smartos.quota = 10
|
10
61
|
|
11
|
-
|
62
|
+
# Optional: Specify the nic_tag to use
|
63
|
+
# If omitted, 'admin' will be the default
|
64
|
+
# smartos.nic_tag = "admin"
|
12
65
|
|
13
|
-
|
66
|
+
# Optional: Specify a static IP address for the VM
|
67
|
+
# If omitted, 'dhcp' will be used
|
68
|
+
# smartos.ip_address = "1.2.3.4"
|
14
69
|
|
15
|
-
|
70
|
+
# Optional: Specify the net-mask (required if not using dhcp)
|
71
|
+
# smartos.subnet_mask = "255.255.255.0"
|
16
72
|
|
17
|
-
|
73
|
+
# Optional: Specify the gateway (required if not using dhcp)
|
74
|
+
# smartos.gateway = "255.255.255.0"
|
18
75
|
|
19
|
-
|
76
|
+
# Optional: Specify a VLAN tag for this VM
|
77
|
+
# smartos.vlan = 1234
|
78
|
+
end
|
20
79
|
|
21
|
-
|
80
|
+
# RSync'ed shared folders should work as normal
|
81
|
+
config.vm.synced_folder "./", "/work-dir"
|
22
82
|
|
23
|
-
|
83
|
+
# Multi-VMs should be fine, too; they will take the default parameters from above, and you can override
|
84
|
+
# specifics for each VM
|
85
|
+
#
|
86
|
+
# config.vm.define :box1 do |box|
|
87
|
+
# box.vm.provider :smartos do |smartos, override|
|
88
|
+
# smartos.ip_address = "172.16.251.21"
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# config.vm.define :box2 do |box|
|
93
|
+
# box.vm.provider :smartos do |smartos, override|
|
94
|
+
# smartos.ip_address = "172.16.251.21"
|
95
|
+
# end
|
96
|
+
# end
|
97
|
+
#
|
24
98
|
|
25
|
-
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
99
|
+
end
|
data/Vagrantfile
CHANGED
@@ -3,44 +3,26 @@ Vagrant.require_plugin "vagrant-smartos"
|
|
3
3
|
Vagrant.configure("2") do |config|
|
4
4
|
config.vm.box = "smartos-dummy"
|
5
5
|
|
6
|
-
|
7
|
-
config.vm.provision :shell, :inline => "pkgin -y install ruby193-base"
|
8
|
-
|
9
6
|
config.vm.provider :smartos do |smartos, override|
|
10
7
|
|
11
8
|
smartos.hypervisor = "root@172.16.251.129"
|
12
|
-
smartos.image_uuid = "
|
13
|
-
|
14
|
-
|
15
|
-
smartos.
|
16
|
-
smartos.
|
9
|
+
smartos.image_uuid = "13ba5a87-caa8-4092-a488-65589afb7799"
|
10
|
+
smartos.ram = 512
|
11
|
+
|
12
|
+
# smartos.ip_address = "172.16.251.18"
|
13
|
+
# smartos.subnet_mask = "255.255.255.0"
|
14
|
+
# smartos.gateway = "172.16.251.2"
|
17
15
|
end
|
18
16
|
|
19
17
|
config.vm.synced_folder "locales/", "/vagrant"
|
20
18
|
|
21
19
|
|
22
20
|
config.vm.define :test1 do |test|
|
23
|
-
test.vm.provider :smartos do |smartos, override|
|
24
|
-
smartos.ip_address = "172.16.251.21"
|
25
|
-
end
|
21
|
+
# test.vm.provider :smartos do |smartos, override|
|
22
|
+
# smartos.ip_address = "172.16.251.21"
|
23
|
+
# end
|
26
24
|
end
|
27
25
|
|
28
|
-
config.vm.define :test2 do |test|
|
29
|
-
test.vm.provider :smartos do |smartos, override|
|
30
|
-
smartos.ip_address = "172.16.251.22"
|
31
|
-
end
|
32
|
-
end
|
33
26
|
|
34
|
-
config.vm.define :test3 do |test|
|
35
|
-
test.vm.provider :smartos do |smartos, override|
|
36
|
-
smartos.ip_address = "172.16.251.23"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
config.vm.define :test4 do |test|
|
41
|
-
test.vm.provider :smartos do |smartos, override|
|
42
|
-
smartos.ip_address = "172.16.251.24"
|
43
|
-
end
|
44
|
-
end
|
45
27
|
|
46
28
|
end
|
data/lib/vagrant-smartos.rb
CHANGED
@@ -2,12 +2,12 @@ require 'pathname'
|
|
2
2
|
|
3
3
|
require "vagrant-smartos/version"
|
4
4
|
require 'vagrant-smartos/plugin'
|
5
|
+
require 'vagrant-smartos/errors'
|
5
6
|
|
6
7
|
module VagrantPlugins
|
7
8
|
module Smartos
|
8
9
|
lib_path = Pathname.new(File.expand_path("../vagrant-smartos", __FILE__))
|
9
|
-
|
10
|
-
#autoload :Errors, lib_path.join("errors")
|
10
|
+
|
11
11
|
|
12
12
|
# This returns the path to the source of this plugin.
|
13
13
|
#
|
@@ -6,6 +6,31 @@ module VagrantPlugins
|
|
6
6
|
class Provider
|
7
7
|
|
8
8
|
|
9
|
+
class SshOutput
|
10
|
+
attr_accessor :exit_code
|
11
|
+
attr_reader :command
|
12
|
+
|
13
|
+
def initialize(command)
|
14
|
+
@command = command
|
15
|
+
@stderr = []
|
16
|
+
@stdout = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def append_stderr(data)
|
20
|
+
@stderr << data
|
21
|
+
end
|
22
|
+
def append_stdout(data)
|
23
|
+
@stdout << data
|
24
|
+
end
|
25
|
+
|
26
|
+
def stdout
|
27
|
+
@stdout.join("").chomp
|
28
|
+
end
|
29
|
+
def stderr
|
30
|
+
@stderr.join("").chomp
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
9
34
|
class SshWrapper
|
10
35
|
def initialize(net_ssh)
|
11
36
|
@ssh = net_ssh
|
@@ -16,35 +41,35 @@ module VagrantPlugins
|
|
16
41
|
|
17
42
|
# Public: Execute and block on a command on the remote SSH server
|
18
43
|
#
|
19
|
-
# Returns
|
44
|
+
# Returns an SshOutput instance
|
20
45
|
#
|
21
46
|
# Raises SshWrapper::UnexpectedExitCode if the exitcode is non-0
|
22
47
|
# Raises SshWrapper::CommandExecutionFailed if the command failed to execute
|
23
48
|
def exec(command)
|
24
|
-
|
25
|
-
channel = @ssh.open_channel do |ch|
|
26
|
-
ch.exec command do |ch, success|
|
27
|
-
raise SshWrapper::CommandExecutionFailed unless success
|
28
|
-
|
29
|
-
# "on_data" is called when the process writes something to stdout
|
30
|
-
ch.on_data do |c, data|
|
31
|
-
stdout_data << data
|
32
|
-
end
|
49
|
+
SshOutput.new(command).tap do |output|
|
33
50
|
|
34
|
-
|
35
|
-
ch.
|
36
|
-
|
37
|
-
|
51
|
+
channel = @ssh.open_channel do |ch|
|
52
|
+
ch.exec command do |ch, success|
|
53
|
+
raise SshWrapper::CommandExecutionFailed unless success
|
54
|
+
|
55
|
+
# "on_data" is called when the process writes something to stdout
|
56
|
+
ch.on_data do |c, data|
|
57
|
+
output.append_stdout(data)
|
58
|
+
end
|
38
59
|
|
39
|
-
|
40
|
-
|
60
|
+
# "on_extended_data" is called when the process writes something to stderr
|
61
|
+
ch.on_extended_data do |c, type, data|
|
62
|
+
output.append_stderr(data)
|
63
|
+
end
|
64
|
+
|
65
|
+
channel.on_request("exit-status") do |ch,data|
|
66
|
+
output.exit_code = data.read_long
|
67
|
+
end
|
41
68
|
end
|
42
69
|
end
|
43
|
-
end
|
44
70
|
|
45
|
-
|
46
|
-
|
47
|
-
stdout_data.join("")
|
71
|
+
channel.wait
|
72
|
+
end
|
48
73
|
end
|
49
74
|
end
|
50
75
|
|
@@ -12,32 +12,70 @@ module VagrantPlugins
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call(env)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
:port => 22
|
22
|
-
}
|
23
|
-
else
|
15
|
+
# Try reading the VM's "external" state
|
16
|
+
vminfo = env[:machine].id && read_state(env[:hyp], env[:machine])
|
17
|
+
|
18
|
+
# If it's got a DHCP, we'll need to wait until it's running, then read out
|
19
|
+
if !vminfo || vminfo['state'] != "running"
|
20
|
+
# Don't do anything until we're actually running...
|
24
21
|
env[:machine_state_id] = :not_created
|
22
|
+
else
|
23
|
+
|
24
|
+
# Mark the state of the VM
|
25
|
+
env[:machine_state_id] = vminfo["state"].to_sym
|
26
|
+
|
27
|
+
# If the nic is DHCP, then we'll need to grab the internal state :-\
|
28
|
+
if vminfo["nics"].first["ip"] == "dhcp"
|
29
|
+
vm_sysinfo = read_internal_state(env[:hyp], env[:machine])
|
30
|
+
net0_ip = vm_sysinfo["Virtual Network Interfaces"]["net0"]["ip4addr"] rescue nil # I'm so lazy...
|
31
|
+
|
32
|
+
if vm_sysinfo && net0_ip
|
33
|
+
env[:machine_ssh_info] = {
|
34
|
+
:host => net0_ip,
|
35
|
+
:port => 22
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
else
|
40
|
+
env[:machine_ssh_info] = {
|
41
|
+
:host => vminfo["nics"].first["ip"],
|
42
|
+
:port => 22
|
43
|
+
}
|
44
|
+
end
|
25
45
|
end
|
26
46
|
|
27
47
|
@app.call(env)
|
28
48
|
end
|
29
49
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
50
|
+
# Internal: Reads the zone's internal state using a zlogin <uuid> sysinfo call
|
51
|
+
#
|
52
|
+
# hyp - the hypervisor object
|
53
|
+
# machine - the machine object
|
54
|
+
#
|
55
|
+
# Returns a hash of the sysinfo data: {"Live Image"=>"20130207T202554Z", "System Type"=>"SunOS", "Boot Time"=>"1371045058", "ZFS Quota"=>"5G", "UUID"=>"22fc9a70-b596-0130-6aac-109add5d41b9", "Hostname"=>"22fc9a70-b596-0130-6aac-109add5d41b9", "Setup"=>"false", "CPU Total Cores"=>1, "MiB of Memory"=>"512", "Virtual Network Interfaces"=>{"net0"=>{"MAC Address"=>"92:ed:e4:cd:c2:de", "ip4addr"=>"172.16.251.147", "Link Status"=>"up", "VLAN"=>"0"}}}
|
56
|
+
def read_internal_state(hyp, machine)
|
57
|
+
output = hyp.exec("zlogin #{machine.id} sysinfo")
|
58
|
+
if output.exit_code != 0
|
59
|
+
nil
|
60
|
+
else
|
61
|
+
JSON.load(output.stdout)
|
35
62
|
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
# Internal: Reads the current state of the machine from the hypervisor
|
67
|
+
#
|
68
|
+
# hyp - the hypervisor connection object
|
69
|
+
# machine - the Vagrant machine object
|
70
|
+
#
|
71
|
+
# Returns a hash of data returned by vmadm, or nil if the VM isn't found
|
72
|
+
def read_state(hyp, machine)
|
73
|
+
output = hyp.exec("vmadm get #{machine.id}")
|
36
74
|
|
37
|
-
if output.chomp == ""
|
75
|
+
if output.exit_code != 0 || output.stderr.chomp =~ /No such zone configured/ || output.stdout == ""
|
38
76
|
nil
|
39
77
|
else
|
40
|
-
JSON.load(output)
|
78
|
+
JSON.load(output.stdout)
|
41
79
|
end
|
42
80
|
end
|
43
81
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'uuid'
|
2
|
+
require "log4r"
|
3
|
+
require 'vagrant/util/retryable'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Smartos
|
7
|
+
class Provider
|
8
|
+
# This runs the configured instance.
|
9
|
+
class ReloadInstance
|
10
|
+
include Vagrant::Util::Retryable
|
11
|
+
|
12
|
+
def initialize(app, env)
|
13
|
+
@app = app
|
14
|
+
@logger = Log4r::Logger.new("vagrant_smartos::action::reload_instance")
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
vm_uuid = env[:machine].id
|
19
|
+
|
20
|
+
if env[:machine].state.id != :not_created
|
21
|
+
env[:ui].info(I18n.t("vagrant_smartos.reloading"))
|
22
|
+
output = env[:hyp].exec("vmadm reboot #{vm_uuid}")
|
23
|
+
env[:machine].id = nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -16,22 +16,19 @@ module VagrantPlugins
|
|
16
16
|
|
17
17
|
def call(env)
|
18
18
|
|
19
|
-
image_uuid =
|
20
|
-
|
21
|
-
vlan = "" #104
|
22
|
-
nic_tag = "admin"
|
23
|
-
ip_address = "172.16.251.120"
|
24
|
-
subnet_mask = "255.255.255.0"
|
25
|
-
gateway = "172.16.251.2"
|
26
|
-
|
27
19
|
nic = {
|
28
20
|
"nic_tag" => env[:machine].provider_config.nic_tag,
|
29
21
|
"ip" => env[:machine].provider_config.ip_address,
|
30
|
-
"netmask" =>
|
22
|
+
"netmask" =>env[:machine].provider_config.subnet_mask,
|
31
23
|
"gateway" => env[:machine].provider_config.gateway,
|
32
24
|
"primary" => true
|
33
25
|
}
|
34
26
|
|
27
|
+
# Make sure we don't pass empty-string gateway / netmask to vmadm, as it isn't happy with this
|
28
|
+
nic.delete("netmask") if nic['netmask'].nil? || nic['netmask'].length == 0
|
29
|
+
nic.delete("gateway") if nic['gateway'].nil? || nic['gateway'].length == 0
|
30
|
+
|
31
|
+
|
35
32
|
if env[:machine].provider_config.vlan
|
36
33
|
nic["vlan_id"] = env[:machine].provider_config.vlan
|
37
34
|
end
|
@@ -51,11 +48,13 @@ module VagrantPlugins
|
|
51
48
|
}
|
52
49
|
}
|
53
50
|
|
54
|
-
|
55
51
|
# Launch!
|
56
52
|
env[:ui].info(I18n.t("vagrant_smartos.launching_instance"))
|
57
53
|
|
58
|
-
env[:hyp].exec("vmadm create <<JSON\n#{JSON.dump(machine_json)}\nJSON")
|
54
|
+
output = env[:hyp].exec("vmadm create <<JSON\n#{JSON.dump(machine_json)}\nJSON")
|
55
|
+
if output.exit_code != 0 || output.stderr.chomp != "Successfully created #{env[:machine].id}"
|
56
|
+
raise Errors::VmadmError, :message => I18n.t("vagrant_smartos.errors.vmadm_create", :output => output.stderr.chomp)
|
57
|
+
end
|
59
58
|
|
60
59
|
env[:ui].info(I18n.t("vagrant_smartos.waiting_for_ready"))
|
61
60
|
while true
|
@@ -8,7 +8,7 @@ module VagrantPlugins
|
|
8
8
|
module Smartos
|
9
9
|
class Provider
|
10
10
|
# This middleware uses `rsync` to sync the folders over to the
|
11
|
-
#
|
11
|
+
# zone.
|
12
12
|
class SyncFolders
|
13
13
|
include Vagrant::Util::ScopedHashOverride
|
14
14
|
|
@@ -35,9 +35,7 @@ module VagrantPlugins
|
|
35
35
|
# avoid creating an additional directory with rsync
|
36
36
|
hostpath = "#{hostpath}/" if hostpath !~ /\/$/
|
37
37
|
|
38
|
-
env[:ui].info(I18n.t("vagrant_smartos.rsync_folder",
|
39
|
-
:hostpath => hostpath,
|
40
|
-
:guestpath => guestpath))
|
38
|
+
env[:ui].info(I18n.t("vagrant_smartos.rsync_folder", :hostpath => hostpath, :guestpath => guestpath))
|
41
39
|
|
42
40
|
# Create the guest path
|
43
41
|
env[:machine].communicate.sudo("mkdir -p '#{guestpath}'")
|
@@ -54,10 +52,7 @@ module VagrantPlugins
|
|
54
52
|
|
55
53
|
r = Vagrant::Util::Subprocess.execute(*command)
|
56
54
|
if r.exit_code != 0
|
57
|
-
raise Errors::RsyncError,
|
58
|
-
:guestpath => guestpath,
|
59
|
-
:hostpath => hostpath,
|
60
|
-
:stderr => r.stderr
|
55
|
+
raise Errors::RsyncError, :guestpath => guestpath, :hostpath => hostpath, :stderr => r.stderr
|
61
56
|
end
|
62
57
|
end
|
63
58
|
end
|
@@ -19,7 +19,7 @@ module VagrantPlugins
|
|
19
19
|
|
20
20
|
if env[:machine].state.id != :not_created
|
21
21
|
env[:ui].info(I18n.t("vagrant_smartos.terminating"))
|
22
|
-
env[:hyp].exec("vmadm destroy #{vm_uuid}")
|
22
|
+
output = env[:hyp].exec("vmadm destroy #{vm_uuid}")
|
23
23
|
env[:machine].id = nil
|
24
24
|
end
|
25
25
|
end
|
@@ -30,7 +30,7 @@ module VagrantPlugins
|
|
30
30
|
@hypervisor = nil if @hypervisor == UNSET_VALUE
|
31
31
|
@image_uuid = nil if @image_uuid == UNSET_VALUE
|
32
32
|
@nic_tag = "admin" if @nic_tag == UNSET_VALUE
|
33
|
-
@ip_address =
|
33
|
+
@ip_address = "dhcp" if @ip_address == UNSET_VALUE
|
34
34
|
@subnet_mask = nil if @subnet_mask == UNSET_VALUE
|
35
35
|
@gateway = nil if @gateway == UNSET_VALUE
|
36
36
|
@vlan = nil if @vlan == UNSET_VALUE
|
@@ -46,9 +46,10 @@ module VagrantPlugins
|
|
46
46
|
|
47
47
|
errors << I18n.t("vagrant_smartos.config.hypervisor_required") if @hypervisor.nil?
|
48
48
|
errors << I18n.t("vagrant_smartos.config.image_uuid_required") if @image_uuid.nil?
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
unless @ip_address == "dhcp"
|
50
|
+
errors << I18n.t("vagrant_smartos.config.static_netmask_requied") if @subnet_mask.nil?
|
51
|
+
errors << I18n.t("vagrant_smartos.config.static_gateway_required") if @gateway.nil?
|
52
|
+
end
|
52
53
|
|
53
54
|
{ "SmartOS Provider" => errors }
|
54
55
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Smartos
|
5
|
+
module Errors
|
6
|
+
class VagrantSmartosError < Vagrant::Errors::VagrantError
|
7
|
+
error_namespace("vagrant_smartos.errors")
|
8
|
+
end
|
9
|
+
|
10
|
+
class VmadmError < VagrantSmartosError
|
11
|
+
error_key(:vmadm)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -16,6 +16,7 @@ module VagrantPlugins
|
|
16
16
|
autoload :ReadState, action_root.join("read_state")
|
17
17
|
autoload :RunInstance, action_root.join("run_instance")
|
18
18
|
autoload :SyncFolders, action_root.join("sync_folders")
|
19
|
+
autoload :ReloadInstance, action_root.join("reload_instance")
|
19
20
|
autoload :TerminateInstance, action_root.join("terminate_instance")
|
20
21
|
|
21
22
|
def initialize(machine)
|
@@ -47,6 +48,14 @@ module VagrantPlugins
|
|
47
48
|
|
48
49
|
end
|
49
50
|
|
51
|
+
def action_reload
|
52
|
+
Vagrant::Action::Builder.new.tap do |b|
|
53
|
+
b.use ConfigValidate
|
54
|
+
b.use ConnectHypervisor
|
55
|
+
b.use ReloadInstance
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
50
59
|
def action_provision
|
51
60
|
Vagrant::Action::Builder.new.tap do |b|
|
52
61
|
b.use ConfigValidate
|
@@ -121,6 +130,8 @@ module VagrantPlugins
|
|
121
130
|
action_ssh_run
|
122
131
|
when :provision
|
123
132
|
action_provision
|
133
|
+
when :reload
|
134
|
+
action_reload
|
124
135
|
end
|
125
136
|
end
|
126
137
|
|
data/locales/en.yml
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
en:
|
2
2
|
vagrant_smartos:
|
3
|
+
|
4
|
+
errors:
|
5
|
+
vmadm: |-
|
6
|
+
Error when running vmadm on the hypervisor: %{message}
|
7
|
+
|
8
|
+
vmadm_create: |-
|
9
|
+
`vmadm create` returned: '%{output}'
|
10
|
+
|
3
11
|
config:
|
4
12
|
hypervisor_required: |-
|
5
13
|
A hypervisor must be specified
|
@@ -7,32 +15,42 @@ en:
|
|
7
15
|
image_uuid_required: |-
|
8
16
|
An image_uuid value is required
|
9
17
|
|
18
|
+
static_gateway_required: |-
|
19
|
+
A gateway value is required if a static IP address is used
|
20
|
+
|
21
|
+
static_netmask_required: |-
|
22
|
+
A network mask value is required if a static IP address is used
|
23
|
+
|
10
24
|
states:
|
11
|
-
|
12
|
-
Running
|
13
|
-
running_long: |-
|
25
|
+
short_running: |-
|
14
26
|
Running
|
27
|
+
long_running: |-
|
28
|
+
running
|
29
|
+
short_not_created: |-
|
30
|
+
not created
|
31
|
+
long_not_created: |-
|
32
|
+
The zone has not been created
|
15
33
|
|
16
34
|
not_created: |-
|
17
|
-
|
35
|
+
Zone hasn't been created yet
|
18
36
|
|
19
37
|
already_created: |-
|
20
|
-
|
38
|
+
Zone already created
|
21
39
|
|
22
40
|
launching_instance: |-
|
23
|
-
|
41
|
+
Launching SmartOS zone
|
24
42
|
|
25
43
|
waiting_for_ready: |-
|
26
|
-
|
44
|
+
Waiting for zone to be ready
|
27
45
|
|
28
46
|
waiting_for_ssh: |-
|
29
|
-
|
47
|
+
Waiting for SSH
|
30
48
|
|
31
49
|
ready: |-
|
32
|
-
|
50
|
+
Zone is ready
|
33
51
|
|
34
52
|
rsync_folder: |-
|
35
|
-
|
53
|
+
Updating the rsync shared folder
|
36
54
|
|
37
55
|
terminating: |-
|
38
|
-
|
56
|
+
Shutting down the zone
|
data/vagrant-smartos.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["thomas@haggett.org"]
|
11
11
|
gem.description = %q{SmartOS Hypervisor provider for Vagrant}
|
12
12
|
gem.summary = %q{SmartOS Hypervisor provider for Vagrant}
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "http://github.com/joshado/vagrant-smartos/"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,47 +1,41 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-smartos
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1alpha
|
9
|
-
version: 0.0.1alpha
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2pre1
|
5
|
+
prerelease: 5
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Thomas Haggett
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-06-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: uuid
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
version: "0"
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
30
22
|
type: :runtime
|
31
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
32
30
|
description: SmartOS Hypervisor provider for Vagrant
|
33
|
-
email:
|
31
|
+
email:
|
34
32
|
- thomas@haggett.org
|
35
33
|
executables: []
|
36
|
-
|
37
34
|
extensions: []
|
38
|
-
|
39
35
|
extra_rdoc_files: []
|
40
|
-
|
41
|
-
files:
|
36
|
+
files:
|
42
37
|
- .gitignore
|
43
38
|
- Gemfile
|
44
|
-
- LICENSE.txt
|
45
39
|
- README.md
|
46
40
|
- Rakefile
|
47
41
|
- Vagrantfile
|
@@ -54,46 +48,39 @@ files:
|
|
54
48
|
- lib/vagrant-smartos/action/message_already_created.rb
|
55
49
|
- lib/vagrant-smartos/action/message_not_created.rb
|
56
50
|
- lib/vagrant-smartos/action/read_state.rb
|
51
|
+
- lib/vagrant-smartos/action/reload_instance.rb
|
57
52
|
- lib/vagrant-smartos/action/run_instance.rb
|
58
53
|
- lib/vagrant-smartos/action/sync_folders.rb
|
59
54
|
- lib/vagrant-smartos/action/terminate_instance.rb
|
60
55
|
- lib/vagrant-smartos/config.rb
|
56
|
+
- lib/vagrant-smartos/errors.rb
|
61
57
|
- lib/vagrant-smartos/plugin.rb
|
62
58
|
- lib/vagrant-smartos/provider.rb
|
63
59
|
- lib/vagrant-smartos/version.rb
|
64
60
|
- locales/en.yml
|
65
61
|
- vagrant-smartos.gemspec
|
66
|
-
|
67
|
-
homepage: ""
|
62
|
+
homepage: http://github.com/joshado/vagrant-smartos/
|
68
63
|
licenses: []
|
69
|
-
|
70
64
|
post_install_message:
|
71
65
|
rdoc_options: []
|
72
|
-
|
73
|
-
require_paths:
|
66
|
+
require_paths:
|
74
67
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
segments:
|
87
|
-
- 1
|
88
|
-
- 3
|
89
|
-
- 1
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>'
|
78
|
+
- !ruby/object:Gem::Version
|
90
79
|
version: 1.3.1
|
91
80
|
requirements: []
|
92
|
-
|
93
81
|
rubyforge_project:
|
94
|
-
rubygems_version: 1.
|
82
|
+
rubygems_version: 1.8.25
|
95
83
|
signing_key:
|
96
84
|
specification_version: 3
|
97
85
|
summary: SmartOS Hypervisor provider for Vagrant
|
98
86
|
test_files: []
|
99
|
-
|
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2013 Thomas Haggett
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|