Class: VpsAdminOS::Converter::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/vpsadminos-converter/container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, user, group) ⇒ Container

Returns a new instance of Container



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vpsadminos-converter/container.rb', line 7

def initialize(id, user, group)
  @id = id
  @user = user
  @group = group
  @distribution = 'unknown'
  @arch = `uname -m`.strip
  @hostname = 'ct'
  @nesting = false
  @dns_resolvers = []
  @netifs = []
  @cgparams = CGParams.new
  @devices = Devices.new
  @autostart = AutoStart.new
end

Instance Attribute Details

#archObject

Returns the value of attribute arch



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def arch
  @arch
end

#autostartObject (readonly)

Returns the value of attribute autostart



5
6
7
# File 'lib/vpsadminos-converter/container.rb', line 5

def autostart
  @autostart
end

#cgparamsObject (readonly)

Returns the value of attribute cgparams



5
6
7
# File 'lib/vpsadminos-converter/container.rb', line 5

def cgparams
  @cgparams
end

#datasetObject

Returns the value of attribute dataset



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def dataset
  @dataset
end

#devicesObject (readonly)

Returns the value of attribute devices



5
6
7
# File 'lib/vpsadminos-converter/container.rb', line 5

def devices
  @devices
end

#distributionObject

Returns the value of attribute distribution



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def distribution
  @distribution
end

#dns_resolversObject (readonly)

Returns the value of attribute dns_resolvers



5
6
7
# File 'lib/vpsadminos-converter/container.rb', line 5

def dns_resolvers
  @dns_resolvers
end

#groupObject

Returns the value of attribute group



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def group
  @group
end

#hostnameObject

Returns the value of attribute hostname



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def hostname
  @hostname
end

#idObject

Returns the value of attribute id



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def id
  @id
end

#nestingObject

Returns the value of attribute nesting



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def nesting
  @nesting
end

#netifsObject (readonly)

Returns the value of attribute netifs



5
6
7
# File 'lib/vpsadminos-converter/container.rb', line 5

def netifs
  @netifs
end

#rootfsObject

Returns the value of attribute rootfs



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def rootfs
  @rootfs
end

#userObject

Returns the value of attribute user



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def user
  @user
end

#versionObject

Returns the value of attribute version



3
4
5
# File 'lib/vpsadminos-converter/container.rb', line 3

def version
  @version
end

Instance Method Details

#datasetsObject



22
23
24
25
26
# File 'lib/vpsadminos-converter/container.rb', line 22

def datasets
  return @datasets if @datasets

  @datasets = [dataset] + dataset.descendants
end

#dump_configObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vpsadminos-converter/container.rb', line 28

def dump_config
  {
    'user' => user.name,
    'group' => group.name,
    'distribution' => distribution,
    'version' => version,
    'arch' => arch,
    'net_interfaces' => netifs.map(&:dump),
    'cgparams' => cgparams.dump,
    'devices' => devices.dump,
    'prlimits' => [], # TODO
    'mounts' => [], # TODO
    'autostart' => autostart.dump,
    'hostname' => hostname,
    'dns_resolvers' => dns_resolvers.empty? ? nil : dns_resolvers,
    'nesting' => nesting,
  }
end