deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [7/7] git commit: CIMI: updates CIMI networking models and methods for Deltacloud mock driver
Date Tue, 18 Sep 2012 13:37:28 GMT
CIMI: updates CIMI networking models and methods for Deltacloud mock driver


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

Branch: refs/heads/master
Commit: 80b7ac4b0c3669c0c6d1707d4c15593036fe7f6e
Parents: 47339ac
Author: marios <marios@redhat.com>
Authored: Fri Sep 14 18:38:36 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Tue Sep 18 16:34:36 2012 +0300

----------------------------------------------------------------------
 server/lib/cimi/collections/vsp_configurations.rb  |   49 -------
 server/lib/cimi/collections/vsp_templates.rb       |   51 -------
 server/lib/cimi/collections/vsps.rb                |  109 ---------------
 server/lib/cimi/models.rb                          |   12 +-
 server/lib/cimi/models/vsp.rb                      |  102 --------------
 server/lib/cimi/models/vsp_collection.rb           |   34 -----
 server/lib/cimi/models/vsp_configuration.rb        |   40 ------
 .../cimi/models/vsp_configuration_collection.rb    |   34 -----
 server/lib/cimi/models/vsp_template.rb             |   34 -----
 server/lib/cimi/models/vsp_template_collection.rb  |   34 -----
 .../drivers/mock/data/cimi/vsp/vsp1.json           |   16 --
 .../drivers/mock/data/cimi/vsp/vsp2.json           |   16 --
 .../drivers/mock/data/cimi/vsp/vsp3.json           |   18 ---
 .../drivers/mock/data/cimi/vsp/vsp4.json           |   18 ---
 .../data/cimi/vsp_configuration/vspconfig1.json    |   14 --
 .../data/cimi/vsp_configuration/vspconfig2.json    |   14 --
 .../mock/data/cimi/vsp_template/template1.json     |   10 --
 .../mock/data/cimi/vsp_template/template2.json     |   10 --
 .../drivers/mock/mock_driver_cimi_methods.rb       |   56 +++++---
 19 files changed, 40 insertions(+), 631 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/collections/vsp_configurations.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/vsp_configurations.rb b/server/lib/cimi/collections/vsp_configurations.rb
