deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dko...@apache.org
Subject git commit: CIMI: expose import and export of systems and system templates for drivers that support these operations
Date Mon, 03 Jun 2013 11:33:37 GMT
Updated Branches:
  refs/heads/master 7ebb6808b -> d58981fba


CIMI: expose import and export of systems and system templates
for drivers that support these operations


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

Branch: refs/heads/master
Commit: d58981fbad95342bc4938773bd94880854dd94aa
Parents: 7ebb680
Author: Dies Koper <diesk@fast.au.fujitsu.com>
Authored: Tue May 21 20:56:56 2013 +1000
Committer: Dies Koper <diesk@fast.au.fujitsu.com>
Committed: Mon Jun 3 21:29:02 2013 +1000

----------------------------------------------------------------------
 server/lib/cimi/collections/machines.rb            |    2 +-
 server/lib/cimi/collections/system_templates.rb    |   19 ++++
 server/lib/cimi/collections/systems.rb             |   19 ++++
 server/lib/cimi/helpers/cimi_helper.rb             |    4 +-
 server/lib/cimi/helpers/cimi_rabbit_helper.rb      |    4 +-
 server/lib/cimi/models.rb                          |    4 +
 server/lib/cimi/models/collection.rb               |    4 +
 server/lib/cimi/models/system_export.rb            |   21 +++++
 server/lib/cimi/models/system_import.rb            |   20 ++++
 server/lib/cimi/models/system_template_export.rb   |   21 +++++
 server/lib/cimi/models/system_template_import.rb   |   20 ++++
 server/lib/cimi/service.rb                         |    4 +
 server/lib/cimi/service/base.rb                    |   11 +++
 server/lib/cimi/service/system_export.rb           |   29 ++++++
 server/lib/cimi/service/system_import.rb           |   27 ++++++
 server/lib/cimi/service/system_template_export.rb  |   29 ++++++
 server/lib/cimi/service/system_template_import.rb  |   27 ++++++
 .../drivers/mock/data/cimi/system/system1.json     |    1 +
 .../drivers/mock/data/cimi/system/system2.json     |    1 +
 .../mock/data/cimi/system_template/template1.json  |    1 +
 .../drivers/mock/mock_driver_cimi_methods.rb       |   69 +++++++++++++++
 21 files changed, 332 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/collections/machines.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/machines.rb b/server/lib/cimi/collections/machines.rb
index 0892604..be1abd5 100644
--- a/server/lib/cimi/collections/machines.rb
+++ b/server/lib/cimi/collections/machines.rb
@@ -127,7 +127,7 @@ module CIMI::Collections
             volume_to_attach, location = MachineVolume.find_to_attach_from_xml(request.body.read,
self)
           end
           machine_volume = Machine.attach_volume(volume_to_attach,location, self)
-          headers_for_create machine_volume
+          header_for_location machine_volume.id
           respond_to do |format|
             format.json{ machine_volume.to_json}
             format.xml{machine_volume.to_xml}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/collections/system_templates.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/system_templates.rb b/server/lib/cimi/collections/system_templates.rb
index d7e51f6..a2b2564 100644
--- a/server/lib/cimi/collections/system_templates.rb
+++ b/server/lib/cimi/collections/system_templates.rb
@@ -18,6 +18,11 @@ module CIMI::Collections
 
     set :capability, lambda { |m| driver.respond_to? m }
 
+    post '/system_templates/import' do
+      CIMI::Service::SystemTemplateImport.parse(self).import
+      no_content_with_status(202)
+    end
+
     collection :system_templates do
 
       generate_index_operation :with_capability => :system_templates
@@ -25,6 +30,20 @@ module CIMI::Collections
       generate_create_operation :with_capability => :create_system_template
       generate_delete_operation :with_capability => :destroy_system_template
 
+      action :export, :with_capability => :export_system_template do
+        description "Export specific system template."
+        param :id,          :string,    :required
+        control do
+          location = CIMI::Service::SystemTemplateExport.parse(self).export(params[:id])
+          if location
+            header_for_location(location)
+          else
+            no_content_with_status(202)
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
     end
 
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/collections/systems.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/systems.rb b/server/lib/cimi/collections/systems.rb
index e11ed88..db8fe68 100644
--- a/server/lib/cimi/collections/systems.rb
+++ b/server/lib/cimi/collections/systems.rb
@@ -18,6 +18,11 @@ module CIMI::Collections
 
     set :capability, lambda { |m| driver.respond_to? m }
 
+    post '/systems/import' do
+      CIMI::Service::SystemImport.parse(self).import
+      no_content_with_status(202)
+    end
+
     collection :systems do
       description 'List all systems'
 
@@ -91,6 +96,20 @@ module CIMI::Collections
         end
       end
 
