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.
- checksums.yaml +7 -0
- data/LEGAL.txt +13 -0
- data/README.md +21 -0
- data/lib/opsmgr.rb +12 -0
- data/lib/opsmgr/api/client.rb +85 -0
- data/lib/opsmgr/api/endpoints_factory.rb +39 -0
- data/lib/opsmgr/api/http_client.rb +204 -0
- data/lib/opsmgr/api/results.rb +257 -0
- data/lib/opsmgr/api/version20/endpoints.rb +93 -0
- data/lib/opsmgr/cmd/bosh_command.rb +213 -0
- data/lib/opsmgr/cmd/ops_manager.rb +100 -0
- data/lib/opsmgr/environments.rb +77 -0
- data/lib/opsmgr/errand_runner.rb +75 -0
- data/lib/opsmgr/log.rb +70 -0
- data/lib/opsmgr/product_upload_wrapper.rb +69 -0
- data/lib/opsmgr/renderer.rb +23 -0
- data/lib/opsmgr/renderer/aws.rb +147 -0
- data/lib/opsmgr/renderer/noop.rb +21 -0
- data/lib/opsmgr/settings/microbosh/installation_settings.rb +84 -0
- data/lib/opsmgr/settings/microbosh/job.rb +54 -0
- data/lib/opsmgr/settings/microbosh/job_list.rb +27 -0
- data/lib/opsmgr/settings/microbosh/network.rb +21 -0
- data/lib/opsmgr/settings/microbosh/product.rb +88 -0
- data/lib/opsmgr/settings/microbosh/product_list.rb +27 -0
- data/lib/opsmgr/settings/microbosh/property.rb +31 -0
- data/lib/opsmgr/settings/microbosh/property_list.rb +27 -0
- data/lib/opsmgr/tasks.rb +16 -0
- data/lib/opsmgr/tasks/bosh.rake +70 -0
- data/lib/opsmgr/tasks/destroy.rake +42 -0
- data/lib/opsmgr/tasks/info.rake +19 -0
- data/lib/opsmgr/tasks/opsmgr.rake +179 -0
- data/lib/opsmgr/tasks/product.rake +53 -0
- data/lib/opsmgr/teapot.rb +51 -0
- data/lib/opsmgr/teapot/app.rb +50 -0
- data/lib/opsmgr/teapot/spec_helper.rb +33 -0
- data/lib/opsmgr/ui_helpers/add_first_user_spec.rb +25 -0
- data/lib/opsmgr/ui_helpers/config_helper.rb +151 -0
- data/lib/opsmgr/ui_helpers/delete_installation_spec.rb +41 -0
- data/lib/opsmgr/ui_helpers/delete_product_if_present_spec.rb +43 -0
- data/lib/opsmgr/ui_helpers/delete_product_spec.rb +39 -0
- data/lib/opsmgr/ui_helpers/export_installation_spec.rb +31 -0
- data/lib/opsmgr/ui_helpers/get_latest_install_log_spec.rb +29 -0
- data/lib/opsmgr/ui_helpers/import_installation_spec.rb +29 -0
- data/lib/opsmgr/ui_helpers/import_stemcell_spec.rb +30 -0
- data/lib/opsmgr/ui_helpers/microbosh/configure_microbosh_spec.rb +31 -0
- data/lib/opsmgr/ui_helpers/trigger_install_spec.rb +35 -0
- data/lib/opsmgr/ui_helpers/ui_spec_runner.rb +117 -0
- data/lib/opsmgr/ui_helpers/uncheck_errands_spec.rb +29 -0
- data/lib/opsmgr/ui_helpers/upload_and_add_product_spec.rb +27 -0
- data/lib/opsmgr/ui_helpers/upload_and_upgrade_product_spec.rb +36 -0
- data/lib/opsmgr/version.rb +11 -0
- metadata +360 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'opsmgr/environments'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
module Opsmgr
|
5
|
+
class ErrandRunner
|
6
|
+
def initialize(iaas_gateway:, bosh_command:, environment_name:, logger:, product_name:, errand_name:, download_logs:)
|
7
|
+
@iaas_gateway = iaas_gateway
|
8
|
+
@bosh_command = bosh_command
|
9
|
+
@environment = Opsmgr::Environments.for(environment_name)
|
10
|
+
@logger = logger
|
11
|
+
@product_name = product_name
|
12
|
+
@errand_name = errand_name
|
13
|
+
@download_logs = download_logs ? "--download-logs" : ""
|
14
|
+
end
|
15
|
+
|
16
|
+
def run_errand
|
17
|
+
iaas_gateway.gateway do
|
18
|
+
set_bosh_deployment
|
19
|
+
|
20
|
+
system_or_fail(
|
21
|
+
"#{bosh_command_prefix} run errand #{@errand_name} #{@download_logs}",
|
22
|
+
"Errand #{@errand_name} failed"
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def set_bosh_deployment
|
30
|
+
system_or_fail(bosh_command.target, 'bosh target failed')
|
31
|
+
|
32
|
+
bosh_deployment = bosh_deployment_name(bosh_command_prefix)
|
33
|
+
|
34
|
+
deployment_file = "#{ENV.fetch('TMPDIR', '/tmp')}/#{environment.settings.name}.yml"
|
35
|
+
|
36
|
+
system_or_fail(
|
37
|
+
"#{bosh_command_prefix} -n download manifest #{bosh_deployment} #{deployment_file}",
|
38
|
+
'bosh download manifest failed'
|
39
|
+
)
|
40
|
+
system_or_fail(
|
41
|
+
"#{bosh_command_prefix} deployment #{deployment_file}",
|
42
|
+
'bosh deployment failed'
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def system_or_fail(command, failure_message)
|
47
|
+
logger.info("Running #{command}")
|
48
|
+
Bundler.clean_system(command) || fail(failure_message)
|
49
|
+
end
|
50
|
+
|
51
|
+
def bosh_deployment_name(command)
|
52
|
+
@bosh_deployment_name ||= begin
|
53
|
+
Bundler.with_clean_env do
|
54
|
+
bosh_deployment, status = Open3.capture2("#{command} deployments | grep -Eoh '#{@product_name}-[0-9a-f]{8,}'")
|
55
|
+
fail('bosh deployments failed') unless status.success?
|
56
|
+
bosh_deployment.chomp
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def bosh_command_prefix
|
62
|
+
@bosh_command_prefix ||= bosh_command.command
|
63
|
+
end
|
64
|
+
|
65
|
+
attr_reader :iaas_gateway, :bosh_command, :environment, :logger, :product_name, :errand_name, :download_logs
|
66
|
+
end
|
67
|
+
end
|
68
|
+
# Copyright (c) 2014-2015 Pivotal Software, Inc.
|
69
|
+
# All rights reserved.
|
70
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
71
|
+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
72
|
+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
73
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
74
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
75
|
+
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/opsmgr/log.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Opsmgr
|
4
|
+
class << self
|
5
|
+
def log
|
6
|
+
Log.instance
|
7
|
+
end
|
8
|
+
|
9
|
+
def logger_for(progname)
|
10
|
+
LoggerWithProgName.new(progname)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Loggable
|
15
|
+
def log
|
16
|
+
@logger ||= LoggerWithProgName.new(self.class.name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.included(other_module)
|
20
|
+
def other_module.log
|
21
|
+
@logger ||= LoggerWithProgName.new(name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Log
|
27
|
+
class << self
|
28
|
+
def instance
|
29
|
+
@instance || fail('Logging attempted without being configured first!')
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_mode!
|
33
|
+
log_path = '/tmp/opsmgr_test.log'
|
34
|
+
File.open(log_path, 'w') {} # empty out the file in a cross-platform-safe way
|
35
|
+
@instance = ::Logger.new(log_path, File::WRONLY | File::APPEND)
|
36
|
+
instance.sev_threshold = ::Logger::DEBUG
|
37
|
+
end
|
38
|
+
|
39
|
+
def stdout_mode!
|
40
|
+
STDOUT.sync = true
|
41
|
+
@instance = ::Logger.new(STDOUT)
|
42
|
+
instance.sev_threshold = ::Logger.const_get(ENV.fetch('LOG_LEVEL', 'INFO'))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class LoggerWithProgName
|
48
|
+
def initialize(progname)
|
49
|
+
@progname = progname
|
50
|
+
end
|
51
|
+
|
52
|
+
%w(debug info warn error fatal).map(&:to_sym).each do |level|
|
53
|
+
define_method(level) do |message|
|
54
|
+
Log.instance.public_send(level, progname) { message }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
attr_reader :progname
|
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,69 @@
|
|
1
|
+
require 'opsmgr/ui_helpers/ui_spec_runner'
|
2
|
+
require 'opsmgr/environments'
|
3
|
+
require 'opsmgr/cmd/ops_manager'
|
4
|
+
require 'opsmgr/api/client'
|
5
|
+
|
6
|
+
class ProductUploadWrapper
|
7
|
+
def self.wrap_add(environment:, product_path:, product_name:)
|
8
|
+
wrap_add_upgrade(environment, product_path, product_name, 'add')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.wrap_upgrade(environment:, product_path:, product_name:)
|
12
|
+
wrap_add_upgrade(environment, product_path, product_name, 'upgrade')
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.wrap_add_upgrade(environment, product_path, product_name, operation)
|
16
|
+
if operation != 'add' && operation != 'upgrade'
|
17
|
+
fail "Operation '#{operation}' is not available"
|
18
|
+
end
|
19
|
+
|
20
|
+
environment_object = Opsmgr::Environments.for(environment)
|
21
|
+
client = Opsmgr::Api::Client.new(environment_object)
|
22
|
+
opsmgr_cmd = Opsmgr::Cmd::OpsManager.new(environment_object)
|
23
|
+
opsmgr_cmd.upload_product(client, product_path)
|
24
|
+
|
25
|
+
products_list = opsmgr_cmd.list_products(client)
|
26
|
+
|
27
|
+
stored_version = find_latest_version(product_name, products_list)
|
28
|
+
|
29
|
+
fail "#{product_name} is not available" if stored_version.nil?
|
30
|
+
|
31
|
+
if operation == 'add'
|
32
|
+
opsmgr_cmd.add_product(client, product_name, stored_version.to_s)
|
33
|
+
else
|
34
|
+
installed_products = opsmgr_cmd.installed_products(client)
|
35
|
+
product_guid = installed_products.guid_for(product_name)
|
36
|
+
opsmgr_cmd.upgrade_product(client, product_guid, stored_version.to_s)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.find_latest_version(product_name, products_list)
|
41
|
+
stored_version = nil
|
42
|
+
|
43
|
+
products_list.products.each do |p|
|
44
|
+
if p['name'] != product_name
|
45
|
+
next
|
46
|
+
end
|
47
|
+
|
48
|
+
if stored_version.nil?
|
49
|
+
stored_version = Gem::Version.new p['product_version']
|
50
|
+
else
|
51
|
+
new_version = Gem::Version.new p['product_version']
|
52
|
+
|
53
|
+
if new_version > stored_version
|
54
|
+
stored_version = new_version
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
stored_version
|
60
|
+
end
|
61
|
+
end
|
62
|
+
# Copyright (c) 2014-2015 Pivotal Software, Inc.
|
63
|
+
# All rights reserved.
|
64
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
65
|
+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
66
|
+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
67
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
68
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
69
|
+
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'opsmgr/renderer/aws'
|
2
|
+
require 'opsmgr/renderer/noop'
|
3
|
+
|
4
|
+
module Opsmgr
|
5
|
+
module Renderer
|
6
|
+
def self.for(settings_file_contents)
|
7
|
+
case YAML.load(settings_file_contents)['iaas_type']
|
8
|
+
when 'aws'
|
9
|
+
AWS.new(settings_file_contents)
|
10
|
+
else
|
11
|
+
Noop.new(settings_file_contents)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
# Copyright (c) 2014-2015 Pivotal Software, Inc.
|
17
|
+
# All rights reserved.
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
19
|
+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
20
|
+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
22
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
23
|
+
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'aws-sdk-v1'
|
2
|
+
require 'mustache'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
|
6
|
+
module Opsmgr
|
7
|
+
module Renderer
|
8
|
+
class AWS < Mustache
|
9
|
+
BASE_RENDERER_FIELDS = {
|
10
|
+
vpc: 'PcfVpc',
|
11
|
+
iam_aws_access_key_id: 'PcfIamUserAccessKey',
|
12
|
+
iam_aws_secret_access_key: 'PcfIamUserSecretAccessKey',
|
13
|
+
ssh_key_pair_name: 'PcfKeyPairName',
|
14
|
+
public_subnet_id: 'PcfPublicSubnetId',
|
15
|
+
private_subnet_id: 'PcfPrivateSubnetId',
|
16
|
+
ops_manager_security_group_id: 'PcfOpsManagerSecurityGroupId',
|
17
|
+
vms_security_group_id: 'PcfVmsSecurityGroupId',
|
18
|
+
private_subnet_availability_zone: 'PcfPrivateSubnetAvailabilityZone',
|
19
|
+
public_subnet_availability_zone: 'PcfPublicSubnetAvailabilityZone',
|
20
|
+
s3_bucket_name: 'PcfOpsManagerS3Bucket',
|
21
|
+
ert_s3_bucket_name: 'PcfElasticRuntimeS3Bucket',
|
22
|
+
ert_s3_buildpacks_bucket_name: 'PcfElasticRuntimeS3BuildpacksBucket',
|
23
|
+
ert_s3_droplets_bucket_name: 'PcfElasticRuntimeS3DropletsBucket',
|
24
|
+
ert_s3_packages_bucket_name: 'PcfElasticRuntimeS3PackagesBucket',
|
25
|
+
ert_s3_resources_bucket_name: 'PcfElasticRuntimeS3ResourcesBucket',
|
26
|
+
rds_address: 'PcfRdsAddress',
|
27
|
+
rds_port: 'PcfRdsPort',
|
28
|
+
rds_username: 'PcfRdsUsername',
|
29
|
+
rds_password: 'PcfRdsPassword',
|
30
|
+
rds_ops_manager_dbname: 'PcfRdsDBName',
|
31
|
+
ert_elb_dns_name: 'PcfElbDnsName',
|
32
|
+
ert_ssh_elb_dns_name: 'PcfElbSshDnsName',
|
33
|
+
}
|
34
|
+
|
35
|
+
BASE_RENDERER_FIELDS.each do |method_sym, output_key|
|
36
|
+
define_method(method_sym) do
|
37
|
+
output(output_key)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
attr_reader :stack_name, :region
|
42
|
+
def initialize(settings_file_contents)
|
43
|
+
@settings_file_contents = settings_file_contents
|
44
|
+
settings = YAML.load(@settings_file_contents)
|
45
|
+
@vm_configs = settings.fetch('vm_shepherd').fetch('vm_configs')
|
46
|
+
@stack_name = settings.fetch('vm_shepherd').fetch('env_config').fetch('stack_name')
|
47
|
+
@region = settings.fetch('vm_shepherd').fetch('env_config').fetch('region')
|
48
|
+
|
49
|
+
::AWS.config(
|
50
|
+
access_key_id: settings.fetch('vm_shepherd').fetch('env_config').fetch('aws_access_key'),
|
51
|
+
secret_access_key: settings.fetch('vm_shepherd').fetch('env_config').fetch('aws_secret_key'),
|
52
|
+
region: region,
|
53
|
+
)
|
54
|
+
@cloud_formation = ::AWS::CloudFormation.new
|
55
|
+
@ec2 = ::AWS::EC2.new
|
56
|
+
|
57
|
+
@custom_renderer_fields = settings.fetch('custom_renderer_fields', [])
|
58
|
+
setup_custom_renderer_field_methods! unless @custom_renderer_fields.empty?
|
59
|
+
end
|
60
|
+
|
61
|
+
def setup_custom_renderer_field_methods!
|
62
|
+
@custom_renderer_fields.each do |property|
|
63
|
+
method_body = proc do
|
64
|
+
# convert my_custom_key to MyCustomKey to match AWS format
|
65
|
+
output(property.camelize)
|
66
|
+
end
|
67
|
+
|
68
|
+
self.class.send(:define_method, property.to_sym, &method_body)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def rendered_settings
|
73
|
+
render(@settings_file_contents)
|
74
|
+
end
|
75
|
+
|
76
|
+
def vms_security_group_name
|
77
|
+
security_group = @ec2.security_groups.find { |g| g.id == vms_security_group_id }
|
78
|
+
security_group ? security_group.name : ''
|
79
|
+
end
|
80
|
+
|
81
|
+
def s3_endpoint
|
82
|
+
{
|
83
|
+
'us-east-1' => 'https://s3.amazonaws.com',
|
84
|
+
'us-west-1' => 'https://s3-us-west-1.amazonaws.com',
|
85
|
+
}[region]
|
86
|
+
end
|
87
|
+
|
88
|
+
def release_candidate_public_ip
|
89
|
+
ops_manager_elastic_ip ? ops_manager_elastic_ip.public_ip : nil
|
90
|
+
end
|
91
|
+
|
92
|
+
def previous_version_public_ip
|
93
|
+
previous_version_elastic_ip ? previous_version_elastic_ip.public_ip : nil
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def output(key)
|
99
|
+
output = outputs.detect { |o| o.key == key }
|
100
|
+
return output.value unless output.nil?
|
101
|
+
''
|
102
|
+
rescue ::AWS::CloudFormation::Errors::ValidationError
|
103
|
+
''
|
104
|
+
end
|
105
|
+
|
106
|
+
def outputs
|
107
|
+
@outputs ||= @cloud_formation.stacks[@stack_name].outputs
|
108
|
+
rescue ::AWS::CloudFormation::Errors::ValidationError
|
109
|
+
@outputs = {}
|
110
|
+
end
|
111
|
+
|
112
|
+
def ops_manager_elastic_ip
|
113
|
+
@ops_manager_elastic_ip ||= ops_manager_instance ? ops_manager_instance.elastic_ip : nil
|
114
|
+
end
|
115
|
+
|
116
|
+
def ops_manager_instance
|
117
|
+
@ops_manager_instance ||= find_vm_instance('RELEASE-CANDIATE')
|
118
|
+
end
|
119
|
+
|
120
|
+
def previous_version_elastic_ip
|
121
|
+
@previous_version_elastic_ip ||= previous_version_instance ? previous_version_instance.elastic_ip : nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def previous_version_instance
|
125
|
+
@previous_version_instance ||= find_vm_instance('PREVIOUS-VERSION')
|
126
|
+
end
|
127
|
+
|
128
|
+
def find_vm_instance(vm_name_token)
|
129
|
+
@ec2.instances.find do |instance|
|
130
|
+
instance.tags.to_h['Name'] == find_vm_name(vm_name_token) && instance.status == :running
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def find_vm_name(vm_name_token)
|
135
|
+
@vm_configs.find { |config| config.fetch('vm_name').match(vm_name_token) }.fetch('vm_name')
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
# Copyright (c) 2014-2015 Pivotal Software, Inc.
|
141
|
+
# All rights reserved.
|
142
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
143
|
+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
144
|
+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
145
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
146
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
147
|
+
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Opsmgr
|
2
|
+
module Renderer
|
3
|
+
class Noop
|
4
|
+
def initialize(settings_file_contents)
|
5
|
+
@settings_file_contents = settings_file_contents
|
6
|
+
end
|
7
|
+
|
8
|
+
def rendered_settings
|
9
|
+
@settings_file_contents
|
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,84 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'opsmgr/settings/microbosh/product'
|
3
|
+
require 'opsmgr/log'
|
4
|
+
|
5
|
+
module Opsmgr
|
6
|
+
module Settings
|
7
|
+
module Microbosh
|
8
|
+
class InstallationSettings
|
9
|
+
include Loggable
|
10
|
+
|
11
|
+
def self.from_api_result(result)
|
12
|
+
new(result.as_hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(installation_hash)
|
16
|
+
@installation_hash = installation_hash
|
17
|
+
end
|
18
|
+
|
19
|
+
def product(product_name)
|
20
|
+
products.find { |p| p.name == product_name }
|
21
|
+
end
|
22
|
+
|
23
|
+
def network_guid(network_name)
|
24
|
+
networks = installation_hash.fetch('infrastructure', {}).fetch('networks', [])
|
25
|
+
matching_network = networks.find { |network| network['name'] == network_name }
|
26
|
+
|
27
|
+
if matching_network.nil?
|
28
|
+
available_network_names = networks.map { |network| network['name'] }
|
29
|
+
log.warn("No network matching name #{network_name}. Available names: #{available_network_names.join(', ')}")
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
|
33
|
+
matching_network.fetch('guid')
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_availability_zone_guid
|
37
|
+
first_zone = installation_hash.fetch('infrastructure', {}).fetch('availability_zones', []).first
|
38
|
+
first_zone['guid'] if first_zone
|
39
|
+
end
|
40
|
+
|
41
|
+
def availability_zone_guid(zone_name)
|
42
|
+
zones = installation_hash.fetch('infrastructure', {}).fetch('availability_zones', [])
|
43
|
+
matching_zone = zones.find do |zone|
|
44
|
+
zone['name'] == zone_name
|
45
|
+
end
|
46
|
+
|
47
|
+
if matching_zone.nil?
|
48
|
+
available_zone_names = zones.map { |network| network['name'] }
|
49
|
+
log.warn("No availability zone matching name #{zone_name}. Available names: #{available_zone_names.join(', ')}")
|
50
|
+
return nil
|
51
|
+
end
|
52
|
+
|
53
|
+
matching_zone.fetch('guid')
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_yaml
|
57
|
+
YAML.dump(installation_hash)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
attr_reader :installation_hash
|
63
|
+
|
64
|
+
def products
|
65
|
+
if installation_hash.key?('components')
|
66
|
+
installation_hash.fetch('components').map { |h| Opsmgr::Settings::Microbosh::Product.new(h) }
|
67
|
+
elsif installation_hash.key?('products')
|
68
|
+
installation_hash.fetch('products').map { |h| Opsmgr::Settings::Microbosh::Product.new(h) }
|
69
|
+
else
|
70
|
+
fail 'Unknown Ops Manager installation schema. Please check Ops Manager version.'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
# Copyright (c) 2014-2015 Pivotal Software, Inc.
|
78
|
+
# All rights reserved.
|
79
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
80
|
+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
81
|
+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
82
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
83
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
84
|
+
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|