From: Dies Koper <di...@fast.au.fujitsu.com>

---
 .../deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb   | 15 ++++++++++-----
 .../deltacloud/drivers/mock/mock_driver_cimi_methods.rb   |  4 ++++
 2 files changed, 14 insertions(+), 5 deletions(-)

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 0380fb1..386cc11 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
@@ -48,7 +48,8 @@ module Deltacloud::Drivers::Fgcp
           )
         end
         systems = systems.select { |s| opts[:id] == s[:id] } if opts[:id]
-        # now add system state and advertised operations
+
+        # now add system state and advertise operations
         systems.each do |system|
           vservers = 
client.list_vservers(system[:id])['vservers'][0]['vserver']
           if vservers.nil?
@@ -57,19 +58,23 @@ module Deltacloud::Drivers::Fgcp
             vservers.each do |vserver|
               state = 
@@MACHINE_STATE_MAP[client.get_vserver_status(vserver['vserverId'][0])['vserverStatus'][0]]
               system[:state] ||= state
-              system[:operations] <<  { :href => 
context.system_url("#{system[:id]}/start"), :rel => 
"http://schemas.dmtf.org/cimi/1/action/start"; } if state == 'STOPPED'
-              system[:operations] <<  { :href => 
context.system_url("#{system[:id]}/stop"), :rel => 
"http://schemas.dmtf.org/cimi/1/action/stop"; } if state == 'STARTED'
+              system[:operations] << { :href => 
context.system_url("#{system[:id]}/start"), :rel => 
"http://schemas.dmtf.org/cimi/1/action/start"; } if state == 'STOPPED'
+              system[:operations] << { :href => 
context.system_url("#{system[:id]}/stop"), :rel => 
"http://schemas.dmtf.org/cimi/1/action/stop"; } if state == 'STARTED'
               if system[:state] != state
                 system[:state] = 'MIXED'
                 # this case could have been caused by one machine in capturing 
state and one in e.g. creating,
                 # but just advertise both operations to cut it short
-                system[:operations] <<  { :href => 
context.system_url("#{system[:id]}/start"), :rel => 
"http://schemas.dmtf.org/cimi/1/action/start"; }
-                system[:operations] <<  { :href => 
context.system_url("#{system[:id]}/stop"), :rel => 
"http://schemas.dmtf.org/cimi/1/action/stop"; }
+                system[:operations] << { :href => 
context.system_url("#{system[:id]}/start"), :rel => 
"http://schemas.dmtf.org/cimi/1/action/start"; }
+                system[:operations] << { :href => 
context.system_url("#{system[:id]}/stop"), :rel => 
"http://schemas.dmtf.org/cimi/1/action/stop"; }
                 break
               end
             end
             system[:operations].uniq!
           end
+          # check for special case: in destroy_system the FW is stopped before 
the system is deleted
+          system[:state] = 'DELETING' if ((vservers.nil? and system[:state] != 
'CREATING') or system[:state] == 'STOPPED') and
+                                         ['STOPPED', 'STOPPING'].include? 
client.get_efm_status("#{system[:id]}-S-0001")['efmStatus'][0]
+          system[:operations] << { :href => context.system_url(system[:id]), 
:rel => "delete" } if system[:state] == 'STOPPED'
         end
         systems
       end
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 4ac01aa..217736a 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -297,6 +297,8 @@ module Deltacloud::Drivers::Mock
 
     # Convert all attributes that have values of the form
     #   http://cimi.example.org/COLL/ID
+    #   or
+    #   http://cimi.example.org/COLL/ID/SUBCOLL/ENT_ID
     def convert_urls(val, context)
       if val.nil? || val.is_a?(Fixnum)
         # Nothing to do
@@ -324,6 +326,8 @@ module Deltacloud::Drivers::Mock
     #
     # URLs that should be rewritten need to be in the form
     #   http://cimi.example.org/COLLECTION/ID
+    #   or
+    #   http://cimi.example.org/COLLECTION/SYSTEM_ID/SUBCOLLECTION/ENT_ID
     def rewrite_url(s, context)
       begin
         u = URI.parse(s)
-- 
1.8.0.msysgit.0


Reply via email to