opsmgr 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/LEGAL.txt +13 -0
  3. data/README.md +21 -0
  4. data/lib/opsmgr.rb +12 -0
  5. data/lib/opsmgr/api/client.rb +85 -0
  6. data/lib/opsmgr/api/endpoints_factory.rb +39 -0
  7. data/lib/opsmgr/api/http_client.rb +204 -0
  8. data/lib/opsmgr/api/results.rb +257 -0
  9. data/lib/opsmgr/api/version20/endpoints.rb +93 -0
  10. data/lib/opsmgr/cmd/bosh_command.rb +213 -0
  11. data/lib/opsmgr/cmd/ops_manager.rb +100 -0
  12. data/lib/opsmgr/environments.rb +77 -0
  13. data/lib/opsmgr/errand_runner.rb +75 -0
  14. data/lib/opsmgr/log.rb +70 -0
  15. data/lib/opsmgr/product_upload_wrapper.rb +69 -0
  16. data/lib/opsmgr/renderer.rb +23 -0
  17. data/lib/opsmgr/renderer/aws.rb +147 -0
  18. data/lib/opsmgr/renderer/noop.rb +21 -0
  19. data/lib/opsmgr/settings/microbosh/installation_settings.rb +84 -0
  20. data/lib/opsmgr/settings/microbosh/job.rb +54 -0
  21. data/lib/opsmgr/settings/microbosh/job_list.rb +27 -0
  22. data/lib/opsmgr/settings/microbosh/network.rb +21 -0
  23. data/lib/opsmgr/settings/microbosh/product.rb +88 -0
  24. data/lib/opsmgr/settings/microbosh/product_list.rb +27 -0
  25. data/lib/opsmgr/settings/microbosh/property.rb +31 -0
  26. data/lib/opsmgr/settings/microbosh/property_list.rb +27 -0
  27. data/lib/opsmgr/tasks.rb +16 -0
  28. data/lib/opsmgr/tasks/bosh.rake +70 -0
  29. data/lib/opsmgr/tasks/destroy.rake +42 -0
  30. data/lib/opsmgr/tasks/info.rake +19 -0
  31. data/lib/opsmgr/tasks/opsmgr.rake +179 -0
  32. data/lib/opsmgr/tasks/product.rake +53 -0
  33. data/lib/opsmgr/teapot.rb +51 -0
  34. data/lib/opsmgr/teapot/app.rb +50 -0
  35. data/lib/opsmgr/teapot/spec_helper.rb +33 -0
  36. data/lib/opsmgr/ui_helpers/add_first_user_spec.rb +25 -0
  37. data/lib/opsmgr/ui_helpers/config_helper.rb +151 -0
  38. data/lib/opsmgr/ui_helpers/delete_installation_spec.rb +41 -0
  39. data/lib/opsmgr/ui_helpers/delete_product_if_present_spec.rb +43 -0
  40. data/lib/opsmgr/ui_helpers/delete_product_spec.rb +39 -0
  41. data/lib/opsmgr/ui_helpers/export_installation_spec.rb +31 -0
  42. data/lib/opsmgr/ui_helpers/get_latest_install_log_spec.rb +29 -0
  43. data/lib/opsmgr/ui_helpers/import_installation_spec.rb +29 -0
  44. data/lib/opsmgr/ui_helpers/import_stemcell_spec.rb +30 -0
  45. data/lib/opsmgr/ui_helpers/microbosh/configure_microbosh_spec.rb +31 -0
  46. data/lib/opsmgr/ui_helpers/trigger_install_spec.rb +35 -0
  47. data/lib/opsmgr/ui_helpers/ui_spec_runner.rb +117 -0
  48. data/lib/opsmgr/ui_helpers/uncheck_errands_spec.rb +29 -0
  49. data/lib/opsmgr/ui_helpers/upload_and_add_product_spec.rb +27 -0
  50. data/lib/opsmgr/ui_helpers/upload_and_upgrade_product_spec.rb +36 -0
  51. data/lib/opsmgr/version.rb +11 -0
  52. metadata +360 -0
