Class: Opsmgr::Api::InstallationSettingsResult

Inherits:
Result
  • Object
show all
Defined in:
lib/opsmgr/api/results.rb

Instance Attribute Summary

Attributes inherited from Result

#message

Instance Method Summary collapse

Methods inherited from Result

#success?

Constructor Details

#initialize(install_hash) ⇒ InstallationSettingsResult

Returns a new instance of InstallationSettingsResult.



100
101
102
# File 'lib/opsmgr/api/results.rb', line 100

def initialize(install_hash)
  @install_hash = install_hash
end

Instance Method Details

#apps_domainObject



152
153
154
155
156
157
# File 'lib/opsmgr/api/results.rb', line 152

def apps_domain
  properties = cc_job.fetch('properties')
  property_list = Opsmgr::Settings::Microbosh::PropertyList.new(properties)
  credential_property = property_list.find { |property| property.name == 'apps_domain' }
  credential_property.fetch('value')
end

#as_hashObject



175
176
177
# File 'lib/opsmgr/api/results.rb', line 175

def as_hash
  install_hash
end

#director_ipObject



104
105
106
107
# File 'lib/opsmgr/api/results.rb', line 104

def director_ip
  ips_for_job(product_name: 'p-bosh', job_name: 'director').first ||
    ips_for_job(product_name: 'microbosh', job_name: 'director').first
end

#director_passwordObject



125
126
127
128
129
130
131
132
133
# File 'lib/opsmgr/api/results.rb', line 125

def director_password
  microbosh_jobs = microbosh_settings.fetch('jobs')
  microbosh_job_list = Opsmgr::Settings::Microbosh::JobList.new(microbosh_jobs)
  director_job = microbosh_job_list.find { |job| job.name == 'director' }
  properties = director_job.fetch('properties')
  property_list = Opsmgr::Settings::Microbosh::PropertyList.new(properties)
  credential_property = property_list.find { |property| property.name == 'director_credentials' }
  credential_property.fetch('value').fetch('password')
end

#ips_for_job(product_name:, job_name:) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/opsmgr/api/results.rb', line 109

def ips_for_job(product_name:, job_name:)
  product = products.find { |p| p.name == product_name }
  return [] if product.nil?

  if install_hash['ip_assignments']
    install_hash['ip_assignments']['assignments'][product['guid']].each do |job_guid, assignment|
      return assignment.values.flatten if job_guid.starts_with?(job_name)
    end
  else
    product.fetch('ips').each do |job_guid, ips|
      return ips if job_guid.starts_with?(job_name)
    end
  end
  []
end

#ops_manager_installation_settingsObject



171
172
173
# File 'lib/opsmgr/api/results.rb', line 171

def ops_manager_installation_settings
  Opsmgr::Settings::Microbosh::InstallationSettings.from_api_result(self)
end

#product_version(product_guid) ⇒ Object



159
160
161
162
163
# File 'lib/opsmgr/api/results.rb', line 159

def product_version(product_guid)
  product = products.find { |p| p.guid == product_guid }
  return nil if product.nil?
  product.fetch('product_version')
end

#product_version_by_name(product_name) ⇒ Object



165
166
167
168
169
# File 'lib/opsmgr/api/results.rb', line 165

def product_version_by_name(product_name)
  product = products.find { |p| p.name == product_name }
  return nil if product.nil?
  product.fetch('product_version')
end

#system_domainObject



145
146
147
148
149
150
# File 'lib/opsmgr/api/results.rb', line 145

def system_domain
  properties = cc_job.fetch('properties')
  property_list = Opsmgr::Settings::Microbosh::PropertyList.new(properties)
  credential_property = property_list.find { |property| property.name == 'system_domain' }
  credential_property.fetch('value')
end

#uaa_admin_passwordObject



135
136
137
138
139
140
141
142
143
# File 'lib/opsmgr/api/results.rb', line 135

def uaa_admin_password
  jobs = cf_settings.fetch('jobs')
  job_list = Opsmgr::Settings::Microbosh::JobList.new(jobs)
  uaa_job = job_list.find { |job| job.name == 'uaa' }
  properties = uaa_job.fetch('properties')
  property_list = Opsmgr::Settings::Microbosh::PropertyList.new(properties)
  credential_property = property_list.find { |property| property.name == 'admin_credentials' }
  credential_property.fetch('value').fetch('password')
end