-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 ACK.
-- Michal mar...@redhat.com wrote: > From: marios <mar...@redhat.com> > > > Signed-off-by: marios <mar...@redhat.com> --- > server/lib/cimi/model.rb | 1 + > server/lib/cimi/model/volume.rb | 31 > ++++++++++++++++++++++++++++ server/spec/cimi/data/volume.json | > 16 ++++++++++++++ server/spec/cimi/data/volume.xml | 12 > +++++++++++ server/spec/cimi/model/volume_spec.rb | 36 > +++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), > 0 deletions(-) create mode 100644 server/lib/cimi/model/volume.rb > create mode 100644 server/spec/cimi/data/volume.json create mode > 100644 server/spec/cimi/data/volume.xml create mode 100644 > server/spec/cimi/model/volume_spec.rb > > diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb > index 1e4a34a..c436074 100644 --- a/server/lib/cimi/model.rb +++ > b/server/lib/cimi/model.rb @@ -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' diff > --git a/server/lib/cimi/model/volume.rb > b/server/lib/cimi/model/volume.rb new file mode 100644 index > 0000000..b83fcc3 --- /dev/null +++ b/server/lib/cimi/model/volume.rb > @@ -0,0 +1,31 @@ +# 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::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 > diff --git a/server/spec/cimi/data/volume.json > b/server/spec/cimi/data/volume.json new file mode 100644 index > 0000000..af22517 --- /dev/null +++ > b/server/spec/cimi/data/volume.json @@ -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" } + ] +} diff > --git a/server/spec/cimi/data/volume.xml > b/server/spec/cimi/data/volume.xml new file mode 100644 index > 0000000..2e4699e --- /dev/null +++ > b/server/spec/cimi/data/volume.xml @@ -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> diff --git a/server/spec/cimi/model/volume_spec.rb > b/server/spec/cimi/model/volume_spec.rb new file mode 100644 index > 0000000..829dc57 --- /dev/null +++ > b/server/spec/cimi/model/volume_spec.rb @@ -0,0 +1,36 @@ +# 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 "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 + + 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 - -- - -- Michal Fojtik, mfoj...@redhat.com Deltacloud API: http://deltacloud.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJOxigEAAoJEEnFpmY+LvFRYfgIAKKF6s+FJzYXUwXdvrjE5yBz gMEpSL1bLzvYPt+ZfEgt7sm0LXXGN33EEk66uPeIZtH+t1ySr89msDMbZ0bRAiUl GH8wP/5lqOyH0WyaVgvvYsaXw4tk16b/sgZc7KE97HLnjjQ5VfSmINveqJjw1tWr x321Vqf4qFiSrJQSP5kPdxkd7QXhN8H5w6+j1FpBik390uxbaI3cnjvc0dBvJmp8 A0SFwZQ1mbLQxRx+PKu/OZxu6AgU+kZxyxRguoirhbX13xJvZwzUI2tLbX0oMu9x azz2s99zKkLBkpXevZ3EmtnSVBeorJfk591UIhS04QVI3Bn0ae0y5nYG4IOITD4= =/nnk -----END PGP SIGNATURE-----