On 01/11/2012 05:27 PM, gblomqui(a)redhat.com wrote:
> From: Greg Blomquist<gblomqui(a)redhat.com>
>
> Adds a version to the deployable XML schema.
> ---
> src/app/models/deployable.rb | 2 +-
> src/app/util/deployable-rng.xml | 8 +++
> src/app/util/deployable_xml.rb | 5 ++
> src/features/upload_files/deployable.xml | 4 +-
> src/spec/factories/deployable.rb | 4 +-
> src/spec/vcr/cassettes/deployable_xml.yml | 99 +++++++----------------------
> 6 files changed, 41 insertions(+), 81 deletions(-)
>
> diff --git a/src/app/models/deployable.rb b/src/app/models/deployable.rb
> index 5720617..0ec5f93 100644
> --- a/src/app/models/deployable.rb
> +++ b/src/app/models/deployable.rb
> @@ -99,7 +99,7 @@ class Deployable< ActiveRecord::Base
> def set_from_image(image_id, name, hw_profile)
> image = Aeolus::Image::Warehouse::Image.find(image_id)
> doc = Nokogiri::XML ''
> - doc.root = doc.create_element('deployable', :name => name)
> + doc.root = doc.create_element('deployable', :version =>
DeployableXML.version, :name => name)
> description = doc.create_element('description')
> doc.root<< description
> assemblies = doc.create_element('assemblies')
> diff --git a/src/app/util/deployable-rng.xml b/src/app/util/deployable-rng.xml
> index 651271b..88884e8 100644
> --- a/src/app/util/deployable-rng.xml
> +++ b/src/app/util/deployable-rng.xml
> @@ -24,6 +24,14 @@
>
> <start>
> <element name="deployable">
> +<optional>
> +<!-- make the version attribute optional for backwards compat -->
> +<attribute name="version">
> +<choice>
> +<value>1.0</value>
> +</choice>
> +</attribute>
> +</optional>
> <attribute name="name"><text/></attribute>
> <optional>
> <attribute name="id"><text/></attribute>
> diff --git a/src/app/util/deployable_xml.rb b/src/app/util/deployable_xml.rb
> index 995cfff..9ece7b5 100644
> --- a/src/app/util/deployable_xml.rb
> +++ b/src/app/util/deployable_xml.rb
> @@ -169,6 +169,11 @@ end
>
> class DeployableXML
>
> + DEPLOYABLE_VERSION = "1.0"
> + def self.version
> + DEPLOYABLE_VERSION
> + end
> +
> def initialize(xmlstr_or_node = "")
> if xmlstr_or_node.is_a? Nokogiri::XML::Node
> @root = xmlstr_or_node
> diff --git a/src/features/upload_files/deployable.xml
b/src/features/upload_files/deployable.xml
> index c8f67e1..0b73ef7 100644
> --- a/src/features/upload_files/deployable.xml
> +++ b/src/features/upload_files/deployable.xml
> @@ -1,5 +1,5 @@
> <?xml version="1.0"?>
> -<deployable name="my">
> +<deployable version="1.0" name="my">
> <description>This is my testing image</description>
> <assemblies>
> <assembly name="frontend" hwp="hwp1">
> @@ -39,4 +39,4 @@
> </services>
> </assembly>
> </assemblies>
> -</deployable>
> \ No newline at end of file
> +</deployable>
> diff --git a/src/spec/factories/deployable.rb b/src/spec/factories/deployable.rb
> index 2bb2df0..08ef529 100644
> --- a/src/spec/factories/deployable.rb
> +++ b/src/spec/factories/deployable.rb
> @@ -18,7 +18,7 @@ FactoryGirl.define do
> factory :deployable do
> sequence(:name) { |n| "deployable#{n}" }
> xml "<?xml version=\"1.0\"?>
> -<deployable name='my'>
> +<deployable version='1.0' name='my'>
> <description>This is my testing image</description>
> <assemblies>
> <assembly name='frontend' hwp='front_hwp1'>
> @@ -35,7 +35,7 @@ FactoryGirl.define do
>
> factory :deployable_with_parameters, :parent => :deployable do
> xml "<?xml version=\"1.0\"?>
> -<deployable name='deployable_with_launch_parameters'>
> +<deployable version='1.0'
name='deployable_with_launch_parameters'>
> <description>A Deployable with launch
parameters</description>
> <assemblies>
> <assembly name='assembly_with_launch_parameters'
hwp='front_hwp1'>
> diff --git a/src/spec/vcr/cassettes/deployable_xml.yml
b/src/spec/vcr/cassettes/deployable_xml.yml
> index f035a0e..070da46 100644
> --- a/src/spec/vcr/cassettes/deployable_xml.yml
> +++ b/src/spec/vcr/cassettes/deployable_xml.yml
> @@ -1,35 +1,35 @@
> ----
> -- !ruby/struct:VCR::HTTPInteraction
> - request: !ruby/struct:VCR::Request
> +---
> +- !ruby/struct:VCR::HTTPInteraction
> + request: !ruby/struct:VCR::Request
> method: :get
> uri:
http://localhost:80/deployables/deployable1.xml
> - body:
> - headers:
> - accept:
> + body:
> + headers:
> + accept:
> - "*/*; q=0.5, application/xml"
> - accept-encoding:
> + accept-encoding:
> - gzip, deflate
> - response: !ruby/struct:VCR::Response
> - status: !ruby/struct:VCR::ResponseStatus
> + response: !ruby/struct:VCR::Response
> + status: !ruby/struct:VCR::ResponseStatus
> code: 200
> message: OK
> - headers:
> - etag:
> - - "\"2718-1a0-4a540da89cc0d\""
> - last-modified:
> - - Thu, 09 Jun 2011 05:37:49 GMT
> - content-type:
> + headers:
> + etag:
> + - "\"5df9-1b6-4b62f5a36fac2\""
> + last-modified:
> + - Tue, 10 Jan 2012 16:53:20 GMT
> + content-type:
> - text/xml
> - server:
> - - Apache/2.2.17 (Fedora)
> - date:
> - - Tue, 14 Jun 2011 14:54:15 GMT
> - content-length:
> - - "416"
> - accept-ranges:
> + server:
> + - Apache/2.2.21 (Fedora)
> + date:
> + - Wed, 11 Jan 2012 16:40:37 GMT
> + content-length:
> + - "438"
> + accept-ranges:
> - bytes
> body: |
> -<deployable name="Redmine">
> +<deployable version="1.0" name="Redmine">
> <description>Redmine is a web-based project management
> application</description>
> <assemblies>
> @@ -45,56 +45,3 @@
> </deployable>
>
> http_version: "1.1"
> -
> -- !ruby/struct:VCR::HTTPInteraction
> - request: !ruby/struct:VCR::Request
> - method: :get
> - uri:
http://localhost:80/deployables/deployable_with_launch_parameters.xml
> - body:
> - headers:
> - accept:
> - - "*/*; q=0.5, application/xml"
> - accept-encoding:
> - - gzip, deflate
> - response: !ruby/struct:VCR::Response
> - status: !ruby/struct:VCR::ResponseStatus
> - code: 200
> - message: OK
> - headers:
> - etag:
> - - "\"2718-1a0-4a540da89cc0e\""
> - last-modified:
> - - Thu, 09 Jun 2011 05:37:49 GMT
> - content-type:
> - - text/xml
> - server:
> - - Apache/2.2.17 (Fedora)
> - date:
> - - Tue, 14 Jun 2011 14:54:15 GMT
> - content-length:
> - - "578"
> - accept-ranges:
> - - bytes
> - body: |
> -<deployable name='deployable_with_launch_parameters'>
> -<description>A Deployable with launch parameters</description>
> -<assemblies>
> -<assembly name='assembly_with_launch_parameters'
hwp='front_hwp1'>
> -<image id='34c87aa0-3405-42f8-820e-309054029295'/>
> -<services>
> -<service name='service_with_launch_parameters'>
> -<executable url='executable_url'/>
> -<files>
> -<file url='file_url'/>
> -</files>
> -<parameters>
> -<parameter name='launch_parameter_1' type='scalar'/>
> -<parameter name='launch_parameter_2' type='scalar'/>
> -</parameters>
> -</service>
> -</services>
> -</assembly>
> -</assemblies>
> -</deployable>
> -
> - http_version: "1.1"
self-ack
All tests pass. And, the introduced change is backwards compatible with
previous deployables.
from deployable_xml.yml is breaking one test for me.
Patch forthcoming from me that fixes this...
Scott