You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2011/12/07 14:13:12 UTC

[PATCH core 2/2] CIMI: Replaced .inspect in Details with formatted data

From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 clients/cimi/lib/cimi_frontend_helper.rb           |   17 ++++++++++
 clients/cimi/views/machines/show.haml              |   32 +++++++++++++++++++-
 clients/cimi/views/volume_configurations/show.haml |   13 ++++++--
 clients/cimi/views/volume_images/show.haml         |    9 ++++-
 clients/cimi/views/volumes/show.haml               |   24 +++++++++++++--
 5 files changed, 86 insertions(+), 9 deletions(-)

diff --git a/clients/cimi/lib/cimi_frontend_helper.rb b/clients/cimi/lib/cimi_frontend_helper.rb
index 8d1fba9..80ae9ed 100644
--- a/clients/cimi/lib/cimi_frontend_helper.rb
+++ b/clients/cimi/lib/cimi_frontend_helper.rb
@@ -46,6 +46,23 @@ module CIMI
         halt(*args)
       end
 
+      def boolean_span_for(bool)
+        return bool if !bool.nil? and bool!='true' and bool!='false'
+        capture_haml do
+          haml_tag :span, :class => [ 'label', bool.nil? ? '' : (bool===false) ? 'important' : 'success' ] do
+            haml_concat bool.nil? ? 'not specified' : (bool===false) ? 'no' : 'yes'
+          end
+        end
+      end
+
+      def state_span_for(state)
+        capture_haml do
+          haml_tag :span, :class => [ 'label', state=='STARTED' ? 'success' : 'important' ] do
+            haml_concat state
+          end
+        end
+      end
+
     end
   end
 end
diff --git a/clients/cimi/views/machines/show.haml b/clients/cimi/views/machines/show.haml
index fa637e5..a5b7638 100644
--- a/clients/cimi/views/machines/show.haml
+++ b/clients/cimi/views/machines/show.haml
@@ -43,7 +43,22 @@
   %dt Created
   %dd #{@machine.created}&nbsp;
   %dt State
-  %dd=@machine.state
+  %dd=state_span_for @machine.state
+  %dt CPU
+  %dd=boolean_span_for @machine.cpu
+  %dt Memory
+  %dd
+    - if @machine.memory.quantity.nil?
+      %span.label Not specified
+    - else
+      =[@memory.quantity, @memory.units].join("&nbsp;")
+  %dt Meters
+  %dd
+    - if @machine.meters.empty?
+      %span.label No meters
+    - else
+      - @machine.meters.each do |meters|
+        %dd=meters.ref
 
 %h3 Network Interfaces
 
@@ -76,3 +91,18 @@
           %a{:href => "/cimi/volumes/#{href_to_id(volume.href)}" }=href_to_id(volume.href)
         %td=volume.attachment_point
         %td=volume.protocol
+
+%h3 Disks
+
+%table.bordered-table
+  %thead
+    %tr
+      %th Capacity
+      %th Format
+      %th Attachment point
+  %tbody
+    - @machine.disks.each do |disk|
+      %tr
+        %td=[boolean_span_for(disk.capacity.quantity), disk.capacity.units].join("&nbsp;")
+        %td=boolean_span_for disk.format
+        %td=boolean_span_for disk.attachment_point
diff --git a/clients/cimi/views/volume_configurations/show.haml b/clients/cimi/views/volume_configurations/show.haml
index 6378ee7..1e55473 100644
--- a/clients/cimi/views/volume_configurations/show.haml
+++ b/clients/cimi/views/volume_configurations/show.haml
@@ -30,6 +30,13 @@
   %dt Description
   %dd=@volume_configuration.description
   %dt Created
-  %dd #{@volume_configuration.created}&nbsp;
-  %dt Details
-  %dd=@volume_configuration.inspect
+  %dd=@volume_configuration.created
+  %dt Format
+  %dd=boolean_span_for @volume_configuration.format
+  %dt Supports snapshots
+  %dd=boolean_span_for @volume_configuration.supports_snapshots
+  %dt Guest interface
+  %dd=boolean_span_for @volume_configuration.guest_interface
+  %dt Capacity
+  %dd
+    =[@volume_configuration.capacity.quantity, @volume_configuration.capacity.units].join('&nbsp;')
diff --git a/clients/cimi/views/volume_images/show.haml b/clients/cimi/views/volume_images/show.haml
index 20b3ef4..f76bf5e 100644
--- a/clients/cimi/views/volume_images/show.haml
+++ b/clients/cimi/views/volume_images/show.haml
@@ -29,5 +29,10 @@
   %dd=@volume_image.description
   %dt Created
   %dd=@volume_image.created
-  %dt Details
-  %dd=@volume_image.inspect
+  %dt Bootable
+  %dd=boolean_span_for @volume_image.bootable
+  %dt Image Location
+  %dd
+    %a{:href => "/cimi/volumes/#{href_to_id(@volume_image.image_location.href)}"}=href_to_id @volume_image.image_location.href
+  %dt Image Data
+  %dd=boolean_span_for @volume_image.image_data
diff --git a/clients/cimi/views/volumes/show.haml b/clients/cimi/views/volumes/show.haml
index f08006b..0352d52 100644
--- a/clients/cimi/views/volumes/show.haml
+++ b/clients/cimi/views/volumes/show.haml
@@ -28,6 +28,24 @@
   %dt Description
   %dd=@volume.description
   %dt Created
-  %dd #{@volume.created}&nbsp;
-  %dt Details
-  %dd=@volume.inspect
+  %dd=@volume.created
+  %dt Bootable
+  %dd=boolean_span_for @volume.bootable
+  %dt Support Snapshots
+  %dd=boolean_span_for @volume.supports_snapshots
+  %dt Guest Interface
+  %dd=boolean_span_for @volume.guest_interface
+  %dt Snapshots
+  %dd
+    - if @volume.snapshots.empty?
+      %span.label No snapshots
+    - else
+      - @volume.snapshots.each do |snapshot|
+        %dd=snapshot.ref
+  %dt Meters
+  %dd
+    - if @volume.meters.empty?
+      %span.label No meters
+    - else
+      - @volume.meters.each do |meters|
+        %dd=meters.ref
-- 
1.7.4.4


Re: [PATCH core 2/2] CIMI: Replaced .inspect in Details with formatted data

Posted by Michal Fojtik <mf...@redhat.com>.
On Dec 7, 2011, at 4:01 PM, Tong Li wrote:

> ACK. thanks.

Thanks. Pushing.

  -- Michal

