Class: Opsmgr::Settings::Microbosh::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/opsmgr/settings/microbosh/product.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product_hash) ⇒ Product

Returns a new instance of Product.



9
10
11
# File 'lib/opsmgr/settings/microbosh/product.rb', line 9

def initialize(product_hash)
  @product_hash = product_hash
end

Instance Attribute Details

#product_hashObject (readonly)

Returns the value of attribute product_hash.



7
8
9
# File 'lib/opsmgr/settings/microbosh/product.rb', line 7

def product_hash
  @product_hash
end

Instance Method Details

#availability_zone_references=(zones_array) ⇒ Object



27
28
29
# File 'lib/opsmgr/settings/microbosh/product.rb', line 27

def availability_zone_references=(zones_array)
  product_hash['availability_zone_references'] = zones_array
end

#disabled_post_deploy_errand_names(errands = nil) ⇒ Object



23
24
25
# File 'lib/opsmgr/settings/microbosh/product.rb', line 23

def disabled_post_deploy_errand_names(errands = nil)
  product_hash['disabled_post_deploy_errand_names'] = errands
end

#for_job(job_name) {|job_result| ... } ⇒ Object

Yields:

  • (job_result)


43
44
45
46
# File 'lib/opsmgr/settings/microbosh/product.rb', line 43

def for_job(job_name)
  job_result = job(job_name)
  yield job_result if job_result
end

#guidObject



13
14
15
# File 'lib/opsmgr/settings/microbosh/product.rb', line 13

def guid
  product_hash.fetch('guid')
end

#job(job_name) ⇒ Object



48
49
50
# File 'lib/opsmgr/settings/microbosh/product.rb', line 48

def job(job_name)
  jobs.find { |job| job.name == job_name }
end

#jobsObject



52
53
54
# File 'lib/opsmgr/settings/microbosh/product.rb', line 52

def jobs
  product_hash['jobs'].map { |h| Opsmgr::Settings::Microbosh::Job.new(h) }
end

#nameObject



17
18
19
20
21
# File 'lib/opsmgr/settings/microbosh/product.rb', line 17

def name
  product_hash.fetch('identifier')
rescue
  product_hash.fetch('type')
end

#network_reference=(network_references) ⇒ Object



35
36
37
# File 'lib/opsmgr/settings/microbosh/product.rb', line 35

def network_reference=(network_references)
  product_hash['network_reference'] = network_references
end

#product_versionObject



56
57
58
# File 'lib/opsmgr/settings/microbosh/product.rb', line 56

def product_version
  product_hash['product_version']
end

#property(name) ⇒ Object



64
65
66
67
68
# File 'lib/opsmgr/settings/microbosh/product.rb', line 64

def property(name)
  return nil if properties.empty?
  key = properties.first['identifier'] ? 'identifier' : 'definition'
  properties.find { |property| property[key] == name }
end

#set_property(name, value) ⇒ Object



39
40
41
# File 'lib/opsmgr/settings/microbosh/product.rb', line 39

def set_property(name, value)
  property(name)['value'] = value
end

#singleton_availability_zoneObject



60
61
62
# File 'lib/opsmgr/settings/microbosh/product.rb', line 60

def singleton_availability_zone
  product_hash['singleton_availability_zone_reference']
end

#singleton_availability_zone=(value) ⇒ Object



31
32
33
# File 'lib/opsmgr/settings/microbosh/product.rb', line 31

def singleton_availability_zone=(value)
  product_hash['singleton_availability_zone_reference'] = value
end