You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by dk...@apache.org on 2013/04/04 15:14:39 UTC
[1/2] git commit: CIMI: add missing service subcollections of system
Updated Branches:
refs/heads/master a2ffc293f -> 4551f3ce9
CIMI: add missing service subcollections of system
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/f2bebdab
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/f2bebdab
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/f2bebdab
Branch: refs/heads/master
Commit: f2bebdabba0ff644e237ddd25949b76226969596
Parents: a2ffc29
Author: Dies Koper <di...@fast.au.fujitsu.com>
Authored: Thu Apr 4 11:11:57 2013 +1100
Committer: Dies Koper <di...@fast.au.fujitsu.com>
Committed: Fri Apr 5 00:14:15 2013 +1100
----------------------------------------------------------------------
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(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f2bebdab/server/lib/cimi/service.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'
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f2bebdab/server/lib/cimi/service/system_credential.rb
----------------------------------------------------------------------
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
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f2bebdab/server/lib/cimi/service/system_network_port.rb
----------------------------------------------------------------------
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
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f2bebdab/server/lib/cimi/service/system_system.rb
----------------------------------------------------------------------
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
[2/2] git commit: FGCP: added nil check for systems with no machines,
volumes or addresses; also fixed system state when CREATING
Posted by dk...@apache.org.
FGCP: added nil check for systems with no machines, volumes or
addresses; also fixed system state when CREATING
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/4551f3ce
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/4551f3ce
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/4551f3ce
Branch: refs/heads/master
Commit: 4551f3ce9ad1210e26b5ca523f36932c6650366e
Parents: f2bebda
Author: Dies Koper <di...@fast.au.fujitsu.com>
Authored: Thu Apr 4 17:50:24 2013 +1100
Committer: Dies Koper <di...@fast.au.fujitsu.com>
Committed: Fri Apr 5 00:14:29 2013 +1100
----------------------------------------------------------------------
server/lib/deltacloud/drivers/fgcp/fgcp_client.rb | 4 ++
.../drivers/fgcp/fgcp_driver_cimi_methods.rb | 29 ++++++++++++---
2 files changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4551f3ce/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb b/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
index 9597c13..5520735 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
@@ -82,6 +82,10 @@ class FgcpClient
request('ListVSYS')
end
+ def get_vsys_status(vsys_id)
+ request('GetVSYSStatus', {'vsysId' => vsys_id})
+ end
+
def get_vsys_attributes(vsys_id)
request('GetVSYSAttributes', {'vsysId' => vsys_id})
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4551f3ce/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb b/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
index 6e08de9..e147960 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
@@ -51,11 +51,10 @@ module Deltacloud::Drivers::Fgcp
systems.each do |system|
vservers = client.list_vservers(system[:id])['vservers'][0]['vserver']
if vservers.nil?
- system[:state] = 'MIXED'
+ system[:state] = client.get_vsys_status(system[:id])['vsysStatus'][0] == 'DEPLOYING' ? 'CREATING' : 'MIXED'
else
vservers.each do |vserver|
- state = @@INSTANCE_STATE_MAP[client.get_vserver_status(vserver['vserverId'][0])['vserverStatus'][0]]
- state = 'STARTED' if state == 'RUNNING'
+ state = @@MACHINE_STATE_MAP[client.get_vserver_status(vserver['vserverId'][0])['vserverStatus'][0]]
system[:state] ||= state
if system[:state] != state
system[:state] = 'MIXED'
@@ -91,7 +90,7 @@ module Deltacloud::Drivers::Fgcp
context = opts[:env]
vsys_id = opts[:system_id]
xml = client.list_vservers(vsys_id)['vservers']
- return [] if xml.nil?
+ return [] unless xml and xml[0]['vserver']
machines = xml[0]['vserver'].collect do |vserver|
vserver_id = vserver['vserverId'][0]
@@ -112,7 +111,7 @@ module Deltacloud::Drivers::Fgcp
vsys_id = opts[:system_id]
#if :expand not specified, list of hrefs only, else convert from :storage_volumes?
xml = client.list_vdisk(vsys_id)['vdisks']
- return [] if xml.nil?
+ return [] unless xml and xml[0]['vdisk']
volumes = xml[0]['vdisk'].collect do |vdisk|
vdisk_id = vdisk['vdiskId'][0]
@@ -155,7 +154,7 @@ module Deltacloud::Drivers::Fgcp
vsys_id = opts[:system_id]
#if :expand not specified, list of hrefs only, else ??
xml = client.list_public_ips(vsys_id)['publicips']
- return [] if xml.nil?
+ return [] unless xml and xml[0]['publicip']
# retrieve network segment (subnet) info
addresses = xml[0]['publicip'].collect do |ip|
@@ -246,6 +245,24 @@ module Deltacloud::Drivers::Fgcp
end
end
+ # FGCP instance states mapped to CIMI machine states
+ @@MACHINE_STATE_MAP = {
+ 'DEPLOYING' => 'CREATING',
+ 'RUNNING' => 'STARTED',
+ 'STOPPING' => 'STOPPING',
+ 'STOPPED' => 'STOPPED',
+ 'STARTING' => 'STARTING', # not sure about this one
+ 'FAILOVER' => 'STARTED',
+ 'UNEXPECTED_STOP' => 'STOPPED',
+ 'RESTORING' => 'RESTORING',
+ 'BACKUP_ING' => 'CAPTURING',
+ 'ERROR' => 'ERROR', # allowed actions limited
+ 'START_ERROR' => 'STOPPED', # allowed actions are same as for STOPPED
+ 'STOP_ERROR' => 'STARTED', # allowed actions are same as for RUNNING
+ 'REGISTERING' => 'PENDING',
+ 'CHANGE_TYPE' => 'PENDING'
+ }
+
end
end