Class: OsCtl::Image::Image
- Inherits:
-
Object
- Object
- OsCtl::Image::Image
- Defined in:
- lib/osctl/image/image.rb
Instance Attribute Summary collapse
- #arch ⇒ String readonly
- #base_dir ⇒ String readonly
- #builder ⇒ String readonly
- #distribution ⇒ String readonly
- #name ⇒ String readonly
- #variant ⇒ String readonly
- #vendor ⇒ String readonly
- #version ⇒ String readonly
Instance Method Summary collapse
-
#initialize(base_dir, name) ⇒ Image
constructor
A new instance of Image.
- #load_config ⇒ Object
- #parse_name ⇒ Object protected
- #to_s ⇒ Object
Constructor Details
#initialize(base_dir, name) ⇒ Image
Returns a new instance of Image.
29 30 31 32 33 |
# File 'lib/osctl/image/image.rb', line 29 def initialize(base_dir, name) @base_dir = base_dir @name = name parse_name end |
Instance Attribute Details
#arch ⇒ String (readonly)
19 20 21 |
# File 'lib/osctl/image/image.rb', line 19 def arch @arch end |
#base_dir ⇒ String (readonly)
4 5 6 |
# File 'lib/osctl/image/image.rb', line 4 def base_dir @base_dir end |
#builder ⇒ String (readonly)
10 11 12 |
# File 'lib/osctl/image/image.rb', line 10 def builder @builder end |
#distribution ⇒ String (readonly)
13 14 15 |
# File 'lib/osctl/image/image.rb', line 13 def distribution @distribution end |
#name ⇒ String (readonly)
7 8 9 |
# File 'lib/osctl/image/image.rb', line 7 def name @name end |
#variant ⇒ String (readonly)
25 26 27 |
# File 'lib/osctl/image/image.rb', line 25 def variant @variant end |
#vendor ⇒ String (readonly)
22 23 24 |
# File 'lib/osctl/image/image.rb', line 22 def vendor @vendor end |
#version ⇒ String (readonly)
16 17 18 |
# File 'lib/osctl/image/image.rb', line 16 def version @version end |
Instance Method Details
#load_config ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/osctl/image/image.rb', line 35 def load_config cfg = Operations::Config::ParseAttrs.run(base_dir, :image, name) unless cfg.has_key?('BUILDER') fail "builder not set for #{name}" end { builder: 'BUILDER', 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 end |
#parse_name ⇒ Object (protected)
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/osctl/image/image.rb', line 59 def parse_name if name.index('-') @distribution, @version, @arch, @vendor, @variant = name.split('-') else @distribution = name end @arch ||= 'x86_64' @vendor ||= 'vpsadminos' @variant ||= 'minimal' end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/osctl/image/image.rb', line 54 def to_s name end |