vagrant-smartos-zones 0.0.1.pre.21

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 (78) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rubocop.yml +12 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +268 -0
  7. data/Rakefile +6 -0
  8. data/Vagrantfile +29 -0
  9. data/examples/Vagrantfile +18 -0
  10. data/examples/Vagrantfile.chef_server +33 -0
  11. data/examples/Vagrantfile.lx +22 -0
  12. data/examples/Vagrantfile.rsync +23 -0
  13. data/files/gz_vnic/create_gz_vnic +15 -0
  14. data/files/smf/create-gz-vnic.xml +31 -0
  15. data/files/smf/zonegate.xml +34 -0
  16. data/files/zonegate/zonegate +60 -0
  17. data/files/zonegate/zonemon +15 -0
  18. data/files/zonegate/zonenat +153 -0
  19. data/lib/vagrant/smartos/locales/en.yml +41 -0
  20. data/lib/vagrant/smartos/zones/action/configure_zone_synced_folders.rb +53 -0
  21. data/lib/vagrant/smartos/zones/action/create_gz_vnic.rb +28 -0
  22. data/lib/vagrant/smartos/zones/action/forward_gz_ports.rb +46 -0
  23. data/lib/vagrant/smartos/zones/action/helper.rb +33 -0
  24. data/lib/vagrant/smartos/zones/action/imgadm_import.rb +24 -0
  25. data/lib/vagrant/smartos/zones/action/virtualbox/platform_iso.rb +57 -0
  26. data/lib/vagrant/smartos/zones/action/zone/create.rb +25 -0
  27. data/lib/vagrant/smartos/zones/action/zone/start.rb +25 -0
  28. data/lib/vagrant/smartos/zones/action/zone/stop.rb +25 -0
  29. data/lib/vagrant/smartos/zones/action/zone_gate/enable.rb +26 -0
  30. data/lib/vagrant/smartos/zones/action/zone_gate/install.rb +26 -0
  31. data/lib/vagrant/smartos/zones/action.rb +75 -0
  32. data/lib/vagrant/smartos/zones/cap/base.rb +29 -0
  33. data/lib/vagrant/smartos/zones/cap/create_gz_vnic.rb +45 -0
  34. data/lib/vagrant/smartos/zones/cap/imgadm_import.rb +30 -0
  35. data/lib/vagrant/smartos/zones/cap/platform_image/install.rb +17 -0
  36. data/lib/vagrant/smartos/zones/cap/platform_image/latest.rb +19 -0
  37. data/lib/vagrant/smartos/zones/cap/platform_image/list.rb +17 -0
  38. data/lib/vagrant/smartos/zones/cap/zone/base.rb +32 -0
  39. data/lib/vagrant/smartos/zones/cap/zone/create.rb +45 -0
  40. data/lib/vagrant/smartos/zones/cap/zone/start.rb +29 -0
  41. data/lib/vagrant/smartos/zones/cap/zone/stop.rb +29 -0
  42. data/lib/vagrant/smartos/zones/cap/zone_gate/enable.rb +20 -0
  43. data/lib/vagrant/smartos/zones/cap/zone_gate/install.rb +46 -0
  44. data/lib/vagrant/smartos/zones/commands/dataset.rb +91 -0
  45. data/lib/vagrant/smartos/zones/commands/global_zone.rb +43 -0
  46. data/lib/vagrant/smartos/zones/commands/multi_command.rb +46 -0
  47. data/lib/vagrant/smartos/zones/commands/smartos.rb +70 -0
  48. data/lib/vagrant/smartos/zones/commands/zlogin.rb +35 -0
  49. data/lib/vagrant/smartos/zones/commands/zones.rb +136 -0
  50. data/lib/vagrant/smartos/zones/communicator/smartos.rb +87 -0
  51. data/lib/vagrant/smartos/zones/config/global_zone.rb +26 -0
  52. data/lib/vagrant/smartos/zones/config/zone.rb +33 -0
  53. data/lib/vagrant/smartos/zones/errors.rb +9 -0
  54. data/lib/vagrant/smartos/zones/guest.rb +25 -0
  55. data/lib/vagrant/smartos/zones/hooks.rb +41 -0
  56. data/lib/vagrant/smartos/zones/models/dataset.rb +27 -0
  57. data/lib/vagrant/smartos/zones/models/snapshot.rb +71 -0
  58. data/lib/vagrant/smartos/zones/models/zone.rb +80 -0
  59. data/lib/vagrant/smartos/zones/models/zone_group.rb +11 -0
  60. data/lib/vagrant/smartos/zones/models/zone_user.rb +11 -0
  61. data/lib/vagrant/smartos/zones/plugin.rb +118 -0
  62. data/lib/vagrant/smartos/zones/util/checksum.rb +22 -0
  63. data/lib/vagrant/smartos/zones/util/downloader.rb +48 -0
  64. data/lib/vagrant/smartos/zones/util/global_zone/connection.rb +192 -0
  65. data/lib/vagrant/smartos/zones/util/global_zone/helper.rb +33 -0
  66. data/lib/vagrant/smartos/zones/util/global_zone/ssh_info.rb +85 -0
  67. data/lib/vagrant/smartos/zones/util/platform_images.rb +132 -0
  68. data/lib/vagrant/smartos/zones/util/public_key.rb +14 -0
  69. data/lib/vagrant/smartos/zones/util/snapshots.rb +63 -0
  70. data/lib/vagrant/smartos/zones/util/zone_group.rb +34 -0
  71. data/lib/vagrant/smartos/zones/util/zone_info.rb +72 -0
  72. data/lib/vagrant/smartos/zones/util/zone_json.rb +77 -0
  73. data/lib/vagrant/smartos/zones/util/zone_project.rb +25 -0
  74. data/lib/vagrant/smartos/zones/util/zone_user.rb +63 -0
  75. data/lib/vagrant/smartos/zones/version.rb +7 -0
  76. data/lib/vagrant/smartos/zones.rb +10 -0
  77. data/vagrant-smartos-zones.gemspec +24 -0
  78. metadata +163 -0
