Class: Sle2Docker::Image
- Inherits:
-
Object
- Object
- Sle2Docker::Image
- Defined in:
- lib/sle2docker/image.rb
Overview
This class is the base class of native and prebulid images for SUSE Linux Enterprise
Direct Known Subclasses
Instance Attribute Summary collapse
-
#image_id ⇒ Object
readonly
Returns the value of attribute image_id.
Instance Method Summary collapse
- #activated? ⇒ Boolean
- #check_image_exists ⇒ Object
- #rpm_package_name ⇒ Object
- #verify_image ⇒ Object
Instance Attribute Details
#image_id ⇒ Object (readonly)
Returns the value of attribute image_id.
5 6 7 |
# File 'lib/sle2docker/image.rb', line 5 def image_id @image_id end |
Instance Method Details
#activated? ⇒ Boolean
7 8 9 |
# File 'lib/sle2docker/image.rb', line 7 def activated? Docker::Image.exist?(image_id) end |
#check_image_exists ⇒ Object
36 37 38 39 40 41 |
# File 'lib/sle2docker/image.rb', line 36 def check_image_exists msg = "Cannot find pre-built image #{@image_name}" raise(ImageNotFoundError, msg) unless File.exist? File.join( self.class::IMAGES_DIR, "#{@image_name}.tar.xz" ) end |
#rpm_package_name ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sle2docker/image.rb', line 24 def rpm_package_name image_file = File.join(self.class::IMAGES_DIR, "#{@image_name}.tar.xz") package_name = `rpm -qf #{image_file}` if $CHILD_STATUS.exitstatus.nonzero? raise( ImageVerificationError, "Cannot find rpm package providing #{file}: #{package_name}" ) end package_name end |
#verify_image ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sle2docker/image.rb', line 11 def verify_image check_image_exists puts 'Verifying integrity of the pre-built image' package_name = rpm_package_name verification = `rpm --verify #{package_name}` if $CHILD_STATUS.exitstatus.nonzero? raise(ImageVerificationError, "Verification of #{package_name} failed: #{verification}") end true end |