opsmgr-cgfrost 0.35.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LEGAL.txt +13 -0
- data/README.md +123 -0
- data/lib/opsmgr.rb +12 -0
- data/lib/opsmgr/api/client.rb +116 -0
- data/lib/opsmgr/api/http_client.rb +399 -0
- data/lib/opsmgr/api/results.rb +280 -0
- data/lib/opsmgr/api/version20/endpoints.rb +121 -0
- data/lib/opsmgr/bosh_command_runner.rb +84 -0
- data/lib/opsmgr/cmd/bosh_command.rb +189 -0
- data/lib/opsmgr/cmd/ops_manager.rb +142 -0
- data/lib/opsmgr/environments.rb +106 -0
- data/lib/opsmgr/errand_runner.rb +62 -0
- data/lib/opsmgr/log.rb +70 -0
- data/lib/opsmgr/product_upload_wrapper.rb +71 -0
- data/lib/opsmgr/renderer.rb +23 -0
- data/lib/opsmgr/renderer/aws.rb +148 -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 +56 -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 +90 -0
- data/lib/opsmgr/settings/microbosh/product_list.rb +27 -0
- data/lib/opsmgr/settings/microbosh/property.rb +33 -0
- data/lib/opsmgr/settings/microbosh/property_list.rb +27 -0
- data/lib/opsmgr/tasks.rb +16 -0
- data/lib/opsmgr/tasks/bosh.rake +104 -0
- data/lib/opsmgr/tasks/destroy.rake +42 -0
- data/lib/opsmgr/tasks/info.rake +19 -0
- data/lib/opsmgr/tasks/opsmgr.rake +205 -0
- data/lib/opsmgr/tasks/product.rake +82 -0
- data/lib/opsmgr/ui_helpers/add_first_user_spec.rb +25 -0
- data/lib/opsmgr/ui_helpers/config_helper.rb +38 -0
- data/lib/opsmgr/ui_helpers/delete_installation_spec.rb +41 -0
- data/lib/opsmgr/ui_helpers/delete_product_if_present_spec.rb +37 -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_stemcell_spec.rb +30 -0
- data/lib/opsmgr/ui_helpers/microbosh/configure_microbosh_spec.rb +32 -0
- data/lib/opsmgr/ui_helpers/post_import_configuration_spec.rb +31 -0
- data/lib/opsmgr/ui_helpers/revert_staged_changes_spec.rb +39 -0
- data/lib/opsmgr/ui_helpers/settings_helper.rb +132 -0
- data/lib/opsmgr/ui_helpers/trigger_install_spec.rb +35 -0
- data/lib/opsmgr/ui_helpers/ui_spec_runner.rb +122 -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
- data/sample_env_files/aws.yml +95 -0
- data/sample_env_files/vsphere.yml +87 -0
- metadata +392 -0
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,71 @@
|
|
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:, om_version:)
|
8
|
+
wrap_operation(environment, product_path, product_name, 'add', om_version)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.wrap_upgrade(environment:, product_path:, product_name:, om_version:)
|
12
|
+
wrap_operation(environment, product_path, product_name, 'upgrade', om_version)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.wrap_upload(environment:, product_path:, product_name:, om_version:)
|
16
|
+
wrap_operation(environment, product_path, product_name, 'upload', om_version)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.wrap_operation(environment, product_path, product_name, operation, om_version)
|
20
|
+
unless %w(add upgrade upload).include?(operation)
|
21
|
+
fail "Operation '#{operation}' is not available"
|
22
|
+
end
|
23
|
+
|
24
|
+
environment_object = Opsmgr::Environments.for(environment)
|
25
|
+
client = Opsmgr::Api::Client.new(environment_object, om_version)
|
26
|
+
opsmgr_cmd = Opsmgr::Cmd::OpsManager.new(environment_object)
|
27
|
+
opsmgr_cmd.upload_product(client, product_path)
|
28
|
+
|
29
|
+
products_list = opsmgr_cmd.list_products(client)
|
30
|
+
|
31
|
+
stored_version = find_latest_version(product_name, products_list)
|
32
|
+
|
33
|
+
fail "#{product_name} is not available" if stored_version.nil?
|
34
|
+
|
35
|
+
return if operation == 'upload'
|
36
|
+
|
37
|
+
if operation == 'add'
|
38
|
+
opsmgr_cmd.add_product(client, product_name, stored_version)
|
39
|
+
else
|
40
|
+
installed_products = opsmgr_cmd.installed_products(client)
|
41
|
+
product_guid = installed_products.guid_for(product_name)
|
42
|
+
opsmgr_cmd.upgrade_product(client, product_guid, stored_version)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.find_latest_version(product_name, products_list)
|
47
|
+
stored_version = nil
|
48
|
+
|
49
|
+
products_list.products.each do |p|
|
50
|
+
if p['name'] != product_name
|
51
|
+
next
|
52
|
+
end
|
53
|
+
|
54
|
+
if stored_version.nil?
|
55
|
+
stored_version = p['product_version']
|
56
|
+
elsif Gem::Version.new(p['product_version']) > Gem::Version.new(stored_version)
|
57
|
+
stored_version = p['product_version']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
stored_version
|
62
|
+
end
|
63
|
+
end
|
64
|
+
# Copyright (c) 2014-2015 Pivotal Software, Inc.
|
65
|
+
# All rights reserved.
|
66
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
67
|
+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
68
|
+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
69
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
70
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
71
|
+
# 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,148 @@
|
|
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
|
+
ert_tcp_elb_dns_name: 'PcfElbTcpDnsName'
|
34
|
+
}.freeze
|
35
|
+
|
36
|
+
BASE_RENDERER_FIELDS.each do |method_sym, output_key|
|
37
|
+
define_method(method_sym) do
|
38
|
+
output(output_key)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
attr_reader :stack_name, :region
|
43
|
+
def initialize(settings_file_contents)
|
44
|
+
@settings_file_contents = settings_file_contents
|
45
|
+
settings = YAML.load(@settings_file_contents)
|
46
|
+
@vm_configs = settings.fetch('vm_shepherd').fetch('vm_configs')
|
47
|
+
@stack_name = settings.fetch('vm_shepherd').fetch('env_config').fetch('stack_name')
|
48
|
+
@region = settings.fetch('vm_shepherd').fetch('env_config').fetch('region')
|
49
|
+
|
50
|
+
::AWS.config(
|
51
|
+
access_key_id: settings.fetch('vm_shepherd').fetch('env_config').fetch('aws_access_key'),
|
52
|
+
secret_access_key: settings.fetch('vm_shepherd').fetch('env_config').fetch('aws_secret_key'),
|
53
|
+
region: region,
|
54
|
+
)
|
55
|
+
@cloud_formation = ::AWS::CloudFormation.new
|
56
|
+
@ec2 = ::AWS::EC2.new
|
57
|
+
|
58
|
+
@custom_renderer_fields = settings.fetch('custom_renderer_fields', [])
|
59
|
+
setup_custom_renderer_field_methods! unless @custom_renderer_fields.empty?
|
60
|
+
end
|
61
|
+
|
62
|
+
def setup_custom_renderer_field_methods!
|
63
|
+
@custom_renderer_fields.each do |property|
|
64
|
+
method_body = proc do
|
65
|
+
# convert my_custom_key to MyCustomKey to match AWS format
|
66
|
+
output(property.camelize)
|
67
|
+
end
|
68
|
+
|
69
|
+
self.class.send(:define_method, property.to_sym, &method_body)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def rendered_settings
|
74
|
+
render(@settings_file_contents)
|
75
|
+
end
|
76
|
+
|
77
|
+
def vms_security_group_name
|
78
|
+
security_group = @ec2.security_groups.find { |g| g.id == vms_security_group_id }
|
79
|
+
security_group ? security_group.name : ''
|
80
|
+
end
|
81
|
+
|
82
|
+
def s3_endpoint
|
83
|
+
{
|
84
|
+
'us-east-1' => 'https://s3.amazonaws.com',
|
85
|
+
'us-west-1' => 'https://s3-us-west-1.amazonaws.com',
|
86
|
+
}[region]
|
87
|
+
end
|
88
|
+
|
89
|
+
def release_candidate_public_ip
|
90
|
+
ops_manager_elastic_ip ? ops_manager_elastic_ip.public_ip : nil
|
91
|
+
end
|
92
|
+
|
93
|
+
def previous_version_public_ip
|
94
|
+
previous_version_elastic_ip ? previous_version_elastic_ip.public_ip : nil
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def output(key)
|
100
|
+
output = outputs.detect { |o| o.key == key }
|
101
|
+
return output.value unless output.nil?
|
102
|
+
''
|
103
|
+
rescue ::AWS::CloudFormation::Errors::ValidationError
|
104
|
+
''
|
105
|
+
end
|
106
|
+
|
107
|
+
def outputs
|
108
|
+
@outputs ||= @cloud_formation.stacks[@stack_name].outputs
|
109
|
+
rescue ::AWS::CloudFormation::Errors::ValidationError
|
110
|
+
@outputs = {}
|
111
|
+
end
|
112
|
+
|
113
|
+
def ops_manager_elastic_ip
|
114
|
+
@ops_manager_elastic_ip ||= ops_manager_instance ? ops_manager_instance.elastic_ip : nil
|
115
|
+
end
|
116
|
+
|
117
|
+
def ops_manager_instance
|
118
|
+
@ops_manager_instance ||= find_vm_instance('RELEASE-CANDIATE')
|
119
|
+
end
|
120
|
+
|
121
|
+
def previous_version_elastic_ip
|
122
|
+
@previous_version_elastic_ip ||= previous_version_instance ? previous_version_instance.elastic_ip : nil
|
123
|
+
end
|
124
|
+
|
125
|
+
def previous_version_instance
|
126
|
+
@previous_version_instance ||= find_vm_instance('PREVIOUS-VERSION')
|
127
|
+
end
|
128
|
+
|
129
|
+
def find_vm_instance(vm_name_token)
|
130
|
+
@ec2.instances.find do |instance|
|
131
|
+
instance.tags.to_h['Name'] == find_vm_name(vm_name_token) && instance.status == :running
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def find_vm_name(vm_name_token)
|
136
|
+
@vm_configs.find { |config| config.fetch('vm_name').match(vm_name_token) }.fetch('vm_name')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
# Copyright (c) 2014-2015 Pivotal Software, Inc.
|
142
|
+
# All rights reserved.
|
143
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
144
|
+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
145
|
+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
146
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
147
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
148
|
+
# 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.
|
@@ -0,0 +1,56 @@
|
|
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')
|
13
|
+
rescue
|
14
|
+
job_hash.fetch('type')
|
15
|
+
end
|
16
|
+
|
17
|
+
def property(property_name)
|
18
|
+
properties('properties').find { |property| property.name == property_name }
|
19
|
+
end
|
20
|
+
|
21
|
+
def resource(resource_name)
|
22
|
+
properties('resources').find { |resource| resource.name == resource_name }
|
23
|
+
end
|
24
|
+
|
25
|
+
def networks=(networks)
|
26
|
+
job_hash['network_references'] = networks
|
27
|
+
end
|
28
|
+
|
29
|
+
def elb_name=(name)
|
30
|
+
job_hash['elb_name'] = name
|
31
|
+
end
|
32
|
+
|
33
|
+
def instances=(instance_count)
|
34
|
+
job_hash['instances'].first['value'] = instance_count
|
35
|
+
job_hash.delete('partitions')
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
attr_reader :job_hash
|
41
|
+
|
42
|
+
def properties(key)
|
43
|
+
job_hash[key].map { |property| Opsmgr::Settings::Microbosh::Property.new(property) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
# Copyright (c) 2014-2015 Pivotal Software, Inc.
|
50
|
+
# All rights reserved.
|
51
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
52
|
+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
53
|
+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
54
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
55
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
56
|
+
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|