vagrant-smartos-zones 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84fc0df3970935bc53940c6a9bf1be5b825537b7
4
- data.tar.gz: ec8eaf0b1edbc52daeecbc073d591d19ddbd7575
3
+ metadata.gz: 1df692477b2ec1b9b16af72471943afc89c47e56
4
+ data.tar.gz: 896cd4b6f1731874af686af0c7e197bf593dfd27
5
5
  SHA512:
6
- metadata.gz: fc7c7632350219fade70bc11585d116149760c0a559188d4c42357ad89406805c2a5371540ae8ed5e366babdd19e821874fd4531d5ece7d71422baf090c36662
7
- data.tar.gz: 506620ca02aa02d3f35cf4af3c9fcf7c85c594d2b1e4d3c1e89842a0d6d0d1f02529c8dee03ae0dcbb62805f74a954f7979c8e83994851801f1713b1dd3e9163
6
+ metadata.gz: 6e9ff7c4b39346cd7daf63b95e14a6a1041c8f3c12235cf86f73ac560d038bd5e5e99a3b9be6b91d187691a817ef7b6220ae8cce21864690eb7f430c76645106
7
+ data.tar.gz: 3fd14dd777071cc407a25801367fd5f4ecfc35365f20a7ed0d3ad4ec621024580707b1106687e1b18bb6650f26f0bc57f3ec69072a69b730f760e84db0ccbfa5
data/README.md CHANGED
@@ -257,6 +257,23 @@ vagrant zones config key value
257
257
  vagrant zones config --delete key
258
258
  ```
259
259
 
260
+ ### Network
261
+
262
+ Networks conflict, particularly when assumptions are made about local
263
+ networks. For this reason, the network chosen by the plugin when
264
+ configuring the Global Zone and its local zone can be globally
265
+ overridden.
266
+
267
+ ```bash
268
+ vagrant zones config network 10.0.0.0/24
269
+ ```
270
+
271
+ What can go wrong? Well... basically, what can go wrong is that the
272
+ Global Zone port forwarding will break, and we won't actually be able to
273
+ create zones. It should be pretty obvious when this is the case.
274
+
275
+ * Does your network overlap with VirtualBox's local network space?
276
+
260
277
  ### Pkgsrc mirror
261
278
 
262
279
  ```bash
@@ -295,11 +312,5 @@ references have fallen by the wayside.
295
312
 
296
313
  ## Contributing
297
314
 
