Class: Prof::OpsManager
- Inherits:
-
Object
- Object
- Prof::OpsManager
- Defined in:
- lib/prof/ops_manager.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #bosh_credentials ⇒ Object
- #cf_admin_credentials ⇒ Object
-
#initialize(environment_name:, version: "1.7") ⇒ OpsManager
constructor
A new instance of OpsManager.
- #system_domain ⇒ Object
- #vms_for_job_type(job_type) ⇒ Object
Constructor Details
#initialize(environment_name:, version: "1.7") ⇒ OpsManager
Returns a new instance of OpsManager.
16 17 18 19 20 21 22 23 24 25 |
# 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 ) @version = Gem::Version.new(version) @api_installation_settings = @api.installation_settings end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
27 28 29 |
# File 'lib/prof/ops_manager.rb', line 27 def url @url end |
Instance Method Details
#bosh_credentials ⇒ Object
36 37 38 39 40 41 |
# File 'lib/prof/ops_manager.rb', line 36 def bosh_credentials { 'identity' => 'director', 'password' => @api_installation_settings.director_password } end |
#cf_admin_credentials ⇒ Object
29 30 31 32 33 34 |
# File 'lib/prof/ops_manager.rb', line 29 def cf_admin_credentials OpenStruct.new({ 'username' => 'admin', 'password' => @api_installation_settings.uaa_admin_password }) end |
#system_domain ⇒ Object
43 44 45 |
# File 'lib/prof/ops_manager.rb', line 43 def system_domain @api_installation_settings.system_domain end |
#vms_for_job_type(job_type) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/prof/ops_manager.rb', line 47 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 |