vagrant-smartos-zones 0.0.1.pre.21

Sign up to get free protection for your applications and to get access to all the features.
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,45 @@
1
+ require 'vagrant/smartos/zones/cap/base'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Cap
7
+ class CreateGZVnic < Base
8
+ cap_method :create_gz_vnic
9
+
10
+ def execute
11
+ return unless machine.communicate.test('test -d %s' % vm_tmp_folder)
12
+
13
+ ui.info 'Installing vnic in global zone'
14
+ sudo = machine.config.smartos.suexec_cmd
15
+
16
+ machine.communicate.upload(create_vnic_script, '%s/create_gz_vnic' % vm_tmp_folder)
17
+ machine.communicate.upload(vnic_smf_manifest, '%s/create-gz-vnic.xml' % vm_tmp_folder)
18
+
19
+ machine.communicate.execute("#{sudo} mv %s/create_gz_vnic /opt/custom/method" % vm_tmp_folder)
20
+ machine.communicate.execute("#{sudo} mv %s/create-gz-vnic.xml /opt/custom/smf" % vm_tmp_folder)
21
+
22
+ machine.communicate.execute("#{sudo} svccfg import /opt/custom/smf/create-gz-vnic.xml")
23
+ machine.communicate.execute("#{sudo} svcadm enable -s create-gz-vnic")
24
+ end
25
+
26
+ def local_files_folder
27
+ File.expand_path('../../../../../../files', __FILE__)
28
+ end
29
+
30
+ def create_vnic_script
31
+ File.join(local_files_folder, 'gz_vnic', 'create_gz_vnic')
32
+ end
33
+
34
+ def vnic_smf_manifest
35
+ File.join(local_files_folder, 'smf', 'create-gz-vnic.xml')
36
+ end
37
+
38
+ def vm_tmp_folder
39
+ '/usbkey/vagrant'
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,30 @@
1
+ require 'vagrant/smartos/zones/cap/base'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Cap
7
+ class ImgadmImport < Base
8
+ cap_method :imgadm_import
9
+
10
+ def execute
11
+ return ui.info 'No zone image set, skipping import' unless image
12
+
13
+ installed = machine.communicate.gz_test("#{sudo} imgadm get #{image}")
14
+
15
+ ui.info "Checking for zone image #{image}: #{installed ? 'installed' : 'not installed'}"
16
+ return if installed
17
+
18
+ ui.info ' Importing...'
19
+ machine.communicate.gz_execute("#{sudo} imgadm sources -a https://updates.joyent.com")
20
+ machine.communicate.gz_execute("#{sudo} imgadm import #{image}")
21
+ end
22
+
23
+ def image
24
+ machine.config.zone.image
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,17 @@
1
+ require 'vagrant/smartos/zones/util/platform_images'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Cap
7
+ module PlatformImage
8
+ class Install
9
+ def self.platform_image_install(env, image)
10
+ Zones::Util::PlatformImages.new(env).install(image)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ require 'vagrant/smartos/zones/util/platform_images'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Cap
7
+ module PlatformImage
8
+ class Latest
9
+ def self.platform_image_latest(env)
10
+ platform_image = Zones::Util::PlatformImages.new(env).latest
11
+ env.ui.info 'Unable to find platform image' unless platform_image
12
+ env.ui.info platform_image
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ require 'vagrant/smartos/zones/util/platform_images'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Cap
7
+ module PlatformImage
8
+ class List
9
+ def self.platform_image_list(env)
10
+ Zones::Util::PlatformImages.new(env).list
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ require 'vagrant/smartos/zones/cap/base'
2
+ require 'vagrant/smartos/zones/models/zone'
3
+ require 'vagrant/smartos/zones/util/zone_info'
4
+
5
+ module Vagrant
6
+ module Smartos
7
+ module Zones
8
+ module Cap
9
+ module Zone
10
+ class Base < Vagrant::Smartos::Zones::Cap::Base
11
+ def zone_exists?
12
+ name = machine.config.zone.name
13
+ machine.communicate.gz_test("#{sudo} vmadm list -H | awk '{print $5}' | grep #{name}")
14
+ end
15
+
16
+ def zone_valid?
17
+ machine.config.zone && machine.config.zone.image && machine.config.zone.name
18
+ end
19
+
20
+ def zone_info
21
+ @zone_info ||= Util::ZoneInfo.new(machine)
22
+ end
23
+
24
+ def zone
25
+ @zone ||= Models::Zone.find(machine, machine.config.zone.name)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ require 'vagrant/smartos/zones/cap/zone/base'
2
+ require 'vagrant/smartos/zones/util/zone_json'
3
+
4
+ module Vagrant
5
+ module Smartos
6
+ module Zones
7
+ module Cap
8
+ module Zone
9
+ class Create < Base
10
+ cap_method :zone__create
11
+
12
+ def execute
13
+ return warn_zone_config unless zone_valid?
14
+ return update_zone if zone_exists?
15
+ create_zone
16
+ end
17
+
18
+ def create_zone
19
+ zone_info.create(machine.config.zone.name)
20
+ end
21
+
22
+ def update_zone
23
+ ui.info "Zone #{machine.config.zone.name} exists"
24
+ zone_info.update(machine.config.zone.name)
25
+ end
26
+
27
+ def warn_zone_config
28
+ ui.info 'No zone configured, skipping'
29
+ ui.info ' add the following to your Vagrantfile to configure a local zone:'
30
+ ui.info " config.zone.name = 'my-zone'"
31
+ ui.info " config.zone.image = 'uuid'"
32
+ ui.info " config.zone.brand = 'joyent'"
33
+ ui.info ' config.zone.memory = 2048'
34
+ ui.info ' config.zone.disk_size = 5'
35
+ end
36
+
37
+ def zone_json
38
+ Util::ZoneJson.new(machine).to_json
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,29 @@
1
+ require 'vagrant/smartos/zones/cap/zone/base'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Cap
7
+ module Zone
8
+ class Start < Base
9
+ cap_method :zone__start
10
+
11
+ def execute
12
+ return unless zone_valid?
13
+ return unless zone_exists?
14
+
15
+ start_zone
16
+ end
17
+
18
+ def start_zone
19
+ return if zone.running?
20
+ name = machine.config.zone.name
21
+ ui.info "Starting zone #{name}"
22
+ zone.start
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'vagrant/smartos/zones/cap/zone/base'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Cap
7
+ module Zone
8
+ class Stop < Base
9
+ cap_method :zone__stop
10
+
11
+ def execute
12
+ return unless zone_valid?
13
+ return unless zone_exists?
14
+
15
+ stop_zone
16
+ end
17
+
18
+ def stop_zone
19
+ return unless zone.running?
20
+ name = machine.config.zone.name
21
+ ui.info "Stopping zone #{name}"
22
+ zone.stop
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ require 'vagrant/smartos/zones/cap/base'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Cap
7
+ module ZoneGate
8
+ class Enable < Cap::Base
9
+ cap_method :zone_gate_enable
10
+
11
+ def execute
12
+ ui.info 'Enabling ZoneGate'
13
+ machine.communicate.gz_execute("#{sudo} svcadm enable -s zonegate")
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,46 @@
1
+ require 'vagrant/smartos/zones/cap/base'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ module Zones
6
+ module Cap
7
+ module ZoneGate
8
+ class Install < Cap::Base
9
+ cap_method :zone_gate_install
10
+
11
+ LOCAL_FILES_FOLDER = File.expand_path('../../../../../../../files', __FILE__)
12
+ LOCAL_ZONEGATE_FOLDER = File.join(LOCAL_FILES_FOLDER, 'zonegate')
13
+ LOCAL_SMF_MANIFEST = File.join(LOCAL_FILES_FOLDER, 'smf', 'zonegate.xml')
14
+ SMF_TMP_FOLDER = '/usbkey/vagrant'
15
+ SMF_FOLDER = '/opt/custom/smf'
16
+ ZONEGATE_FOLDER = '/opt/custom/method'
17
+
18
+ def execute
19
+ ui.info 'Installing ZoneGate'
20
+
21
+ create_zonegate_folder
22
+ upload_zonegate
23
+ install_zonegate
24
+ end
25
+
26
+ def create_zonegate_folder
27
+ machine.communicate.execute("#{sudo} mkdir -p %s/zonegate" % ZONEGATE_FOLDER)
28
+ machine.communicate.execute("#{sudo} chown vagrant:other %s/zonegate" % ZONEGATE_FOLDER)
29
+ end
30
+
31
+ def upload_zonegate
32
+ machine.communicate.upload(LOCAL_ZONEGATE_FOLDER, ZONEGATE_FOLDER)
33
+ machine.communicate.upload(LOCAL_SMF_MANIFEST, '%s/zonegate.xml' % SMF_TMP_FOLDER)
34
+ end
35
+
36
+ def install_zonegate
37
+ machine.communicate.execute("#{sudo} mv %s/zonegate.xml %s/zonegate.xml" % [SMF_TMP_FOLDER, SMF_FOLDER])
38
+ machine.communicate.execute("#{sudo} chown root:root %s/zonegate.xml" % SMF_FOLDER)
39
+ machine.communicate.execute("#{sudo} svccfg import %s/zonegate.xml" % SMF_FOLDER)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,91 @@
1
+ require 'vagrant'
2
+ require_relative 'multi_command'
3
+ require 'vagrant/smartos/zones/errors'
4
+ require 'vagrant/smartos/zones/models/dataset'
5
+ require 'vagrant/smartos/zones/models/zone'
6
+
7
+ module Vagrant
8
+ module Smartos
9
+ module Zones
10
+ module Command
11
+ class Dataset < Vagrant.plugin('2', :command)
12
+ include MultiCommand
13
+
14
+ attr_accessor :host, :ui
15
+
16
+ COMMANDS = %w(list create delete install).freeze
17
+
18
+ OPTION_PARSER = OptionParser.new do |o|
19
+ o.banner = 'Usage: vagrant dataset [subcommand] [options]'
20
+ o.separator ''
21
+ o.separator 'Commands:'
22
+ o.separator ' create [zone] [name] create a local dataset [name] from running zone [zone]'
23
+ o.separator ' delete [name] delete a local dataset [name]'
24
+ o.separator ' list show all locally installed datasets'
25
+ o.separator ' install [url] download a dataset to the local machine'
26
+ o.separator ''
27
+ o.separator 'Options:'
28
+ o.separator ''
29
+ end
30
+
31
+ def self.synopsis
32
+ 'Manage local SmartOS datasets'
33
+ end
34
+
35
+ def execute
36
+ process_subcommand
37
+ end
38
+
39
+ private
40
+
41
+ def host
42
+ @env.host
43
+ end
44
+
45
+ def create(zonename, dataset)
46
+ with_zone(zonename) do |zone|
47
+ Models::Dataset.create(dataset, zone)
48
+ end
49
+ end
50
+
51
+ def delete(dataset_name)
52
+ return ui.warn('Unable to delete datasets') unless host.capability?(:dataset_delete)
53
+ host.capability(:dataset_delete, dataset_name)
54
+ end
55
+
56
+ def list(*_args)
57
+ return ui.warn('Unable to list datasets') unless host.capability?(:dataset_list)
58
+ host.capability(:dataset_list)
59
+ end
60
+
61
+ def install(url)
62
+ if url.nil?
63
+ ui.warn 'No url given'
64
+ ui.warn ''
65
+ ui.warn OPTION_PARSER.to_s
66
+ exit 1
67
+ end
68
+
69
+ return ui.warn('Unable to install dataset') unless host.capability?(:dataset_install)
70
+ host.capability(:dataset_install, url)
71
+ end
72
+
73
+ def ui
74
+ @env.ui
75
+ end
76
+
77
+ def with_zone(name)
78
+ with_target_vms('default', single_target: true) do |machine|
79
+ Models::Zone.find(machine, name).tap do |zone|
80
+ yield zone
81
+ end
82
+ end
83
+ rescue ZoneNotFound
84
+ ui.warn(I18n.t('vagrant.smartos.zones.warning.zone_not_found',
85
+ name: name), prefix: false)
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,43 @@
1
+ require 'vagrant'
2
+ require 'vagrant/smartos/zones/util/global_zone/ssh_info'
3
+ require 'vagrant/util/ssh'
4
+ require_relative 'multi_command'
5
+
6
+ module Vagrant
7
+ module Smartos
8
+ module Zones
9
+ module Command
10
+ class GlobalZone < Vagrant.plugin('2', :command)
11
+ include MultiCommand
12
+
13
+ COMMANDS = %w(ssh)
14
+
15
+ OPTION_PARSER = OptionParser.new do |o|
16
+ o.banner = 'Usage: vagrant global-zone [command]'
17
+ o.separator ''
18
+ o.separator 'Commands:'
19
+ o.separator ' ssh ssh into the global zone'
20
+ o.separator ''
21
+ o.separator 'Options:'
22
+ o.separator ''
23
+ end
24
+
25
+ def self.synopsis
26
+ 'View and interact with the SmartOS global zone'
27
+ end
28
+
29
+ def execute
30
+ process_subcommand
31
+ end
32
+
33
+ def ssh(*_args)
34
+ with_target_vms('default', single_target: true) do |machine|
35
+ ssh_info = Util::GlobalZone::SSHInfo.new(machine.provider, machine.config, machine.env).to_hash
36
+ Vagrant::Util::SSH.exec(ssh_info)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,46 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Zones
4
+ module Command
5
+ # Requires
6
+ #
7
+ # Define a COMMANDS constant, which is an array of method names:
8
+ #
9
+ # COMMANDS = %w(subcommand other_subcommand)
10
+ #
11
+ # Define an OPTION_PARSER constant, which is an instance of an
12
+ # OptionParser
13
+ #
14
+ module MultiCommand
15
+ def process_subcommand
16
+ args = parse_options(option_parser)
17
+ exit unless args
18
+
19
+ command = args.shift
20
+ command_method = subcommands.find { |c| c == command }
21
+
22
+ unless command_method
23
+ ui.warn option_parser.to_s, prefix: false
24
+ exit 1
25
+ end
26
+
27
+ send command, *args
28
+ end
29
+
30
+ def fail_options!
31
+ ui.warn option_parser.to_s, prefix: false
32
+ exit 1
33
+ end
34
+
35
+ def option_parser
36
+ self.class.const_get('OPTION_PARSER')
37
+ end
38
+
39
+ def subcommands
40
+ self.class.const_get('COMMANDS')
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,70 @@
1
+ require 'vagrant'
2
+ require_relative 'multi_command'
3
+
4
+ module Vagrant
5
+ module Smartos
6
+ module Zones
7
+ module Command
8
+ class Smartos < Vagrant.plugin('2', :command)
9
+ include MultiCommand
10
+
11
+ attr_accessor :host, :ui
12
+
13
+ COMMANDS = %w(latest list install).freeze
14
+
15
+ OPTION_PARSER = OptionParser.new do |o|
16
+ o.banner = 'Usage: vagrant smartos [name]'
17
+ o.separator ''
18
+ o.separator 'Commands:'
19
+ o.separator ' latest show the latest remote SmartOS platform image'
20
+ o.separator ' list show installed SmartOS platform images'
21
+ o.separator ' install [image] install SmartOS platform image'
22
+ o.separator ''
23
+ o.separator 'Options:'
24
+ o.separator ''
25
+ end
26
+
27
+ def self.synopsis
28
+ 'Manage SmartOS platform images'
29
+ end
30
+
31
+ def execute
32
+ process_subcommand
33
+ end
34
+
35
+ private
36
+
37
+ def host
38
+ @env.host
39
+ end
40
+
41
+ def install(image)
42
+ if image.nil?
43
+ ui.warn 'No image given'
44
+ ui.warn ''
45
+ ui.warn OPTION_PARSER.to_s
46
+ exit 1
47
+ end
48
+
49
+ return ui.warn('Unable to install platform image') unless host.capability?(:platform_image_install)
50
+ host.capability(:platform_image_install, image)
51
+ end
52
+
53
+ def latest(*_args)
54
+ return ui.warn('Unable to show latest platform image') unless host.capability?(:platform_image_latest)
55
+ host.capability(:platform_image_latest)
56
+ end
57
+
58
+ def list(*_args)
59
+ return ui.warn('Unable to list platform image') unless host.capability?(:platform_image_list)
60
+ host.capability(:platform_image_list)
61
+ end
62
+
63
+ def ui
64
+ @env.ui
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,35 @@
1
+ require 'vagrant'
2
+ require 'vagrant/smartos/zones/util/global_zone/ssh_info'
3
+ require 'vagrant/smartos/zones/models/zone'
4
+ require 'vagrant/util/ssh'
5
+
6
+ module Vagrant
7
+ module Smartos
8
+ module Zones
9
+ module Command
10
+ class Zlogin < Vagrant.plugin('2', :command)
11
+ OPTION_PARSER = OptionParser.new do |o|
12
+ o.banner = 'Usage: vagrant zlogin [name]'
13
+ end
14
+
15
+ def self.synopsis
16
+ 'Log into a SmartOS local zone'
17
+ end
18
+
19
+ def execute
20
+ argv = parse_options(OPTION_PARSER)
21
+ return unless argv
22
+
23
+ zone_alias = argv.shift
24
+
25
+ with_target_vms('default', single_target: true) do |machine|
26
+ ssh_info = Util::GlobalZone::SSHInfo.new(machine.provider, machine.config, machine.env).to_hash
27
+ zone = Models::Zone.find(machine, zone_alias)
28
+ Vagrant::Util::SSH.exec(ssh_info, extra_args: ['-t', "pfexec zlogin -l vagrant #{zone.uuid}"])
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end