2013-06-20 13:36:34 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
2013-08-27 05:19:54 -04:00
|
|
|
class VcloudDirector
|
2013-06-20 13:36:34 -04:00
|
|
|
|
|
|
|
class Task < Fog::Model
|
2013-09-10 13:01:42 -04:00
|
|
|
|
2013-06-20 13:36:34 -04:00
|
|
|
identity :id
|
2013-09-10 13:01:42 -04:00
|
|
|
|
2013-06-20 13:36:34 -04:00
|
|
|
attribute :name
|
|
|
|
attribute :type
|
|
|
|
attribute :href
|
|
|
|
attribute :status
|
|
|
|
attribute :operation
|
|
|
|
attribute :operation_name, :aliases => :operationName
|
2013-09-10 13:01:42 -04:00
|
|
|
attribute :expiry_time, :aliases => :expiryTime, :type => :time
|
2013-06-20 13:36:34 -04:00
|
|
|
attribute :end_time, :aliases => :endTime, :type => :time
|
2013-09-10 13:01:42 -04:00
|
|
|
attribute :start_time, :aliases => :startTime, :type => :time
|
2013-06-20 13:36:34 -04:00
|
|
|
attribute :error, :aliases => :Error
|
|
|
|
attribute :result, :aliases => :Result
|
2013-09-10 13:01:42 -04:00
|
|
|
attribute :progress, :aliases => :Progress, :type => :integer
|
|
|
|
|
|
|
|
# Since 5.1
|
|
|
|
attribute :operation_key, :aliases => :operationKey
|
|
|
|
attribute :cancel_requested, :aliases => :cancelRequested, :type => :boolean
|
|
|
|
attribute :service_namespace, :aliases => :serviceNamespace
|
|
|
|
|
2013-06-26 08:23:54 -04:00
|
|
|
def ready?
|
|
|
|
status == 'success'
|
|
|
|
end
|
2013-09-10 13:01:42 -04:00
|
|
|
|
2013-07-05 09:21:40 -04:00
|
|
|
def success?
|
|
|
|
status == 'success'
|
|
|
|
end
|
2013-09-10 13:01:42 -04:00
|
|
|
|
2013-07-05 10:33:51 -04:00
|
|
|
def non_running?
|
|
|
|
if status == 'running'
|
|
|
|
if progress.to_i == 0
|
|
|
|
printf '.'
|
|
|
|
else
|
2013-07-05 13:10:43 -04:00
|
|
|
print " #{progress} %\r"
|
2013-07-05 10:33:51 -04:00
|
|
|
end
|
|
|
|
else
|
2013-07-05 13:10:43 -04:00
|
|
|
puts " #{status}"
|
2013-07-05 10:33:51 -04:00
|
|
|
end
|
|
|
|
status != 'running'
|
|
|
|
end
|
2013-09-10 13:01:42 -04:00
|
|
|
|
|
|
|
def cancel
|
|
|
|
service.post_task_cancel(id)
|
|
|
|
end
|
|
|
|
|
2013-06-20 13:36:34 -04:00
|
|
|
end
|
2013-09-10 13:01:42 -04:00
|
|
|
|
2013-06-20 13:36:34 -04:00
|
|
|
end
|
|
|
|
end
|
2013-09-10 13:01:42 -04:00
|
|
|
end
|