@@ -0,0 +1,54 @@
1
+ require 'opsmgr/settings/microbosh/property'
2
+
3
+ module Opsmgr
4
+ module Settings
5
+ module Microbosh
6
+ class Job
7
+ def initialize(job_hash)
8
+ @job_hash = job_hash
9
+ end
10
+
11
+ def name
12
+ job_hash.fetch('identifier') rescue job_hash.fetch('type')
13
+ end
14
+
15
+ def property(property_name)
16
+ properties('properties').find { |property| property.name == property_name }
17
+ end
18
+
19
+ def resource(resource_name)
20
+ properties('resources').find { |resource| resource.name == resource_name }
21
+ end
22
+
23
+ def networks=(networks)
24
+ job_hash['network_references'] = networks
25
+ end
26
+
27
+ def elb_name=(name)
28
+ job_hash['elb_name'] = name
29
+ end
30
+
31
+ def instances=(instance_count)
32
+ job_hash['instances'].first['value'] = instance_count
33
+ job_hash.delete('partitions')
34
+ end
35
+
36
+ private
37
+
38
+ attr_reader :job_hash
39
+
40
+ def properties(key)
41
+ job_hash[key].map { |property| Opsmgr::Settings::Microbosh::Property.new(property) }
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
48
+ # All rights reserved.
49
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
50
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
51
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
52
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
53
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
54
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,27 @@
1
+ require 'opsmgr/settings/microbosh/job'
2
+
3
+ module Opsmgr
4
+ module Settings
5
+ module Microbosh
6
+ class JobList
7
+ def initialize(job_hashes)
8
+ @job_hashes = job_hashes
9
+ end
10
+
11
+ def find
12
+ @job_hashes.find do |job_hash|
13
+ yield(Job.new(job_hash))
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
21
+ # All rights reserved.
22
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
24
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
27
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ require 'digest/md5'
2
+
3
+ module Opsmgr
4
+ module Settings
5
+ module Microbosh
6
+ class Network
7
+ def self.guid_for_name(name)
8
+ Digest::MD5.hexdigest(name)[0...20]
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
15
+ # All rights reserved.
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
18
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,88 @@
1
+ require 'opsmgr/settings/microbosh/job'
2
+
3
+ module Opsmgr
4
+ module Settings
5
+ module Microbosh
6
+ class Product
7
+ attr_reader :product_hash
8
+
9
+ def initialize(product_hash)
10
+ @product_hash = product_hash
11
+ end
12
+
13
+ def guid
14
+ product_hash.fetch('guid')
15
+ end
16
+
17
+ def name
18
+ product_hash.fetch('identifier') rescue product_hash.fetch('type')
19
+ end
20
+
21
+ def disabled_post_deploy_errand_names(errands = nil)
22
+ product_hash['disabled_post_deploy_errand_names'] = errands
23
+ end
24
+
25
+ def availability_zone_references=(zones_array)
26
+ product_hash['availability_zone_references'] = zones_array
27
+ end
28
+
29
+ def singleton_availability_zone=(value)
30
+ product_hash['singleton_availability_zone_reference'] = value
31
+ end
32
+
33
+ def network_reference=(network_references)
34
+ product_hash['network_reference'] = network_references
35
+ end
36
+
37
+ def set_property(name, value)
38
+ property(name)['value'] = value
39
+ end
40
+
41
+ def for_job(job_name)
42
+ job_result = job(job_name)
43
+ yield job_result if job_result
44
+ end
45
+
46
+ def job(job_name)
47
+ jobs.find { |job| job.name == job_name }
48
+ end
49
+
50
+ def jobs
51
+ product_hash['jobs'].map { |h| Opsmgr::Settings::Microbosh::Job.new(h) }
52
+ end
53
+
54
+ def product_version
55
+ product_hash['product_version']
56
+ end
57
+
58
+ def singleton_availability_zone
59
+ product_hash['singleton_availability_zone_reference']
60
+ end
61
+
62
+ def property(name)
63
+ return nil if properties.empty?
64
+ key = properties.first['identifier'] ? 'identifier' : 'definition'
65
+ properties.find { |property| property[key] == name }
66
+ end
67
+
68
+ private
69
+
70
+ def properties
71
+ product_hash['properties'] ||= []
72
+ end
73
+
74
+ def has_property?(property)
75
+ properties.find_index(property) != -1
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
82
+ # All rights reserved.
83
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
84
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
85
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
86
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
87
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
88
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,27 @@
1
+ require 'opsmgr/settings/microbosh/product'
2
+
3
+ module Opsmgr
4
+ module Settings
5
+ module Microbosh
6
+ class ProductList
7
+ def initialize(product_hashes)
8
+ @product_hashes = product_hashes
9
+ end
10
+
11
+ def find
12
+ @product_hashes.find do |product_hash|
13
+ yield(Product.new(product_hash))
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
21
+ # All rights reserved.
22
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
24
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
27
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ module Opsmgr
2
+ module Settings
3
+ module Microbosh
4
+ class Property
5
+ def initialize(hash)
6
+ @hash = hash
7
+ end
8
+
9
+ def name
10
+ @hash.fetch('identifier') rescue @hash['definition']
11
+ end
12
+
13
+ def value
14
+ @hash['value']
15
+ end
16
+
17
+ def value=(value)
18
+ @hash['value'] = value
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
25
+ # All rights reserved.
26
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
27
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
28
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
30
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
31
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,27 @@
1
+ require 'opsmgr/settings/microbosh/property'
2
+
3
+ module Opsmgr
4
+ module Settings
5
+ module Microbosh
6
+ class PropertyList
7
+ def initialize(property_hashes)
8
+ @property_hashes = property_hashes
9
+ end
10
+
11
+ def find
12
+ @property_hashes.find do |property_hash|
13
+ yield Property.new(property_hash)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
21
+ # All rights reserved.
22
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
24
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
27
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ current_dir = File.expand_path(File.dirname(__FILE__))
2
+ Dir.glob(File.join(current_dir, 'tasks', '*.rake')).each do |tasks_file|
3
+ load tasks_file
4
+ end
5
+
6
+ require 'opsmgr/log'
7
+
8
+ Opsmgr::Log.stdout_mode!
9
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
10
+ # All rights reserved.
11
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
13
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
14
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
15
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,70 @@
1
+ namespace :opsmgr do
2
+ namespace :microbosh do
3
+ desc 'Print out a copy-pasteable partial bosh command (eg bosh -t example.com -u user -p password)'
4
+ task :command, [:environment, :om_version] do |_, args|
5
+ require 'opsmgr/cmd/bosh_command'
6
+ puts Opsmgr::Cmd::BoshCommand.new(
7
+ env_name: args.environment,
8
+ om_version: args.om_version
9
+ ).command
10
+ end
11
+
12
+ desc 'Print out a bosh command to set the target to the bosh for the given environment'
13
+ task :target, [:environment, :om_version] do |_, args|
14
+ require 'opsmgr/cmd/bosh_command'
15
+ puts Opsmgr::Cmd::BoshCommand.new(
16
+ env_name: args.environment,
17
+ om_version: args.om_version
18
+ ).target
19
+ end
20
+
21
+ desc 'Print out the ip address of the director'
22
+ task :director_ip, [:environment, :om_version] do |_, args|
23
+ require 'opsmgr/cmd/bosh_command'
24
+ puts Opsmgr::Cmd::BoshCommand.new(
25
+ env_name: args.environment,
26
+ om_version: args.om_version
27
+ ).director_ip
28
+ end
29
+
30
+ desc 'Configure Microbosh [:environment, :om_version]'
31
+ task :configure, [:environment, :om_version] do |_, args|
32
+ require 'opsmgr/ui_helpers/ui_spec_runner'
33
+ require 'opsmgr/environments'
34
+ require 'opsmgr/api/client'
35
+ require 'opsmgr/cmd/ops_manager'
36
+
37
+ environment = Opsmgr::Environments.for(args.environment)
38
+ client = Opsmgr::Api::Client.new(environment)
39
+ Opsmgr::Cmd::OpsManager.new(environment).configure_microbosh_infrastructure(client)
40
+
41
+ UiSpecRunner.new(
42
+ environment: args.environment,
43
+ om_version: args.om_version
44
+ ).configure_microbosh
45
+ end
46
+ end
47
+
48
+ desc 'Download BOSH Stemcell from bosh.io'
49
+ task :download_stemcell, [:iaas, :version] do |_, args|
50
+ case args.iaas
51
+ when 'aws'
52
+ system("wget --content-disposition --progress=dot:giga https://bosh.io/d/stemcells/bosh-aws-xen-hvm-ubuntu-trusty-go_agent?v=#{args.version}")
53
+ when 'vsphere'
54
+ system("wget --content-disposition --progress=dot:giga https://bosh.io/d/stemcells/bosh-vsphere-esxi-ubuntu-trusty-go_agent?v=#{args.version}")
55
+ when 'vcloud'
56
+ system("wget --content-disposition --progress=dot:giga https://bosh.io/d/stemcells/bosh-vcloud-esxi-ubuntu-trusty-go_agent?v=#{args.version}")
57
+ when 'openstack'
58
+ system("wget --content-disposition --progress=dot:giga https://bosh.io/d/stemcells/bosh-openstack-kvm-ubuntu-trusty-go_agent-raw?v=#{args.version}")
59
+ end
60
+ system('ls *bosh*.tgz > stemcell_reference.txt')
61
+ end
62
+ end
63
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
64
+ # All rights reserved.
65
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
66
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
67
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
68
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
69
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
70
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ namespace :opsmgr do
2
+ desc "Alias for opsmgr:destroy:vms"
3
+ task :destroy, [:environment] => %w(opsmgr:destroy:vms)
4
+
5
+ namespace :destroy do
6
+ desc "- Clear our Resource Pool, deleting stemcells, all installed products' VMs (including Ops Mgr)"
7
+ task :vms, [:environment] do |_, args|
8
+ require 'opsmgr/cmd/ops_manager'
9
+ require 'opsmgr/environments'
10
+ require 'opsmgr/api/client'
11
+
12
+ env = Opsmgr::Environments.for(args.environment)
13
+ begin
14
+ installation_settings = Opsmgr::Api::Client.new(env).installation_settings.as_hash
15
+ rescue
16
+ installation_settings = { 'infrastructure' => {} }
17
+ end
18
+ require 'vm_shepherd'
19
+ shep = VmShepherd::Shepherd.new(settings: env.settings_with_merged_folders(installation_settings))
20
+ shep.clean_environment
21
+ shep.destroy
22
+ end
23
+
24
+ desc '- Destroy Existing Ops Manager'
25
+ task :opsmgr, [:environment] do |_, args|
26
+ require 'opsmgr/environments'
27
+ require 'vm_shepherd'
28
+ env = Opsmgr::Environments.for(args.environment)
29
+
30
+ shep = VmShepherd::Shepherd.new(settings: env.settings)
31
+ shep.destroy
32
+ end
33
+ end
34
+ end
35
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
36
+ # All rights reserved.
37
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
38
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
40
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
41
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
42
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ namespace :opsmgr do
2
+ namespace :info do
3
+ desc 'Display the host of the Ops Manager for the given environment'
4
+ task :host, [:environment] do |_, args|
5
+ require 'opsmgr/environments'
6
+ require 'uri'
7
+ uri = URI(Opsmgr::Environments.for(args.environment).settings.ops_manager.url)
8
+ puts uri.host
9
+ end
10
+ end
11
+ end
12
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
13
+ # All rights reserved.
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
17
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,179 @@
1
+ namespace :opsmgr do
2
+ desc 'Trigger an install on Ops Manager for the specified environment'
3
+ task :trigger_install, [:environment, :om_version, :install_timeout] do |_, args|
4
+ require 'opsmgr/ui_helpers/ui_spec_runner'
5
+
6
+ UiSpecRunner.new(
7
+ environment: args.environment,
8
+ om_version: args.om_version
9
+ ).trigger_install(args.install_timeout)
10
+ end
11
+
12
+ desc 'Get latest install log from Ops Manager'
13
+ task :get_latest_install_log, [:environment, :om_version] do |_, args|
14
+ require 'opsmgr/ui_helpers/ui_spec_runner'
15
+
16
+ UiSpecRunner.new(
17
+ environment: args.environment,
18
+ om_version: args.om_version
19
+ ).get_latest_install_log
20
+ end
21
+
22
+ desc 'Export installation'
23
+ task :export_installation, [:environment, :om_version, :export_destination] do |_, args|
24
+ require 'opsmgr/ui_helpers/ui_spec_runner'
25
+
26
+ UiSpecRunner.new(
27
+ environment: args.environment,
28
+ om_version: args.om_version
29
+ ).export_installation(args.export_destination)
30
+ end
31
+
32
+ desc 'Import installation'
33
+ task :import_installation, [:environment, :om_version, :import_file] do |_, args|
34
+ require 'opsmgr/ui_helpers/ui_spec_runner'
35
+
36
+ UiSpecRunner.new(
37
+ environment: args.environment,
38
+ om_version: args.om_version
39
+ ).import_installation(args.import_file)
40
+ end
41
+
42
+ desc 'Delete installation'
43
+ task :delete_installation, [:environment, :om_version] do |_, args|
44
+ require 'opsmgr/ui_helpers/ui_spec_runner'
45
+ UiSpecRunner.new(
46
+ environment: args.environment,
47
+ om_version: args.om_version
48
+ ).delete_installation
49
+ end
50
+
51
+ desc 'Add first user'
52
+ task :add_first_user, [:environment, :om_version] do |_, args|
53
+ require 'opsmgr/ui_helpers/ui_spec_runner'
54
+
55
+ UiSpecRunner.new(
56
+ environment: args.environment,
57
+ om_version: args.om_version
58
+ ).add_first_user
59
+ end
60
+
61
+ desc 'Prepare Environment'
62
+ task :prepare, [:environment] do |_, args|
63
+ require 'opsmgr/log'
64
+ require 'opsmgr/environments'
65
+ require 'vm_shepherd'
66
+
67
+ logger = Opsmgr.logger_for('Rake')
68
+ logger.info "Preparing environment for #{args[:environment]}"
69
+
70
+ environment = Opsmgr::Environments.for(args.environment)
71
+
72
+ shep = VmShepherd::Shepherd.new(settings: environment.settings)
73
+ shep.prepare_environment
74
+ end
75
+
76
+ desc 'Install Operations Manager .image'
77
+ task :install, [:environment, :image] do |_, args|
78
+ require 'timeout'
79
+ require 'opsmgr/log'
80
+ require 'opsmgr/environments'
81
+ require 'vm_shepherd'
82
+
83
+ logger = Opsmgr.logger_for('Rake')
84
+ logger.info "installing #{args[:environment]}'s Ops Manager"
85
+
86
+ environment = Opsmgr::Environments.for(args.environment)
87
+ image = args[:image]
88
+
89
+ shep = VmShepherd::Shepherd.new(settings: environment.settings)
90
+ shep.deploy(paths: [image])
91
+ end
92
+
93
+ desc 'Delete a product'
94
+ task :delete_product, [:environment, :om_version, :product_name, :timeout] do |_, args|
95
+ require 'opsmgr/ui_helpers/ui_spec_runner'
96
+
97
+ DEFAULT_DELETE_TIMEOUT = 25
98
+
99
+ UiSpecRunner.new(
100
+ environment: args.environment,
101
+ om_version: args.om_version
102
+ ).delete_product(args.product_name, args.timeout || DEFAULT_DELETE_TIMEOUT.to_s)
103
+ end
104
+
105
+ desc 'Delete a product if present (will not fail if product is not preset)'
106
+ task :delete_product_if_present, [:environment, :om_version, :product_name, :timeout] do |_, args|
107
+ require 'opsmgr/ui_helpers/ui_spec_runner'
108
+
109
+ DEFAULT_DELETE_TIMEOUT = 25
110
+
111
+ UiSpecRunner.new(
112
+ environment: args.environment,
113
+ om_version: args.om_version
114
+ ).delete_product_if_present(args.product_name, args.timeout || DEFAULT_DELETE_TIMEOUT.to_s)
115
+ end
116
+
117
+ desc 'Delete unused products'
118
+ task :delete_unused_products, [:environment] do |_, args|
119
+ require 'opsmgr/api/client'
120
+ require 'opsmgr/cmd/ops_manager'
121
+ require 'opsmgr/environments'
122
+
123
+ environment = Opsmgr::Environments.for(args.environment)
124
+ client = Opsmgr::Api::Client.new(environment)
125
+ Opsmgr::Cmd::OpsManager.new(environment).delete_unused_products(client)
126
+ end
127
+
128
+ desc 'Saves the private key into the given file'
129
+ task :get_private_key, [:environment, :key_file_path] do |_, args|
130
+ require 'opsmgr/environments'
131
+ environment = Opsmgr::Environments.for(args.environment)
132
+ case environment.settings.iaas_type
133
+ when 'aws'
134
+ private_key = environment.settings.ops_manager.aws.ssh_key
135
+ when 'openstack'
136
+ private_key = environment.settings.ops_manager.openstack.ssh_private_key
137
+ else
138
+ raise 'Unsupported IaaS - this task only works for AWS and Openstack'
139
+ end
140
+ File.open(args.key_file_path, 'w+') do |f|
141
+ f << private_key
142
+ f.chmod(0600)
143
+ end
144
+ end
145
+
146
+ desc 'run an errand'
147
+ task :run_errand, [:environment_name, :om_version, :product_name, :errand_name, :download_logs] do |_, args|
148
+ require 'opsmgr/cmd/bosh_command'
149
+ require 'opsmgr/log'
150
+ require 'opsmgr/errand_runner'
151
+
152
+ logger = Opsmgr.logger_for('Rake')
153
+ bosh_command = Opsmgr::Cmd::BoshCommand.new(
154
+ env_name: args.environment_name,
155
+ om_version: args.om_version
156
+ )
157
+ iaas_gateway = Opsmgr::Cmd::IaasGateway.new(
158
+ bosh_command: bosh_command,
159
+ environment_name: args.environment_name,
160
+ logger: logger
161
+ )
162
+ Opsmgr::ErrandRunner.new(
163
+ iaas_gateway: iaas_gateway,
164
+ bosh_command: bosh_command,
165
+ environment_name: args.environment_name,
166
+ logger: logger,
167
+ product_name: args.product_name,
168
+ errand_name: args.errand_name,
169
+ download_logs: args.with_defaults(download_logs: false)).run_errand
170
+ end
171
+ end
172
+ # Copyright (c) 2014-2015 Pivotal Software, Inc.
173
+ # All rights reserved.
174
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
175
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
176
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
177
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
178
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
179
+ # USE OR OTHER DEALINGS IN THE SOFTWARE.