deleted file mode 100644
index 8a76605..0000000
--- a/server/lib/cimi/collections/vsp_configurations.rb
+++ /dev/null
@@ -1,49 +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.
-
-module CIMI::Collections
-  class VspConfigurations < Base
-
-    set :capability, lambda { |m| driver.respond_to? m }
-
-    collection :vsp_configurations do
-
-      operation :index, :with_capability => :vsp_configurations do
-        description 'List all VSPConfigurations in the VSPConfigurationCollection'
-        param :CIMISelect, :string, :optional
-        control do
-          vsp_configs = VSPConfigurationCollection.default(self).filter_by(params[:CIMISelect])
-          respond_to do |format|
-            format.xml {vsp_configs.to_xml}
-            format.json {vsp_configs.to_json}
-          end
-        end
-      end
-
-      operation :show, :with_capability => :vsp_configuration do
-        description 'Show a specific VSPConfiguration'
-        control do
-          vsp_config = VSPConfiguration.find(params[:id], self)
-          respond_to do |format|
-            format.xml {vsp_config.to_xml}
-            format.json {vsp_config.to_json}
-          end
-        end
-      end
-
-    end
-
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/collections/vsp_templates.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/vsp_templates.rb b/server/lib/cimi/collections/vsp_templates.rb
deleted file mode 100644
index dab7db3..0000000
--- a/server/lib/cimi/collections/vsp_templates.rb
+++ /dev/null
@@ -1,51 +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.
-
-module CIMI::Collections
-  class VspTemplates < Base
-
-    set :capability, lambda { |m| driver.respond_to? m }
-
-    collection :vsp_templates do
-
-      description 'The VSP Template is a set of Configuration values for realizing a VSP.
A VSP Template may be used to create multiple VSPs'
-
-      operation :index, :with_capability => :vsp_templates do
-        description 'List all VSPTemplates in the VSPTemplateCollection'
-        param :CIMISelect, :string, :optional
-        control do
-          vsp_templates = VSPTemplateCollection.default(self).filter_by(params[:CIMISelect])
-          respond_to do |format|
-            format.xml {vsp_templates.to_xml}
-            format.json {vsp_templates.to_json}
-          end
-        end
-      end
-
-      operation :show, :with_capability => :vsp_template do
-        description 'Show a specific VSPTemplate'
-        control do
-          vsp_template = VSPTemplate.find(params[:id], self)
-          respond_to do |format|
-            format.xml {vsp_template.to_xml}
-            format.json {vsp_template.to_json}
-          end
-        end
-      end
-
-    end
-
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/collections/vsps.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/vsps.rb b/server/lib/cimi/collections/vsps.rb
deleted file mode 100644
index 7106c91..0000000
--- a/server/lib/cimi/collections/vsps.rb
+++ /dev/null
@@ -1,109 +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.
-
-module CIMI::Collections
-  class Vsps < Base
-
-    set :capability, lambda { |m| driver.respond_to? m }
-
-    collection :vsps do
-
-      description 'A VSP represents the connection parameters of a network port'
-
-      operation :index, :with_capability => :vsps 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, :with_capability => :vsp do
-        description 'Show a specific VSP'
-        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
-
-      operation :create, :with_capability => :create_vsp do
-        description "Create a new VSP"
-        control do
-          if request.content_type.end_with?("json")
-            vsp = CIMI::Model::VSP.create(request.body.read, self, :json)
-          else
-            vsp = CIMI::Model::VSP.create(request.body.read, self, :xml)
-          end
-          respond_to do |format|
-            format.xml { vsp.to_xml }
-            format.json { vsp.to_json }
-          end
-        end
-      end
-
-      operation :destroy, :with_capability => :delete_vsp do
-        description "Delete a specified VSP"
-        control do
-          CIMI::Model::VSP.delete!(params[:id], self)
-          no_content_with_status(200)
-        end
-      end
-
-      action :start, :with_capability => :start_vsp do
-        description "Start specific VSP."
-        param :id,          :string,    :required
-        control do
-          vsp = VSP.find(params[:id], self)
-          report_error(404) unless vsp
-          if request.content_type.end_with?("json")
-            action = Action.from_json(request.body.read)
-          else
-            action = Action.from_xml(request.body.read)
-          end
-          vsp.perform(action, self) do |operation|
-            no_content_with_status(202) if operation.success?
-            # Handle errors using operation.failure?
-          end
-        end
-      end
-
-      action :stop, :with_capability => :stop_vsp do
-        description "Stop specific VSP."
-        control do
-          vsp = VSP.find(params[:id], self)
-          report_error(404) unless vsp
-          if request.content_type.end_with?("json")
-            action = Action.from_json(request.body.read)
-          else
-            action = Action.from_xml(request.body.read)
-          end
-          vsp.perform(action, self) do |operation|
-            no_content_with_status(202) if operation.success?
-            # Handle errors using operation.failure?
-          end
-        end
-      end
-
-    end
-
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/models.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb
index b447e50..333f5bd 100644
--- a/server/lib/cimi/models.rb
+++ b/server/lib/cimi/models.rb
@@ -54,12 +54,12 @@ require_relative './models/routing_group'
 require_relative './models/routing_group_collection'
 require_relative './models/routing_group_template'
 require_relative './models/routing_group_template_collection'
-require_relative './models/vsp'
-require_relative './models/vsp_collection'
-require_relative './models/vsp_configuration'
-require_relative './models/vsp_configuration_collection'
-require_relative './models/vsp_template'
-require_relative './models/vsp_template_collection'
+require_relative './models/network_port'
+require_relative './models/network_port_collection'
+require_relative './models/network_port_configuration'
+require_relative './models/network_port_configuration_collection'
+require_relative './models/network_port_template'
+require_relative './models/network_port_template_collection'
 require_relative './models/address'
 require_relative './models/address_collection'
 require_relative './models/address_template'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/models/vsp.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp.rb b/server/lib/cimi/models/vsp.rb
