You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2011/11/21 16:44:50 UTC
[PATCH 3/3] Adds CIMI Volume Template model+spec/test
From: marios <ma...@redhat.com>
Signed-off-by: marios <ma...@redhat.com>
---
server/lib/cimi/model.rb | 1 +
server/lib/cimi/model/volume_template.rb | 19 ++++++++++++
server/spec/cimi/data/volume_template.json | 14 +++++++++
server/spec/cimi/data/volume_template.xml | 10 ++++++
server/spec/cimi/model/volume_template_spec.rb | 36 ++++++++++++++++++++++++
5 files changed, 80 insertions(+), 0 deletions(-)
create mode 100644 server/lib/cimi/model/volume_template.rb
create mode 100644 server/spec/cimi/data/volume_template.json
create mode 100644 server/spec/cimi/data/volume_template.xml
create mode 100644 server/spec/cimi/model/volume_template_spec.rb
diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb
index 0a9236a..d6a879f 100644
--- a/server/lib/cimi/model.rb
+++ b/server/lib/cimi/model.rb
@@ -28,3 +28,4 @@ require 'cimi/model/machine_configuration'
require 'cimi/model/volume'
require 'cimi/model/volume_configuration'
require 'cimi/model/volume_image'
+require 'cimi/model/volume_template'
diff --git a/server/lib/cimi/model/volume_template.rb b/server/lib/cimi/model/volume_template.rb
new file mode 100644
index 0000000..51248d6
--- /dev/null
+++ b/server/lib/cimi/model/volume_template.rb
@@ -0,0 +1,19 @@
+# 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::VolumeTemplate < CIMI::Model::Base
+ href :volume_config
+ href :volume_image
+end
diff --git a/server/spec/cimi/data/volume_template.json b/server/spec/cimi/data/volume_template.json
new file mode 100644
index 0000000..3fd47b6
--- /dev/null
+++ b/server/spec/cimi/data/volume_template.json
@@ -0,0 +1,14 @@
+{
+ "uri": "http://cimi.example.org/volume_templates/1",
+ "name": "volume_template_1",
+ "description": "Volume Template One",
+ "created": "2011-11-21",
+ "volumeConfig":{ "href": "http://cimi.example.com/volume_configurations/1" },
+ "volumeImage":{ "href": "http://cimi.example.com/volume_images/1" },
+ "operations": [
+ { "rel": "edit",
+ "href": "http://cimi.example.org/volume_templates/1/edit" },
+ { "rel": "delete",
+ "href": "http://cimi.example.org/volume_templates/1/delete" }
+ ]
+}
diff --git a/server/spec/cimi/data/volume_template.xml b/server/spec/cimi/data/volume_template.xml
new file mode 100644
index 0000000..e7b5e0a
--- /dev/null
+++ b/server/spec/cimi/data/volume_template.xml
@@ -0,0 +1,10 @@
+<VolumeTemplate xmlns="http://www.dmtf.org/cimi">
+ <uri>http://cimi.example.org/volume_templates/1</uri>
+ <name>volume_template_1</name>
+ <description>Volume Template One</description>
+ <created>2011-11-21</created>
+ <volumeImage href="http://cimi.example.com/volume_images/1"/>
+ <volumeConfig href="http://cimi.example.com/volume_configurations/1"/>
+ <operation rel="edit" href="http://cimi.example.org/volume_templates/1/edit"/>
+ <operation rel="delete" href="http://cimi.example.org/volume_templates/1/delete"/>
+</VolumeTemplate>
diff --git a/server/spec/cimi/model/volume_template_spec.rb b/server/spec/cimi/model/volume_template_spec.rb
new file mode 100644
index 0000000..2c765d4
--- /dev/null
+++ b/server/spec/cimi/model/volume_template_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 Template model" do
+
+ before(:all) do
+ @xml = IO::read(File::join(DATA_DIR, "volume_template.xml"))
+ @json = IO::read(File::join(DATA_DIR, "volume_template.json"))
+ end
+
+ it "can be constructed from XML" do
+ conf = CIMI::Model::VolumeTemplate.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::VolumeTemplate.from_json(@json)
+ conf.should_not be_nil
+ should_serialize_from_json! conf, @xml, @json
+ end
+
+end
--
1.7.6.4
Re: [PATCH 3/3] Adds CIMI Volume Template model+spec/test
Posted by Michal Fojtik <mf...@redhat.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
ACK
-- Michal
marios@redhat.com wrote:
> From: marios <ma...@redhat.com>
>
>
> Signed-off-by: marios <ma...@redhat.com> ---
> server/lib/cimi/model.rb | 1 +
> server/lib/cimi/model/volume_template.rb | 19 ++++++++++++
> server/spec/cimi/data/volume_template.json | 14 +++++++++
> server/spec/cimi/data/volume_template.xml | 10 ++++++
> server/spec/cimi/model/volume_template_spec.rb | 36
> ++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 0
> deletions(-) create mode 100644
> server/lib/cimi/model/volume_template.rb create mode 100644
> server/spec/cimi/data/volume_template.json create mode 100644
> server/spec/cimi/data/volume_template.xml create mode 100644
> server/spec/cimi/model/volume_template_spec.rb
>
> diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb
> index 0a9236a..d6a879f 100644 --- a/server/lib/cimi/model.rb +++
> b/server/lib/cimi/model.rb @@ -28,3 +28,4 @@ require
> 'cimi/model/machine_configuration' require 'cimi/model/volume'
> require 'cimi/model/volume_configuration' require
> 'cimi/model/volume_image' +require 'cimi/model/volume_template' diff
> --git a/server/lib/cimi/model/volume_template.rb
> b/server/lib/cimi/model/volume_template.rb new file mode 100644 index
> 0000000..51248d6 --- /dev/null +++
> b/server/lib/cimi/model/volume_template.rb @@ -0,0 +1,19 @@ +#
> 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::VolumeTemplate < CIMI::Model::Base + href
> :volume_config + href :volume_image +end diff --git
> a/server/spec/cimi/data/volume_template.json
> b/server/spec/cimi/data/volume_template.json new file mode 100644
> index 0000000..3fd47b6 --- /dev/null +++
> b/server/spec/cimi/data/volume_template.json @@ -0,0 +1,14 @@ +{ +
> "uri": "http://cimi.example.org/volume_templates/1", + "name":
> "volume_template_1", + "description": "Volume Template One", +
> "created": "2011-11-21", + "volumeConfig":{ "href":
> "http://cimi.example.com/volume_configurations/1" }, +
> "volumeImage":{ "href": "http://cimi.example.com/volume_images/1" },
> + "operations": [ + { "rel": "edit", + "href":
> "http://cimi.example.org/volume_templates/1/edit" }, + { "rel":
> "delete", + "href":
> "http://cimi.example.org/volume_templates/1/delete" } + ] +} diff
> --git a/server/spec/cimi/data/volume_template.xml
> b/server/spec/cimi/data/volume_template.xml new file mode 100644
> index 0000000..e7b5e0a --- /dev/null +++
> b/server/spec/cimi/data/volume_template.xml @@ -0,0 +1,10 @@
> +<VolumeTemplate xmlns="http://www.dmtf.org/cimi"> +
> <uri>http://cimi.example.org/volume_templates/1</uri> +
> <name>volume_template_1</name> + <description>Volume Template
> One</description> + <created>2011-11-21</created> + <volumeImage
> href="http://cimi.example.com/volume_images/1"/> + <volumeConfig
> href="http://cimi.example.com/volume_configurations/1"/> +
> <operation rel="edit"
> href="http://cimi.example.org/volume_templates/1/edit"/> +
> <operation rel="delete"
> href="http://cimi.example.org/volume_templates/1/delete"/>
> +</VolumeTemplate> diff --git
> a/server/spec/cimi/model/volume_template_spec.rb
> b/server/spec/cimi/model/volume_template_spec.rb new file mode
> 100644 index 0000000..2c765d4 --- /dev/null +++
> b/server/spec/cimi/model/volume_template_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 Template
> model" do + + before(:all) do + @xml =
> IO::read(File::join(DATA_DIR, "volume_template.xml")) + @json =
> IO::read(File::join(DATA_DIR, "volume_template.json")) + end + + it
> "can be constructed from XML" do + conf =
> CIMI::Model::VolumeTemplate.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::VolumeTemplate.from_json(@json) + conf.should_not
> be_nil + should_serialize_from_json! conf, @xml, @json + end +
> +end
- --
- --
Michal Fojtik, mfojtik@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/
iQEcBAEBAgAGBQJOy3VaAAoJEEnFpmY+LvFR9cMH/RE5LaB4GeZHmYCij5uNiRRJ
Xr6RfNItrt/Bp77AUdPPvQ1obEOs85qBRfltB3EfD1gFHAl+rvOMIj/IyvAFFUOh
ihumsWFoApUx0NgqBm1dE3p2HijWfScp1AYCs20L1+fI9nLTqlabLAur1fYqAewP
F+oE9AInoV8gELjMESjKIWODje3zHFEI3QoQHyDGl32HMPDEobxkaXwbQ9aroUh+
b6iSbg80RnPnVYozUVq/F8B+q/LRfQpKqyoW008G2y4p9k6lE2CABut1sn3ONmoC
zjKMYjyTB0MJhM2qFS9QreqrHK8AU+XCrPOQSRofAbizpuNmxVtWJJsuRI3nKhA=
=T7Cz
-----END PGP SIGNATURE-----