This script allows QE to test the deployable parsing outside of the context of
Conductor. This will allow QE to test the Audrey components without requiring
Conductor to parse the deployable.
The reason this patch is in Conductor and not the Audrey repo is because all of
the DeployableXML parsing code lives in Conductor. A reasonable next step could
be to extract the DeployableXML parsing code into a separate component that
other pieces (including Conductor) can pull in as a library.
For the time being, however, in the interest of not duplicating code, this patch
goes to Conductor.
---
Greg
Show replies by date
From: Greg Blomquist <gblomqui(a)redhat.com>
This is mainly for QE's purpose, so they can test the functionality of Audrey
outside of Conductor. The reason this patch is in Conductor (instead of Audrey)
is because all of the deployable XML parsing code is in Conductor.
---
util/parse_deployable.rb | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
create mode 100755 util/parse_deployable.rb
diff --git a/util/parse_deployable.rb b/util/parse_deployable.rb
new file mode 100755
index 0000000..f559309
--- /dev/null
+++ b/util/parse_deployable.rb
@@ -0,0 +1,39 @@
+#!/usr/bin/ruby
+
+require 'rubygems'
+require '../src/app/util/deployable_xml'
+require '../src/app/util/config_server_util'
+
+USAGE="#{__FILE__} <filename>"
+
+deployable_file = ARGV[0]
+if deployable_file.nil?
+ puts "ERROR: Supply a deployable file as the only argument"
+ puts "Example: #{USAGE}"
+ exit(1)
+end
+
+xml = File.open(deployable_file) {|f| f.read}
+deployable = DeployableXML.new(xml)
+begin
+ deployable.validate!
+rescue ValidationError => e
+ puts "ERROR: Could not validate deployable XML: #{e}"
+ exit(1)
+end
+
+instance_configs = ConfigServerUtil.instance_configs(deployable, nil, nil)
+
+instance_configs.each_pair do |assembly_name, config|
+ begin
+ xml = config.to_s
+ File.open("#{config.uuid}.xml", 'w') {|f| f.write(xml)}
+ puts "Created file #{config.uuid}.xml for assembly #{assembly_name}"
+ rescue ConfigServerUtil::InstanceConfigError => e
+ if e.message.include? "No value provided for parameter."
+ puts "ERROR: #{e}"
+ else
+ raise e
+ end
+ end
+end
--
1.7.6.4