deleted file mode 100644
index b8b27f5..0000000
--- a/server/lib/cimi/models/vsp.rb
+++ /dev/null
@@ -1,102 +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::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
-
-  def self.create(request_body, context, type)
-    input = (type == :xml)? XmlSimple.xml_in(request_body, {"ForceArray"=>false, "NormaliseSpace"=>2})
: JSON.parse(request_body)
-    if input["vspTemplate"]["href"] #template by reference
-      vsp_config, network = get_by_reference(input, context)
-    else
-      if input["vspTemplate"]["vspConfig"]["href"] # configuration by reference
-        vsp_config = CIMI::Model::VSPConfiguration.find(context.href_id(input["vspTemplate"]["vspConfig"]["href"],:vsp_configurations),
context)
-      else #configuration by value
-        vsp_config = get_by_value(request_body, type)
-      end
-      network = CIMI::Model::Network.find(context.href_id(input["vspTemplate"]["network"]["href"],
:networks), context)
-    end
-    params = {:vsp_config => vsp_config, :network => network, :name=>input["name"],
:description=>input["description"], :env=>context}
-    raise CIMI::Model::BadRequest.new("Bad request - missing required parameters. Client
sent: #{request_body} which produced #{params.inspect}")  if params.has_value?(nil)
-    context.driver.create_vsp(context.credentials, params)
-  end
-
-  def self.delete!(id, context)
-    context.driver.delete_vsp(context.credentials, id)
-  end
-
-  def perform(action, context, &block)
-    begin
-      if context.driver.send(:"#{action.name}_vsp", context.credentials, self.name)
-        block.callback :success
-      else
-        raise "Operation #{action.name} failed to execute on the VSP #{self.name} "
-      end
-    rescue => e
-      block.callback :failure, e.message
-    end
-  end
-
-
-  private
-
-  def self.get_by_reference(input, context)
-    vsp_template = CIMI::Model::VSPTemplate.find(context.href_id(input["vspTemplate"]["href"],
:vsp_templates), context)
-    vsp_config = CIMI::Model::VSPConfiguration.find(context.href_id(vsp_template.vsp_config.href,
:vsp_configurations), context)
-    network = CIMI::Model::Network.find(context.href_id(vsp_template.network.href, :networks),
context)
-    return vsp_config, network
-  end
-
-  def self.get_by_value(request_body, type)
-    if type == :xml
-      xml_arrays = XmlSimple.xml_in(request_body, {"NormaliseSpace"=>2})
-      vsp_config = CIMI::Model::VSPConfiguration.from_xml(XmlSimple.xml_out(xml_arrays["vspTemplate"][0]["vspConfig"][0]))
-    else
-     json = JSON.parse(request_body)
-      vsp_config = CIMI::Model::VSPConfiguration.from_json(JSON.generate(json["vspTemplate"]["vspConfig"]))
-    end
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/models/vsp_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_collection.rb b/server/lib/cimi/models/vsp_collection.rb
deleted file mode 100644
index fc72024..0000000
--- a/server/lib/cimi/models/vsp_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::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 => CIMI::Model::VSP.all_uri(context)
-    )
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/models/vsp_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_configuration.rb b/server/lib/cimi/models/vsp_configuration.rb
deleted file mode 100644
index c9a9bf3..0000000
--- a/server/lib/cimi/models/vsp_configuration.rb
+++ /dev/null
@@ -1,40 +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::VSPConfiguration < CIMI::Model::Base
-
-  text :bandwidth_reservation
-
-  text :traffic_priority
-
-  text :max_traffic_delay
-
-  text :max_traffic_loss
-
-  text :max_traffic_jitter
-
-  array :operations do
-    scalar :rel, :href
-  end
-
-  def self.find(id, context)
-    if id==:all
-      context.driver.vsp_configurations(context.credentials, {:env=>context})
-    else
-      context.driver.vsp_configurations(context.credentials, {:env=>context, :id=>id})
-    end
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/models/vsp_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_configuration_collection.rb b/server/lib/cimi/models/vsp_configuration_collection.rb
deleted file mode 100644
index d4927e7..0000000
--- a/server/lib/cimi/models/vsp_configuration_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::VSPConfigurationCollection < CIMI::Model::Base
-
-  CIMI::Model.register_as_root_entity! "VSPConfigurations"
-
-  array :vsp_configurations do
-    scalar :href
-  end
-
-  def self.default(context)
-    self.new(
-      :id => context.vsp_configurations_url,
-      :name => 'default',
-      :created => Time.now,
-      :description => "#{context.driver.name.capitalize} VSPConfigurationCollection",
-      :vsp_configurations => CIMI::Model::VSPConfiguration.all_uri(context)
-    )
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/models/vsp_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_template.rb b/server/lib/cimi/models/vsp_template.rb
deleted file mode 100644
index f1b8078..0000000
--- a/server/lib/cimi/models/vsp_template.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::VSPTemplate < CIMI::Model::Base
-
-  href :network
-
-  href :vsp_config
-
-  array :operations do
-    scalar :rel, :href
-  end
-
-  def self.find(id, context)
-    if id==:all
-      context.driver.vsp_templates(context.credentials, {:env=>context})
-    else
-      context.driver.vsp_templates(context.credentials, {:env=>context, :id=>id})
-    end
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/cimi/models/vsp_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/vsp_template_collection.rb b/server/lib/cimi/models/vsp_template_collection.rb
deleted file mode 100644
index 61d5311..0000000
--- a/server/lib/cimi/models/vsp_template_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::VSPTemplateCollection < CIMI::Model::Base
-
-  CIMI::Model.register_as_root_entity! "VSPTemplates"
-
-  array :vsp_templates do
-    scalar :href
-  end
-
-  def self.default(context)
-    self.new(
-      :id => context.vsp_templates_url,
-      :name => 'default',
-      :created => Time.now,
-      :description => "#{context.driver.name.capitalize} VSPTemplateCollection",
-      :vsp_templates => CIMI::Model::VSPTemplate.all_uri(context)
-    )
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp1.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp1.json
deleted file mode 100644
index 191ed4e..0000000
--- a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp1.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{ "id": "http://cimi.example.org/vsps/vsp1",
-  "name": "vsp1",
-  "description": "a mock switchport",
-  "created": "Fri Mar 16 17:06:41 EET 2012",
-  "state": "STARTED",
-  "network": {"href": "http://cimi.example.org/networks/network1"},
-  "bandwidthReservation": 0.5,
-  "trafficPriority": 1,
-  "maxTrafficDelay": 500000,
-  "maxTrafficLoss": 100,
-  "maxTrafficJitter": 100000,
-  "operations": [
-    { "rel": "edit", "href": "http://cimi.example.org/vsps/vsp1" },
-    { "rel": "delete", "href": "http://cimi.example.org/vsps/vsp1" }
-  ]
-}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp2.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp2.json
deleted file mode 100644
index 4173f0c..0000000
--- a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp2.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{ "id": "http://cimi.example.org/vsps/vsp2",
-  "name": "vsp2",
-  "description": "a mock switchport",
-  "created": "Fri Mar 16 17:09:27 EET 2012",
-  "state": "STARTED",
-  "network": {"href": "http://cimi.example.org/networks/network1"},
-  "bandwidthReservation": 0.5,
-  "trafficPriority": 1,
-  "maxTrafficDelay": 500000,
-  "maxTrafficLoss": 100,
-  "maxTrafficJitter": 100000,
-  "operations": [
-    { "rel": "edit", "href": "http://cimi.example.org/vsps/vsp2" },
-    { "rel": "delete", "href": "http://cimi.example.org/vsps/vsp2" }
-  ]
-}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp3.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp3.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp3.json
deleted file mode 100644
index b7f9cf5..0000000
--- a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp3.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{ "id": "http://cimi.example.org/vsps/vsp3",
-  "name": "vsp3",
-  "description": "a mock switchport",
-  "created": "Fri Mar 16 17:10:36 EET 2012",
-  "state": "STARTED",
-  "network": {"href": "http://cimi.example.org/networks/network2"},
-  "bandwidthReservation": 1,
-  "trafficPriority": 1,
-  "maxTrafficDelay": 500000,
-  "maxTrafficLoss": 100,
-  "maxTrafficJitter": 100000,
-  "operations": [
-    { "rel": "edit", "href": "http://cimi.example.org/vsps/vsp3" },
-    { "rel": "delete", "href": "http://cimi.example.org/vsps/vsp3" }
-  ]
-}
-
-

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp4.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp4.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp4.json
deleted file mode 100644
index 33fcbf8..0000000
--- a/server/lib/deltacloud/drivers/mock/data/cimi/vsp/vsp4.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{ "id": "http://cimi.example.org/vsps/vsp4",
-  "name": "vsp4",
-  "description": "a mock switchport",
-  "created": "Fri Mar 16 17:10:36 EET 2012",
-  "state": "STARTED",
-  "network": {"href": "http://cimi.example.org/networks/network2"},
-  "bandwidthReservation": 1,
-  "trafficPriority": 1,
-  "maxTrafficDelay": 500000,
-  "maxTrafficLoss": 100,
-  "maxTrafficJitter": 100000,
-  "operations": [
-    { "rel": "edit", "href": "http://cimi.example.org/vsps/vsp4" },
-    { "rel": "delete", "href": "http://cimi.example.org/vsps/vsp4" }
-  ]
-}
-
-

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_configuration/vspconfig1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_configuration/vspconfig1.json
b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_configuration/vspconfig1.json
deleted file mode 100644
index f43bd62..0000000
--- a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_configuration/vspconfig1.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{ "id": "http://cimi.example.org/vsp_configurations/vspconfig1",
-  "name": "vspconfig1",
-  "description": "a mock vsp configuration",
-  "created": "Fri Mar 16 18:39:41 EET 2012",
-  "bandwidthReservation": 0.5,
-  "trafficPriority": 1,
-  "maxTrafficDelay": 500000,
-  "maxTrafficLoss": 100,
-  "maxTrafficJitter": 100000,
-  "operations": [
-    { "rel": "edit", "href": "http://cimi.example.org/vsp_configurations/vspconfig1" },
-    { "rel": "delete", "href": "http://cimi.example.org/vsp_configurations/vspconfig1" }
-  ]
-}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_configuration/vspconfig2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_configuration/vspconfig2.json
b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_configuration/vspconfig2.json
deleted file mode 100644
index 1910259..0000000
--- a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_configuration/vspconfig2.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{ "id": "http://cimi.example.org/vsp_configurations/vspconfig2",
-  "name": "vspconfig2",
-  "description": "a mock vsp configuration",
-  "created": "Fri Mar 16 18:41:41 EET 2012",
-  "bandwidthReservation": 1,
-  "trafficPriority": 1,
-  "maxTrafficDelay": 500000,
-  "maxTrafficLoss": 100,
-  "maxTrafficJitter": 100000,
-  "operations": [
-    { "rel": "edit", "href": "http://cimi.example.org/vsp_configurations/vspconfig2" },
-    { "rel": "delete", "href": "http://cimi.example.org/vsp_configurations/vspconfig2" }
-  ]
-}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template1.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template1.json
deleted file mode 100644
index 5df8fdd..0000000
--- a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template1.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{ "id": "http://cimi.example.org/vsp_templates/template1",
-  "name": "template1",
-  "description": "A mock VSP template",
-  "created": "Fri Mar 16 19:26:41 EET 2012",
-  "network": { "href": "http://cimi.example.org/networks/network1"},
-  "vspConfig": { "href": "http://cimi.example.org/vsp_configs/vspconfig1"},
-  "operations": [
-    { "rel": "edit", "href": "http://cimi.example.org/vsp_templates/template1" },
-    { "rel": "delete", "href": "http://cimi.example.org/vsp_templates/template1" }]
-}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template2.json b/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template2.json
deleted file mode 100644
index cc17c1b..0000000
--- a/server/lib/deltacloud/drivers/mock/data/cimi/vsp_template/template2.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{ "id": "http://cimi.example.org/vsp_templates/template2",
-  "name": "template2",
-  "description": "A mock VSP template",
-  "created": "Fri Mar 16 19:26:41 EET 2012",
-  "network": { "href": "http://cimi.example.org/networks/network2"},
-  "vspConfig": { "href": "http://cimi.example.org/vsp_configs/vspconfig2"},
-  "operations": [
-    { "rel": "edit", "href": "http://cimi.example.org/vsp_templates/template2" },
-    { "rel": "delete", "href": "http://cimi.example.org/vsp_templates/template2" }]
-}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/80b7ac4b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
index bebc45c..3431e51 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -20,7 +20,6 @@
 module Deltacloud::Drivers::Mock
 
   class MockDriver < Deltacloud::BaseDriver
