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)


35
36
37
38
39
# File 'lib/osctl/image/builder.rb', line 35

def initialize(base_dir, name)
  @base_dir = base_dir
  @name = name
  @ctid = "builder-#{Digest::SHA2.hexdigest(name)[0..7]}"
end

Instance Attribute Details

#archString (readonly)

Returns:

  • (String)


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

def arch
  @arch
end

#attrsHash (readonly)

Attributes returned by ‘osctl ct show`

Returns:

  • (Hash)


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

def attrs
  @attrs
end

#base_dirString (readonly)

Returns:

  • (String)


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

def base_dir
  @base_dir
end

#ctidString (readonly)

Returns:

  • (String)


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

def ctid
  @ctid
end

#distributionString (readonly)

Returns:

  • (String)


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

def distribution
  @distribution
end

#nameString (readonly)

Returns:

  • (String)


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

def name
  @name
end

#variantString (readonly)

Returns:

  • (String)


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

def variant
  @variant
end

#vendorString (readonly)

Returns:

  • (String)


24
25
26
# File 'lib/osctl/image/builder.rb', line 24

def vendor
  @vendor
end

#versionString (readonly)

Returns:

  • (String)


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

def version
  @version
end

Instance Method Details

#load_attrs(client = nil) ⇒ Object



60
61
62
# File 'lib/osctl/image/builder.rb', line 60

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

#load_configObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/osctl/image/builder.rb', line 41

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