Return-Path: X-Original-To: apmail-incubator-deltacloud-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-deltacloud-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CDE1C964A for ; Wed, 2 Nov 2011 14:05:09 +0000 (UTC) Received: (qmail 23335 invoked by uid 500); 2 Nov 2011 14:05:09 -0000 Delivered-To: apmail-incubator-deltacloud-dev-archive@incubator.apache.org Received: (qmail 23323 invoked by uid 500); 2 Nov 2011 14:05:09 -0000 Mailing-List: contact deltacloud-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-dev@incubator.apache.org Received: (qmail 23315 invoked by uid 99); 2 Nov 2011 14:05:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Nov 2011 14:05:09 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mfojtik@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Nov 2011 14:05:03 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pA2E4g3N030876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Nov 2011 10:04:42 -0400 Received: from dhcp-29-121.brq.redhat.com (dhcp-29-121.brq.redhat.com [10.34.29.121]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pA2E4abq022488 for ; Wed, 2 Nov 2011 10:04:42 -0400 From: mfojtik@redhat.com To: deltacloud-dev@incubator.apache.org Subject: [PATCH core 4/4] Core: Updated views to support InstanceAddress. Get rid of address type guessing and formating Date: Wed, 2 Nov 2011 15:05:32 +0100 Message-Id: <1320242732-81971-5-git-send-email-mfojtik@redhat.com> In-Reply-To: <1320242732-81971-1-git-send-email-mfojtik@redhat.com> References: <1320242732-81971-1-git-send-email-mfojtik@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 From: Michal Fojtik Signed-off-by: Michal fojtik --- .../lib/deltacloud/helpers/application_helper.rb | 25 -------------------- server/views/instances/show.html.haml | 4 +- server/views/instances/show.xml.haml | 11 +++----- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/server/lib/deltacloud/helpers/application_helper.rb b/server/lib/deltacloud/helpers/application_helper.rb index 859129a..d44f108 100644 --- a/server/lib/deltacloud/helpers/application_helper.rb +++ b/server/lib/deltacloud/helpers/application_helper.rb @@ -248,31 +248,6 @@ module ApplicationHelper end end - # FIXME: It would be cleaner if we stored the type of address explicitly in - # public_addresses instead of guessing it; especially since now a RHEV-M - # vnc address in theory could look like type ipv4. - # - # Instead of pushing just the address onto public_addresses, we should - # just push a pair [type, address], i.e. [:vnc, "172.16.0.1"] or a hash - # { :vnc => "172.16.0.1" } - # - def address_type(address) - case address - when /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})?$/; :ipv4 - when /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:[\-\d]+)$/; :vnc - when /^(\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2})?$/; :mac - else :hostname - end - end - - def format_address(address, opts={}) - capture_haml do - haml_tag :address, { :type => address_type(address) }.merge(opts) do - haml_concat address - end - end - end - def translate_error_code(code) case code when 400; { :message => "Bad Request" } diff --git a/server/views/instances/show.html.haml b/server/views/instances/show.html.haml index 63286e8..6891f1b 100644 --- a/server/views/instances/show.html.haml +++ b/server/views/instances/show.html.haml @@ -28,10 +28,10 @@ default %li{ :'data-role' => 'list-divider'} Public addresses %li - %p{ :'data-role' => 'fieldcontain'}=@instance.public_addresses.map.join(',') + %p{ :'data-role' => 'fieldcontain'}=@instance.public_addresses.join(',') %li{ :'data-role' => 'list-divider'} Private addresses %li - %p{ :'data-role' => 'fieldcontain'}=@instance.private_addresses.map.join(',') + %p{ :'data-role' => 'fieldcontain'}=@instance.private_addresses.join(',') - if @instance.password or @instance.keyname %li{ :'data-role' => 'list-divider'} Authentication - if @instance.password diff --git a/server/views/instances/show.xml.haml b/server/views/instances/show.xml.haml index ab60fb7..5b929f4 100644 --- a/server/views/instances/show.xml.haml +++ b/server/views/instances/show.xml.haml @@ -31,15 +31,12 @@ =@instance.launch_time - if @instance.public_addresses %public_addresses< - - @instance.public_addresses.each do |address| - - if address.class.eql?(Hash) and address[:address]!="" - =format_address(address[:address], :port => address[:port], :type => address[:type], :mac => address[:mac]) - - elsif address.class.eql?(String) - =format_address(address) + - @instance.public_addresses.each do |a| + %address{ :type => a.address_type, :port => a.port }=a.address - if @instance.private_addresses %private_addresses< - - @instance.private_addresses.each do |address| - =format_address(address) + - @instance.private_addresses.each do |a| + %address{ :type => a.address_type, :port => a.port }=a.address - if @instance.firewalls %firewalls< - @instance.firewalls.each do |firewall| -- 1.7.4.4