Class: Opsmgr::Cmd::OpsManager
- Inherits:
-
Object
- Object
- Opsmgr::Cmd::OpsManager
- Includes:
- Loggable
- Defined in:
- lib/opsmgr/cmd/ops_manager.rb
Instance Method Summary collapse
- #add_product(client, name, version) ⇒ Object
- #configure_microbosh_infrastructure(client) ⇒ Object
- #delete_unused_products(client) ⇒ Object
- #download_staged_manifest(client, guid, manifest_filepath) ⇒ Object
- #import_installation(client, path) ⇒ Object
- #import_stemcell(client, path) ⇒ Object
-
#initialize(target_environment) ⇒ OpsManager
constructor
A new instance of OpsManager.
- #installed_products(client) ⇒ Object
- #list_products(client) ⇒ Object
- #revert_staged_changes(client) ⇒ Object
- #upgrade_product(client, guid, version) ⇒ Object
- #upload_product(client, path) ⇒ Object
Methods included from Loggable
Constructor Details
#initialize(target_environment) ⇒ OpsManager
Returns a new instance of OpsManager.
11 12 13 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 11 def initialize(target_environment) @environment = target_environment end |
Instance Method Details
#add_product(client, name, version) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 63 def add_product(client, name, version) result = client.add_product(name, version) if result.success? log.info 'Successfully added product' else fail result. end end |
#configure_microbosh_infrastructure(client) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 15 def configure_microbosh_infrastructure(client) result = client.installation_settings return unless result.success? result = result.as_hash return if result.fetch('installation_version', '') != '1.4' return if result['infrastructure']['type'] != 'vsphere' result['infrastructure']['file_system'] = { 'microbosh_vm_folder' => environment.settings.dig('name'), 'microbosh_template_folder' => environment.settings.dig('name'), 'microbosh_disk_path' => environment.settings.dig('name'), } file = Tempfile.new('om_install_settings') file.write(YAML.dump(result)) file.close client.upload_product_installation_settings(file.path) end |
#delete_unused_products(client) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 36 def delete_unused_products(client) result = client.delete_unused_products if result.success? log.info 'Successfully deleted unused products' else fail result. end end |
#download_staged_manifest(client, guid, manifest_filepath) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 108 def download_staged_manifest(client, guid, manifest_filepath) result = client.download_staged_manifest(guid) if result.success? File.open(manifest_filepath, 'w') do |mf| mf.write(result.manifest) end log.info 'Successfully downloaded staged manifest for product' else fail result. end end |
#import_installation(client, path) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 90 def import_installation(client, path) result = client.import_installation(path, environment.settings.dig('ops_manager', 'password')) if result.success? log.info 'Successfully imported installation' else fail result. end end |
#import_stemcell(client, path) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 99 def import_stemcell(client, path) result = client.import_stemcell(path) if result.success? log.info 'Successfully imported stemcell' else fail result. end end |
#installed_products(client) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 81 def installed_products(client) result = client.installed_products if result.success? result else fail result. end end |
#list_products(client) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 54 def list_products(client) result = client.list_products if result.success? result else fail result. end end |
#revert_staged_changes(client) ⇒ Object
120 121 122 123 124 125 126 127 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 120 def revert_staged_changes(client) result = client.revert_staged_changes if result.success? log.info 'Successfully reverted staged changes' else fail result. end end |
#upgrade_product(client, guid, version) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 72 def upgrade_product(client, guid, version) result = client.upgrade_product(guid, version) if result.success? log.info 'Successfully upgraded product' else fail result. end end |
#upload_product(client, path) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/opsmgr/cmd/ops_manager.rb', line 45 def upload_product(client, path) result = client.upload_component(path) if result.success? log.info 'Successfully uploaded product' else fail result. end end |