298
- 1. Fork it ( https://github.com/vagrant-smartos/vagrant-smartos-zones/fork )
299
- 2. Create your feature branch (`git checkout -b my-new-feature`)
300
- 3. Commit your changes (`git commit -am 'Add some feature'`)
301
- 4. Push to the branch (`git push origin my-new-feature`)
302
- 5. Create new Pull Request
303
-
304
- When creating a new Pull Request, `/cc @sax` in the notes to make sure
305
- I get an email about it.
315
+ See the [Contributing](https://github.com/vagrant-smartos/vagrant-smartos-zones/wiki/Contributing)
316
+ page for guidelines/recommendations on contributions.
@@ -8,6 +8,8 @@ Vagrant.configure('2') do |config|
8
8
  config.vm.synced_folder '.', '/vagrant', disabled: true
9
9
  config.vm.communicator = 'smartos'
10
10
 
11
+ config.ssh.insert_key = false
12
+
11
13
  config.global_zone.platform_image = 'latest'
12
14
 
13
15
  config.zone.name = 'base64'
@@ -11,6 +11,8 @@ Vagrant.configure('2') do |config|
11
11
  config.vm.synced_folder '.', '/vagrant', disabled: true
12
12
  config.vm.communicator = 'smartos'
13
13
 
14
+ config.ssh.insert_key = false
15
+
14
16
  config.global_zone.platform_image = 'latest'
15
17
 
16
18
  config.zone.name = 'base64'
@@ -11,6 +11,8 @@ Vagrant.configure('2') do |config|
11
11
  config.vm.synced_folder '.', '/vagrant', disabled: true
12
12
  config.vm.communicator = 'smartos'
13
13
 
14
+ config.ssh.insert_key = false
15
+
14
16
  config.global_zone.platform_image = 'hourly-20141121'
15
17
  config.global_zone.platform_image_url = 'https://us-east.manta.joyent.com/nahamu/public/smartos/platform-hourly.iso'
16
18
 
@@ -13,6 +13,8 @@ Vagrant.configure('2') do |config|
13
13
 
14
14
  config.vm.synced_folder ".", "/vagrant", type: "rsync"
15
15
 
16
+ config.ssh.insert_key = false
17
+
16
18
  config.global_zone.platform_image = 'latest'
17
19
 
18
20
  config.zone.name = 'base64'
@@ -3,13 +3,13 @@
3
3
  dladm create-etherstub stub0
4
4
  dladm create-vnic -l stub0 vnic0
5
5
  ipadm create-if vnic0
6
- ipadm create-addr -T static -a 10.0.0.1/24 vnic0/static
6
+ ipadm create-addr -T static -a <gz_addr> vnic0/static
7
7
 
8
- echo 'map e1000g0 10.0.0.0/24 -> 0.0.0.0/32' | ipnat -f -
8
+ echo 'map e1000g0 <zone_network> -> 0.0.0.0/32' | ipnat -f -
9
9
 
10
10
  # When we SSH into port 2222, ensure that that goes to 22 in the GZ
11
11
  # and is never forwarded to the zone.
12
- echo 'rdr e1000g0 0.0.0.0/0 port 2222 -> 10.0.0.1 port 22' | ipnat -f -
12
+ echo 'rdr e1000g0 0.0.0.0/0 port 2222 -> <gz_ip> port 22' | ipnat -f -
13
13
 
14
14
  routeadm -u -e ipv4-forwarding
15
15
  routeadm -u -e ipv4-routing
@@ -1,4 +1,5 @@
1
1
  require 'vagrant/smartos/zones/cap/base'
2
+ require 'vagrant/smartos/zones/models/network'
2
3
 
3
4
  module Vagrant
4
5
  module Smartos
@@ -13,10 +14,13 @@ module Vagrant
13
14
  ui.info 'Installing vnic in global zone'
14
15
  sudo = machine.config.smartos.suexec_cmd
15
16
 
16
- machine.communicate.upload(create_vnic_script, '%s/create_gz_vnic' % vm_tmp_folder)
17
+ machine.communicate.upload(create_vnic_script, tmp_script)
18
+ machine.communicate.execute('sed -i -e \'s@<gz_addr>@%s@\' %s' % [network.gz_addr, tmp_script])
19
+ machine.communicate.execute('sed -i -e \'s@<zone_network>@%s@\' %s' % [network.zone_network, tmp_script])
20
+ machine.communicate.execute('sed -i -e \'s@<gz_ip>@%s@\' %s' % [network.gz_stub_ip, tmp_script])
17
21
  machine.communicate.upload(vnic_smf_manifest, '%s/create-gz-vnic.xml' % vm_tmp_folder)
18
22
 
19
- machine.communicate.execute("#{sudo} mv %s/create_gz_vnic /opt/custom/method" % vm_tmp_folder)
23
+ machine.communicate.execute("#{sudo} mv %s /opt/custom/method" % tmp_script)
20
24
  machine.communicate.execute("#{sudo} mv %s/create-gz-vnic.xml /opt/custom/smf" % vm_tmp_folder)
21
25
 
22
26
  machine.communicate.execute("#{sudo} svccfg import /opt/custom/smf/create-gz-vnic.xml")
@@ -31,6 +35,14 @@ module Vagrant
31
35
  File.join(local_files_folder, 'gz_vnic', 'create_gz_vnic')
32
36
  end
33
37
 
38
+ def network
39
+ @network ||= Models::Network.new(machine.env)
40
+ end
41
+
42
+ def tmp_script
43
+ '%s/create_gz_vnic' % vm_tmp_folder
44
+ end
45
+
34
46
  def vnic_smf_manifest
35
47
  File.join(local_files_folder, 'smf', 'create-gz-vnic.xml')
36
48
  end
@@ -0,0 +1,48 @@
1
+ require 'netaddr'
2
+ require 'vagrant/smartos/zones/models/config'
3
+
4
+ module Vagrant
5
+ module Smartos
6
+ module Zones
7
+ module Models
8
+ class Network
9
+ attr_reader :env
10
+
11
+ def initialize(env)
12
+ @env = env
13
+ end
14
+
15
+ def network
16
+ plugin_config.hash['network'] || '172.16.0.0/24'
17
+ end
18
+
19
+ def zone_network
20
+ [cidr.network, cidr.bits].join('/')
21
+ end
22
+
23
+ def gz_addr
24
+ [gz_stub_ip, cidr.bits].join('/')
25
+ end
26
+
27
+ def gz_stub_ip
28
+ cidr[1].ip
29
+ end
30
+
31
+ def zone_ip
32
+ cidr[2].ip
33
+ end
34
+
35
+ private
36
+
37
+ def cidr
38
+ @cidr ||= NetAddr::CIDR.create(network)
39
+ end
40
+
41
+ def plugin_config
42
+ @config ||= Models::Config.config(env)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,3 +1,5 @@
1
+ require 'vagrant/smartos/zones/models/network'
2
+
1
3
  module Vagrant
2
4
  module Smartos
3
5
  module Zones
@@ -51,7 +53,7 @@ module Vagrant
51
53
 
52
54
  def nics
53
55
  {
54
- 'nics' => [nic_info('stub0', '10.0.0.2')]
56
+ 'nics' => [nic_info('stub0', network.zone_ip)]
55
57
  }
56
58
  end
57
59
 
@@ -60,7 +62,7 @@ module Vagrant
60
62
  'nic_tag' => tag,
61
63
  'ip' => ip,
62
64
  'netmask' => '255.255.255.0',
63
- 'gateway' => '10.0.0.1',
65
+ 'gateway' => network.gz_stub_ip,
64
66
  'allow_ip_spoofing' => true
65
67
  }
66
68
  end
@@ -70,6 +72,10 @@ module Vagrant
70
72
  def lx_brand?
71
73
  machine.config.zone.brand == 'lx'
72
74
  end
75
+
76
+ def network
77
+ @network ||= Models::Network.new(machine.env)
78
+ end
73
79
  end
74
80
  end
75
81
  end
@@ -1,7 +1,7 @@
1
1
  module Vagrant
2
2
  module Smartos
3
3
  module Zones
4
- VERSION = '0.0.3'
4
+ VERSION = '0.1.0'
5
5
  end
6
6
  end
7
7
  end
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.add_dependency 'netaddr'
22
+
21
23
  spec.add_development_dependency 'bundler', '~> 1.5'
22
24
  spec.add_development_dependency 'pry-nav'
23
25
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-smartos-zones
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Saxby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-12 00:00:00.000000000 Z
11
+ date: 2015-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: netaddr
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +131,7 @@ files:
117
131
  - lib/vagrant/smartos/zones/hooks.rb
118
132
  - lib/vagrant/smartos/zones/models/config.rb
119
133
  - lib/vagrant/smartos/zones/models/dataset.rb
134
+ - lib/vagrant/smartos/zones/models/network.rb
120
135
  - lib/vagrant/smartos/zones/models/snapshot.rb
121
136
  - lib/vagrant/smartos/zones/models/zone.rb
122
137
  - lib/vagrant/smartos/zones/models/zone_group.rb
@@ -172,3 +187,4 @@ test_files:
172
187
  - test/integration/default/serverspec/user_spec.rb
173
188
  - test/templates/Vagrantfile.smartos.erb
174
189
  - test/templates/bootstrap.sh
190
+ has_rdoc: