Class: Vagrant::Smartos::Zones::Util::ZoneJson

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/smartos/zones/util/zone_json.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(machine) ⇒ ZoneJson

Returns a new instance of ZoneJson.



10
11
12
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 10

def initialize(machine)
  @machine = machine
end

Instance Attribute Details

#machineObject (readonly)

Returns the value of attribute machine.



8
9
10
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 8

def machine
  @machine
end

Instance Method Details

#genericsObject



32
33
34
35
36
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 32

def generics
  {
    'fs_allowed' => 'vboxfs'
  }
end

#kernel_versionObject



38
39
40
41
42
43
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 38

def kernel_version
  return {} unless lx_brand?
  {
    'kernel_version' => machine.config.zone.kernel_version
  }
end

#nic_info(tag, ip) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 60

def nic_info(tag, ip)
  {
    'nic_tag' => tag,
    'ip' => ip,
    'netmask' => '255.255.255.0',
    'gateway' => network.gz_stub_ip,
    'allow_ip_spoofing' => true
  }
end

#nicsObject



54
55
56
57
58
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 54

def nics
  {
    'nics' => [nic_info('stub0', network.zone_ip)]
  }
end

#resolversObject



45
46
47
48
49
50
51
52
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 45

def resolvers
  {
    'resolvers' => [
      '8.8.8.8',
      '8.8.4.4'
    ]
  }
end

#to_jsonObject



14
15
16
17
18
19
20
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 14

def to_json
  zone_info
    .merge(generics)
    .merge(kernel_version)
    .merge(resolvers)
    .merge(nics).to_json
end

#zone_infoObject



22
23
24
25
26
27
28
29
30
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 22

def zone_info
  {
    'brand' => machine.config.zone.brand,
    'alias' => machine.config.zone.name,
    'dataset_uuid' => machine.config.zone.image,
    'quota' => machine.config.zone.disk_size || 1,
    'max_physical_memory' => machine.config.zone.memory || 64
  }
end