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.
- #product_manifest(product_name) ⇒ Object
- #staged_manifest(product_name) ⇒ Object
- #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 26 |
# 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 |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
28 29 30 |
# File 'lib/prof/ops_manager.rb', line 28 def url @url end |
Instance Method Details
#bosh_credentials ⇒ Object
37 38 39 40 41 42 |
# File 'lib/prof/ops_manager.rb', line 37 def bosh_credentials { 'identity' => 'director', 'password' => @api_installation_settings.director_password } end |
#cf_admin_credentials ⇒ Object
30 31 32 33 34 35 |
# 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) ⇒ Object
76 77 78 79 80 81 |
# 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) ⇒ Object
69 70 71 72 73 74 |
# 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 ⇒ Object
44 45 46 |
# File 'lib/prof/ops_manager.rb', line 44 def system_domain @api_installation_settings.system_domain end |
#vms_for_job_type(job_type) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# 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 |