Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #2612 - move Task into Orchestration namespace due to RbVmomi confict #730

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/orchestration/queue.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'task'
require 'orchestration/task'
module Orchestration
# Represents tasks queue for orchestration
class Queue
Expand Down
41 changes: 41 additions & 0 deletions lib/orchestration/task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Orchestration
class Task
attr_reader :name, :status, :priority, :action, :timestamp

def initialize opts
@name = opts[:name]
@status = opts[:status]
@priority = opts[:priority] || 0
@action = opts[:action]
update_ts
end

def status=s
if Orchestration::Queue::STATUS.include?(s)
update_ts
@status = s
else
raise "invalid STATE #{s}"
end
end

def to_s
"#{name}\t #{priority}\t #{status}\t #{action}"
end

def as_json options = {}
super :only => [:name, :timestamp, :status]
end

private
def update_ts
@timestamp = Time.now
end

# sort based on priority
def <=> other
self.priority <=> other.priority
end

end
end
39 changes: 0 additions & 39 deletions lib/task.rb

This file was deleted.