deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [5/12] git commit: CIMI models: add a MachineCreate model
Date Fri, 22 Feb 2013 10:32:24 GMT
CIMI models: add a MachineCreate model


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/91e0b38e
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/91e0b38e
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/91e0b38e

Branch: refs/heads/master
Commit: 91e0b38ee1f78b16a3f33660cdd039259a9ec236
Parents: 6646a7e
Author: David Lutterkort <lutter@redhat.com>
Authored: Sat Feb 9 21:54:36 2013 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Thu Feb 21 15:31:31 2013 +0100

----------------------------------------------------------------------
 server/lib/cimi/models.rb                      |    1 +
 server/lib/cimi/models/machine_create.rb       |   18 ++++++++
 server/tests/cimi/model/machine_create_spec.rb |   44 +++++++++++++++++++
 3 files changed, 63 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/91e0b38e/server/lib/cimi/models.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb
index 8e27537..8b8512a 100644
--- a/server/lib/cimi/models.rb
+++ b/server/lib/cimi/models.rb
@@ -69,6 +69,7 @@ require_relative './models/machine'
 require_relative './models/machine_configuration'
 require_relative './models/machine_image'
 require_relative './models/machine_template'
+require_relative './models/machine_create'
 require_relative './models/network_port'
 require_relative './models/network'
 require_relative './models/network_template'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/91e0b38e/server/lib/cimi/models/machine_create.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_create.rb b/server/lib/cimi/models/machine_create.rb
new file mode 100644
index 0000000..8f9fc89
--- /dev/null
+++ b/server/lib/cimi/models/machine_create.rb
@@ -0,0 +1,18 @@
+# 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::MachineCreate < CIMI::Model::Base
+  ref :machine_template
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/91e0b38e/server/tests/cimi/model/machine_create_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/model/machine_create_spec.rb b/server/tests/cimi/model/machine_create_spec.rb
new file mode 100644
index 0000000..7070bd8
--- /dev/null
+++ b/server/tests/cimi/model/machine_create_spec.rb
@@ -0,0 +1,44 @@
+# 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.
+#
+require 'rubygems'
+require 'require_relative' if RUBY_VERSION < '1.9'
+
+require_relative '../spec_helper.rb' if require 'minitest/autorun'
+
+describe "MachineCreate model" do
+
+  before do
+    @xml = read_data_file("machine_create_by_value.xml")
+  end
+
+  it "can be constructed from XML with template by value" do
+    mc = CIMI::Model::MachineCreate.from_xml(@xml)
+    mc.name.must_equal "xml_machine_by_value"
+    mt = mc.machine_template
+    mt.wont_be_nil
+    mt.href.must_be_nil
+    mt.machine_config.href.wont_be_nil
+  end
+
+  it "can be built in code" do
+    mc = CIMI::Model::MachineCreate.new(:name => "from_code")
+    mc.machine_template.href = "/mts/1"
+    mc.machine_template.machine_config.cpu = 42
+    json = JSON::parse(mc.to_json)
+    json["machineTemplate"]["href"].must_equal "/mts/1"
+    json["machineTemplate"]["machineConfig"]["cpu"].must_equal 42
+  end
+end


Mime
View raw message