> 
> Tong Li
> Emerging Technologies & Standards
> Building 501/B205
> litong01@us.ibm.com
> 
> mfojtik@redhat.com wrote on 12/07/2011 08:13:12 AM:
> 
>> From: mfojtik@redhat.com
>> To: dev@deltacloud.apache.org
>> Date: 12/07/2011 08:15 AM
>> Subject: [PATCH core 2/2] CIMI: Replaced .inspect in Details with
>> formatted data
>> 
>> From: Michal Fojtik <mf...@redhat.com>
>> 
>> 
>> Signed-off-by: Michal fojtik <mf...@redhat.com>
>> ---
>> clients/cimi/lib/cimi_frontend_helper.rb           |   17 ++++++++++
>> clients/cimi/views/machines/show.haml              |   32 +++++++++
>> ++++++++++-
>> clients/cimi/views/volume_configurations/show.haml |   13 ++++++--
>> clients/cimi/views/volume_images/show.haml         |    9 ++++-
>> clients/cimi/views/volumes/show.haml               |   24 ++++++++++++
> +--
>> 5 files changed, 86 insertions(+), 9 deletions(-)
>> 
>> diff --git a/clients/cimi/lib/cimi_frontend_helper.rb b/clients/
>> cimi/lib/cimi_frontend_helper.rb
>> index 8d1fba9..80ae9ed 100644
>> --- a/clients/cimi/lib/cimi_frontend_helper.rb
>> +++ b/clients/cimi/lib/cimi_frontend_helper.rb
>> @@ -46,6 +46,23 @@ module CIMI
>>         halt(*args)
>>       end
>> 
>> +      def boolean_span_for(bool)
>> +        return bool if !bool.nil? and bool!='true' and bool!='false'
>> +        capture_haml do
>> +          haml_tag :span, :class => [ 'label', bool.nil? ? '' :
>> (bool===false) ? 'important' : 'success' ] do
>> +            haml_concat bool.nil? ? 'not specified' :
>> (bool===false) ? 'no' : 'yes'
>> +          end
>> +        end
>> +      end
>> +
>> +      def state_span_for(state)
>> +        capture_haml do
>> +          haml_tag :span, :class => [ 'label', state=='STARTED' ?
>> 'success' : 'important' ] do
>> +            haml_concat state
>> +          end
>> +        end
>> +      end
>> +
>>     end
>>   end
>> end
>> diff --git a/clients/cimi/views/machines/show.haml b/clients/cimi/
>> views/machines/show.haml
>> index fa637e5..a5b7638 100644
>> --- a/clients/cimi/views/machines/show.haml
>> +++ b/clients/cimi/views/machines/show.haml
>> @@ -43,7 +43,22 @@
>>   %dt Created
>>   %dd #{@machine.created}&nbsp;
>>   %dt State
>> -  %dd=@machine.state
>> +  %dd=state_span_for @machine.state
>> +  %dt CPU
>> +  %dd=boolean_span_for @machine.cpu
>> +  %dt Memory
>> +  %dd
>> +    - if @machine.memory.quantity.nil?
>> +      %span.label Not specified
>> +    - else
>> +      =[@memory.quantity, @memory.units].join("&nbsp;")
>> +  %dt Meters
>> +  %dd
>> +    - if @machine.meters.empty?
>> +      %span.label No meters
>> +    - else
>> +      - @machine.meters.each do |meters|
>> +        %dd=meters.ref
>> 
>> %h3 Network Interfaces
>> 
>> @@ -76,3 +91,18 @@
>>           %a{:href => "/cimi/volumes/#{href_to_id(volume.href)}" }
>> =href_to_id(volume.href)
>>         %td=volume.attachment_point
>>         %td=volume.protocol
>> +
>> +%h3 Disks
>> +
>> +%table.bordered-table
>> +  %thead
>> +    %tr
>> +      %th Capacity
>> +      %th Format
>> +      %th Attachment point
>> +  %tbody
>> +    - @machine.disks.each do |disk|
>> +      %tr
>> +        %td=[boolean_span_for(disk.capacity.quantity),
>> disk.capacity.units].join("&nbsp;")
>> +        %td=boolean_span_for disk.format
>> +        %td=boolean_span_for disk.attachment_point
>> diff --git a/clients/cimi/views/volume_configurations/show.haml b/
>> clients/cimi/views/volume_configurations/show.haml
>> index 6378ee7..1e55473 100644
>> --- a/clients/cimi/views/volume_configurations/show.haml
>> +++ b/clients/cimi/views/volume_configurations/show.haml
>> @@ -30,6 +30,13 @@
>>   %dt Description
>>   %dd=@volume_configuration.description
>>   %dt Created
>> -  %dd #{@volume_configuration.created}&nbsp;
>> -  %dt Details
>> -  %dd=@volume_configuration.inspect
>> +  %dd=@volume_configuration.created
>> +  %dt Format
>> +  %dd=boolean_span_for @volume_configuration.format
>> +  %dt Supports snapshots
>> +  %dd=boolean_span_for @volume_configuration.supports_snapshots
>> +  %dt Guest interface
>> +  %dd=boolean_span_for @volume_configuration.guest_interface
>> +  %dt Capacity
>> +  %dd
>> +    =[@volume_configuration.capacity.quantity,
>> @volume_configuration.capacity.units].join('&nbsp;')
>> diff --git a/clients/cimi/views/volume_images/show.haml b/clients/
>> cimi/views/volume_images/show.haml
>> index 20b3ef4..f76bf5e 100644
>> --- a/clients/cimi/views/volume_images/show.haml
>> +++ b/clients/cimi/views/volume_images/show.haml
>> @@ -29,5 +29,10 @@
>>   %dd=@volume_image.description
>>   %dt Created
>>   %dd=@volume_image.created
>> -  %dt Details
>> -  %dd=@volume_image.inspect
>> +  %dt Bootable
>> +  %dd=boolean_span_for @volume_image.bootable
>> +  %dt Image Location
>> +  %dd
>> +    %a{:href => "/cimi/volumes/#{href_to_id
>> (@volume_image.image_location.href)}"}=href_to_id
>> @volume_image.image_location.href
>> +  %dt Image Data
>> +  %dd=boolean_span_for @volume_image.image_data
>> diff --git a/clients/cimi/views/volumes/show.haml b/clients/cimi/
>> views/volumes/show.haml
>> index f08006b..0352d52 100644
>> --- a/clients/cimi/views/volumes/show.haml
>> +++ b/clients/cimi/views/volumes/show.haml
>> @@ -28,6 +28,24 @@
>>   %dt Description
>>   %dd=@volume.description
>>   %dt Created
>> -  %dd #{@volume.created}&nbsp;
>> -  %dt Details
>> -  %dd=@volume.inspect
>> +  %dd=@volume.created
>> +  %dt Bootable
>> +  %dd=boolean_span_for @volume.bootable
>> +  %dt Support Snapshots
>> +  %dd=boolean_span_for @volume.supports_snapshots
>> +  %dt Guest Interface
>> +  %dd=boolean_span_for @volume.guest_interface
>> +  %dt Snapshots
>> +  %dd
>> +    - if @volume.snapshots.empty?
>> +      %span.label No snapshots
>> +    - else
>> +      - @volume.snapshots.each do |snapshot|
>> +        %dd=snapshot.ref
>> +  %dt Meters
>> +  %dd
>> +    - if @volume.meters.empty?
>> +      %span.label No meters
>> +    - else
>> +      - @volume.meters.each do |meters|
>> +        %dd=meters.ref
>> --
>> 1.7.4.4
>> 
> 

