ruby_aem_aws_odysseas 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/conf/gem.yaml +1 -0
- data/lib/ruby_aem_aws/abstract/cloudwatch.rb +83 -0
- data/lib/ruby_aem_aws/abstract/component.rb +54 -0
- data/lib/ruby_aem_aws/abstract/grouped_component.rb +39 -0
- data/lib/ruby_aem_aws/abstract/single_component.rb +36 -0
- data/lib/ruby_aem_aws/abstract/snapshot.rb +35 -0
- data/lib/ruby_aem_aws/abstract/stackmanager.rb +68 -0
- data/lib/ruby_aem_aws/architecture/consolidated_stack.rb +49 -0
- data/lib/ruby_aem_aws/architecture/full_set_stack.rb +141 -0
- data/lib/ruby_aem_aws/architecture/stack_manager.rb +44 -0
- data/lib/ruby_aem_aws/client/cloudwatch.rb +87 -0
- data/lib/ruby_aem_aws/client/dynamo_db.rb +36 -0
- data/lib/ruby_aem_aws/client/s3.rb +42 -0
- data/lib/ruby_aem_aws/client/sns_topic.rb +30 -0
- data/lib/ruby_aem_aws/component/author.rb +71 -0
- data/lib/ruby_aem_aws/component/author_dispatcher.rb +84 -0
- data/lib/ruby_aem_aws/component/author_primary.rb +62 -0
- data/lib/ruby_aem_aws/component/author_publish_dispatcher.rb +56 -0
- data/lib/ruby_aem_aws/component/author_standby.rb +62 -0
- data/lib/ruby_aem_aws/component/chaos_monkey.rb +78 -0
- data/lib/ruby_aem_aws/component/component_descriptor.rb +28 -0
- data/lib/ruby_aem_aws/component/orchestrator.rb +78 -0
- data/lib/ruby_aem_aws/component/publish.rb +78 -0
- data/lib/ruby_aem_aws/component/publish_dispatcher.rb +83 -0
- data/lib/ruby_aem_aws/component/stack_manager_resources.rb +90 -0
- data/lib/ruby_aem_aws/constants.rb +53 -0
- data/lib/ruby_aem_aws/error.rb +68 -0
- data/lib/ruby_aem_aws/mixins/healthy_count_verifier.rb +154 -0
- data/lib/ruby_aem_aws/mixins/healthy_resource_verifier.rb +188 -0
- data/lib/ruby_aem_aws/mixins/healthy_state_verifier.rb +45 -0
- data/lib/ruby_aem_aws/mixins/instance_describer.rb +34 -0
- data/lib/ruby_aem_aws/mixins/metric_verifier.rb +189 -0
- data/lib/ruby_aem_aws/mixins/snapshot_verifier.rb +37 -0
- data/lib/ruby_aem_aws_odysseas.rb +152 -0
- metadata +148 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
# Copyright 2018 Shine Solutions
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative '../abstract/single_component'
|
16
|
+
require_relative '../abstract/snapshot'
|
17
|
+
require_relative '../mixins/healthy_state_verifier'
|
18
|
+
require_relative '../mixins/metric_verifier'
|
19
|
+
require_relative 'component_descriptor'
|
20
|
+
require_relative '../mixins/snapshot_verifier'
|
21
|
+
|
22
|
+
module RubyAemAws
|
23
|
+
module Component
|
24
|
+
# Interface to a single AWS instance running all three AEM components as a consolidated stack.
|
25
|
+
class AuthorPublishDispatcher
|
26
|
+
attr_reader :descriptor, :ec2_resource, :cloud_watch_client, :cloud_watch_log_client
|
27
|
+
include AbstractSingleComponent
|
28
|
+
include AbstractSnapshot
|
29
|
+
include HealthyStateVerifier
|
30
|
+
include MetricVerifier
|
31
|
+
include SnapshotVerifier
|
32
|
+
|
33
|
+
EC2_COMPONENT = 'author-publish-dispatcher'.freeze
|
34
|
+
EC2_NAME = 'AuthorPublishDispatcher'.freeze
|
35
|
+
|
36
|
+
# @param stack_prefix AWS tag: StackPrefix
|
37
|
+
# @param params Array of AWS Clients and Resource connections:
|
38
|
+
# - CloudWatchClient: AWS Cloudwatch Client.
|
39
|
+
# - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
|
40
|
+
# - Ec2Resource: AWS EC2 Resource connection.
|
41
|
+
# @return new RubyAemAws::Consolidated::AuthorPublishDispatcher instance
|
42
|
+
def initialize(stack_prefix, params)
|
43
|
+
@descriptor = ComponentDescriptor.new(stack_prefix,
|
44
|
+
EC2Descriptor.new(EC2_COMPONENT, EC2_NAME))
|
45
|
+
@cloud_watch_client = params[:CloudWatchClient]
|
46
|
+
@cloud_watch_log_client = params[:CloudWatchLogsClient]
|
47
|
+
@ec2_resource = params[:Ec2Resource]
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_tags
|
51
|
+
instance = get_instance
|
52
|
+
instance.tags
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Copyright 2018 Shine Solutions
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative '../abstract/single_component'
|
16
|
+
require_relative '../abstract/snapshot'
|
17
|
+
require_relative '../mixins/healthy_state_verifier'
|
18
|
+
require_relative '../mixins/metric_verifier'
|
19
|
+
require_relative '../mixins/snapshot_verifier'
|
20
|
+
|
21
|
+
module RubyAemAws
|
22
|
+
module Component
|
23
|
+
# Interface to the AWS instance running the Author-Standby component of a full-set AEM stack.
|
24
|
+
class AuthorStandby
|
25
|
+
attr_reader :descriptor, :ec2_resource, :cloud_watch_client, :cloud_watch_log_client
|
26
|
+
include AbstractSingleComponent
|
27
|
+
include AbstractSnapshot
|
28
|
+
include HealthyStateVerifier
|
29
|
+
include MetricVerifier
|
30
|
+
include SnapshotVerifier
|
31
|
+
|
32
|
+
EC2_COMPONENT = 'author-standby'.freeze
|
33
|
+
EC2_NAME = 'AEM Author - Standby'.freeze
|
34
|
+
|
35
|
+
# @param stack_prefix AWS tag: StackPrefix
|
36
|
+
# @param params Array of AWS Clients and Resource connections:
|
37
|
+
# - CloudWatchClient: AWS Cloudwatch Client.
|
38
|
+
# - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
|
39
|
+
# - Ec2Resource: AWS EC2 Resource connection.
|
40
|
+
# @return new RubyAemAws::FullSet::AuthorStandby
|
41
|
+
def initialize(stack_prefix, params)
|
42
|
+
@descriptor = ComponentDescriptor.new(stack_prefix,
|
43
|
+
EC2Descriptor.new(EC2_COMPONENT, EC2_NAME))
|
44
|
+
@cloud_watch_client = params[:CloudWatchClient]
|
45
|
+
@cloud_watch_log_client = params[:CloudWatchLogsClient]
|
46
|
+
@ec2_resource = params[:Ec2Resource]
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return Aws::EC2::Instance
|
50
|
+
def terminate
|
51
|
+
instance = get_instance
|
52
|
+
instance.terminate
|
53
|
+
instance.wait_until_terminated
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_tags
|
57
|
+
instance = get_instance
|
58
|
+
instance.tags
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Copyright 2018 Shine Solutions
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative '../abstract/grouped_component'
|
16
|
+
require_relative '../abstract/snapshot'
|
17
|
+
require_relative '../constants'
|
18
|
+
require_relative '../mixins/healthy_resource_verifier'
|
19
|
+
require_relative '../mixins/metric_verifier'
|
20
|
+
require_relative '../mixins/snapshot_verifier'
|
21
|
+
|
22
|
+
module RubyAemAws
|
23
|
+
module Component
|
24
|
+
# Interface to the AWS instance running the ChaosMonkey component of a full-set AEM stack.
|
25
|
+
class ChaosMonkey
|
26
|
+
attr_reader :descriptor, :ec2_resource, :asg_client, :cloud_watch_client, :cloud_watch_log_client
|
27
|
+
include AbstractGroupedComponent
|
28
|
+
include AbstractSnapshot
|
29
|
+
include HealthyResourceVerifier
|
30
|
+
include MetricVerifier
|
31
|
+
include SnapshotVerifier
|
32
|
+
|
33
|
+
EC2_COMPONENT = 'chaos-monkey'.freeze
|
34
|
+
EC2_NAME = 'AEM Chaos Monkey'.freeze
|
35
|
+
|
36
|
+
# @param stack_prefix AWS tag: StackPrefix
|
37
|
+
# @param params Array of AWS Clients and Resource connections:
|
38
|
+
# - AutoScalingClient: AWS AutoScalingGroup Client.
|
39
|
+
# - CloudWatchClient: AWS Cloudwatch Client.
|
40
|
+
# - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
|
41
|
+
# - Ec2Resource: AWS EC2 Resource connection.
|
42
|
+
# @return new RubyAemAws::FullSet::ChaosMonkey
|
43
|
+
def initialize(stack_prefix, params)
|
44
|
+
@descriptor = ComponentDescriptor.new(stack_prefix,
|
45
|
+
EC2Descriptor.new(EC2_COMPONENT, EC2_NAME))
|
46
|
+
@asg_client = params[:AutoScalingClient]
|
47
|
+
@cloud_watch_client = params[:CloudWatchClient]
|
48
|
+
@cloud_watch_log_client = params[:CloudWatchLogsClient]
|
49
|
+
@ec2_resource = params[:Ec2Resource]
|
50
|
+
end
|
51
|
+
|
52
|
+
def terminate_all_instances
|
53
|
+
get_all_instances.each do |i|
|
54
|
+
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING
|
55
|
+
|
56
|
+
i.terminate
|
57
|
+
i.wait_until_terminated
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def terminate_random_instance
|
62
|
+
instance = get_random_instance
|
63
|
+
instance.terminate
|
64
|
+
instance.wait_until_terminated
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_tags
|
68
|
+
tags = []
|
69
|
+
get_all_instances.each do |i|
|
70
|
+
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING
|
71
|
+
|
72
|
+
tags.push(i.tags)
|
73
|
+
end
|
74
|
+
tags
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright 2018 Shine Solutions
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module RubyAemAws
|
16
|
+
module Component
|
17
|
+
ComponentDescriptor = Struct.new(:stack_prefix_in, :ec2, :elb) do
|
18
|
+
def stack_prefix
|
19
|
+
# Unwrap from {:stack_prefix = value} to the value if necessary.
|
20
|
+
return stack_prefix_in[:stack_prefix] if stack_prefix_in.is_a? Hash
|
21
|
+
|
22
|
+
stack_prefix_in
|
23
|
+
end
|
24
|
+
end
|
25
|
+
EC2Descriptor = Struct.new(:component, :name)
|
26
|
+
ELBDescriptor = Struct.new(:id, :name)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Copyright 2018 Shine Solutions
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative '../abstract/grouped_component'
|
16
|
+
require_relative '../abstract/snapshot'
|
17
|
+
require_relative '../constants'
|
18
|
+
require_relative '../mixins/healthy_resource_verifier'
|
19
|
+
require_relative '../mixins/metric_verifier'
|
20
|
+
require_relative '../mixins/snapshot_verifier'
|
21
|
+
|
22
|
+
module RubyAemAws
|
23
|
+
module Component
|
24
|
+
# Interface to the AWS instance running the Orchestrator component of a full-set AEM stack.
|
25
|
+
class Orchestrator
|
26
|
+
attr_reader :descriptor, :ec2_resource, :asg_client, :cloud_watch_client, :cloud_watch_log_client
|
27
|
+
include AbstractGroupedComponent
|
28
|
+
include AbstractSnapshot
|
29
|
+
include HealthyResourceVerifier
|
30
|
+
include MetricVerifier
|
31
|
+
include SnapshotVerifier
|
32
|
+
|
33
|
+
EC2_COMPONENT = 'orchestrator'.freeze
|
34
|
+
EC2_NAME = 'AEM Orchestrator'.freeze
|
35
|
+
|
36
|
+
# @param stack_prefix AWS tag: StackPrefix
|
37
|
+
# @param params Array of AWS Clients and Resource connections:
|
38
|
+
# - AutoScalingClient: AWS AutoScalingGroup Client.
|
39
|
+
# - CloudWatchClient: AWS Cloudwatch Client.
|
40
|
+
# - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
|
41
|
+
# - Ec2Resource: AWS EC2 Resource connection.
|
42
|
+
# @return new RubyAemAws::FullSet::Orchestrator
|
43
|
+
def initialize(stack_prefix, params)
|
44
|
+
@descriptor = ComponentDescriptor.new(stack_prefix,
|
45
|
+
EC2Descriptor.new(EC2_COMPONENT, EC2_NAME))
|
46
|
+
@asg_client = params[:AutoScalingClient]
|
47
|
+
@cloud_watch_client = params[:CloudWatchClient]
|
48
|
+
@cloud_watch_log_client = params[:CloudWatchLogsClient]
|
49
|
+
@ec2_resource = params[:Ec2Resource]
|
50
|
+
end
|
51
|
+
|
52
|
+
def terminate_all_instances
|
53
|
+
get_all_instances.each do |i|
|
54
|
+
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING
|
55
|
+
|
56
|
+
i.terminate
|
57
|
+
i.wait_until_terminated
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def terminate_random_instance
|
62
|
+
instance = get_random_instance
|
63
|
+
instance.terminate
|
64
|
+
instance.wait_until_terminated
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_tags
|
68
|
+
tags = []
|
69
|
+
get_all_instances.each do |i|
|
70
|
+
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING
|
71
|
+
|
72
|
+
tags.push(i.tags)
|
73
|
+
end
|
74
|
+
tags
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Copyright 2018 Shine Solutions
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative '../abstract/grouped_component'
|
16
|
+
require_relative '../abstract/snapshot'
|
17
|
+
require_relative '../constants'
|
18
|
+
require_relative '../mixins/healthy_resource_verifier'
|
19
|
+
require_relative '../mixins/metric_verifier'
|
20
|
+
require_relative '../mixins/snapshot_verifier'
|
21
|
+
|
22
|
+
module RubyAemAws
|
23
|
+
module Component
|
24
|
+
# Interface to the AWS instance running the Publish component of a full-set AEM stack.
|
25
|
+
class Publish
|
26
|
+
attr_reader :descriptor, :ec2_resource, :cloud_watch_client, :asg_client, :cloud_watch_log_client
|
27
|
+
include AbstractGroupedComponent
|
28
|
+
include AbstractSnapshot
|
29
|
+
include HealthyResourceVerifier
|
30
|
+
include MetricVerifier
|
31
|
+
include SnapshotVerifier
|
32
|
+
|
33
|
+
EC2_COMPONENT = 'publish'.freeze
|
34
|
+
EC2_NAME = 'AEM Publish'.freeze
|
35
|
+
|
36
|
+
# @param stack_prefix AWS tag: StackPrefix
|
37
|
+
# @param params Array of AWS Clients and Resource connections:
|
38
|
+
# - AutoScalingClient: AWS AutoScalingGroup Client.
|
39
|
+
# - CloudWatchClient: AWS Cloudwatch Client.
|
40
|
+
# - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
|
41
|
+
# - Ec2Resource: AWS EC2 Resource connection.
|
42
|
+
# @return new RubyAemAws::FullSet::AuthorPrimary
|
43
|
+
def initialize(stack_prefix, params)
|
44
|
+
@descriptor = ComponentDescriptor.new(stack_prefix,
|
45
|
+
EC2Descriptor.new(EC2_COMPONENT, EC2_NAME))
|
46
|
+
@asg_client = params[:AutoScalingClient]
|
47
|
+
@cloud_watch_client = params[:CloudWatchClient]
|
48
|
+
@cloud_watch_log_client = params[:CloudWatchLogsClient]
|
49
|
+
@ec2_resource = params[:Ec2Resource]
|
50
|
+
end
|
51
|
+
|
52
|
+
def terminate_all_instances
|
53
|
+
get_all_instances.each do |i|
|
54
|
+
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING
|
55
|
+
|
56
|
+
i.terminate
|
57
|
+
i.wait_until_terminated
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def terminate_random_instance
|
62
|
+
instance = get_random_instance
|
63
|
+
instance.terminate
|
64
|
+
instance.wait_until_terminated
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_tags
|
68
|
+
tags = []
|
69
|
+
get_all_instances.each do |i|
|
70
|
+
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING
|
71
|
+
|
72
|
+
tags.push(i.tags)
|
73
|
+
end
|
74
|
+
tags
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# Copyright 2018 Shine Solutions
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative '../abstract/grouped_component'
|
16
|
+
require_relative '../abstract/snapshot'
|
17
|
+
require_relative '../constants'
|
18
|
+
require_relative '../mixins/healthy_resource_verifier'
|
19
|
+
require_relative '../mixins/metric_verifier'
|
20
|
+
require_relative '../mixins/snapshot_verifier'
|
21
|
+
|
22
|
+
module RubyAemAws
|
23
|
+
module Component
|
24
|
+
# Interface to the AWS instance running the PublishDispatcher component of a full-set AEM stack.
|
25
|
+
class PublishDispatcher
|
26
|
+
attr_reader :descriptor, :ec2_resource, :asg_client, :elb_client, :cloud_watch_client, :cloud_watch_log_client
|
27
|
+
include AbstractGroupedComponent
|
28
|
+
include AbstractSnapshot
|
29
|
+
include HealthyResourceVerifier
|
30
|
+
include MetricVerifier
|
31
|
+
include SnapshotVerifier
|
32
|
+
|
33
|
+
EC2_COMPONENT = 'publish-dispatcher'.freeze
|
34
|
+
EC2_NAME = 'AEM Publish Dispatcher'.freeze
|
35
|
+
ELB_ID = 'PublishDispatcherLoadBalancer'.freeze
|
36
|
+
ELB_NAME = 'AEM Publish Dispatcher Load Balancer'.freeze
|
37
|
+
|
38
|
+
# @param stack_prefix AWS tag: StackPrefix
|
39
|
+
# @param params Array of AWS Clients and Resource connections:
|
40
|
+
# - AutoScalingClient: AWS AutoScalingGroup Client.
|
41
|
+
# - CloudWatchClient: AWS Cloudwatch Client.
|
42
|
+
# - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
|
43
|
+
# - Ec2Resource: AWS EC2 Resource connection.
|
44
|
+
# - ElbClient: AWS ElasticLoadBalancer Client.
|
45
|
+
# @return new RubyAemAws::FullSet::PublishDispatcher
|
46
|
+
def initialize(stack_prefix, params)
|
47
|
+
@descriptor = ComponentDescriptor.new(stack_prefix,
|
48
|
+
EC2Descriptor.new(EC2_COMPONENT, EC2_NAME),
|
49
|
+
ELBDescriptor.new(ELB_ID, ELB_NAME))
|
50
|
+
@asg_client = params[:AutoScalingClient]
|
51
|
+
@cloud_watch_client = params[:CloudWatchClient]
|
52
|
+
@cloud_watch_log_client = params[:CloudWatchLogsClient]
|
53
|
+
@ec2_resource = params[:Ec2Resource]
|
54
|
+
@elb_client = params[:ElbClient]
|
55
|
+
end
|
56
|
+
|
57
|
+
def terminate_all_instances
|
58
|
+
get_all_instances.each do |i|
|
59
|
+
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING
|
60
|
+
|
61
|
+
i.terminate
|
62
|
+
i.wait_until_terminated
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def terminate_random_instance
|
67
|
+
instance = get_random_instance
|
68
|
+
instance.terminate
|
69
|
+
instance.wait_until_terminated
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_tags
|
73
|
+
tags = []
|
74
|
+
get_all_instances.each do |i|
|
75
|
+
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING
|
76
|
+
|
77
|
+
tags.push(i.tags)
|
78
|
+
end
|
79
|
+
tags
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|