Hi,
I replaced xml_converter by HAML templates. This patch should apply on top of HWP patch posted by David.
- Michal
--- server/server.rb | 9 ++++--- server/views/images/index.xml.haml | 7 ++++++ server/views/images/show.xml.haml | 5 ++++ server/views/instances/index.xml.haml | 23 ++++++++++++++++++++ server/views/instances/show.xml.haml | 28 +++++++++++++++++++++++++ server/views/realms/index.xml.haml | 12 ++++++++++ server/views/realms/show.xml.haml | 10 +++++++++ server/views/storage_snapshots/index.xml.haml | 11 +++++++++ server/views/storage_snapshots/show.xml.haml | 9 ++++++++ server/views/storage_volumes/index.xml.haml | 13 +++++++++++ server/views/storage_volumes/show.xml.haml | 13 +++++++++++ 11 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 server/views/images/index.xml.haml create mode 100644 server/views/images/show.xml.haml create mode 100644 server/views/instances/index.xml.haml create mode 100644 server/views/instances/show.xml.haml create mode 100644 server/views/realms/index.xml.haml create mode 100644 server/views/realms/show.xml.haml create mode 100644 server/views/storage_snapshots/index.xml.haml create mode 100644 server/views/storage_snapshots/show.xml.haml create mode 100644 server/views/storage_volumes/index.xml.haml create mode 100644 server/views/storage_volumes/show.xml.haml
diff --git a/server/server.rb b/server/server.rb index 7f61123..a47168a 100644 --- a/server/server.rb +++ b/server/server.rb @@ -48,9 +48,9 @@ def filter_all(model) @elements = driver.send(model.to_sym, credentials, filter) instance_variable_set(:"@#{model}", @elements) respond_to do |format| - format.xml { convert_to_xml(singular, @elements) } format.json { convert_to_json(singular, @elements) } format.html { haml :"#{model}/index" } + format.xml { haml :"#{model}/index" } end end
@@ -58,9 +58,9 @@ def show(model) @element = driver.send(model, credentials, { :id => params[:id]} ) instance_variable_set("@#{model}", @element) respond_to do |format| - format.xml { convert_to_xml(model, @element) } format.json { convert_to_json(model, @element) } format.html { haml :"#{model.to_s.pluralize}/show" } + format.xml { haml :"#{model.to_s.pluralize}/show" } end end
@@ -205,9 +205,9 @@ end def instance_action(name) @instance = driver.send(:"#{name}_instance", credentials, params[:id]) respond_to do |format| - format.xml { convert_to_xml(:instance, @instance) } format.json {convert_to_json(:instance, @instance) } format.html { haml :"instances/show" } + format.xml { haml :"instances/show" } end end
@@ -239,7 +239,8 @@ collection :instances do format.xml do response.status = 201 # Created response['Location'] = instance_url(instance.id) - convert_to_xml(:instance, instance) + @instance = instance + haml :"instances/show" end format.html { redirect instance_url(instance.id) } end diff --git a/server/views/images/index.xml.haml b/server/views/images/index.xml.haml new file mode 100644 index 0000000..6d14b21 --- /dev/null +++ b/server/views/images/index.xml.haml @@ -0,0 +1,7 @@ +!!! XML +%images + - @elements.each do |image| + %image{:href => image_url(image.id)} + - image.attributes.each do |attribute| + - haml_tag(attribute, :<) do + - haml_concat image.send(attribute) diff --git a/server/views/images/show.xml.haml b/server/views/images/show.xml.haml new file mode 100644 index 0000000..fbb5d07 --- /dev/null +++ b/server/views/images/show.xml.haml @@ -0,0 +1,5 @@ +!!! XML +%image{:href => image_url(@image.id)} + - @image.attributes.each do |attribute| + - haml_tag(attribute, :<) do + - haml_concat @image.send(attribute) diff --git a/server/views/instances/index.xml.haml b/server/views/instances/index.xml.haml new file mode 100644 index 0000000..8e5ad9f --- /dev/null +++ b/server/views/instances/index.xml.haml @@ -0,0 +1,23 @@ +!!! XML +%instances + - @elements.each do |instance| + %instance{:href => instance_url(instance.id)} + %id #{instance.id} + %name #{instance.name} + %owner_id #{instance.owner_id} + %image{:href => image_url(instance.image_id)} + %realm{:href => realm_url(instance.realm_id)} + %state #{instance.state} + - haml_tag :"hardware-profile", { :href => hardware_profile_url(instance.instance_profile.id)} do + %id #{instance.instance_profile.id} + - instance.instance_profile.overrides.each do |p, v| + %property{:kind => 'fixed', :name => p, :value => v, :unit => Deltacloud::HardwareProfile::unit(p)} + %actions + - instance.actions.compact.each do |action| + %link{:rel => action, :href => self.send("#{action}_instance_url", action.id)} + - haml_tag :"public-addresses" do + - instance.public_addresses.each do |address| + %address #{address} + - haml_tag :"private-addresses" do + - instance.private_addresses.each do |address| + %address #{address} diff --git a/server/views/instances/show.xml.haml b/server/views/instances/show.xml.haml new file mode 100644 index 0000000..c149a55 --- /dev/null +++ b/server/views/instances/show.xml.haml @@ -0,0 +1,28 @@ +!!! XML +%instance{:href => instance_url(@instance.id)} + %id< + =@instance.id + %name< + =@instance.name + %owner_id< + =@instance.owner_id + %image{:href => image_url(@instance.image_id)} + %realm{:href => realm_url(@instance.realm_id)} + %state< + =@instance.state + - haml_tag :"hardware-profile", {:href => hardware_profile_url(@instance.instance_profile.id)} do + %id< + =@instance.instance_profile.id + - @instance.instance_profile.overrides.each do |p, v| + %property{:kind => 'fixed', :name => p, :value => v, :unit => Deltacloud::HardwareProfile::unit(p)} + %actions + - @instance.actions.compact.each do |action| + %link{:rel => action, :href => self.send("#{action}_instance_url", action.id)} + - haml_tag :"public-addresses" do + - @instance.public_addresses.each do |address| + %address< + =address + - haml_tag :"private-addresses" do + - @instance.private_addresses.each do |address| + %address< + =address diff --git a/server/views/realms/index.xml.haml b/server/views/realms/index.xml.haml new file mode 100644 index 0000000..03dd3df --- /dev/null +++ b/server/views/realms/index.xml.haml @@ -0,0 +1,12 @@ +!!!XML +%realms + - @elements.each do |realm| + %realm{:href => realm_url(realm.id)} + %id< + =realm.id + %name< + =realm.name + %state< + =realm.state + %limit< + =realm.limit.eql?(:unlimited) ? '' : realm.limit diff --git a/server/views/realms/show.xml.haml b/server/views/realms/show.xml.haml new file mode 100644 index 0000000..21ab97f --- /dev/null +++ b/server/views/realms/show.xml.haml @@ -0,0 +1,10 @@ +!!!XML +%realm{:href => realm_url(@realm.id)} + %id< + =@realm.id + %name< + =@realm.name + %state< + =@realm.state + %limit< + =@realm.limit.eql?(:unlimited) ? '' : @realm.limit diff --git a/server/views/storage_snapshots/index.xml.haml b/server/views/storage_snapshots/index.xml.haml new file mode 100644 index 0000000..734e00f --- /dev/null +++ b/server/views/storage_snapshots/index.xml.haml @@ -0,0 +1,11 @@ +!!!XML +%storage-snapshots + - @elements.each do |snapshot| + %storage-snapshot{ :href => storage_snapshot_url(snapshot.id)} + %id< + =snapshot.id + %created< + =snapshot.created + %state< + =snapshot.state + %storage-volume{ :href => storage_volume_url(snapshot.storage_volume_id)} diff --git a/server/views/storage_snapshots/show.xml.haml b/server/views/storage_snapshots/show.xml.haml new file mode 100644 index 0000000..49e3f00 --- /dev/null +++ b/server/views/storage_snapshots/show.xml.haml @@ -0,0 +1,9 @@ +!!!XML +%storage-snapshot{:href => storage_snapshot_url(@storage_snapshot.id)} + %id< + =@storage_snapshot.id + %created< + =@storage_snapshot.created + %state< + =@storage_snapshot.state + %storage-volume{:href => storage_volume_url(@storage_snapshot.storage_volume_id)} diff --git a/server/views/storage_volumes/index.xml.haml b/server/views/storage_volumes/index.xml.haml new file mode 100644 index 0000000..e07596f --- /dev/null +++ b/server/views/storage_volumes/index.xml.haml @@ -0,0 +1,13 @@ +!!!XML +%storage-volumes + - @elements.each do |volume| + %storage-volume{ :href => storage_volume_url(volume.id)} + %id< + =volume.id + %created< + =volume.created + %capacity< + =volume.capacity + %device< + =volume.device + %instance{:href => volume.instance_id} diff --git a/server/views/storage_volumes/show.xml.haml b/server/views/storage_volumes/show.xml.haml new file mode 100644 index 0000000..18f2e42 --- /dev/null +++ b/server/views/storage_volumes/show.xml.haml @@ -0,0 +1,13 @@ +!!!XML +%storage-volume{ :href => storage_volume_url(@storage_volume.id)} + %id< + =@storage_volume.id + %created< + =@storage_volume.created + %capacity< + =@storage_volume.capacity + %device< + =@storage_volume.device + %state< + =@storage_volume.state + %instance{:href => @storage_volume.instance_id}
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
I pushed this patch into master after using it for few days.
- - Michal
- -- - -------------------------------------------------------- Michal Fojtik, mfojtik@redhat.com, +420 532 294 4307 Ruby / Ruby On Rails Developer Deltacloud API: http://deltacloud.org - --------------------------------------------------------
deltacloud-devel@lists.fedorahosted.org