You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2011/11/21 16:02:30 UTC
[PATCH core 1/2] CIMI: Fixed formatting in machine_template model
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
server/lib/cimi/model/machine_template.rb | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/server/lib/cimi/model/machine_template.rb b/server/lib/cimi/model/machine_template.rb
index 458f365..5f1ebfe 100644
--- a/server/lib/cimi/model/machine_template.rb
+++ b/server/lib/cimi/model/machine_template.rb
@@ -17,19 +17,23 @@ class CIMI::Model::MachineTemplate < CIMI::Model::Base
href :machine_config
href :machine_image
href :machine_admin
+
array :volumes do
scalar :href
scalar :protocol
scalar :attachment_point
end
+
array :volume_templates do
scalar :href, :attachment_point, :protocol
end
+
array :network_interfaces do
href :vsp
text :hostname, :mac_address, :state, :protocol, :allocation
text :address, :default_gateway, :dns, :max_transmission_unit
end
+
array :operations do
scalar :rel, :href
end
--
1.7.4.4
Re: [PATCH core 1/2] CIMI: Fixed formatting in machine_template model
Posted by "marios@redhat.com" <ma...@redhat.com>.
ACK
On 21/11/11 17:02, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
>
>
> Signed-off-by: Michal fojtik <mf...@redhat.com>
> ---
> server/lib/cimi/model/machine_template.rb | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/server/lib/cimi/model/machine_template.rb b/server/lib/cimi/model/machine_template.rb
> index 458f365..5f1ebfe 100644
> --- a/server/lib/cimi/model/machine_template.rb
> +++ b/server/lib/cimi/model/machine_template.rb
> @@ -17,19 +17,23 @@ class CIMI::Model::MachineTemplate < CIMI::Model::Base
> href :machine_config
> href :machine_image
> href :machine_admin
> +
> array :volumes do
> scalar :href
> scalar :protocol
> scalar :attachment_point
> end
> +
> array :volume_templates do
> scalar :href, :attachment_point, :protocol
> end
> +
> array :network_interfaces do
> href :vsp
> text :hostname, :mac_address, :state, :protocol, :allocation
> text :address, :default_gateway, :dns, :max_transmission_unit
> end
> +
> array :operations do
> scalar :rel, :href
> end
Re: [PATCH core 2/2] CIMI: Added Machine model and spec files
Posted by "marios@redhat.com" <ma...@redhat.com>.
ACK (+ couple minor nits inline):
On 21/11/11 17:02, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
>
>
> Signed-off-by: Michal fojtik <mf...@redhat.com>
> ---
KIND, either express or implied. See the
> +# License for the specific language governing permissions and limitations
> +# under the License.
> +
> +class CIMI::Model::Machine < CIMI::Model::Base
> +
> + text :state
> + text :cpu
> +
> + struct :memory do
> + scalar :quantity
> + scalar :units
> + end
> +
> + href :event_log
> +
> + array :disks do
> + struct :capacity do
> + scalar :quantity
> + scalar :units
> + end
I think :disks ends there, i.e. couldn't find :format and
:attachment_point for disks (maybe a typo, confusion with volumes)
> + scalar :format
> + scalar :attachment_point
> + end
> +
> +
> + array :meters do
> + scalar :href
> + end
> +
+ needs href :eventlog (you already have this in xml/json examples below)
> + array :operations do
> + scalar :rel, :href
> + end
> +
> +end
> diff --git a/server/spec/cimi/data/machine.json b/server/spec/cimi/data/machine.json
> new file mode 100644
> index 0000000..a1df3c3
> --- /dev/null
> +++ b/server/spec/cimi/data/machine.json
> @@ -0,0 +1,43 @@
> +{ "uri": "http://cimi.example.org/machines/1",
> + "name": "machine1",
> + "description": "Machine one description",
> + "created": "2011-11-21",
> + "properties": { "owner_id": "mockuser" },
> + "state": "STARTED",
> + "cpu": "4",
> + "memory": { "quantity": "1", "units": "gibibyte" },
> + "disks" : [
> + { "capacity": { "quantity": "1", "units": "terabyte" } }
> + ],
> + "volumes": [{
> + "href": "http://cimi.example.org/volumes/1",
> + "attachmentPoint": "/dev/sda",
> + "protocol": "nfs"
> + }],
from the json serialization example, i see this as
"volumes": [{
"volume": { "href":"http://cimi.example.org/volumes/1" },
"attachmentPoint": "/dev/sda",
"protocol": "nfs" }]
(like you did for "vsp" of "networkInterfaces" below)
> + "networkInterfaces": [{
> + "vsp": { "href": "http://cimi.example.org/vsps/2" },
> + "hostname": "machine1.cimi.example.org",
> + "macAddress": "00:11:22:33:44:56",
> + "state": "UP",
> + "protocol": "TCP",
> + "allocation": "static",
> + "address": "192.168.0.18",
> + "defaultGateway": "192.168.0.1",
[PATCH core 2/2] CIMI: Added Machine model and spec files
Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
server/lib/cimi/model.rb | 1 +
server/lib/cimi/model/machine.rb | 57 ++++++++++++++++++++++++++++++++
server/spec/cimi/data/machine.json | 43 ++++++++++++++++++++++++
server/spec/cimi/data/machine.xml | 33 ++++++++++++++++++
server/spec/cimi/model/machine_spec.rb | 35 +++++++++++++++++++
5 files changed, 169 insertions(+), 0 deletions(-)
create mode 100644 server/lib/cimi/model/machine.rb
create mode 100644 server/spec/cimi/data/machine.json
create mode 100644 server/spec/cimi/data/machine.xml
create mode 100644 server/spec/cimi/model/machine_spec.rb
diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb
index c436074..2cdb183 100644
--- a/server/lib/cimi/model.rb
+++ b/server/lib/cimi/model.rb
@@ -25,4 +25,5 @@ require 'cimi/model/base'
require 'cimi/model/machine_template'
require 'cimi/model/machine_image'
require 'cimi/model/machine_configuration'
+require 'cimi/model/machine'
require 'cimi/model/volume'
diff --git a/server/lib/cimi/model/machine.rb b/server/lib/cimi/model/machine.rb
new file mode 100644
index 0000000..932acdf
--- /dev/null
+++ b/server/lib/cimi/model/machine.rb
@@ -0,0 +1,57 @@
+# 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::Machine < CIMI::Model::Base
+
+ text :state
+ text :cpu
+
+ struct :memory do
+ scalar :quantity
+ scalar :units
+ end
+
+ href :event_log
+
+ array :disks do
+ struct :capacity do
+ scalar :quantity
+ scalar :units
+ end
+ scalar :format
+ scalar :attachment_point
+ end
+
+ array :volumes do
+ scalar :href
+ scalar :protocol
+ scalar :attachment_point
+ end
+
+ array :network_interfaces do
+ href :vsp
+ text :hostname, :mac_address, :state, :protocol, :allocation
+ text :address, :default_gateway, :dns, :max_transmission_unit
+ end
+
+ array :meters do
+ scalar :href
+ end
+
+ array :operations do
+ scalar :rel, :href
+ end
+
+end
diff --git a/server/spec/cimi/data/machine.json b/server/spec/cimi/data/machine.json
new file mode 100644
index 0000000..a1df3c3
--- /dev/null
+++ b/server/spec/cimi/data/machine.json
@@ -0,0 +1,43 @@
+{ "uri": "http://cimi.example.org/machines/1",
+ "name": "machine1",
+ "description": "Machine one description",
+ "created": "2011-11-21",
+ "properties": { "owner_id": "mockuser" },
+ "state": "STARTED",
+ "cpu": "4",
+ "memory": { "quantity": "1", "units": "gibibyte" },
+ "disks" : [
+ { "capacity": { "quantity": "1", "units": "terabyte" } }
+ ],
+ "volumes": [{
+ "href": "http://cimi.example.org/volumes/1",
+ "attachmentPoint": "/dev/sda",
+ "protocol": "nfs"
+ }],
+ "networkInterfaces": [{
+ "vsp": { "href": "http://cimi.example.org/vsps/2" },
+ "hostname": "machine1.cimi.example.org",
+ "macAddress": "00:11:22:33:44:56",
+ "state": "UP",
+ "protocol": "TCP",
+ "allocation": "static",
+ "address": "192.168.0.18",
+ "defaultGateway": "192.168.0.1",
+ "dns": "192.168.0.1",
+ "maxTransmissionUnit": "1500"
+ }],
+ "meters": [
+ { "href": "http://cimi.example.org/meters/1" }
+ ],
+ "eventLog": { "href": "http://cimi.example.org/event_logs/1" },
+ "operations": [
+ { "rel": "edit",
+ "href": "http://cimi.example.org/machines/1/edit" },
+ { "rel": "delete",
+ "href": "http://cimi.example.org/machines/1/delete" },
+ { "rel": "http://www.dmtf.org/cimi/action/stop",
+ "href": "http://cimi.example.org/machines/1/stop" },
+ { "rel": "http://www.dmtf.org/cimi/action/restart",
+ "href": "http://cimi.example.org/machines/1/restart" }
+ ]
+}
diff --git a/server/spec/cimi/data/machine.xml b/server/spec/cimi/data/machine.xml
new file mode 100644
index 0000000..ea1c055
--- /dev/null
+++ b/server/spec/cimi/data/machine.xml
@@ -0,0 +1,33 @@
+<Machine xmlns="http://www.dmtf.org/cimi">
+ <uri>http://cimi.example.org/machines/1</uri>
+ <name>machine1</name>
+ <description>Machine one description</description>
+ <created>2011-11-21</created>
+ <property name="owner_id">mockuser</property>
+ <cpu>4</cpu>
+ <memory quantity="1" units="gibibyte"/>
+ <state>STARTED</state>
+ <disk>
+ <capacity quantity="1" units="terabyte"/>
+ </disk>
+ <volume href="http://cimi.example.org/volumes/1"
+ attachmentPoint="/dev/sda" protocol="nfs" />
+ <networkInterface>
+ <vsp href="http://cimi.example.org/vsps/2"/>
+ <hostname>machine1.cimi.example.org</hostname>
+ <macAddress>00:11:22:33:44:56</macAddress>
+ <state>UP</state>
+ <protocol>TCP</protocol>
+ <allocation>static</allocation>
+ <address>192.168.0.18</address>
+ <defaultGateway>192.168.0.1</defaultGateway>
+ <dns>192.168.0.1</dns>
+ <maxTransmissionUnit>1500</maxTransmissionUnit>
+ </networkInterface>
+ <meter href="http://cimi.example.org/meters/1"/>
+ <eventLog href="http://cimi.example.org/event_logs/1"/>
+ <operation rel="edit" href="http://cimi.example.org/machines/1/edit"/>
+ <operation rel="delete" href="http://cimi.example.org/machines/1/delete"/>
+ <operation rel="http://www.dmtf.org/cimi/action/stop" href="http://cimi.example.org/machines/1/stop"/>
+ <operation rel="http://www.dmtf.org/cimi/action/restart" href="http://cimi.example.org/machines/1/restart"/>
+</Machine>
diff --git a/server/spec/cimi/model/machine_spec.rb b/server/spec/cimi/model/machine_spec.rb
new file mode 100644
index 0000000..d50b078
--- /dev/null
+++ b/server/spec/cimi/model/machine_spec.rb
@@ -0,0 +1,35 @@
+# 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 "Machine model" do
+
+ before(:all) do
+ @xml = IO::read(File::join(DATA_DIR, "machine.xml"))
+ @json = IO::read(File::join(DATA_DIR, "machine.json"))
+ end
+
+ it "can be constructed from XML" do
+ machine = CIMI::Model::Machine.from_xml(@xml)
+ machine.should_not be_nil
+ should_serialize_from_xml! machine, @xml, @json
+ end
+
+ it "can be constructed from JSON" do
+ machine = CIMI::Model::Machine.from_json(@json)
+ machine.should_not be_nil
+ should_serialize_from_json! machine, @xml, @json
+ end
+
+end
--
1.7.4.4