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.



85
86
87
88
89
# File 'lib/bosh/director/jobs/ssh.rb', line 85

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.



83
84
85
# File 'lib/bosh/director/jobs/ssh.rb', line 83

def ids
  @ids
end

#indexesObject (readonly)

Returns the value of attribute indexes.



83
84
85
# File 'lib/bosh/director/jobs/ssh.rb', line 83

def indexes
  @indexes
end

#jobObject (readonly)

Returns the value of attribute job.



83
84
85
# File 'lib/bosh/director/jobs/ssh.rb', line 83

def job
  @job
end

Instance Method Details

#id_filterObject



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/bosh/director/jobs/ssh.rb', line 99

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)


91
92
93
# File 'lib/bosh/director/jobs/ssh.rb', line 91

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

#indexes_provided?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/bosh/director/jobs/ssh.rb', line 95

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