deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dko...@apache.org
Subject [2/2] git commit: FGCP: added nil check for systems with no machines, volumes or addresses; also fixed system state when CREATING
Date Thu, 04 Apr 2013 13:14:40 GMT
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 <diesk@fast.au.fujitsu.com>
Authored: Thu Apr 4 17:50:24 2013 +1100
Committer: Dies Koper <diesk@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


Mime
View raw message