Return-Path: X-Original-To: apmail-deltacloud-dev-archive@www.apache.org Delivered-To: apmail-deltacloud-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1337F9ABE for ; Mon, 28 Nov 2011 10:11:34 +0000 (UTC) Received: (qmail 69862 invoked by uid 500); 28 Nov 2011 10:11:33 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 69747 invoked by uid 500); 28 Nov 2011 10:11:29 -0000 Mailing-List: contact dev-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list dev@deltacloud.apache.org Received: (qmail 69738 invoked by uid 99); 28 Nov 2011 10:11:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Nov 2011 10:11:27 +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 (nike.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; Mon, 28 Nov 2011 10:11:21 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pASAAwuD005041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 28 Nov 2011 05:10:58 -0500 Received: from dhcp-29-121.brq.redhat.com (dhcp-29-121.brq.redhat.com [10.34.29.121]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pASAAtSX031477 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Mon, 28 Nov 2011 05:10:57 -0500 Subject: Re: [PATCH 5/5] Adds create operation to CIMI::Volume model Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii From: Michal Fojtik In-Reply-To: <1322242039-30326-6-git-send-email-marios@redhat.com> Date: Mon, 28 Nov 2011 11:11:51 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1322242039-30326-1-git-send-email-marios@redhat.com> <1322242039-30326-6-git-send-email-marios@redhat.com> To: dev@deltacloud.apache.org X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Virus-Checked: Checked by ClamAV on apache.org On Nov 25, 2011, at 6:27 PM, marios@redhat.com wrote: > From: marios >=20 >=20 > Signed-off-by: marios > --- > server/lib/cimi/model/volume.rb | 17 +++++++++++++++++ > 1 files changed, 17 insertions(+), 0 deletions(-) >=20 > diff --git a/server/lib/cimi/model/volume.rb = b/server/lib/cimi/model/volume.rb > index 4bdd6ca..695546d 100644 > --- a/server/lib/cimi/model/volume.rb > +++ b/server/lib/cimi/model/volume.rb > @@ -43,6 +43,23 @@ class CIMI::Model::Volume < CIMI::Model::Base >=20 > def self.all(_self); find(:all, _self); end >=20 > + def self.create(params, _self) > + case params[:content_type] > + when :json > + json =3D JSON.parse(_self.request.body.read) > + volume_config_id =3D = json["volumeTemplate"]["volumeConfig"]["href"].split("/").last > + volume_image_id =3D = (json["volumeTemplate"].has_key?("volumeImage") ? = json["volumeTemplate"]["volumeImage"]["href"].split("/").last : nil) > + when :xml > + xml =3D XmlSimple.xml_in(_self.request.body.read) > + volume_config_id =3D = xml["volumeTemplate"][0]["volumeConfig"][0]["href"].split("/").last > + volume_image_id =3D = (xml["volumeTemplate"][0].has_key?("volumeImage") ? = xml["volumeTemplate"][0]["volumeImage"][0]["href"].split("/").last : = nil) > + end > + volume_config =3D VolumeConfiguration.find(volume_config_id, = _self) > + opts =3D {:capacity=3D>volume_config.capacity[:quantity], = :snapshot_id=3D>volume_image_id } > + storage_volume =3D = self.driver.create_storage_volume(_self.credentials, opts) > + from_storage_volume(storage_volume, _self) I think it would be better to split this method to: def self.create_from_json(params, _self) def self.create_from_xml(params, _self) This two could return an array so: data, volume_config_id, volume_image_id =3D create_from_json def self.create(params, _self) What do you think? ------------------------------------------------------ Michal Fojtik, mfojtik@redhat.com Deltacloud API: http://deltacloud.org