From: Dan Radez <dradez(a)redhat.com>
---
src/app/models/deployment.rb | 2 +-
src/app/models/instance.rb | 6 +-
src/app/util/assembly_xml.rb | 119 ------------------------------------
src/app/util/config_server_util.rb | 27 ++------
src/app/util/config_tooling_xml.rb | 93 ----------------------------
src/app/util/deployable-rng.xml | 5 +-
src/app/util/deployable_xml.rb | 12 +++-
src/app/util/parameter_xml.rb | 117 -----------------------------------
src/app/util/service_xml.rb | 81 ------------------------
9 files changed, 25 insertions(+), 437 deletions(-)
delete mode 100644 src/app/util/assembly_xml.rb
delete mode 100644 src/app/util/config_tooling_xml.rb
delete mode 100644 src/app/util/parameter_xml.rb
delete mode 100644 src/app/util/service_xml.rb
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index affb5e0..d21345d 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -393,7 +393,7 @@ class Deployment < ActiveRecord::Base
return status
end
found = matches.first
- config_server = found.account.config_server
+ config_server = found.provider_account.config_server
instance_configs = ConfigServerUtil.instance_configs(deployable_xml, config_values,
config_server)
assembly_instances.each do |assembly_name, instance|
config = instance_configs[assembly_name]
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index 5c3e63f..d9eb5f2 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -56,7 +56,7 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
-require 'util/assembly_xml'
+require 'util/deployable_xml'
require 'util/instance_config_xml'
class Instance < ActiveRecord::Base
@@ -419,8 +419,8 @@ class Instance < ActiveRecord::Base
# TODO: Determine if there's more to check here
matches.reject! do |match|
rejected = false
- if !match.account.quota.can_start? instances
- errors << "#{match.account} quota limit too low to launch
deployable"
+ if !match.provider_account.quota.can_start? instances
+ errors << "#{match.provider_account} quota limit too low to launch
deployable"
rejected = true
end
rejected
diff --git a/src/app/util/assembly_xml.rb b/src/app/util/assembly_xml.rb
deleted file mode 100644
index a61fecb..0000000
--- a/src/app/util/assembly_xml.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-#
-# Copyright (C) 2011 Red Hat, Inc.
-# Written by Scott Seago <sseago(a)redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at
http://www.gnu.org/copyleft/gpl.html.
-
-require 'util/config_tooling_xml'
-require 'util/service_xml'
-
-class AssemblyXML
- class ValidationError < RuntimeError; end
-=begin Assembly XML Format
- <assembly name="assembly_name" hwp="hardware_profile">
- <image id="image_id"/>
- <tooling> ... (see config_tooling_xml.rb) </tooling>
- <services> ... (see service_xml.rb) </services>
- </assembly>
-=end
-
- def initialize(xmlstr = "")
- @doc = Nokogiri::XML(xmlstr)
- @root = @doc.root.at_xpath('/assembly') if @doc.root
- @image = @root.at_xpath('image') if @root
- end
-
- def to_s
- @root.to_s
- end
-
- def validate!
- # hmm...seems like all this validation should be replaced by relaxNG
- raise ValidationError, "Assembly XML root element not found" unless
@doc.root
- raise ValidationError, "<assembly> element not found" unless @root
- errors = []
- errors << "assembly name not found" unless name
- if @image
- if image_id
- errors << "image with uuid #{image_id} not found" unless
Image.find(image_id)
- if image_build
- errors << "build with uuid #{image_build} not found" unless
ImageBuild.find(image_build)
- end
- else
- errors << "image id not found"
- end
- else
- errors << "<image> element not found"
- end
- if config_tooling
- begin
- config_tooling.validate!
- rescue ConfigToolingXML::ValidationError => e
- errors << e.message
- end
- end
- unless services.empty?
- services.each do |service|
- begin
- service.validate!
- rescue ServiceXML::ValidationError => e
- errors << e.message
- end
- end
- end
- raise ValidationError, errors.join(", ") unless errors.empty?
- end
-
- def name
- @root["name"] if @root
- end
-
- def hwp
- @root["hwp"] if @root
- end
-
- def image_id
- @image["id"] if @image
- end
-
- def image_build
- @image["build"] if @image
- end
-
- def requires_config_server?
- not (config_tooling.nil? and services.empty? and output_parameters.empty?)
- end
-
- def config_tooling
- @config_tooling ||= if @root and @root.at_xpath('tooling')
- ConfigToolingXML.new((a)root.at_xpath('tooling').to_s)
- end
- end
-
- def services
- @services ||=
- @root.xpath('services/service').collect do |service_node|
- ServiceXML.new(service_node.to_s)
- end
- end
-
- def output_parameters
- @output_parameters ||=
- @root.xpath('returns/parameter').collect do |parameter_node|
- parameter_node['name']
- end
- end
-end
diff --git a/src/app/util/config_server_util.rb b/src/app/util/config_server_util.rb
index 34e17ce..b655ebc 100644
--- a/src/app/util/config_server_util.rb
+++ b/src/app/util/config_server_util.rb
@@ -116,8 +116,8 @@ module ConfigServerUtil
end
def executable
- @executable ||= if @svc.config_tooling and @svc.config_tooling.executable
- @svc.config_tooling.executable
+ @executable ||= if @svc.executable
+ @svc.executable
end
end
@@ -136,7 +136,7 @@ module ConfigServerUtil
unless files.empty?
xml " <files>\n"
files.each do |file|
- xml " <file url='#{file.url}'/>\n"
+ xml " <file url='#{file}'/>\n"
end
xml " </files>\n"
end
@@ -196,19 +196,6 @@ module ConfigServerUtil
xml "<instance-config id='#{@uuid}'
name='#{(a)assembly.name}'"
xml " password='#{password}'" if password
xml ">\n <deployable name='#{@deployable_name}'
id='#{@deployable_id}'/>\n"
- if @assembly.config_tooling
- config_tooling = @assembly.config_tooling
- if config_tooling.executable
- xml " <executable
url='#{config_tooling.executable}'/>\n"
- end
- unless config_tooling.files.empty?
- xml " <files>\n"
- config_tooling.files.map do |f|
- xml " <file url='#{f.url}'/>\n"
- end.join
- xml " </files>\n"
- end
- end
xml " <provided-parameters>\n"
provided_parameters.map do |p|
xml " <provided-parameter name='#{p}'/>\n"
@@ -222,14 +209,14 @@ module ConfigServerUtil
private
def executable
- @executable ||= if @assembly.config_tooling and
@assembly.config_tooling.executable
- @assembly.config_tooling.executable
+ @executable ||= if @assembly.executable
+ @assembly.executable
end
end
def files
- @files ||= unless @assembly.config_tooling.nil? or
@assembly.config_tooling.files.empty?
- @assembly.config_tooling.files.map {|f| f.url }
+ @files ||= unless @assembly.files.empty?
+ @assembly.files
end
end
diff --git a/src/app/util/config_tooling_xml.rb b/src/app/util/config_tooling_xml.rb
deleted file mode 100644
index 1ed8278..0000000
--- a/src/app/util/config_tooling_xml.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-# Copyright (C) 2011 Red Hat, Inc.
-# Written by Greg Blomquist <gblomqui(a)redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at
http://www.gnu.org/copyleft/gpl.html.
-
-class ConfigToolingXML
- class ValidationError < RuntimeError; end
-
- class FileXML
- def initialize(xmlstr = "")
- @doc = Nokogiri::XML(xmlstr)
- @root = @doc.root.at_xpath('/file') if @doc.root
- end
-
- def to_s
- @root.to_s
- end
-
- def validate!
- raise ValidationError, "File XML root element not found" unless
@doc.root
- raise ValidationError, "<file> element not found" unless @root
- errors = []
- errors << "file element does not have a URL" unless url
- raise ValidationError, errors.join(", ") unless errors.empty?
- end
-
- def url
- @root['url'] if @root
- end
- end
-
-=begin Config Tooling XML Format
- <config-tooling>
- <executable
url="http://example.com/config.sh"/>
- <files>
- <file
url="http://example.com/file.conf"/>
- <file
url="http://example.com/file.tar.gz"/>
- </files>
- </config-tooling>
-=end
-
- def initialize(xmlstr = "")
- @doc = Nokogiri::XML(xmlstr)
- @root = @doc.root.at_xpath('/tooling') if @doc.root
- @executable = @root.at_xpath('executable') if @root
- end
-
- def to_s
- @root.to_s
- end
-
- def validate!
- raise ValidationError, "Config Tooling XML root element not found" unless
@doc.root
- raise ValidationError, "<tooling> element not found" unless @root
- errors = []
- errors << "executable does not have a URL" if @executable and not
@executable['url']
- unless files.empty?
- files.each do |file|
- begin
- file.validate!
- rescue ValidationError => e
- errors << e.message
- end
- end
- end
- raise ValidationError, errors.join(", ") unless errors.empty?
- end
-
- def executable
- @executable['url'] if @executable
- end
-
- def files
- @files ||=
- @root.xpath('files/file').collect do |file_node|
- FileXML.new(file_node.to_s)
- end
- end
-end
diff --git a/src/app/util/deployable-rng.xml b/src/app/util/deployable-rng.xml
index 65bb176..44453f6 100644
--- a/src/app/util/deployable-rng.xml
+++ b/src/app/util/deployable-rng.xml
@@ -42,6 +42,9 @@
<!-- the image id corresponds to an image warehouse image id -->
<element name="image">
<attribute name="id"><text/></attribute>
+ <optional>
+ <attribute name="build"><text/></attribute>
+ </optional>
</element>
<optional>
<ref name="services-definition"/>
@@ -67,7 +70,7 @@
</element>
</define>
- <!-- tooling describes the executable, additional files, and runtime
+ <!-- service describes the executable, additional files, and runtime
parameters that should be propagated to the launched instance -->
<define name="service-configuration-definition">
<element name="executable">
diff --git a/src/app/util/deployable_xml.rb b/src/app/util/deployable_xml.rb
index 3153c57..19c6af9 100644
--- a/src/app/util/deployable_xml.rb
+++ b/src/app/util/deployable_xml.rb
@@ -113,8 +113,8 @@ class AssemblyXML
if xmlstr_or_node.is_a? Nokogiri::XML::Node
@root = xmlstr_or_node
else
- doc = Nokogiri::XML(xmlstr)
- @root = doc.root.at_xpath("/assembly") if doc.root
+ doc = Nokogiri::XML(xmlstr_or_node)
+ @root = doc.at_xpath("./assembly") if doc.root
end
end
@@ -135,6 +135,14 @@ class AssemblyXML
@image_id ||= image['id']
end
+ def name
+ @name ||= @root['name']
+ end
+
+ def hwp
+ @hwp ||= @root['hwp']
+ end
+
def image_build
@image_build ||= image['build']
end
diff --git a/src/app/util/parameter_xml.rb b/src/app/util/parameter_xml.rb
deleted file mode 100644
index 493a11c..0000000
--- a/src/app/util/parameter_xml.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-#
-# Copyright (C) 2011 Red Hat, Inc.
-# Written by Greg Blomquist <gblomqui(a)redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at
http://www.gnu.org/copyleft/gpl.html.
-
-class ParameterXML
- class ValidationError < RuntimeError; end
-=begin Parameter XML Format
- <parameter name="service_configuration_parameter_name"
type="scalar" default="default_value"/>
-
- <parameter name="service_configuration_parameter_name"
type="scalar">
- <reference assembly="other_assembly_name"
service="other_assembly_service_name"
- parameter="other_assembly_parameter_name"/>
- </parameter>
-
- <parameter name="service_configuration_parameter_name"
type="scalar">
- <reference assembly="other_assembly_name"
parameter="other_assembly_parameter_name"/>
- </parameter>
-=end
-
- class ParameterReferenceXML
- def initialize(xmlstr = "")
- @doc = Nokogiri::XML(xmlstr)
- @root = @doc.root.at_xpath('/reference') if @doc.root
- end
-
- def to_s
- @root.to_s
- end
-
- def validate!
- raise ValidationError, "Reference XML root element not found" unless
@doc.root
- raise ValidationError, "<reference> element not found" unless
@root
- errors = []
- errors << "reference assembly name not found" unless assembly
- errors << "reference parameter name not found" unless parameter
- raise ValidationError, errors.join(", ") unless errors.empty?
- end
-
- def assembly
- @root['assembly'] if @root
- end
-
- def service
- @root['service'] if @root
- end
-
- def parameter
- @root['parameter'] if @root
- end
- end
-
- def initialize(xmlstr = "")
- @doc = Nokogiri::XML(xmlstr)
- @root = @doc.root.at_xpath('/parameter') if @doc.root
- end
-
- def to_s
- @root.to_s
- end
-
- def validate!
- raise ValidationError, "Parameter XML root element not found" unless
@doc.root
- raise ValidationError, "<parameter> element not found" unless @root
- errors = []
- errors << "parameter name not found" unless name
- errors << "parameter type not found" unless type
- if reference
- begin
- reference.validate!
- rescue ValidationError => e
- errors << e.message
- end
- end
- raise ValidationError, errors.join(", ") unless errors.empty?
- end
-
- def name
- @root['name'] if @root
- end
-
- def type
- @root['type'] if @root
- end
-
- def default?
- not default.nil?
- end
-
- def reference?
- not reference.nil?
- end
-
- def default
- @root['default'] if @root
- end
-
- def reference
- @reference ||= if @root and @root.at_xpath('reference')
- ParameterReferenceXML.new((a)root.at_xpath('reference').to_s)
- end
- end
-end
diff --git a/src/app/util/service_xml.rb b/src/app/util/service_xml.rb
deleted file mode 100644
index 0e9adb2..0000000
--- a/src/app/util/service_xml.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-#
-# Copyright (C) 2011 Red Hat, Inc.
-# Written by Greg Blomquist <gblomqui(a)redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at
http://www.gnu.org/copyleft/gpl.html.
-
-require 'util/config_tooling_xml'
-require 'util/parameter_xml'
-
-class ServiceXML
- class ValidationError < RuntimeError; end
-=begin Service XML Format
- <service name="service_name">
- <parameters> ... (see parameter_xml.rb) </parameters>
- <tooling> ... (see config_tooling_xml.rb) </tooling>
- </service>
-=end
-
- def initialize(xmlstr = "")
- @doc = Nokogiri::XML(xmlstr)
- @root = @doc.root.at_xpath('/service') if @doc.root
- end
-
- def to_s
- @root.to_s
- end
-
- def validate!
- raise ValidationError, "Service XML root element not found" unless
@doc.root
- raise ValidationError, "<service> element not found" unless @root
- errors = []
- errors << "service name not found" unless name
- if config_tooling
- begin
- config_tooling.validate!
- rescue ConfigToolingXML::ValidationError => e
- errors << e.message
- end
- end
- unless parameters.empty?
- parameters.each do |parameter|
- begin
- parameter.validate!
- rescue ParameterXML::ValidationError => e
- errors << e.message
- end
- end
- end
- raise ValidationError, errors.join(", ") unless errors.empty?
- end
-
- def name
- @root['name'] if @root
- end
-
- def parameters
- @parameters ||=
- @root.xpath('parameters/parameter').collect do |parameter_node|
- ParameterXML.new(parameter_node.to_s)
- end
- end
-
- def config_tooling
- @config_tooling ||= if @root and @root.at_xpath('tooling')
- ConfigToolingXML.new((a)root.at_xpath('tooling').to_s)
- end
- end
-end
--
1.7.4.4