deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <di...@fast.au.fujitsu.com>
Subject [PATCH] CIMI: add missing service subcollections of system
Date Thu, 04 Apr 2013 00:12:06 GMT
From: Dies Koper <diesk@fast.au.fujitsu.com>

---
 server/lib/cimi/service.rb                     |  3 +++
 server/lib/cimi/service/system_credential.rb   | 34 ++++++++++++++++++++++++++
 server/lib/cimi/service/system_network_port.rb | 34 ++++++++++++++++++++++++++
 server/lib/cimi/service/system_system.rb       | 34 ++++++++++++++++++++++++++
 4 files changed, 105 insertions(+)
 create mode 100644 server/lib/cimi/service/system_credential.rb
 create mode 100644 server/lib/cimi/service/system_network_port.rb
 create mode 100644 server/lib/cimi/service/system_system.rb

diff --git a/server/lib/cimi/service.rb b/server/lib/cimi/service.rb
index 892f6ad..58bed94 100644
--- a/server/lib/cimi/service.rb
+++ b/server/lib/cimi/service.rb
@@ -49,7 +49,10 @@ require_relative './service/system_machine'
 require_relative './service/system_volume'
 require_relative './service/system_network'
 require_relative './service/system_forwarding_group'
+require_relative './service/system_network_port'
 require_relative './service/system_address'
+require_relative './service/system_credential'
+require_relative './service/system_system'
 require_relative './service/system'
 require_relative './service/system_create'
 require_relative './service/address_template_create'
diff --git a/server/lib/cimi/service/system_credential.rb b/server/lib/cimi/service/system_credential.rb
new file mode 100644
index 0000000..3ff256b
--- /dev/null
+++ b/server/lib/cimi/service/system_credential.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::Service::SystemCredential < CIMI::Service::Base
+
+  def self.find(system_id, context, id=:all)
+    if id == :all
+      credentials = context.driver.system_credentials(context.credentials, {:env=>context,
:system_id=>system_id})
+    else
+      credentials = context.driver.system_credentials(context.credentials, {:env=>context,
:system_id=>system_id, :id=>id})
+      raise CIMI::Model::NotFound if credentials.empty?
+      credentials.first
+    end
+  end
+
+  def self.collection_for_system(system_id, context)
+    system_credentials = self.find(system_id, context)
+    credentials_url = context.url("/system/#{system_id}/credentials") if context.driver.has_capability?
:add_credentials_to_system
+    CIMI::Model::SystemCredential.list(credentials_url, system_credentials, :add_url =>
credentials_url)
+  end
+
+end
diff --git a/server/lib/cimi/service/system_network_port.rb b/server/lib/cimi/service/system_network_port.rb
new file mode 100644
index 0000000..f7b3e69
--- /dev/null
+++ b/server/lib/cimi/service/system_network_port.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::Service::SystemNetworkPort < CIMI::Service::Base
+
+  def self.find(system_id, context, id=:all)
+    if id == :all
+      ports = context.driver.system_network_ports(context.credentials, {:env=>context,
:system_id=>system_id})
+    else
+      ports = context.driver.system_network_ports(context.credentials, {:env=>context,
:system_id=>system_id, :id=>id})
+      raise CIMI::Model::NotFound if ports.empty?
+      ports.first
+    end
+  end
+
+  def self.collection_for_system(system_id, context)
+    system_network_ports = self.find(system_id, context)
+    network_ports_url = context.url("/system/#{system_id}/network_ports") if context.driver.has_capability?
:add_network_ports_to_system
+    CIMI::Model::SystemNetworkPort.list(network_ports_url, system_network_ports, :add_url
=> network_ports_url)
+  end
+
+end
diff --git a/server/lib/cimi/service/system_system.rb b/server/lib/cimi/service/system_system.rb
new file mode 100644
index 0000000..233825c
--- /dev/null
+++ b/server/lib/cimi/service/system_system.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::Service::SystemSystem < CIMI::Service::Base
+
+  def self.find(system_id, context, id=:all)
+    if id == :all
+      systems = context.driver.system_systems(context.systems, {:env=>context, :system_id=>system_id})
+    else
+      systems = context.driver.system_systems(context.systems, {:env=>context, :system_id=>system_id,
:id=>id})
+      raise CIMI::Model::NotFound if systems.empty?
+      systems.first
+    end
+  end
+
+  def self.collection_for_system(system_id, context)
+    system_systems = self.find(system_id, context)
+    systems_url = context.url("/system/#{system_id}/systems") if context.driver.has_capability?
:add_systems_to_system
+    CIMI::Model::SystemSystem.list(systems_url, system_systems, :add_url => systems_url)
+  end
+
+end
-- 
1.8.0.msysgit.0



Mime
View raw message