This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uploading appliance definition files works now
- Loading branch information
Showing
3 changed files
with
79 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,76 @@ | ||
#require 'models/rest-config' | ||
# | ||
#log = ActiveRecord::Base.logger | ||
# | ||
#plugin_config_file = "#{Rails.root}/config/boxgrinder.yml" | ||
# | ||
#if File.exists?(plugin_config_file) | ||
# plugin_config = YAML.load_file(plugin_config_file) | ||
# return if plugin_config.nil? | ||
# | ||
# log.info "Preparing BoxGrinder REST server..." | ||
# | ||
# ['platform', 'delivery'].each do |type| | ||
# | ||
# log.info "Registering #{type} plugins..." | ||
# | ||
# plugin_config['plugins'][type].each do |plugins| | ||
# plugins.each do |plugin| | ||
# log.info "- #{plugin}" | ||
# BoxGrinder::RESTConfig.instance.register_plugin(plugin.to_s.downcase, type.to_sym) | ||
# end | ||
# end unless plugin_config['plugins'][type].nil? | ||
# end unless plugin_config['plugins'].nil? | ||
# | ||
# plugin_config['operating_systems'].each do |name, versions| | ||
# | ||
# log.info "Registering operating system plugin for #{name} #{versions.join(', ')}..." | ||
# | ||
# versions.each do |version| | ||
# BoxGrinder::RESTConfig.instance.register_operating_system(name.downcase, version.to_s.downcase) | ||
# end | ||
# end unless plugin_config['operating_systems'].nil? | ||
# | ||
# plugin_config['architectures'].each do |arch| | ||
# log.info "Registering #{arch} architecture..." | ||
# BoxGrinder::RESTConfig.instance.register_architecture(arch.downcase) | ||
# end unless plugin_config['architectures'].nil? | ||
# | ||
# log.info "BoxGrinder REST server prepared." | ||
#end | ||
# | ||
require 'singleton' | ||
|
||
module BoxGrinder | ||
class RESTConfig | ||
include Singleton | ||
|
||
def initialize | ||
@plugins = {} | ||
@operating_systems = {} | ||
@architectures = [] | ||
end | ||
|
||
def register_plugin(name, type) | ||
@plugins[type] = [] if @plugins[type].nil? | ||
|
||
begin | ||
@plugins[type] << name | ||
rescue | ||
raise "Not supported plugin type: #{type}" | ||
end | ||
end | ||
|
||
def register_operating_system(name, version) | ||
@operating_systems[name] = [] if @operating_systems[name].nil? | ||
|
||
@operating_systems[name] << version | ||
end | ||
|
||
def register_architecture(arch) | ||
@architectures << arch | ||
end | ||
|
||
attr_reader :plugins | ||
attr_reader :architectures | ||
attr_reader :operating_systems | ||
end | ||
end | ||
|
||
log = ActiveRecord::Base.logger | ||
|
||
plugin_config_file = "#{Rails.root}/config/boxgrinder.yml" | ||
|
||
if File.exists?(plugin_config_file) | ||
plugin_config = YAML.load_file(plugin_config_file) | ||
return if plugin_config.nil? | ||
|
||
log.info "Preparing BoxGrinder REST server..." | ||
|
||
['platform', 'delivery'].each do |type| | ||
|
||
log.info "Registering #{type} plugins..." | ||
|
||
plugin_config['plugins'][type].each do |plugins| | ||
plugins.each do |plugin| | ||
log.info "- #{plugin}" | ||
BoxGrinder::RESTConfig.instance.register_plugin(plugin.to_s.downcase, type.to_sym) | ||
end | ||
end unless plugin_config['plugins'][type].nil? | ||
end unless plugin_config['plugins'].nil? | ||
|
||
plugin_config['operating_systems'].each do |name, versions| | ||
|
||
log.info "Registering operating system plugin for #{name} #{versions.join(', ')}..." | ||
|
||
versions.each do |version| | ||
BoxGrinder::RESTConfig.instance.register_operating_system(name.downcase, version.to_s.downcase) | ||
end | ||
end unless plugin_config['operating_systems'].nil? | ||
|
||
plugin_config['architectures'].each do |arch| | ||
log.info "Registering #{arch} architecture..." | ||
BoxGrinder::RESTConfig.instance.register_architecture(arch.downcase) | ||
end unless plugin_config['architectures'].nil? | ||
|
||
log.info "BoxGrinder REST server prepared." | ||
end |