Class: Wakame::Actions::MigrateService
- Inherits:
-
Wakame::Action
- Object
- Wakame::Action
- Wakame::Actions::MigrateService
- Defined in:
- lib/wakame/actions/migrate_service.rb
Constant Summary
Constants included from AttributeHelper
AttributeHelper::CLASS_TYPE_KEY, AttributeHelper::CONVERT_CLASSES, AttributeHelper::PRIMITIVE_CLASSES
Instance Attribute Summary
Attributes inherited from Wakame::Action
Instance Method Summary collapse
-
#initialize(svc, dest_cloud_host = nil) ⇒ MigrateService
constructor
A new instance of MigrateService.
- #on_failed ⇒ Object
- #run ⇒ Object
Methods inherited from Wakame::Action
#acquire_lock, #actor_request, #agent_monitor, #all_subactions_complete?, #flush_subactions, #master, #notes, #notify, #on_canceled, #service_cluster, #status=, #subactions, #sync_actor_request, #trigger_action, #walk_subactions
Methods included from ThreadImmutable
#bind_thread, included, #target_thread, #target_thread?, #thread_check
Methods included from AttributeHelper
#dump_attrs, #retrieve_attr_attribute
Constructor Details
#initialize(svc, dest_cloud_host = nil) ⇒ MigrateService
Returns a new instance of MigrateService.
5 6 7 8 9 |
# File 'lib/wakame/actions/migrate_service.rb', line 5 def initialize(svc, dest_cloud_host=nil) raise ArgumentError unless svc.is_a?(Service::ServiceInstance) @svc = svc @dest_cloud_host = dest_cloud_host end |
Instance Method Details
#on_failed ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/wakame/actions/migrate_service.rb', line 37 def on_failed StatusDB. { @svc.update_status(Service::STATUS_FAIL) if @new_svc @new_svc.update_status(Service::STATUS_FAIL) end } end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wakame/actions/migrate_service.rb', line 11 def run acquire_lock(@svc.resource.class.to_s) @svc.reload if @svc.status == Service::STATUS_MIGRATING Wakame.log.info("Ignore to migrate the service as is already MIGRATING: #{@svc.resource.class}") return end StatusDB. { @svc.update_status(Service::STATUS_MIGRATING) } if @svc.resource.duplicable clone_service() flush_subactions trigger_action(StopService.new(@svc)) @svc.reload else trigger_action(StopService.new(@svc)) @svc.reload flush_subactions clone_service() end flush_subactions end |