------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org


Re: [PATCH core 2/2] CIMI: Replaced .inspect in Details with formatted data

Posted by Tong Li <li...@us.ibm.com>.
ACK. thanks.

Tong Li
Emerging Technologies & Standards
Building 501/B205
litong01@us.ibm.com

mfojtik@redhat.com wrote on 12/07/2011 08:13:12 AM:

> From: mfojtik@redhat.com
> To: dev@deltacloud.apache.org
> Date: 12/07/2011 08:15 AM
> Subject: [PATCH core 2/2] CIMI: Replaced .inspect in Details with
> formatted data
>
> From: Michal Fojtik <mf...@redhat.com>
>
>
> Signed-off-by: Michal fojtik <mf...@redhat.com>
> ---
>  clients/cimi/lib/cimi_frontend_helper.rb           |   17 ++++++++++
>  clients/cimi/views/machines/show.haml              |   32 +++++++++
> ++++++++++-
>  clients/cimi/views/volume_configurations/show.haml |   13 ++++++--
>  clients/cimi/views/volume_images/show.haml         |    9 ++++-
>  clients/cimi/views/volumes/show.haml               |   24 ++++++++++++
+--
>  5 files changed, 86 insertions(+), 9 deletions(-)
>
> diff --git a/clients/cimi/lib/cimi_frontend_helper.rb b/clients/
> cimi/lib/cimi_frontend_helper.rb
> index 8d1fba9..80ae9ed 100644
> --- a/clients/cimi/lib/cimi_frontend_helper.rb
> +++ b/clients/cimi/lib/cimi_frontend_helper.rb
> @@ -46,6 +46,23 @@ module CIMI
>          halt(*args)
>        end
>
> +      def boolean_span_for(bool)
> +        return bool if !bool.nil? and bool!='true' and bool!='false'
> +        capture_haml do
> +          haml_tag :span, :class => [ 'label', bool.nil? ? '' :
> (bool===false) ? 'important' : 'success' ] do
> +            haml_concat bool.nil? ? 'not specified' :
> (bool===false) ? 'no' : 'yes'
> +          end
> +        end
> +      end
> +
> +      def state_span_for(state)
> +        capture_haml do
> +          haml_tag :span, :class => [ 'label', state=='STARTED' ?
> 'success' : 'important' ] do
> +            haml_concat state
> +          end
> +        end
> +      end
> +
>      end
>    end
>  end
> diff --git a/clients/cimi/views/machines/show.haml b/clients/cimi/
> views/machines/show.haml
> index fa637e5..a5b7638 100644
> --- a/clients/cimi/views/machines/show.haml
> +++ b/clients/cimi/views/machines/show.haml
> @@ -43,7 +43,22 @@
>    %dt Created
>    %dd #{@machine.created}&nbsp;
>    %dt State
> -  %dd=@machine.state
> +  %dd=state_span_for @machine.state
> +  %dt CPU
> +  %dd=boolean_span_for @machine.cpu
> +  %dt Memory
> +  %dd
> +    - if @machine.memory.quantity.nil?
> +      %span.label Not specified
> +    - else
> +      =[@memory.quantity, @memory.units].join("&nbsp;")
> +  %dt Meters
> +  %dd
> +    - if @machine.meters.empty?
> +      %span.label No meters
> +    - else
> +      - @machine.meters.each do |meters|
> +        %dd=meters.ref
>
>  %h3 Network Interfaces
>
> @@ -76,3 +91,18 @@
>            %a{:href => "/cimi/volumes/#{href_to_id(volume.href)}" }
> =href_to_id(volume.href)
>          %td=volume.attachment_point
>          %td=volume.protocol
> +
> +%h3 Disks
> +
> +%table.bordered-table
> +  %thead
> +    %tr
> +      %th Capacity
> +      %th Format
> +      %th Attachment point
> +  %tbody
> +    - @machine.disks.each do |disk|
> +      %tr
> +        %td=[boolean_span_for(disk.capacity.quantity),
> disk.capacity.units].join("&nbsp;")
> +        %td=boolean_span_for disk.format
> +        %td=boolean_span_for disk.attachment_point
> diff --git a/clients/cimi/views/volume_configurations/show.haml b/
> clients/cimi/views/volume_configurations/show.haml
> index 6378ee7..1e55473 100644
> --- a/clients/cimi/views/volume_configurations/show.haml
> +++ b/clients/cimi/views/volume_configurations/show.haml
> @@ -30,6 +30,13 @@
>    %dt Description
>    %dd=@volume_configuration.description
>    %dt Created
> -  %dd #{@volume_configuration.created}&nbsp;
> -  %dt Details
> -  %dd=@volume_configuration.inspect
> +  %dd=@volume_configuration.created
> +  %dt Format
> +  %dd=boolean_span_for @volume_configuration.format
> +  %dt Supports snapshots
> +  %dd=boolean_span_for @volume_configuration.supports_snapshots
> +  %dt Guest interface
> +  %dd=boolean_span_for @volume_configuration.guest_interface
> +  %dt Capacity
> +  %dd
> +    =[@volume_configuration.capacity.quantity,
> @volume_configuration.capacity.units].join('&nbsp;')
> diff --git a/clients/cimi/views/volume_images/show.haml b/clients/
> cimi/views/volume_images/show.haml
> index 20b3ef4..f76bf5e 100644
> --- a/clients/cimi/views/volume_images/show.haml
> +++ b/clients/cimi/views/volume_images/show.haml
> @@ -29,5 +29,10 @@
>    %dd=@volume_image.description
>    %dt Created
>    %dd=@volume_image.created
> -  %dt Details
> -  %dd=@volume_image.inspect
> +  %dt Bootable
> +  %dd=boolean_span_for @volume_image.bootable
> +  %dt Image Location
> +  %dd
> +    %a{:href => "/cimi/volumes/#{href_to_id
> (@volume_image.image_location.href)}"}=href_to_id
> @volume_image.image_location.href
> +  %dt Image Data
> +  %dd=boolean_span_for @volume_image.image_data
> diff --git a/clients/cimi/views/volumes/show.haml b/clients/cimi/
> views/volumes/show.haml
> index f08006b..0352d52 100644
> --- a/clients/cimi/views/volumes/show.haml
> +++ b/clients/cimi/views/volumes/show.haml
> @@ -28,6 +28,24 @@
>    %dt Description
>    %dd=@volume.description
>    %dt Created
> -  %dd #{@volume.created}&nbsp;
> -  %dt Details
> -  %dd=@volume.inspect
> +  %dd=@volume.created
> +  %dt Bootable
> +  %dd=boolean_span_for @volume.bootable
> +  %dt Support Snapshots
> +  %dd=boolean_span_for @volume.supports_snapshots
> +  %dt Guest Interface
> +  %dd=boolean_span_for @volume.guest_interface
> +  %dt Snapshots
> +  %dd
> +    - if @volume.snapshots.empty?
> +      %span.label No snapshots
> +    - else
> +      - @volume.snapshots.each do |snapshot|
> +        %dd=snapshot.ref
> +  %dt Meters
> +  %dd
> +    - if @volume.meters.empty?
> +      %span.label No meters
> +    - else
> +      - @volume.meters.each do |meters|
> +        %dd=meters.ref
> --
> 1.7.4.4
>