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
-
#datasets ⇒ Hash<String, String>
readonly
Dataset name => mountpoint.
- #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.
32 33 34 35 36 |
# File 'lib/osctl/image/image.rb', line 32 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 |
#datasets ⇒ Hash<String, String> (readonly)
Returns dataset name => mountpoint.
28 29 30 |
# File 'lib/osctl/image/image.rb', line 28 def datasets @datasets 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
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/osctl/image/image.rb', line 38 def load_config cfg = Operations::Config::ParseAttrs.run(base_dir, :image, name) unless cfg.has_key?('BUILDER') raise "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 @datasets = if cfg.has_key?('DATASETS') cfg['DATASETS'].split(':').to_h { |v| v.split('=') } else {} end end |
#parse_name ⇒ Object (protected)
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/osctl/image/image.rb', line 70 def parse_name if name.index('-') @distribution, @version, @arch, @vendor, @variant = name.split('-') else @distribution = name end @arch ||= 'x86_64' @vendor ||= 'vpsadminos' @variant ||= 'minimal' nil end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/osctl/image/image.rb', line 64 def to_s name end |