+      action :export, :with_capability => :export_system do
+        description "Export specific system."
+        param :id,          :string,    :required
+        control do
+          location = CIMI::Service::SystemExport.parse(self).export(params[:id])
+          if location
+            header_for_location(location)
+          else
+            no_content_with_status(202)
+            # Handle errors using operation.failure?
+          end
+        end
+      end
+
       collection :systems, :with_id => :ent_id do
         description 'List system\'s systems'
         generate_system_subcollection_index_operation :with_capability => :system_systems

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/helpers/cimi_helper.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/helpers/cimi_helper.rb b/server/lib/cimi/helpers/cimi_helper.rb
index 6d9403e..6e37bdd 100644
--- a/server/lib/cimi/helpers/cimi_helper.rb
+++ b/server/lib/cimi/helpers/cimi_helper.rb
@@ -39,9 +39,9 @@ module CIMI
     end
 
     # Set status to 201 and a Location header
-    def headers_for_create(resource)
+    def header_for_location(location)
       status 201
-      headers 'Location' => resource.id
+      headers 'Location' => location
     end
 
     def href_id(href, entity)

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/helpers/cimi_rabbit_helper.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/helpers/cimi_rabbit_helper.rb b/server/lib/cimi/helpers/cimi_rabbit_helper.rb
index 0661bf6..a2c1f4b 100644
--- a/server/lib/cimi/helpers/cimi_rabbit_helper.rb
+++ b/server/lib/cimi/helpers/cimi_rabbit_helper.rb
@@ -18,7 +18,7 @@ module CIMI
         description "Create new #{collection_name} entity"
         control do
           ent = CIMI::Service.const_get("#{collection_name}Create").parse(self).create
-          headers_for_create ent
+          header_for_location ent.id
           respond_to do |format|
             format.json { ent.to_json }
             format.xml { ent.to_xml }
@@ -72,7 +72,7 @@ module CIMI
         description "Add specified #{collection_name} entity to System"
         control do
           ent = CIMI::Service.const_get("#{collection_name}Create").parse(params[:id], self).create
-          headers_for_create ent
+          header_for_location ent.id
           respond_to do |format|
             format.json { ent.to_json }
             format.xml { ent.to_xml }

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/models.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb
index 28370b4..26c90e5 100644
--- a/server/lib/cimi/models.rb
+++ b/server/lib/cimi/models.rb
@@ -78,6 +78,8 @@ require_relative './models/forwarding_group_template'
 require_relative './models/network_template'
 require_relative './models/network_create'
 require_relative './models/system_template'
+require_relative './models/system_template_import'
+require_relative './models/system_template_export'
 require_relative './models/system_network_port'
 require_relative './models/system_network'
 require_relative './models/system_address'
@@ -88,4 +90,6 @@ require_relative './models/system_credential'
 require_relative './models/system_system'
 require_relative './models/system'
 require_relative './models/system_create'
+require_relative './models/system_import'
+require_relative './models/system_export'
 require_relative './models/cloud_entry_point_collections'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/models/collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/collection.rb b/server/lib/cimi/models/collection.rb
index ac2ad37..d497823 100644
--- a/server/lib/cimi/models/collection.rb
+++ b/server/lib/cimi/models/collection.rb
@@ -130,6 +130,10 @@ module CIMI::Model
         params[:operations] ||= []
         params[:operations] << { :rel => "add", :href => params.delete(:add_url)
}
       end
+      if params[:import_url]
+        params[:operations] ||= []
+        params[:operations] << { :rel => "http://schemas.dmtf.org/cimi/1/action/import",
:href => params.delete(:import_url) }
+      end
       collection_class.new(params)
     end
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/models/system_export.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_export.rb b/server/lib/cimi/models/system_export.rb
new file mode 100644
index 0000000..e8d7600
--- /dev/null
+++ b/server/lib/cimi/models/system_export.rb
@@ -0,0 +1,21 @@
+# 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::SystemExport < CIMI::Model::Base
+
+  text :format, :required => false
+  text :destination, :required => false
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/models/system_import.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_import.rb b/server/lib/cimi/models/system_import.rb
new file mode 100644
index 0000000..29f41a6
--- /dev/null
+++ b/server/lib/cimi/models/system_import.rb
@@ -0,0 +1,20 @@
+# 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::SystemImport < CIMI::Model::Base
+
+  text :source, :required => true
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/models/system_template_export.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_template_export.rb b/server/lib/cimi/models/system_template_export.rb
new file mode 100644
index 0000000..42a2865
--- /dev/null
+++ b/server/lib/cimi/models/system_template_export.rb
@@ -0,0 +1,21 @@
+# 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::SystemTemplateExport < CIMI::Model::Base
+
+  text :format, :required => false
+  text :destination, :required => false
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/models/system_template_import.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/system_template_import.rb b/server/lib/cimi/models/system_template_import.rb
new file mode 100644
index 0000000..dd5aab2
--- /dev/null
+++ b/server/lib/cimi/models/system_template_import.rb
@@ -0,0 +1,20 @@
+# 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::SystemTemplateImport < CIMI::Model::Base
+
+  text :source, :required => true
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/service.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service.rb b/server/lib/cimi/service.rb
index c3473f5..ed75309 100644
--- a/server/lib/cimi/service.rb
+++ b/server/lib/cimi/service.rb
@@ -27,6 +27,8 @@ require_relative './service/machine'
 require_relative './service/machine_image'
 require_relative './service/volume_image'
 require_relative './service/system_template'