-
     def networks(credentials, opts={})
       check_credentials(credentials)
       if opts[:id].nil?
@@ -76,36 +75,36 @@ module Deltacloud::Drivers::Mock
       end
     end
 
-    def vsps(credentials, opts={})
+    def network_ports(credentials, opts={})
       check_credentials(credentials)
       if opts[:id].nil?
-        vsps = @client.load_all_cimi(:vsp).map{|vsp| CIMI::Model::VSP.from_json(vsp)}
-        vsps.map{|vsp|convert_cimi_mock_urls(:vsp, vsp, opts[:env])}.flatten
+        ports = @client.load_all_cimi(:network_port).map{|net_port| CIMI::Model::NetworkPort.from_json(net_port)}
+        ports.map{|net_port|convert_cimi_mock_urls(:network_port, net_port, opts[:env])}.flatten
       else
-        vsp = CIMI::Model::VSP.from_json(@client.load_cimi(:vsp, opts[:id]))
-        convert_cimi_mock_urls(:vsp, vsp, opts[:env])
+        port = CIMI::Model::NetworkPort.from_json(@client.load_cimi(:network_port, opts[:id]))
+        convert_cimi_mock_urls(:network_port, port, opts[:env])
       end
     end
 
-    def vsp_configurations(credentials, opts={})
+    def network_port_configurations(credentials, opts={})
       check_credentials(credentials)
       if opts[:id].nil?
