deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Fojtik ...@mifo.sk>
Subject Re: [PATCH] Adds CIMI MachineAdmin model and spec/test
Date Sat, 19 Nov 2011 18:02:16 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ACK.

  -- Michal

marios@redhat.com wrote:
> From: marios <marios@redhat.com>
> 
> 
> Signed-off-by: marios <marios@redhat.com> --- 
> server/lib/cimi/model.rb                     |    1 + 
> server/lib/cimi/model/machine_admin.rb       |   26
> +++++++++++++++++ server/spec/cimi/data/machine_admin.json     |   14
> +++++++++ server/spec/cimi/data/machine_admin.xml      |   10
> +++++++ server/spec/cimi/model/machine_admin_spec.rb |   38 
> ++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 0 
> deletions(-) create mode 100644 
> server/lib/cimi/model/machine_admin.rb create mode 100644 
> server/spec/cimi/data/machine_admin.json create mode 100644 
> server/spec/cimi/data/machine_admin.xml create mode 100644 
> server/spec/cimi/model/machine_admin_spec.rb
> 
> diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb 
> index c436074..6db567e 100644 --- a/server/lib/cimi/model.rb +++ 
> b/server/lib/cimi/model.rb @@ -26,3 +26,4 @@ require 
> 'cimi/model/machine_template' require 'cimi/model/machine_image' 
> require 'cimi/model/machine_configuration' require 
> 'cimi/model/volume' +require 'cimi/model/machine_admin' diff --git 
> a/server/lib/cimi/model/machine_admin.rb 
> b/server/lib/cimi/model/machine_admin.rb new file mode 100644 index 
> 0000000..d3d3322 --- /dev/null +++ 
> b/server/lib/cimi/model/machine_admin.rb @@ -0,0 +1,26 @@ +# 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::MachineAdmin < CIMI::Model::Base + +  text :username + 
> text :password +  text :key + +  array :operations do +    scalar 
> :rel, :href +  end + +end diff --git 
> a/server/spec/cimi/data/machine_admin.json 
> b/server/spec/cimi/data/machine_admin.json new file mode 100644 index
> 0000000..d6d2622 --- /dev/null +++ 
> b/server/spec/cimi/data/machine_admin.json @@ -0,0 +1,14 @@ +{ + 
> "uri": "http://cimi.example.org/machine_admin/1", +  "name": 
> "credentials1", +  "description": "Machine Admin One", +  "created":
>  "2011-11-16", +  "username": "mockuser", +  "password": 
> "mockpassword", +  "operations": [ +  { "rel": "edit", +    "href": 
> "http://cimi.example.org/machine_admin/1/edit" }, +  { "rel": 
> "delete", +    "href": 
> "http://cimi.example.org/machine_admin/1/delete" } +  ] +} diff --git
> a/server/spec/cimi/data/machine_admin.xml 
> b/server/spec/cimi/data/machine_admin.xml new file mode 100644 index
>  0000000..a3cfd35 --- /dev/null +++ 
> b/server/spec/cimi/data/machine_admin.xml @@ -0,0 +1,10 @@ 
> +<MachineAdmin xmlns="http://www.dmtf.org/cimi"> + 
> <uri>http://cimi.example.org/machine_admin/1</uri> + 
> <name>credentials1</name> +  <description>Machine Admin 
> One</description> +  <created>2011-11-16</created> + 
> <username>mockuser</username> +  <password>mockpassword</password>
+
>  <operation rel="edit" 
> href="http://cimi.example.org/machine_admin/1/edit"/> +  <operation 
> rel="delete" href="http://cimi.example.org/machine_admin/1/delete"/> 
> +</MachineAdmin> diff --git 
> a/server/spec/cimi/model/machine_admin_spec.rb 
> b/server/spec/cimi/model/machine_admin_spec.rb new file mode 100644 
> index 0000000..e9cabc4 --- /dev/null +++ 
> b/server/spec/cimi/model/machine_admin_spec.rb @@ -0,0 +1,38 @@ +# 
> 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 "MachineAdmin model" do + +  before(:all) do +    @xml = 
> IO::read(File::join(DATA_DIR, "machine_admin.xml")) +    @json = 
> IO::read(File::join(DATA_DIR, "machine_admin.json")) +  end + +  it 
> "can be constructed from XML" do +    conf = 
> CIMI::Model::MachineAdmin.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::MachineAdmin.from_json(@json) +    conf.should_not 
> be_nil +    should_serialize_from_json! conf, @xml, @json +  end + + 
> + +end

- -- 
- ----------------------------------------------------------------
Michal Fojtik
deltacloud.org - Deltacloud API

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOx+8oAAoJEBGIkweUFTuYOYIIAJFBwoAlWKJK1Mj9YpcNEDgP
K5G2C1lbBx6gTnE6mMSdr7KJpEx6ThQ6IfTjXwUQWdMnbY9YxO/GtfRK09uCQV4t
EqArDmyt3S2nFVlXZQyXuWj44iNtPaK2X5eFdE+LPZSnfp09f2TCplU5I4sVNyO9
OOsNbY/tQU8ga6yp3Wm399gidJ5HHYpH6Pq4/06rmckzN8MQ/WZZ+uBPGUPN2QRN
AfeMUVFD4k6qYJAkNUZkbjQcJv1mLu4C7q8qVoN9SkwFE+cbivgwc9oBrlg+taq6
uSzzFkYhSYQAC6I+nnb7+1wLRfQMDdWgLDkNQSuh/RmTWLZ6alwbTAGp0sSSlUk=
=DU0j
-----END PGP SIGNATURE-----

Mime
View raw message