+require_relative './service/system_template_import'
+require_relative './service/system_template_export'
 require_relative './service/network_port_configuration'
 require_relative './service/credential_create'
 require_relative './service/machine_template_create'
@@ -45,6 +47,8 @@ require_relative './service/system_credential'
 require_relative './service/system_system'
 require_relative './service/system'
 require_relative './service/system_create'
+require_relative './service/system_import'
+require_relative './service/system_export'
 require_relative './service/address_template_create'
 require_relative './service/volume'
 require_relative './service/volume_image_create'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/service/base.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service/base.rb b/server/lib/cimi/service/base.rb
index cbf0cb4..695c03f 100644
--- a/server/lib/cimi/service/base.rb
+++ b/server/lib/cimi/service/base.rb
@@ -124,6 +124,9 @@ module CIMI::Service
       params[:add_url] = create_url(ctx)
       if model_class == CIMI::Model::System
         params[:system] = id
+        params[:import_url] = import_url(ctx)
+      elsif model_class == CIMI::Model::SystemTemplate
+        params[:import_url] = import_url(ctx)
       end
       model_class.list(id, entries, params).select_by(ctx.params['$select']).filter_by(ctx.params['$filter'])
     end
@@ -137,6 +140,14 @@ module CIMI::Service
       end
     end
 
+    # used for system and system template import
+    def self.import_url(ctx)
+      if ctx.driver.respond_to?("import_#{model_name}") || provides?(model_name)
+        base_url = ctx.send("#{model_name}_url")
+        "#{base_url}/import"
+      end
+    end
+
     #
     # Resource metadata
     #

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/service/system_export.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service/system_export.rb b/server/lib/cimi/service/system_export.rb
new file mode 100644
index 0000000..5661b77
--- /dev/null
+++ b/server/lib/cimi/service/system_export.rb
@@ -0,0 +1,29 @@
+# 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::Service::SystemExport < CIMI::Service::Base
+
+  def export(id)
+    params = {
+      :id => id,
+      :format => format || 'application/ovf',
+      :destination => destination,
+      :properties => property,
+      :env => context
+    }
+    context.driver.export_system(context.credentials, params)
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/service/system_import.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service/system_import.rb b/server/lib/cimi/service/system_import.rb
new file mode 100644
index 0000000..e2a0759
--- /dev/null
+++ b/server/lib/cimi/service/system_import.rb
@@ -0,0 +1,27 @@
+# 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::Service::SystemImport < CIMI::Service::Base
+
+  def import
+    params = {
+      :source => source,
+      :properties => property,
+      :env => context
+    }
+    context.driver.import_system(context.credentials, params)
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/service/system_template_export.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service/system_template_export.rb b/server/lib/cimi/service/system_template_export.rb
new file mode 100644
index 0000000..eeacedd
--- /dev/null
+++ b/server/lib/cimi/service/system_template_export.rb
@@ -0,0 +1,29 @@
+# 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::Service::SystemTemplateExport < CIMI::Service::Base
+
+  def export(id)
+    params = {
+      :id => id,
+      :format => format || 'application/ovf',
+      :destination => destination,
+      :properties => property,
+      :env => context
+    }
+    context.driver.export_system_template(context.credentials, params)
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/cimi/service/system_template_import.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/service/system_template_import.rb b/server/lib/cimi/service/system_template_import.rb
new file mode 100644
index 0000000..b045d9a
--- /dev/null
+++ b/server/lib/cimi/service/system_template_import.rb
@@ -0,0 +1,27 @@
+# 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::Service::SystemTemplateImport < CIMI::Service::Base
+
+  def import
+    params = {
+      :source => source,
+      :properties => property,
+      :env => context
+    }
+    context.driver.import_system_template(context.credentials, params)
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/deltacloud/drivers/mock/data/cimi/system/system1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/system/system1.json b/server/lib/deltacloud/drivers/mock/data/cimi/system/system1.json
index edff9cb..bddd8ce 100644
--- a/server/lib/deltacloud/drivers/mock/data/cimi/system/system1.json
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/system/system1.json
@@ -12,6 +12,7 @@
   "forwardingGroups": { "href": "http://cimi.example.org/systems/system1/forwarding_groups"},
   "operations": [
     { "rel": "http://schemas.dmtf.org/cimi/1/action/start", "href": "http://cimi.example.org/systems/system1/start"
},
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/export", "href": "http://cimi.example.org/systems/system1/export"
},
     { "rel": "edit", "href": "http://cimi.example.org/systems/system1" },
     { "rel": "delete", "href": "http://cimi.example.org/systems/system1" }
   ]

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/deltacloud/drivers/mock/data/cimi/system/system2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/system/system2.json b/server/lib/deltacloud/drivers/mock/data/cimi/system/system2.json
index ee1dff8..3311f01 100644
--- a/server/lib/deltacloud/drivers/mock/data/cimi/system/system2.json
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/system/system2.json
@@ -6,6 +6,7 @@
   "machines": { "href": "http://cimi.example.org/systems/system2/machines"},
   "operations": [
     { "rel": "http://schemas.dmtf.org/cimi/1/action/start", "href": "http://cimi.example.org/systems/system2/start"
},
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/export", "href": "http://cimi.example.org/systems/system2/export"
},
     { "rel": "edit", "href": "http://cimi.example.org/systems/system2" },
     { "rel": "delete", "href": "http://cimi.example.org/systems/system2" }
   ]

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/server/lib/deltacloud/drivers/mock/data/cimi/system_template/template1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/system_template/template1.json b/server/lib/deltacloud/drivers/mock/data/cimi/system_template/template1.json
index 01d3dbe..1dc5443 100644
--- a/server/lib/deltacloud/drivers/mock/data/cimi/system_template/template1.json
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/system_template/template1.json
@@ -27,6 +27,7 @@
     }
   ],
   "operations": [
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/export", "href": "http://cimi.example.org/system_templates/template1/export"
},
     { "rel": "edit", "href": "http://cimi.example.org/system_templates/template1" },
     { "rel": "delete", "href": "http://cimi.example.org/system_templates/template1" }
   ]

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d58981fb/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 aa7a330..10c6133 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -136,6 +136,14 @@ module Deltacloud::Drivers::Mock
       update_object_state(id, "System", "STOPPED")
     end
 
