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 2012/03/16 18:35:00 UTC

[PATCH 3/9] CIMI: Adds VSP and Collection to CIMI server

From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/cimi/model.rb                |    2 +
 server/lib/cimi/model/vsp.rb            |   50 +++++++++++++++++++++++++++++++
 server/lib/cimi/model/vsp_collection.rb |   34 +++++++++++++++++++++
 server/lib/cimi/server.rb               |   29 ++++++++++++++++++
 4 files changed, 115 insertions(+), 0 deletions(-)
 create mode 100644 server/lib/cimi/model/vsp.rb
 create mode 100644 server/lib/cimi/model/vsp_collection.rb

diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb
index 132ae6a..6f19673 100644
--- a/server/lib/cimi/model.rb
+++ b/server/lib/cimi/model.rb
@@ -55,3 +55,5 @@ require 'cimi/model/routing_group'
 require 'cimi/model/routing_group_collection'
 require 'cimi/model/routing_group_template'
 require 'cimi/model/routing_group_template_collection'
+require 'cimi/model/vsp'
+require 'cimi/model/vsp_collection'
diff --git a/server/lib/cimi/model/vsp.rb b/server/lib/cimi/model/vsp.rb
new file mode 100644
index 0000000..33e5d5b
--- /dev/null
+++ b/server/lib/cimi/model/vsp.rb
@@ -0,0 +1,50 @@
+# 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::VSP < CIMI::Model::Base
+
+  text :state
+
+  href :network
+
+  text :bandwidth_reservation
+
+  text :traffic_priority
+
+  text :max_traffic_delay
+
+  text :max_traffic_loss
+
+  text :max_traffic_jitter
+
+  href :event_log
+
+  array :meters do
+    scalar :href
+  end
+
+  array :operations do
+    scalar :rel, :href
+  end
+
+  def self.find(id, context)
+    if id==:all
+      context.driver.vsps(context.credentials, {:env=>context})
+    else
+      context.driver.vsps(context.credentials, {:id=>id, :env=>context})
+    end
+  end
+
+end
diff --git a/server/lib/cimi/model/vsp_collection.rb b/server/lib/cimi/model/vsp_collection.rb
new file mode 100644
index 0000000..6f659e1
--- /dev/null
+++ b/server/lib/cimi/model/vsp_collection.rb
@@ -0,0 +1,34 @@
+# 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::VSPCollection < CIMI::Model::Base
+
+  CIMI::Model.register_as_root_entity! "VSPs"
+
+  array :vsps do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.vsps_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} VSPCollection",
+      :vsps => VSP.all_uri(context)
+    )
+  end
+
+end
diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
index 9f541d0..308d922 100644
--- a/server/lib/cimi/server.rb
+++ b/server/lib/cimi/server.rb
@@ -668,3 +668,32 @@ global_collection :routing_group_templates do
 end
 
 
+global_collection :vsps do
+
+  description 'A VSP represents the connection parameters of a network port'
+
+  operation :index do
+    description 'List all VSPs in the VSPCollection'
+    param :CIMISelect, :string, :optional
+    control do
+      vsps = VSPCollection.default(self).filter_by(params[:CIMISelect])
+      respond_to do |format|
+        format.xml {vsps.to_xml}
+        format.json {vsps.to_json}
+      end
+    end
+  end
+
+  operation :show do
+    description 'Show a specific VSP'
+    param :id, :string, :required
+    control do
+      vsp = VSP.find(params[:id], self)
+      respond_to do |format|
+        format.xml {vsp.to_xml}
+        format.json {vsp.to_json}
+      end
+    end
+  end
+
+end
-- 
1.7.6.5