deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
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 GMT
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 @@
+<MachineConfiguration xmlns="http://www.dmtf.org/cimi">
+  <uri>http://cimi.example.org/machine_configurations/1</uri>
+  <name>MachineConfiguration1</name>
+  <description>Example MachineConfiguration One</description>
+  <created>2011-11-14</created>
+  <property name="architecture">i386</property>
+  <cpu>2</cpu>
+  <memory quantity="1" units="gigabyte"/>
+  <disk>
+    <capacity quantity="1" units="terabyte" format="ext4" attachmentPoint="/"/>
+  </disk>
+  <operation rel="edit" href="http://cimi.example.org/machine_configurations/1/edit"/>
+  <operation rel="delete" href="http://cimi.example.org/machine_configurations/1/delete"/>
+</MachineConfiguration>

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



Mime
View raw message