class Opsmgr::Settings::Microbosh::InstallationSettings

Attributes

installation_hash[R]

Public Class Methods

from_api_result(result) click to toggle source
# File lib/opsmgr/settings/microbosh/installation_settings.rb, line 11
def self.from_api_result(result)
  new(result.as_hash)
end
new(installation_hash) click to toggle source
# File lib/opsmgr/settings/microbosh/installation_settings.rb, line 15
def initialize(installation_hash)
  @installation_hash = installation_hash
end

Public Instance Methods

availability_zone_guid(zone_name) click to toggle source
# File lib/opsmgr/settings/microbosh/installation_settings.rb, line 41
def availability_zone_guid(zone_name)
  zones = installation_hash.fetch('infrastructure', {}).fetch('availability_zones', [])
  matching_zone = zones.find do |zone|
    zone['name'] == zone_name
  end

  if matching_zone.nil?
    available_zone_names = zones.map { |network| network['name'] }
    log.warn("No availability zone matching name #{zone_name}. Available names: #{available_zone_names.join(', ')}")
    return nil
  end

  matching_zone.fetch('guid')
end
default_availability_zone_guid() click to toggle source
# File lib/opsmgr/settings/microbosh/installation_settings.rb, line 36
def default_availability_zone_guid
  first_zone = installation_hash.fetch('infrastructure', {}).fetch('availability_zones', []).first
  first_zone['guid'] if first_zone
end
network_guid(network_name) click to toggle source
# File lib/opsmgr/settings/microbosh/installation_settings.rb, line 23
def network_guid(network_name)
  networks = installation_hash.fetch('infrastructure', {}).fetch('networks', [])
  matching_network = networks.find { |network| network['name'] == network_name }

  if matching_network.nil?
    available_network_names = networks.map { |network| network['name'] }
    log.warn("No network matching name #{network_name}. Available names: #{available_network_names.join(', ')}")
    return nil
  end

  matching_network.fetch('guid')
end
product(product_name) click to toggle source
# File lib/opsmgr/settings/microbosh/installation_settings.rb, line 19
def product(product_name)
  products.find { |p| p.name == product_name }
end
to_yaml() click to toggle source
# File lib/opsmgr/settings/microbosh/installation_settings.rb, line 56
def to_yaml
  YAML.dump(installation_hash)
end

Private Instance Methods

products() click to toggle source
# File lib/opsmgr/settings/microbosh/installation_settings.rb, line 64
def products
  if installation_hash.key?('components')
    installation_hash.fetch('components').map { |h| Opsmgr::Settings::Microbosh::Product.new(h) }
  elsif installation_hash.key?('products')
    installation_hash.fetch('products').map { |h| Opsmgr::Settings::Microbosh::Product.new(h) }
  else
    fail 'Unknown Ops Manager installation schema. Please check Ops Manager version.'
  end
end