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/05 02:43:23 UTC
git commit: FGCP: advertise and implement cimi system start and stop
Updated Branches:
refs/heads/master 237a45560 -> 2a53220f0
FGCP: advertise and implement cimi system start and stop
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/2a53220f
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/2a53220f
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/2a53220f
Branch: refs/heads/master
Commit: 2a53220f007effb1ec2f2b4109c3f66556060ecf
Parents: 237a455
Author: Dies Koper <di...@fast.au.fujitsu.com>
Authored: Fri Apr 5 00:23:10 2013 +1100
Committer: Dies Koper <di...@fast.au.fujitsu.com>
Committed: Fri Apr 5 11:42:40 2013 +1100
----------------------------------------------------------------------
.../drivers/fgcp/fgcp_driver_cimi_methods.rb | 52 ++++++++++++++-
1 files changed, 50 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2a53220f/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 e147960..1bde935 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
@@ -43,11 +43,12 @@ module Deltacloud::Drivers::Fgcp
:machines => { :href => context.system_url("#{vsys_id}/machines") },
:volumes => { :href => context.system_url("#{vsys_id}/volumes") },
:networks => { :href => context.system_url("#{vsys_id}/networks") },
- :addresses => { :href => context.system_url("#{vsys_id}/addresses") }
+ :addresses => { :href => context.system_url("#{vsys_id}/addresses") },
+ :operations => []
)
end
systems = systems.select { |s| opts[:id] == s[:id] } if opts[:id]
- # now add system state
+ # now add system state and advertised operations
systems.each do |system|
vservers = client.list_vservers(system[:id])['vservers'][0]['vserver']
if vservers.nil?
@@ -56,11 +57,18 @@ 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'
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" }
break
end
end
+ system[:operations].uniq!
end
end
systems
@@ -83,6 +91,46 @@ module Deltacloud::Drivers::Fgcp
delete_firewall(credentials, {:id=>"#{opts[:id]}-S-0001"})
end
+ def start_system(credentials, opts={})
+ safely do
+ client = new_client(credentials)
+ context = opts[:env]
+ vsys_id = opts[:id]
+ xml = client.list_vservers(vsys_id)['vservers']
+ return unless xml and xml[0]['vserver']
+
+ # FIXME: maybe this should be done in a separate thread (in case of gigantic number of servers)
+ # FIXME: error handling (ok to exit loop? Cleanup?) - at this time the cimi spec is quiet on that
+ xml[0]['vserver'].each do |vserver|
+ begin
+ client.start_vserver(vserver['vserverId'][0])
+ rescue Exception => ex
+ raise ex if not ex.message =~ /(ALREADY_STARTED|ILLEGAL_STATE).*/
+ end
+ end
+ end
+ end
+
+ def stop_system(credentials, opts={})
+ safely do
+ client = new_client(credentials)
+ context = opts[:env]
+ vsys_id = opts[:id]
+ xml = client.list_vservers(vsys_id)['vservers']
+ return unless xml and xml[0]['vserver']
+
+ # FIXME: maybe this should be done in a separate thread (in case of gigantic number of servers)
+ # FIXME: error handling (ok to exit loop? Cleanup?) - at this time the cimi spec is quiet on that
+ xml[0]['vserver'].each do |vserver|
+ begin
+ client.stop_vserver(vserver['vserverId'][0])
+ rescue Exception => ex
+ raise ex if not ex.message =~ /(ALREADY_STOPPED|ILLEGAL_STATE).*/
+ end
+ end
+ end
+ end
+
def system_machines(credentials, opts={})
safely do
client = new_client(credentials)