Class: OsCtl::Image::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/osctl/image/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_dir, name) ⇒ Builder

Returns a new instance of Builder.

Parameters:

  • base_dir (String)
  • name (String)


30
31
32
33
# File 'lib/osctl/image/builder.rb', line 30

def initialize(base_dir, name)
  @base_dir = base_dir
  @name = name
end

Instance Attribute Details

#archString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/osctl/image/builder.rb', line 16

def arch
  @arch
end

#attrsHash (readonly)

Attributes returned by ‘osctl ct show`

Returns:

  • (Hash)


26
27
28
# File 'lib/osctl/image/builder.rb', line 26

def attrs
  @attrs
end

#base_dirString (readonly)

Returns:

  • (String)


4
5
6
# File 'lib/osctl/image/builder.rb', line 4

def base_dir
  @base_dir
end

#distributionString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/osctl/image/builder.rb', line 10

def distribution
  @distribution
end

#nameString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/osctl/image/builder.rb', line 7

def name
  @name
end

#variantString (readonly)

Returns:

  • (String)


22
23
24
# File 'lib/osctl/image/builder.rb', line 22

def variant
  @variant
end

#vendorString (readonly)

Returns:

  • (String)


19
20
21
# File 'lib/osctl/image/builder.rb', line 19

def vendor
  @vendor
end

#versionString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/osctl/image/builder.rb', line 13

def version
  @version
end

Instance Method Details

#ctidObject



58
59
60
# File 'lib/osctl/image/builder.rb', line 58

def ctid
  "builder-#{name}"
end

#load_attrs(client = nil) ⇒ Object



54
55
56
# File 'lib/osctl/image/builder.rb', line 54

def load_attrs(client = nil)
  @attrs = (client || OsCtldClient.new).find_container(ctid)
end

#load_configObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/osctl/image/builder.rb', line 35

def load_config
  cfg = Operations::Config::ParseAttrs.run(base_dir, :builder, name)

  {
    distribution: 'DISTNAME',
    version: 'RELVER',
    arch: 'ARCH',
    vendor: 'VENDOR',
    variant: 'VARIANT'
  }.each do |attr, var|
    instance_variable_set(:"@#{attr}", cfg[var]) if cfg.has_key?(var)
  end

  @arch ||= 'x86_64'
  @vendor ||= 'vpsadminos'
  @variant ||= 'minimal'
  nil
end