-        vsp_configurations = @client.load_all_cimi(:vsp_configuration).map{|vsp_config| CIMI::Model::VSPConfiguration.from_json(vsp_config)}
-        vsp_configurations.map{|vsp_config|convert_cimi_mock_urls(:vsp_configuration, vsp_config,
opts[:env])}.flatten
+        network_port_configurations = @client.load_all_cimi(:network_port_configuration).map{|network_port_config|
CIMI::Model::NetworkPortConfiguration.from_json(network_port_config)}
+        network_port_configurations.map{|network_port_config|convert_cimi_mock_urls(:network_port_configuration,
network_port_config, opts[:env])}.flatten
       else
-        vsp_configuration = CIMI::Model::VSPConfiguration.from_json(@client.load_cimi(:vsp_configuration,
opts[:id]))
-        convert_cimi_mock_urls(:vsp_configuration, vsp_configuration, opts[:env])
+        network_port_configuration = CIMI::Model::NetworkPortConfiguration.from_json(@client.load_cimi(:network_port_configuration,
opts[:id]))
+        convert_cimi_mock_urls(:network_port_configuration, network_port_configuration, opts[:env])
       end
     end
 
-    def vsp_templates(credentials, opts={})
+    def network_port_templates(credentials, opts={})
       check_credentials(credentials)
       if opts[:id].nil?
