[PATCH] adding audrey deployable compatibility test

Dan Radez dradez at redhat.com
Thu Jun 7 20:15:09 UTC 2012


---
 src/app/models/deployable.rb |   39 +++++++++++++++++++++++++++++++++++++++
 src/config/locales/en.yml    |    1 +
 2 files changed, 40 insertions(+)

diff --git a/src/app/models/deployable.rb b/src/app/models/deployable.rb
index 7659688..8682d63 100644
--- a/src/app/models/deployable.rb
+++ b/src/app/models/deployable.rb
@@ -192,6 +192,8 @@ class Deployable < ActiveRecord::Base
         deployable_errors << "#{assembly_hash[:name]}: " + I18n.t('deployables.error.attribute_not_exist')
       end
       assemblies_array << assembly_hash
+      audrey_error = check_audrey_api_compatibility(image, assembly)
+      deployable_errors << "#{assembly_hash[:name]}: " + audrey_error if not audrey_error.nil?
     end
     [assemblies_array, images, missing_images, deployable_errors]
   end
@@ -245,6 +247,43 @@ class Deployable < ActiveRecord::Base
     warnings
   end
 
+  def check_audrey_api_compatibility(image, assembly)
+    # get icicle for agent
+    build ||= (image.nil? ? nil : image.latest_pushed_or_unpushed_build)
+    icicle_uuid = build.target_images.first.icicle
+    icicle = Aeolus::Image::Warehouse::Icicle.find(icicle_uuid) if icicle_uuid
+    agent_v = icicle.packages.find_all { |p| p =~ /aeolus-audrey-agent(.*)/ }
+    if not agent_v.empty?
+      agent_v = agent_v.first.split('-')[3]
+    end
+
+    # calculate audrey api version
+    audrey_api_v = if agent_v >= "0.5.0"
+                      1..2
+                    elsif agent_v >= "0.4.0"
+                      1..1
+                    else 0
+                    end
+
+    # initalize compatibility
+    audrey_api_compat = 1
+
+    # do cs_compat
+    ## All agents are compatible with all Config Servers right now
+    ## so no need to check this right now
+    ## this check should call the cs passing the agent_v and validating
+    ## the response the CS sends back
+
+    # audrey api version 2 added service references, lets check for any
+    assembly.services.each do |service|
+      service.parameters.each do |param|
+        audrey_api_compat = 2 if param.reference_service
+      end
+    end
+ 
+    I18n.t('deployables.error.audrey_api_incompatibility') if (audrey_api_v != 0 and audrey_api_v.include?(audrey_api_compat))
+  end
+
   private
 
   def self.apply_search_filter(search)
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 1a1c69e..6900522 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -1008,6 +1008,7 @@ en:
     error:
       attribute_not_exists: invalid
       hwp_not_exists: "Hardware profile %{name} specified in XML doesn't exist."
+      audrey_api_incompatibility: "The deployable uses features not supported by the audrey agent installed in the latest built image."
     properties:
       edit_deployable_xml: Edit Deployable XML
   name: Name
-- 
1.7.10.2




More information about the aeolus-devel mailing list