Sha256: ffa6cb195c8965b3ecd2462716d757dc3d1a305c6b9d192942d9584be3afc376
Contents?: true
Size: 961 Bytes
Versions: 11
Compression:
Stored size: 961 Bytes
Contents
require 'cloud-appliance-descriptor' require 'json-schema' # Takes care of loading appliance descriptors # # @author Michal Kimle class Nifty::Event::Loader # Loads appliance from the file # # @param [String] filename # @raise [Nifty::Errors::Event::LoaderError] when appliance descriptor is invalid # @return [Cloud::Appliance::Descriptor::Appliance] loaded appliance 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 end
Version data entries
11 entries across 11 versions & 1 rubygems