-        vsp_templates = @client.load_all_cimi(:vsp_template).map{|vsp_templ| CIMI::Model::VSPTemplate.from_json(vsp_templ)}
-        vsp_templates.map{|vsp_templ|convert_cimi_mock_urls(:vsp_template, vsp_templ, opts[:env])}.flatten
+        network_port_templates = @client.load_all_cimi(:network_port_template).map{|net_port_templ|
CIMI::Model::NetworkPortTemplate.from_json(net_port_templ)}
+        network_port_templates.map{|net_port_templ|convert_cimi_mock_urls(:network_port_template,
net_port_templ, opts[:env])}.flatten
       else
-        vsp_template = CIMI::Model::VSPTemplate.from_json(@client.load_cimi(:vsp_template,
opts[:id]))
-        convert_cimi_mock_urls(:vsp_template, vsp_template, opts[:env])
+        network_port_template = CIMI::Model::NetworkPortTemplate.from_json(@client.load_cimi(:network_port_template,
opts[:id]))
+        convert_cimi_mock_urls(:network_port_template, network_port_template, opts[:env])
       end
     end
 
@@ -120,7 +119,11 @@ module Deltacloud::Drivers::Mock
                 convert_struct_urls(item, k.to_s.singularize.to_sym, context)
               end
             else
-              convert_struct_urls(v, k, context)
+              opts = nil
+              if is_subcollection?(v, cimi_object.id)
+                opts = {:parent_model_name => model_name, :parent_item_name => cimi_object.name}
+              end
+              convert_struct_urls(v, k, context, opts)
             end
         end
       end
@@ -130,13 +133,22 @@ module Deltacloud::Drivers::Mock
       cimi_object
     end
 
-    def convert_struct_urls(struct, cimi_name, context)
+    def is_subcollection?(struct, cimi_object_id)
+      return false if struct.href.nil?
+      struct.href.include?(cimi_object_id)
+    end
+
+    def convert_struct_urls(struct, cimi_name, context, opts = nil)
       return unless (struct.respond_to?(:href) && (not struct.href.nil?) &&
(not cimi_name == :operation ))
-      obj_name = struct.href.split("/").last
-      if cimi_name.to_s.end_with?("config")
-        struct.href = context.send(:"#{cimi_name}uration_url", obj_name)
+      if opts
+        struct.href = context.send(:"#{opts[:parent_model_name]}_url", opts[:parent_item_name])
+ "/#{cimi_name}"
       else
-        struct.href = context.send(:"#{cimi_name}_url", obj_name)
+        obj_name = struct.href.split("/").last
+        if cimi_name.to_s.end_with?("config")
+          struct.href = context.send(:"#{cimi_name}uration_url", obj_name)
+        else
+          struct.href = context.send(:"#{cimi_name}_url", obj_name)
+        end
       end
     end
 


Mime
View raw message