deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1203563 - in /incubator/deltacloud/trunk/server: lib/cimi/model.rb lib/cimi/model/volume.rb spec/cimi/data/volume.json spec/cimi/data/volume.xml spec/cimi/model/volume_spec.rb
Date Fri, 18 Nov 2011 10:02:34 GMT
Author: marios
Date: Fri Nov 18 10:02:33 2011
New Revision: 1203563

URL: http://svn.apache.org/viewvc?rev=1203563&view=rev
Log:
Adds CIMI Volume model and spec data/test

Added:
    incubator/deltacloud/trunk/server/lib/cimi/model/volume.rb
      - copied, changed from r1203336, incubator/deltacloud/trunk/server/lib/cimi/model.rb
    incubator/deltacloud/trunk/server/spec/cimi/data/volume.json
    incubator/deltacloud/trunk/server/spec/cimi/data/volume.xml
    incubator/deltacloud/trunk/server/spec/cimi/model/volume_spec.rb
      - copied, changed from r1203336, incubator/deltacloud/trunk/server/lib/cimi/model.rb
Modified:
    incubator/deltacloud/trunk/server/lib/cimi/model.rb

Modified: incubator/deltacloud/trunk/server/lib/cimi/model.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/model.rb?rev=1203563&r1=1203562&r2=1203563&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/model.rb (original)
+++ incubator/deltacloud/trunk/server/lib/cimi/model.rb Fri Nov 18 10:02:33 2011
@@ -25,3 +25,4 @@ require 'cimi/model/base'
 require 'cimi/model/machine_template'
 require 'cimi/model/machine_image'
 require 'cimi/model/machine_configuration'
+require 'cimi/model/volume'

Copied: incubator/deltacloud/trunk/server/lib/cimi/model/volume.rb (from r1203336, incubator/deltacloud/trunk/server/lib/cimi/model.rb)
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/cimi/model/volume.rb?p2=incubator/deltacloud/trunk/server/lib/cimi/model/volume.rb&p1=incubator/deltacloud/trunk/server/lib/cimi/model.rb&r1=1203336&r2=1203563&rev=1203563&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/model.rb (original)
+++ incubator/deltacloud/trunk/server/lib/cimi/model/volume.rb Fri Nov 18 10:02:33 2011
@@ -12,16 +12,20 @@
 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 # License for the specific language governing permissions and limitations
 # under the License.
-#
 
-# Declare namespace for CIMI model
-#
-module CIMI
-  module Model; end
+class CIMI::Model::Volume < CIMI::Model::Base
+  struct :capacity do
+    scalar :quantity
+    scalar :units
+  end
+  text :bootable
+  text :supports_snapshots
+  array :snapshots do
+    scalar :ref
+  end
+  text :guest_interface
+  array :meters do
+    scalar :ref
+  end
+  scalar :eventlog
 end
-
-require 'cimi/model/schema'
-require 'cimi/model/base'
-require 'cimi/model/machine_template'
-require 'cimi/model/machine_image'
-require 'cimi/model/machine_configuration'

Added: incubator/deltacloud/trunk/server/spec/cimi/data/volume.json
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/spec/cimi/data/volume.json?rev=1203563&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/spec/cimi/data/volume.json (added)
+++ incubator/deltacloud/trunk/server/spec/cimi/data/volume.json Fri Nov 18 10:02:33 2011
@@ -0,0 +1,16 @@
+{
+  "uri": "http://cimi.example.org/volumes/1",
+  "name": "volume1",
+  "description": "Volume One",
+  "created": "2011-11-17",
+  "capacity": { "quantity": "10", "units": "gigabyte" },
+  "bootable": "false",
+  "supportsSnapshots": "false",
+  "guestInterface": "NFS",
+  "operations": [
+    { "rel": "edit",
+      "href": "http://cimi.example.org/volumes/1/edit" },
+    { "rel": "delete",
+      "href": "http://cimi.example.org/volumes/1/delete" }
+  ]
+}

Added: incubator/deltacloud/trunk/server/spec/cimi/data/volume.xml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/spec/cimi/data/volume.xml?rev=1203563&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/spec/cimi/data/volume.xml (added)
+++ incubator/deltacloud/trunk/server/spec/cimi/data/volume.xml Fri Nov 18 10:02:33 2011
@@ -0,0 +1,12 @@
+<Volume xmlns="http://www.dmtf.org/cimi">
+  <uri>http://cimi.example.org/volumes/1</uri>
+  <name>volume1</name>
+  <description>Volume One</description>
+  <created>2011-11-17</created>
+  <capacity quantity="10" units="gigabyte"/>
+  <bootable>false</bootable>
+  <supportsSnapshots>false</supportsSnapshots>
+  <guestInterface>NFS</guestInterface>
+  <operation rel="edit" href="http://cimi.example.org/volumes/1/edit"/>
+  <operation rel="delete" href="http://cimi.example.org/volumes/1/delete"/>
+</Volume>

Copied: incubator/deltacloud/trunk/server/spec/cimi/model/volume_spec.rb (from r1203336, incubator/deltacloud/trunk/server/lib/cimi/model.rb)
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/spec/cimi/model/volume_spec.rb?p2=incubator/deltacloud/trunk/server/spec/cimi/model/volume_spec.rb&p1=incubator/deltacloud/trunk/server/lib/cimi/model.rb&r1=1203336&r2=1203563&rev=1203563&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/cimi/model.rb (original)
+++ incubator/deltacloud/trunk/server/spec/cimi/model/volume_spec.rb Fri Nov 18 10:02:33 2011
@@ -14,14 +14,23 @@
 # under the License.
 #
 
-# Declare namespace for CIMI model
-#
-module CIMI
-  module Model; end
-end
+describe "Volume model" do
+
+  before(:all) do
+    @xml = IO::read(File::join(DATA_DIR, "volume.xml"))
+    @json = IO::read(File::join(DATA_DIR, "volume.json"))
+  end
 
-require 'cimi/model/schema'
-require 'cimi/model/base'
-require 'cimi/model/machine_template'
-require 'cimi/model/machine_image'
-require 'cimi/model/machine_configuration'
+  it "can be constructed from XML" do
+    conf = CIMI::Model::Volume.from_xml(@xml)
+    conf.should_not be_nil
+    should_serialize_from_xml! conf, @xml, @json
+  end
+
+  it "can be constructed from JSON" do
+    conf = CIMI::Model::Volume.from_json(@json)
+    conf.should_not be_nil
+    should_serialize_from_json! conf, @xml, @json
+  end
+
+end



Mime
View raw message