Class: Bosh::Director::Jobs::Ssh::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/jobs/ssh.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_payload) ⇒ Target

Returns a new instance of Target.



62
63
64
65
66
# File 'lib/bosh/director/jobs/ssh.rb', line 62

def initialize(target_payload)
  @job = target_payload['job']
  @ids = target_payload['ids']
  @indexes = target_payload['indexes']
end

Instance Attribute Details

#idsObject (readonly)

Returns the value of attribute ids.



60
61
62
# File 'lib/bosh/director/jobs/ssh.rb', line 60

def ids
  @ids
end

#indexesObject (readonly)

Returns the value of attribute indexes.



60
61
62
# File 'lib/bosh/director/jobs/ssh.rb', line 60

def indexes
  @indexes
end

#jobObject (readonly)

Returns the value of attribute job.



60
61
62
# File 'lib/bosh/director/jobs/ssh.rb', line 60

def job
  @job
end

Instance Method Details

#id_filterObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/bosh/director/jobs/ssh.rb', line 76

def id_filter
  if !ids_provided? && indexes_provided?
    # for backwards compatibility with old cli
    return {index: @indexes}
  end

  filter = Hash.new { |h,k| h[k] = [] }

  @ids.each do |id|
    if id.to_s =~ /^\d+$/
      filter[:index] << id.to_i
    else
      filter[:uuid] << id
    end
  end

  filter
end

#ids_provided?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/bosh/director/jobs/ssh.rb', line 68

def ids_provided?
  @ids && @ids.size > 0
end

#indexes_provided?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/bosh/director/jobs/ssh.rb', line 72

def indexes_provided?
  @indexes && @indexes.size > 0
end