+    def import_system(credentials, opts={})
+      puts "import_system(#{opts})"
+    end
+
+    def export_system(credentials, opts={})
+      puts "export_system(#{opts})"
+    end
+
     def system_machines(credentials, opts={})
       check_credentials(credentials)
       if opts[:id].nil?
@@ -223,6 +231,67 @@ module Deltacloud::Drivers::Mock
       system_templates.map{|sys_templ| convert_urls(sys_templ, opts[:env])}.flatten
     end
 
+    def import_system_template (credentials, opts={})
+      puts "import_system(#{opts})"
+    end
+
+    def export_system_template(credentials, opts={})
+      puts "export_system(#{opts})"
+    end
+
+    def networks(credentials, opts={})
+      check_credentials(credentials)
+      if opts[:id].nil?
+        networks = @client.load_all_cimi(:network).map{|net| CIMI::Model::Network.from_json(net)}
+        networks.map{|net| convert_urls(net, opts[:env])}.flatten
+      else
+        network = CIMI::Model::Network.from_json(@client.load_cimi(:network, opts[:id]))
+        convert_urls(network, opts[:env])
+      end
+    end
+
+    def create_network(credentials, opts={})
+      check_credentials(credentials)
+      id = "#{opts[:env].send("networks_url")}/#{opts[:name]}"
+      net_hsh = { "id"=> id,
+                  "name" => opts[:name],
+                  "description" => opts[:description],
+                  "created" => Time.now,
+                  "state" => "STARTED",
+                  "networkType" => opts[:network_config].network_type,
+                  "mtu" =>  opts[:network_config].mtu,
+                  "classOfService" => opts[:network_config].class_of_service,
+
+
+                  "forwardingGroup"=> { "href" => opts[:forwarding_group].id },
+                  "operations" => [{"rel"=>"edit", "href"=> id},
+                                   {"rel"=>"delete", "href"=> id}]    }
+      network = CIMI::Model::Network.from_json(JSON.generate(net_hsh))
+
+      @client.store_cimi(:network, network)
+      network
+    end
+
+    def delete_network(credentials, id)
+      check_credentials(credentials)
+      @client.destroy_cimi(:network, id)
+    end
+
+    def start_network(credentials, id)
+      check_credentials(credentials)
+      update_object_state(id, "Network", "STARTED")
+    end
+
+    def stop_network(credentials, id)
+      check_credentials(credentials)
+      update_object_state(id, "Network", "STOPPED")
+    end
+
+    def suspend_network(credentials, id)
+      check_credentials(credentials)
+      update_object_state(id, "Network", "SUSPENDED")
+    end
+
     def network_configurations(credentials, opts={})
       check_credentials(credentials)
       if opts[:id].nil?


Mime
View raw message