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



25
26
27
# File 'lib/opsmgr/settings/microbosh/product.rb', line 25

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

#disabled_post_deploy_errand_names(errands = nil) ⇒ Object



21
22
23
# File 'lib/opsmgr/settings/microbosh/product.rb', line 21

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)


41
42
43
44
# File 'lib/opsmgr/settings/microbosh/product.rb', line 41

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



46
47
48
# File 'lib/opsmgr/settings/microbosh/product.rb', line 46

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

#jobsObject



50
51
52
# File 'lib/opsmgr/settings/microbosh/product.rb', line 50

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

#nameObject



17
18
19
# 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



33
34
35
# File 'lib/opsmgr/settings/microbosh/product.rb', line 33

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

#product_versionObject



54
55
56
# File 'lib/opsmgr/settings/microbosh/product.rb', line 54

def product_version
  product_hash['product_version']
end

#property(name) ⇒ Object



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

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



37
38
39
# File 'lib/opsmgr/settings/microbosh/product.rb', line 37

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

#singleton_availability_zoneObject



58
59
60
# File 'lib/opsmgr/settings/microbosh/product.rb', line 58

def singleton_availability_zone
  product_hash['singleton_availability_zone_reference']
end

#singleton_availability_zone=(value) ⇒ Object



29
30
31
# File 'lib/opsmgr/settings/microbosh/product.rb', line 29

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