deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [1/7] git commit: CIMI: use embedded collection for Machine.disks and Machine.volumes
Date Thu, 11 Oct 2012 08:33:28 GMT
Updated Branches:
  refs/heads/master bbfb5ff8f -> 8592f692a


CIMI: use embedded collection for Machine.disks and Machine.volumes

TrackedAt: http://tracker.deltacloud.org/patch/c890e637da2e16600fd3423c7df929aab8845c17


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

Branch: refs/heads/master
Commit: 8592f692a90a5efe6260abc7bce862e8b4415984
Parents: 01feb53
Author: David Lutterkort <lutter@redhat.com>
Authored: Fri Oct 5 17:40:38 2012 -0700
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Thu Oct 11 10:31:09 2012 +0200

----------------------------------------------------------------------
 server/lib/cimi/models.rb                          |    2 -
 server/lib/cimi/models/disk_collection.rb          |   37 ---------------
 server/lib/cimi/models/machine.rb                  |   13 ++---
 .../lib/cimi/models/machine_volume_collection.rb   |   34 -------------
 server/tests/cimi/spec/cimi/data/machine.json      |    1 -
 server/tests/cimi/spec/cimi/data/machine.xml       |    1 -
 6 files changed, 5 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8592f692/server/lib/cimi/models.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb
index df328f5..1eae2c9 100644
--- a/server/lib/cimi/models.rb
+++ b/server/lib/cimi/models.rb
@@ -25,9 +25,7 @@ require_relative './models/collection'
 require_relative './models/errors'
 require_relative './models/action'
 require_relative './models/disk'
-require_relative './models/disk_collection'
 require_relative './models/machine_volume'
-require_relative './models/machine_volume_collection'
 
 # Toplevel entities; order matters as it determines the order
 # in which the entities appear in the CEP

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8592f692/server/lib/cimi/models/disk_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/disk_collection.rb b/server/lib/cimi/models/disk_collection.rb
deleted file mode 100644
index 7dbff39..0000000
--- a/server/lib/cimi/models/disk_collection.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# 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::DiskCollection < CIMI::Model::Base
-  text :count
-
-  #add disks array:
-  self << CIMI::Model::Disk
-
-  array :operations do
-    scalar :rel, :href
-  end
-
-  def self.default(instance_id, context)
-    instance = context.driver.instance(context.credentials, :id=>instance_id)
-    machine_conf = CIMI::Model::MachineConfiguration.find(instance.instance_profile.name,
context)
-    disks = CIMI::Model::Disk.find(instance, machine_conf, context, :all)
-    self.new(
-      :id => context.machine_url(instance_id)+"/disks",
-      :description => "DiskCollection for Machine #{instance_id}",
-      :created => instance.launch_time,
-      :count => disks.size,
-      :disks => disks
-    )
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8592f692/server/lib/cimi/models/machine.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine.rb b/server/lib/cimi/models/machine.rb
index c605d2a..a15fa81 100644
--- a/server/lib/cimi/models/machine.rb
+++ b/server/lib/cimi/models/machine.rb
@@ -24,11 +24,8 @@ class CIMI::Model::Machine < CIMI::Model::Base
 
   href :event_log
 
-  href :disks
-
-  href :volumes
-
-  href :network_interfaces
+  collection :disks, :class => CIMI::Model::Disk
+  collection :volumes, :class => CIMI::Model::MachineVolume
 
   array :meters do
     scalar :href
@@ -118,6 +115,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
   private
   def self.from_instance(instance, context)
     cpu =  memory = (instance.instance_profile.id == "opaque")? "n/a" : nil
+    machine_conf = CIMI::Model::MachineConfiguration.find(instance.instance_profile.name,
context)
     self.new(
       :name => instance.id,
       :description => instance.name,
@@ -126,10 +124,9 @@ class CIMI::Model::Machine < CIMI::Model::Base
       :state => convert_instance_state(instance.state),
       :cpu => cpu || convert_instance_cpu(instance.instance_profile, context),
       :memory => memory || convert_instance_memory(instance.instance_profile, context),
-      :disks => {:href => context.machine_url(instance.id)+"/disks"},
-      :network_interfaces => {:href => context.machine_url(instance.id+"/network_interfaces")},
+      :disks => CIMI::Model::Disk.find(instance, machine_conf, context, :all),
       :operations => convert_instance_actions(instance, context),
-      :volumes=>{:href=>context.machine_url(instance.id)+"/volumes"},
+      :volumes => CIMI::Model::MachineVolume.find(instance.id, context, :all),
       :property => convert_instance_properties(instance, context)
     )
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8592f692/server/lib/cimi/models/machine_volume_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/machine_volume_collection.rb b/server/lib/cimi/models/machine_volume_collection.rb
deleted file mode 100644
index b9dfcad..0000000
--- a/server/lib/cimi/models/machine_volume_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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::MachineVolumeCollection < CIMI::Model::Base
-
-  text :count
-
-  self << CIMI::Model::MachineVolume
-
-  array :operations do
-    scalar :rel, :href
-  end
-
-  def self.default(instance_id, context)
-    volumes = CIMI::Model::MachineVolume.find(instance_id, context)
-    self.new(
-      :id => context.machine_url(instance_id)+"/volumes",
-      :description => "MachineVolumeCollection for Machine #{instance_id}",
-      :count => volumes.size,
-      :machine_volumes => volumes
-    )
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8592f692/server/tests/cimi/spec/cimi/data/machine.json
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/data/machine.json b/server/tests/cimi/spec/cimi/data/machine.json
index 3b1a574..bf9c464 100644
--- a/server/tests/cimi/spec/cimi/data/machine.json
+++ b/server/tests/cimi/spec/cimi/data/machine.json
@@ -8,7 +8,6 @@
   "memory":12582912,
   "disks":{"href":"http://cimi.example.org/cimi/machines/1/disks"},
   "volumes":{"href":"http://cimi.example.org/cimi/machines/1/volumes"},
-  "networkInterfaces":{"href":"http://cimi.example.org/cimi/machines/1/network_interfaces"},
   "meters": [
     { "href": "http://cimi.example.org/meters/1" }
   ],

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8592f692/server/tests/cimi/spec/cimi/data/machine.xml
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/data/machine.xml b/server/tests/cimi/spec/cimi/data/machine.xml
index 163c272..503abfe 100644
--- a/server/tests/cimi/spec/cimi/data/machine.xml
+++ b/server/tests/cimi/spec/cimi/data/machine.xml
@@ -8,7 +8,6 @@
   <memory>12582912</memory>
   <disks href="http://cimi.example.org/cimi/machines/1/disks" />
   <volumes href="http://cimi.example.org/cimi/machines/1/volumes" />
-  <networkInterfaces href="http://cimi.example.org/cimi/machines/1/network_interfaces"
/>
   <state>STARTED</state>
   <meter href="http://cimi.example.org/meters/1"/>
   <eventLog href="http://cimi.example.org/event_logs/1"/>


Mime
View raw message