Return-Path: X-Original-To: apmail-deltacloud-commits-archive@www.apache.org Delivered-To: apmail-deltacloud-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EBF8C9225 for ; Thu, 8 Dec 2011 16:21:48 +0000 (UTC) Received: (qmail 1973 invoked by uid 500); 8 Dec 2011 16:21:48 -0000 Delivered-To: apmail-deltacloud-commits-archive@deltacloud.apache.org Received: (qmail 1956 invoked by uid 500); 8 Dec 2011 16:21:48 -0000 Mailing-List: contact commits-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 commits@deltacloud.apache.org Received: (qmail 1949 invoked by uid 99); 8 Dec 2011 16:21:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Dec 2011 16:21:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Dec 2011 16:21:47 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E815C2388A29 for ; Thu, 8 Dec 2011 16:21:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1211949 - /deltacloud/trunk/server/lib/cimi/model/machine.rb Date: Thu, 08 Dec 2011 16:21:26 -0000 To: commits@deltacloud.apache.org From: marios@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111208162126.E815C2388A29@eris.apache.org> Author: marios Date: Thu Dec 8 16:21:26 2011 New Revision: 1211949 URL: http://svn.apache.org/viewvc?rev=1211949&view=rev Log: Adds create_entity_metadata to CIMI::Machine model (+typos in xml parsing) Modified: deltacloud/trunk/server/lib/cimi/model/machine.rb Modified: deltacloud/trunk/server/lib/cimi/model/machine.rb URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/cimi/model/machine.rb?rev=1211949&r1=1211948&r2=1211949&view=diff ============================================================================== --- deltacloud/trunk/server/lib/cimi/model/machine.rb (original) +++ deltacloud/trunk/server/lib/cimi/model/machine.rb Thu Dec 8 16:21:26 2011 @@ -70,20 +70,20 @@ class CIMI::Model::Machine < CIMI::Model def self.create_from_json(body, context) json = JSON.parse(body) - hardware_profile_id = xml['MachineTemplate']['MachineConfig']["href"].split('/').last - image_id = xml['MachineTemplate']['MachineImage']["href"].split('/').last + hardware_profile_id = xml['machineTemplate']['machineConfig']["href"].split('/').last + image_id = xml['machineTemplate']['machineImage']["href"].split('/').last instance = context.create_instance(context.credentials, image_id, { :hwp_id => hardware_profile_id }) from_instance(instance, context) end def self.create_from_xml(body, context) xml = XmlSimple.xml_in(body) - machine_template = xml['MachineTemplate'][0] - hardware_profile_id = machine_template['MachineConfig'][0]["href"].split('/').last - image_id = machine_template['MachineImage'][0]["href"].split('/').last + machine_template = xml['machineTemplate'][0] + hardware_profile_id = machine_template['machineConfig'][0]["href"].split('/').last + image_id = machine_template['machineImage'][0]["href"].split('/').last additional_params = {} if machine_template.has_key? 'MachineAdmin' - additional_params[:keyname] = machine_template['MachineAdmin'][0]["href"].split('/').last + additional_params[:keyname] = machine_template['machineAdmin'][0]["href"].split('/').last end instance = context.driver.create_instance(context.credentials, image_id, { :hwp_id => hardware_profile_id @@ -107,6 +107,16 @@ class CIMI::Model::Machine < CIMI::Model context.driver.destroy_instance(context.credentials, id) end + def self.create_entity_metadata(context) + cimi_entity = self.name.split("::").last + metadata = EntityMetadata.metadata_from_deltacloud_features(cimi_entity, :instances, context) + unless metadata.includes_attribute?(:name) + metadata.attributes << {:name=>"name", :required=>"false", + :constraints=>"Determined by the cloud provider", :type=>"xs:string"} + end + metadata + end + private def self.from_instance(instance, context) @@ -163,11 +173,11 @@ class CIMI::Model::Machine < CIMI::Model machine_conf = MachineConfiguration.find(profile.name, context) storage_override = profile.overrides.find { |p, v| p == :storage } [ - { :capacity => { + { :capacity => { :quantity => storage_override.nil? ? machine_conf.disks.first[:capacity][:quantity] : storage_override[1], :units => machine_conf.disks.first[:capacity][:units] - } - } + } + } ] end