Return-Path: X-Original-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 52261914C for ; Wed, 16 Nov 2011 12:50:03 +0000 (UTC) Received: (qmail 10024 invoked by uid 500); 16 Nov 2011 12:50:03 -0000 Delivered-To: apmail-incubator-deltacloud-commits-archive@incubator.apache.org Received: (qmail 10007 invoked by uid 500); 16 Nov 2011 12:50:03 -0000 Mailing-List: contact deltacloud-commits-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-commits@incubator.apache.org Received: (qmail 10000 invoked by uid 99); 16 Nov 2011 12:50:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2011 12:50:03 +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; Wed, 16 Nov 2011 12:49:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5B60423888EA; Wed, 16 Nov 2011 12:49:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1202675 - in /incubator/deltacloud/trunk/server: lib/cimi/model/machine_configuration.rb spec/cimi/data/machine_configuration.json spec/cimi/data/machine_configuration.xml spec/cimi/model/machine_configuration_spec.rb Date: Wed, 16 Nov 2011 12:49:38 -0000 To: deltacloud-commits@incubator.apache.org From: mfojtik@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111116124938.5B60423888EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mfojtik Date: Wed Nov 16 12:49:37 2011 New Revision: 1202675 URL: http://svn.apache.org/viewvc?rev=1202675&view=rev Log: CIMI: Added MachineConfiguration model Added: incubator/deltacloud/trunk/server/lib/cimi/model/machine_configuration.rb (with props) incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.json incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.xml (with props) incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb (with props) Added: incubator/deltacloud/trunk/server/lib/cimi/model/machine_configuration.rb URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/model/machine_configuration.rb?rev=1202675&view=auto ============================================================================== --- incubator/deltacloud/trunk/server/lib/cimi/model/machine_configuration.rb (added) +++ incubator/deltacloud/trunk/server/lib/cimi/model/machine_configuration.rb Wed Nov 16 12:49:37 2011 @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +class CIMI::Model::MachineConfiguration < CIMI::Model::Base + + scalar :memory + text :cpu + + array :disk do + scalar :capacity + end + + array :operations do + scalar :rel, :href + end +end Propchange: incubator/deltacloud/trunk/server/lib/cimi/model/machine_configuration.rb ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.json URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.json?rev=1202675&view=auto ============================================================================== --- incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.json (added) +++ incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.json Wed Nov 16 12:49:37 2011 @@ -0,0 +1,17 @@ +{ + "uri": "http://cimi.example.org/machine_configurations/1", + "name": "MachineConfiguration1", + "description": "Example MachineConfiguration One", + "created": "2011-11-14", + "cpu": "2", + "memory" : { "quantity": "1", "units": "gigabyte" }, + "disks" : [ + { "capacity": { "quantity": "1", "units": "terabyte", "format": "ext4", "attachmentPoint": "/" } } + ], + "properties": [ { "name": "architectore", "value" : "i386" } ], + "operations": [ + { "rel": "edit", + "href": "http://cimi.example.org/machine_images/1/edit" }, + { "rel": "delete", + "href": "http://cimi.example.org/machine_images/1/delete" }] +} Added: incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.xml URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.xml?rev=1202675&view=auto ============================================================================== --- incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.xml (added) +++ incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.xml Wed Nov 16 12:49:37 2011 @@ -0,0 +1,14 @@ + + http://cimi.example.org/machine_configurations/1 + MachineConfiguration1 + Example MachineConfiguration One + 2011-11-14 + i386 + 2 + + + + + + + Propchange: incubator/deltacloud/trunk/server/spec/cimi/data/machine_configuration.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb?rev=1202675&view=auto ============================================================================== --- incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb (added) +++ incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb Wed Nov 16 12:49:37 2011 @@ -0,0 +1,78 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +describe "MachineConfiguration model" do + + before(:all) do + @xml = IO::read(File::join(DATA_DIR, "machine_configuration.xml")) + @json = IO::read(File::join(DATA_DIR, "machine_configuration.json")) + end + + it "can be constructed from XML" do + conf = CIMI::Model::MachineConfiguration.from_xml(@xml) + conf.should_not be_nil + conf.name.should == 'MachineConfiguration1' + conf.uri == 'http://cimi.example.org/machine_configurations/1' + conf.description == 'Example MachineConfiguration One' + conf.created.should == "2011-11-14" + conf.cpu.should == "2" + conf.memory.size.should == 1 + conf.memory[0]['quantity'].should == '1' + conf.memory[0]['units'].should == 'gigabyte' + conf.disk.size.should == 1 + conf.disk[0].respond_to?(:capacity).should be_true + conf.disk[0].capacity.size.should == 1 + conf.disk[0].capacity[0]['format'] == 'ext4' + conf.disk[0].capacity[0]['quantity'] == '1' + conf.disk[0].capacity[0]['attachmentPoint'] == '/' + conf.disk[0].capacity[0]['units'] == 'terabyte' + conf.operations.size.should == 2 + conf.operations.any? { |operation| operation.rel == 'edit' }.should be_true + conf.operations.any? { |operation| operation.rel == 'delete' }.should be_true + conf.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } + conf.should serialize_to @xml, :fmt => :xml + end + + it "should convert strings in keys to symbols when contructed from XML" do + conf = CIMI::Model::MachineConfiguration.from_xml(@xml) + conf.should_not be_nil + conf.attribute_values.keys.each { |key| key.should be_a(Symbol) } + end + + it "can be constructed from JSON" do + conf = CIMI::Model::MachineConfiguration.from_json(@json) + conf.should_not be_nil + conf.name.should == 'MachineConfiguration1' + conf.uri == 'http://cimi.example.org/machine_configurations/1' + conf.description == 'Example MachineConfiguration One' + conf.created.should == "2011-11-14" + conf.cpu.should == "2" + conf.memory.size.should == 1 + conf.memory[0]['quantity'].should == '1' + conf.memory[0]['units'].should == 'gigabyte' + conf.disk.size.should == 1 + conf.disk[0].respond_to?(:capacity).should be_true + conf.disk[0].capacity.size.should == 1 + conf.disk[0].capacity[0]['format'] == 'ext4' + conf.disk[0].capacity[0]['quantity'] == '1' + conf.disk[0].capacity[0]['attachmentPoint'] == '/' + conf.disk[0].capacity[0]['units'] == 'terabyte' + conf.operations.size.should == 2 + conf.operations.any? { |operation| operation.rel == 'edit' }.should be_true + conf.operations.any? { |operation| operation.rel == 'delete' }.should be_true + conf.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } + conf.should serialize_to @json, :fmt => :json + end +end Propchange: incubator/deltacloud/trunk/server/spec/cimi/model/machine_configuration_spec.rb ------------------------------------------------------------------------------ svn:eol-style = native