class Prof::OpsManager
Attributes
url[R]
Public Class Methods
new(environment_name:, version: "1.7")
click to toggle source
# File lib/prof/ops_manager.rb, line 16 def initialize(environment_name:, version: "1.7") @api = Opsmgr::Api::Client.new( Opsmgr::Environments.for(environment_name), version ) @environment = Opsmgr::Environments.for(environment_name) @version = Gem::Version.new(version) @api_installation_settings = @api.installation_settings end
Public Instance Methods
bosh_credentials()
click to toggle source
# File lib/prof/ops_manager.rb, line 37 def bosh_credentials { 'identity' => 'director', 'password' => @api_installation_settings.director_password } end
cf_admin_credentials()
click to toggle source
# File lib/prof/ops_manager.rb, line 30 def cf_admin_credentials OpenStruct.new({ 'username' => 'admin', 'password' => @api_installation_settings.uaa_admin_password }) end
product_manifest(product_name)
click to toggle source
# File lib/prof/ops_manager.rb, line 76 def product_manifest(product_name) product_guid = @api.installed_products.guid_for(product_name) client = Opsmgr::Api::HttpClient.build(@environment, @version.to_s) response = client.product_manifest(product_guid) YAML.load(response.body) end
staged_manifest(product_name)
click to toggle source
# File lib/prof/ops_manager.rb, line 69 def staged_manifest(product_name) product_guid = @api.installed_products.guid_for(product_name) client = Opsmgr::Api::HttpClient.build(@environment, @version.to_s) response = client.download_staged_manifest(product_guid) YAML.load(response.body) end
system_domain()
click to toggle source
# File lib/prof/ops_manager.rb, line 44 def system_domain @api_installation_settings.system_domain end
vms_for_job_type(job_type)
click to toggle source
# File lib/prof/ops_manager.rb, line 48 def vms_for_job_type(job_type) manifest = @api_installation_settings.as_hash product = get_product_for_job(manifest, job_type) ips = @api_installation_settings.ips_for_job(product_name: product['identifier'], job_name: job_type) job = product["jobs"].detect { |job| job["installation_name"] == job_type } if @version >= Gem::Version.new('1.7') vm_credentials = job['vm_credentials'] else vm_credentials = job['properties'].detect { |p| p['identifier'] == 'vm_credentials' }['value'] end ips.map do |ip| OpenStruct.new( :hostname => ip, :username => vm_credentials.fetch("identity"), :password => vm_credentials.fetch("password") ) end end
Private Instance Methods
get_product_for_job(manifest, job_type)
click to toggle source
# File lib/prof/ops_manager.rb, line 85 def get_product_for_job(manifest, job_type) manifest["products"].detect do |product| product['jobs'].any? { |job| job['identifier'] == job_type } end end