@@ -0,0 +1,153 @@
1
+ #!/usr/node/bin/node
2
+ // -*- mode: javascript; tab-width: 4; indent-tabs-mode: 1; st-rulers: [80] -*-
3
+
4
+ // require
5
+ var exec = require('child_process').exec;
6
+
7
+ // global
8
+ var zone;
9
+ var state;
10
+ var adminIp;
11
+ var privateIp;
12
+ var zoneIp;
13
+
14
+ function executeNat(mapCmd, rdrCmd, cb)
15
+ {
16
+ exec(mapCmd, function (err, _stdout, _stderr) {
17
+ if (err) {
18
+ cb(err);
19
+ } else {
20
+ exec(rdrCmd, function (err, _stdout, _stderr) {
21
+ if (err) {
22
+ cb(err);
23
+ } else {
24
+ cb();
25
+ }
26
+ });
27
+ }
28
+ });
29
+ }
30
+
31
+ function enableAdminNat(cb)
32
+ {
33
+ var mapCmd = 'echo "map e1000g0 0/0 -> ' + adminIp + '/32" | ipnat -f -';
34
+ var rdrCmd = 'echo "rdr e1000g0 0/0 -> ' + zoneIp + '" | ipnat -f -';
35
+
36
+ executeNat(mapCmd, rdrCmd, cb);
37
+ }
38
+
39
+ function disableAdminNat(cb)
40
+ {
41
+ var mapCmd = 'echo "map e1000g0 0/0 -> ' + adminIp + '/32" | ipnat -r -f -';
42
+ var rdrCmd = 'echo "rdr e1000g0 0/0 -> ' + zoneIp + '" | ipnat -r -f -';
43
+
44
+ executeNat(mapCmd, rdrCmd, cb);
45
+ }
46
+
47
+ function enablePrivateNat(cb)
48
+ {
49
+ if (!privateIp) {
50
+ cb();
51
+ return;
52
+ }
53
+
54
+ var mapCmd = 'echo "map e1000g1 0/0 -> ' + privateIp + '/32" | ipnat -f -';
55
+ var rdrCmd = 'echo "rdr e1000g1 0/0 -> ' + zoneIp + '" | ipnat -f -';
56
+
57
+ executeNat(mapCmd, rdrCmd, cb);
58
+ }
59
+
60
+ function disablePrivateNat(cb)
61
+ {
62
+ if (!privateIp) {
63
+ cb();
64
+ return;
65
+ }
66
+
67
+ var mapCmd = 'echo "map e1000g1 0/0 -> ' + privateIp + '/32" | ipnat -r -f -';
68
+ var rdrCmd = 'echo "rdr e1000g1 0/0 -> ' + zoneIp + '" | ipnat -r -f -';
69
+
70
+ executeNat(mapCmd, rdrCmd, cb);
71
+ }
72
+
73
+ function probeAddresses(cb)
74
+ {
75
+ var finished = function () {
76
+ if (adminIp != null && privateIp != null && zoneIp != null) {
77
+ cb();
78
+ }
79
+ }
80
+
81
+ // probe adminIp
82
+ exec("ipadm show-addr e1000g0/ -p -o ADDR | sed 's/\\\/.*//'", function (err, stdout, stderr) {
83
+ if (err) {
84
+ adminIp = false;
85
+ } else {
86
+ adminIp = stdout.trim();
87
+ }
88
+ finished();
89
+ });
90
+
91
+ // probe privateIP
92
+ exec("ipadm show-addr e1000g1/ -p -o ADDR | sed 's/\\\/.*//'", function (err, stdout, stderr) {
93
+ if (err) {
94
+ privateIp = false;
95
+ } else {
96
+ privateIp = stdout.trim();
97
+ }
98
+ finished();
99
+ });
100
+
101
+ // probe zoneIP
102
+ exec('vmadm get ' + zone + ' | json nics[0].ip', function (err, stdout, stderr) {
103
+ if (err) {
104
+ zoneIp = false;
105
+ } else {
106
+ zoneIp = stdout.trim();
107
+ }
108
+ finished();
109
+ });
110
+ }
111
+
112
+ function main()
113
+ {
114
+ var data = process.argv[2];
115
+
116
+ if (!data) {
117
+ process.exit(1);
118
+ }
119
+
120
+ data = data.trim().split(':');
121
+
122
+ zone = data[0];
123
+ state = data[1];
124
+
125
+ probeAddresses(function () {
126
+ if (state == 'up') {
127
+ enableAdminNat(function (err) {
128
+ if (err) {
129
+ console.log('error enabling admin nat: ' + err.message);
130
+ }
131
+ });
132
+ enablePrivateNat(function (err) {
133
+ if (err) {
134
+ console.log('error enabling private nat: ' + err.message);
135
+ }
136
+ });
137
+ } else {
138
+ disableAdminNat(function (err) {
139
+ if (err) {
140
+ console.log('error disabling admin nat: ' + err.message);
141
+ }
142
+ });
143
+ disablePrivateNat(function (err) {
144
+ if (err) {
145
+ console.log('error disabling private nat: ' + err.message);
146
+ }
147
+ });
148
+ }
149
+ });
150
+
151
+ }
152
+
153
+ main();
@@ -0,0 +1,41 @@
1
+ en:
2
+ vagrant:
3
+ smartos:
4
+ zones:
5
+ commands:
6
+ zones:
7
+ list: |-
8
+ name state uuid
9
+ %{zones}
10
+ create: |-
11
+ Created zone with name %{name}
12
+ uuid: %{uuid}
13
+ state: %{state}
14
+ brand: %{brand}
15
+ image: %{image}
16
+ destroyed: |-
17
+ Zone destroyed %{name} %{uuid}
18
+ show: |-
19
+ name: %{name}
20
+ state: %{state}
21
+ uuid: %{uuid}
22
+ brand: %{brand}
23
+ image: %{image}
24
+ snapshot:
25
+ list: |-
26
+ name created at used zone
27
+ %{snapshots}
28
+ create: |-
29
+ Creating snapshot with name %{name}
30
+ destroy: |-
31
+ Destroying snapshot with name %{name}
32
+ rollback: |-
33
+ Rolling back zone %{zonename} to snapshot %{name}
34
+ start: |-
35
+ Started zone %{name} %{uuid}
36
+ stop: |-
37
+ Stopped zone %{name} %{uuid}
38
+ warning:
39
+ zone_not_found: |-
40
+ Unable to find zone with name %{name}
41
+
@@ -0,0 +1,53 @@
1
+ require 'vagrant/smartos/zones/models/zone'
2
+ require 'vagrant/smartos/zones/util/zone_user'
3
+ require 'vagrant/smartos/zones/util/zone_group'
4
+ require 'vagrant/smartos/zones/action/helper'
5
+
6
+ # rubocop:disable all
7
+ module Vagrant
8
+ module Smartos
9
+ module Zones
10
+ module Action
11
+ class ConfigureZoneSyncedFolders
12
+ include Helper
13
+
14
+ def initialize(app, env)
15
+ @app = app
16
+ @env = env
17
+ end
18
+
19
+ def call(env)
20
+ app.call(env)
21
+
22
+ if zones_supported?
23
+ zone = Vagrant::Smartos::Zones::Models::Zone.find(machine, machine.config.zone.name)
24
+ machine.config.zone.synced_folders.each do |folder|
25
+ configure_synced_folder(zone, folder)
26
+ end
27
+ end
28
+ end
29
+
30
+ def configure_synced_folder(zone, folder)
31
+ host_path, guest_path, args = folder
32
+ path = "/zones/#{zone.uuid}/root#{guest_path}"
33
+ type = args.delete(:type) { |el| :rsync }
34
+
35
+ username = args[:owner] || 'vagrant'
36
+ groupname = args[:group] || 'vagrant'
37
+ user = Vagrant::Smartos::Zones::Util::ZoneUser.new(machine, zone).find(username)
38
+ group = Vagrant::Smartos::Zones::Util::ZoneGroup.new(machine, zone).find(groupname)
39
+
40
+ machine.config.vm.synced_folders[path] = {
41
+ disabled: false,
42
+ guestpath: path,
43
+ hostpath: host_path,
44
+ type: type.to_sym,
45
+ owner: user.uid,
46
+ group: group.gid
47
+ }.merge(args || {})
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,28 @@
1
+ require 'vagrant/smartos/zones/action/helper'
2
+
3
+ # This action installs a vnic in the global zone, used by
4
+ # local zones. The executed code needs to happen after
5
+ # networks have been configured in the global zone.
6
+ #
7
+ # Zone creation is hooked onto this.
8
+ module Vagrant
9
+ module Smartos
10
+ module Zones
11
+ module Action
12
+ class CreateGZVnic
13
+ include Helper
14
+
15
+ def initialize(app, env)
16
+ @app = app
17
+ @env = env
18
+ end
19
+
20
+ def call(env)
21
+ app.call(env)
22
+ guest.capability(:create_gz_vnic) if zones_supported?
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,46 @@
1
+ require 'vagrant/smartos/zones/action/helper'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Action
7
+ class ForwardGZPorts
8
+ include VagrantPlugins::ProviderVirtualBox::Util::CompileForwardedPorts
9
+ include Helper
10
+
11
+ def initialize(app, env)
12
+ @app = app
13
+ @env = env
14
+ end
15
+
16
+ # This middleware sets up a VirtualBox port forward to 2222 in the global zone.
17
+ # ipnat in the global zone is configured to route this to 22 in the global zone,
18
+ # even when all other ports are forwarded to a zone.
19
+ def call(env)
20
+ configure_gz_port_forward if zone_configured?
21
+
22
+ app.call(env)
23
+ end
24
+
25
+ def configure_gz_port_forward
26
+ machine.ui.info 'Configuring a port forward to talk to the Global Zone'
27
+ machine.config.vm.network :forwarded_port, port_forward_options
28
+ end
29
+
30
+ def network
31
+ machine.config.vm.networks.first
32
+ end
33
+
34
+ def port_forward_options
35
+ scoped_hash_override(network[1], :virtualbox).merge(
36
+ id: 'gz_ssh',
37
+ guest: machine.config.global_zone.ssh_port,
38
+ host: machine.config.global_zone.forwarded_ssh_port,
39
+ auto_correct: true
40
+ )
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,33 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Zones
4
+ module Action
5
+ module Helper
6
+ attr_reader :app, :env
7
+
8
+ private
9
+
10
+ def machine
11
+ @machine ||= env[:machine]
12
+ end
13
+
14
+ def guest
15
+ @guest ||= machine.guest
16
+ end
17
+
18
+ def zones_supported?
19
+ @zones_supported ||= guest.capability?(:imgadm_import)
20
+ end
21
+
22
+ def zone_configured?
23
+ !!machine.config.zone.name
24
+ end
25
+
26
+ def single_zone_mode?
27
+ !!machine.config.zone.name
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ require 'vagrant/smartos/zones/action/helper'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Action
7
+ class ImgadmImport
8
+ include Helper
9
+
10
+ def initialize(app, env)
11
+ @app = app
12
+ @env = env
13
+ end
14
+
15
+ def call(env)
16
+ app.call(env)
17
+ env[:ui].info "Checking if machine supports zones: #{zones_supported? ? 'yes' : 'no'}"
18
+ guest.capability(:imgadm_import) if zones_supported?
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,57 @@
1
+ require 'vagrant/smartos/zones/action/helper'
2
+ require 'vagrant/smartos/zones/util/platform_images'
3
+
4
+ module Vagrant
5
+ module Smartos
6
+ module Zones
7
+ module Action
8
+ module VirtualBox
9
+ class PlatformISO
10
+ include Helper
11
+
12
+ attr_accessor :app, :env, :machine
13
+ def initialize(app, _env)
14
+ @app = app
15
+ end
16
+
17
+ def call(env)
18
+ @env = env
19
+ @machine = env[:machine]
20
+
21
+ if requires_platform_iso?
22
+ env[:ui].warn 'Remapping platform ISO'
23
+ machine.provider_config.customizations << remove_dvddrive
24
+ machine.provider_config.customizations << add_platform_image
25
+ end
26
+
27
+ @app.call(env)
28
+ end
29
+
30
+ private
31
+
32
+ def requires_platform_iso?
33
+ machine.config.global_zone.platform_image &&
34
+ machine.config.vm.communicator == :smartos
35
+ end
36
+
37
+ def remove_dvddrive
38
+ ['pre-boot',
39
+ ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device',
40
+ 0, '--medium', 'none']]
41
+ end
42
+
43
+ def add_platform_image
44
+ ['pre-boot', ['storageattach', :id, '--storagectl', 'IDE Controller',
45
+ '--port', 1, '--device', 0, '--type', 'dvddrive',
46
+ '--medium', platform_image.to_s]]
47
+ end
48
+
49
+ def platform_image
50
+ Util::PlatformImages.new(env, machine).get_platform_image(machine.config.global_zone.platform_image)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,25 @@
1
+ require 'vagrant/smartos/zones/action/helper'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Action
7
+ module Zone
8
+ class Create
9
+ include Helper
10
+
11
+ def initialize(app, env)
12
+ @app = app
13
+ @env = env
14
+ end
15
+
16
+ def call(env)
17
+ app.call(env)
18
+ guest.capability(:zone__create) if zones_supported?
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'vagrant/smartos/zones/action/helper'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Action
7
+ module Zone
8
+ class Start
9
+ include Helper
10
+
11
+ def initialize(app, env)
12
+ @app = app
13
+ @env = env
14
+ end
15
+
16
+ def call(env)
17
+ app.call(env)
18
+ guest.capability(:zone__start) if zones_supported?
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'vagrant/smartos/zones/action/helper'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Action
7
+ module Zone
8
+ class Stop
9
+ include Helper
10
+
11
+ def initialize(app, env)
12
+ @app = app
13
+ @env = env
14
+ end
15
+
16
+ def call(env)
17
+ guest.capability(:zone__stop) if zones_supported?
18
+ app.call(env)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'vagrant/smartos/zones/action/helper'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Action
7
+ module ZoneGate
8
+ class Enable
9
+ include Helper
10
+
11
+ def initialize(app, env)
12
+ @app = app
13
+ @env = env
14
+ end
15
+
16
+ def call(env)
17
+ app.call(env)
18
+ return unless guest.capability?(:zone_gate_enable)
19
+ guest.capability(:zone_gate_enable) if single_zone_mode?
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'vagrant/smartos/zones/action/helper'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Action
7
+ module ZoneGate
8
+ class Install
9
+ include Helper
10
+
11
+ def initialize(app, env)
12
+ @app = app
13
+ @env = env
14
+ end
15
+
16
+ def call(env)
17
+ app.call(env)
18
+ return unless guest.capability?(:zone_gate_install)
19
+ guest.capability(:zone_gate_install) if zones_supported?
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,75 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Zones
4
+ module Action
5
+ require_relative 'action/configure_zone_synced_folders'
6
+ require_relative 'action/create_gz_vnic'
7
+ require_relative 'action/forward_gz_ports'
8
+ require_relative 'action/imgadm_import'
9
+ require_relative 'action/zone/create'
10
+ require_relative 'action/zone/start'
11
+ require_relative 'action/zone/stop'
12
+ require_relative 'action/zone_gate/enable'
13
+ require_relative 'action/zone_gate/install'
14
+ require_relative 'action/virtualbox/platform_iso'
15
+
16
+ class << self
17
+ def configure_zone_synced_folders
18
+ @configure_zone_synced_folders ||= ::Vagrant::Action::Builder.new.tap do |b|
19
+ b.use Vagrant::Smartos::Zones::Action::ConfigureZoneSyncedFolders
20
+ end
21
+ end
22
+
23
+ def create_gz_vnic
24
+ @configure_zone_synced_folders ||= ::Vagrant::Action::Builder.new.tap do |b|
25
+ b.use Vagrant::Smartos::Zones::Action::CreateGZVnic
26
+ end
27
+ end
28
+
29
+ def enable_zone_gate
30
+ @enable_zone_gate ||= ::Vagrant::Action::Builder.new.tap do |b|
31
+ b.use Vagrant::Smartos::Zones::Action::ZoneGate::Enable
32
+ end
33
+ end
34
+
35
+ def forward_gz_ports
36
+ @forward_gz_ports ||= ::Vagrant::Action::Builder.new.tap do |b|
37
+ b.use Vagrant::Smartos::Zones::Action::ForwardGZPorts
38
+ end
39
+ end
40
+
41
+ def install_zone_gate
42
+ @install_zone_gate ||= ::Vagrant::Action::Builder.new.tap do |b|
43
+ b.use Vagrant::Smartos::Zones::Action::ZoneGate::Install
44
+ end
45
+ end
46
+
47
+ def virtualbox_platform_iso
48
+ @virtualbox_platform_iso ||= ::Vagrant::Action::Builder.new.tap do |b|
49
+ b.use Vagrant::Smartos::Zones::Action::VirtualBox::PlatformISO
50
+ end
51
+ end
52
+
53
+ def zone_create
54
+ @zone_create ||= ::Vagrant::Action::Builder.new.tap do |b|
55
+ b.use Vagrant::Smartos::Zones::Action::Zone::Create
56
+ b.use Vagrant::Smartos::Zones::Action::ImgadmImport
57
+ end
58
+ end
59
+
60
+ def zone_start
61
+ @zone_start ||= ::Vagrant::Action::Builder.new.tap do |b|
62
+ b.use Vagrant::Smartos::Zones::Action::Zone::Start
63
+ end
64
+ end
65
+
66
+ def zone_stop
67
+ @zone_stop ||= ::Vagrant::Action::Builder.new.tap do |b|
68
+ b.use Vagrant::Smartos::Zones::Action::Zone::Stop
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,29 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Zones
4
+ module Cap
5
+ class Base
6
+ attr_reader :machine
7
+
8
+ def self.cap_method(method_name)
9
+ self.class.send :define_method, method_name do |machine|
10
+ new(machine).execute
11
+ end
12
+ end
13
+
14
+ def initialize(machine)
15
+ @machine = machine
16
+ end
17
+
18
+ def ui
19
+ machine.ui
20
+ end
21
+
22
+ def sudo
23
+ machine.config.smartos.suexec_cmd
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end