Class: Nifty::Event::Loader
- Inherits:
-
Object
- Object
- Nifty::Event::Loader
- Defined in:
- lib/nifty/event/loader.rb
Overview
Takes care of loading appliance descriptors
Class Method Summary collapse
-
.load_appliance(filename) ⇒ Cloud::Appliance::Descriptor::Appliance
Loads appliance from the file.
Class Method Details
.load_appliance(filename) ⇒ Cloud::Appliance::Descriptor::Appliance
Loads appliance from the file
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nifty/event/loader.rb', line 13 def self.load_appliance(filename) logger.debug "Loading appliance from file #{filename.inspect}..." fail Nifty::Errors::Event::LoaderError, "Descriptor file #{filename.inspect} is not readable" unless File.readable?(filename) JSON::Validator.validate!(Nifty::APPLIANCE_SCHEMA, filename) file = File.read(filename) appliance = Cloud::Appliance::Descriptor::Appliance.from_json(file) logger.debug "Loaded appliance: #{appliance.inspect}" appliance rescue JSON::Schema::ValidationError => ex fail Nifty::Errors::Event::LoaderError, ex end |