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.



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

def initialize(machine)
  @machine = machine
end

Instance Attribute Details

#machineObject (readonly)

Returns the value of attribute machine.



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

def machine
  @machine
end

Instance Method Details

#genericsObject



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

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

#imageObject



71
72
73
# File 'lib/vagrant/smartos/zones/util/zone_json.rb', line 71

def image
  zone_image.install_override? ? zone_image.override_uuid : machine.config.zone.image
end

#kernel_versionObject



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

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

#nic_info(tag, ip) ⇒ Object



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

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



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

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

#resolversObject



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

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

#to_jsonObject



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

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

#zone_infoObject



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

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