prima-twig 0.56.82 → 0.57.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 800b8a6ea7c7da6e8d28909aa71ebf735a7633c006dbd0b973621b57b158ff3e
4
- data.tar.gz: 5cec0cacd51094c1b3c6e11f63745f3cae01b2f08c55e01d01b0023b278b91aa
3
+ metadata.gz: 263cb3add15f62f517e594cd0319db08a667ada510f43d586e18bc68cc221709
4
+ data.tar.gz: 22659c79c2ae2a16377e65043e182c48768b1445b4bd79c01273e60274991904
5
5
  SHA512:
6
- metadata.gz: 4e3a16a61aae91cefc6bf1a8b522cbe6d8d763cf0d5a19bdb8beb30f3df5c7310b3ff4933875005d81d14c1928796a8e0db5e99b6f468f90b974bb5e3c6edde7
7
- data.tar.gz: 7956f2b6a78191c18aac8ee337d122f447575c2808fe9f30610bfe73a674db1c13d681b6a51abebdfda39888c0f71ba6fc15efe332f5bc3b0f5f9caa576f8dc3
6
+ metadata.gz: e8dd33e8a28dc23c7bee07318f30895c7c2c3dba67d1841791f66ee32a42095945abe871753d587b92731c169e259a60caec2bee7935219ca775efd695b28d69
7
+ data.tar.gz: 10c2eaf08194ea86fb6cc836cd9127772955b944d27f2af4647fc597cf61aa94aa41d07dcb8e329a2af2db1c5d5f4da5ee5d14c8ea5c603d212de977173f44f8
@@ -22,7 +22,12 @@ class Release
22
22
  exec "twig feature #{ARGV.join ' '}"
23
23
  end
24
24
  end
25
+ @cf = Aws::CloudFormation::Client.new
26
+ @alb = Aws::ElasticLoadBalancingV2::Client.new
27
+ @ec2 = Aws::EC2::Client.new
28
+ @ecs = Aws::ECS::Client.new
25
29
  @batch = Aws::Batch::Client.new
30
+ @asg = Aws::AutoScaling::Client.new
26
31
  @s3 = Aws::S3::Client.new
27
32
  @s3_bucket = 'prima-artifacts'
28
33
  @artifact_path = '/tmp/prima-artifact.zip'
@@ -750,7 +755,7 @@ class Release
750
755
  create_alb_stack(stack_name_alb, "http", deploy_id, 'qa-minimal') unless stack_exists?(stack_name_alb)
751
756
  create_alb_stack(stack_name_alb_ws, "websocket", deploy_id, 'qa-minimal') unless stack_exists?(stack_name_alb_ws)
752
757
 
753
- resp = describe_stack_resource(cluster_stack_name, 'ECSCluster')
758
+ resp = @cf.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: 'ECSCluster'})
754
759
  @ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
755
760
 
756
761
  asg_stack_name = "ecs-asg-allinone-qa-#{deploy_id}"
@@ -921,7 +926,7 @@ class Release
921
926
  create_alb_stack(stack_name_alb, "http", deploy_id) unless stack_exists?(stack_name_alb)
922
927
  create_alb_stack(stack_name_alb_ws, "websocket", deploy_id) unless stack_exists?(stack_name_alb_ws)
923
928
 
924
- resp = describe_stack_resource(cluster_stack_name, 'ECSCluster')
929
+ resp = @cf.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: 'ECSCluster'})
925
930
  @ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
926
931
 
927
932
  asg_stack_name = "ecs-asg-allinone-qa-#{deploy_id}"
@@ -2032,10 +2037,16 @@ class Release
2032
2037
  end
2033
2038
 
2034
2039
  def ec2_ip_address(asg_stack_name)
2035
- resp = describe_stack_resource(asg_stack_name, 'ECSAutoScalingGroup')
2036
- resp = describe_auto_scaling_groups([resp.stack_resource_detail.physical_resource_id], 1)
2040
+ resp = @cf.describe_stack_resource({
2041
+ stack_name: asg_stack_name,
2042
+ logical_resource_id: 'ECSAutoScalingGroup'
2043
+ })
2044
+ resp = @asg.describe_auto_scaling_groups({
2045
+ auto_scaling_group_names: [resp.stack_resource_detail.physical_resource_id],
2046
+ max_records: 1
2047
+ })
2037
2048
  instance_id = resp.auto_scaling_groups[0].instances[0].instance_id
2038
- resp = describe_instances([instance_id])
2049
+ resp = @ec2.describe_instances({instance_ids: [instance_id]})
2039
2050
  resp.reservations[0].instances[0].private_ip_address
2040
2051
  end
2041
2052
 
@@ -2080,8 +2091,13 @@ class Release
2080
2091
  when stack_name.include?('hutch')
2081
2092
  logical_resource_id = 'EcsApplicationLoadBalancerPublic'
2082
2093
  end
2083
- resp = describe_stack_resource(stack_name, logical_resource_id)
2084
- resp = describe_load_balancers([resp.stack_resource_detail.physical_resource_id])
2094
+ resp = @cf.describe_stack_resource({
2095
+ stack_name: stack_name,
2096
+ logical_resource_id: logical_resource_id
2097
+ })
2098
+ resp = @alb.describe_load_balancers({
2099
+ load_balancer_arns: [resp.stack_resource_detail.physical_resource_id]
2100
+ })
2085
2101
  resp.load_balancers[0].dns_name
2086
2102
  end
2087
2103
 
@@ -2130,8 +2146,18 @@ class Release
2130
2146
  else
2131
2147
  raise "Service name non gestito per lo stack #{stack_name}"
2132
2148
  end
2133
- resp = describe_stack_resource(stack_name, logical_resource_id)
2134
- update_ecs_service(@ecs_cluster_name, resp.stack_resource_detail.physical_resource_id, {minimum_healthy_percent: 0, maximum_percent: 100})
2149
+ resp = @cf.describe_stack_resource(
2150
+ stack_name: stack_name,
2151
+ logical_resource_id: logical_resource_id
2152
+ )
2153
+ @ecs.update_service(
2154
+ cluster: @ecs_cluster_name,
2155
+ service: resp.stack_resource_detail.physical_resource_id,
2156
+ deployment_configuration: {
2157
+ minimum_healthy_percent: 0,
2158
+ maximum_percent: 100
2159
+ }
2160
+ )
2135
2161
  end
2136
2162
 
2137
2163
  def create_activia_artifact(revision)
@@ -2866,20 +2892,24 @@ class Release
2866
2892
  end
2867
2893
 
2868
2894
  def import_dbs(ip_address)
2869
- overrides = {
2870
- container_overrides: [
2871
- {
2872
- name: 'dbrestore',
2873
- environment: [
2874
- {
2875
- name: 'EC2_IP_ADDRESS',
2876
- value: ip_address
2877
- }
2878
- ]
2879
- }
2880
- ]
2881
- }
2882
- resp = run_ecs_task(@ecs_cluster_name, @import_db_task, overrides, 1)
2895
+ resp = @ecs.run_task({
2896
+ cluster: @ecs_cluster_name,
2897
+ task_definition: @import_db_task,
2898
+ overrides: {
2899
+ container_overrides: [
2900
+ {
2901
+ name: 'dbrestore',
2902
+ environment: [
2903
+ {
2904
+ name: 'EC2_IP_ADDRESS',
2905
+ value: ip_address
2906
+ }
2907
+ ]
2908
+ }
2909
+ ]
2910
+ },
2911
+ count: 1
2912
+ })
2883
2913
  return resp
2884
2914
  end
2885
2915
 
@@ -2893,7 +2923,10 @@ class Release
2893
2923
  pp task
2894
2924
  stop_if true, "Task di import DB lanciato, ma risposta vuota!".red
2895
2925
  end
2896
- task = describe_ecs_tasks(task.tasks[0].cluster_arn, [task.tasks[0].task_arn])
2926
+ task = @ecs.describe_tasks({
2927
+ cluster: task.tasks[0].cluster_arn,
2928
+ tasks: [task.tasks[0].task_arn]
2929
+ })
2897
2930
  stopped_at = task.tasks[0].stopped_at unless task.tasks[0].nil?
2898
2931
  sleep_seconds = 10
2899
2932
  seconds_elapsed = 0
@@ -2997,7 +3030,10 @@ class Release
2997
3030
  end
2998
3031
 
2999
3032
  def launch_marley(ip_address, prima_hostname, borat_hostname)
3000
- resp = describe_stack_resource('batch-job-marley', 'JobDefinition')
3033
+ resp = @cf.describe_stack_resource({
3034
+ stack_name: 'batch-job-marley',
3035
+ logical_resource_id: 'JobDefinition'
3036
+ })
3001
3037
 
3002
3038
  @batch.submit_job({
3003
3039
  job_name: "marley-#{@dns_record_identifier}", # required
@@ -18,14 +18,6 @@ module PrimaAwsClient
18
18
  @ec2 ||= Aws::EC2::Client.new
19
19
  end
20
20
 
21
- def alb_client
22
- @alb ||= Aws::ElasticLoadBalancingV2::Client.new
23
- end
24
-
25
- def ecs_client
26
- @ecs ||= Aws::ECS::Client.new
27
- end
28
-
29
21
  def stack_list
30
22
  stacks = []
31
23
  next_token = ''
@@ -315,91 +307,6 @@ module PrimaAwsClient
315
307
  stacks
316
308
  end
317
309
 
318
- def describe_stack_resource(cluster_stack_name, logical_resource_id)
319
- begin
320
- resp = cf_client.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: logical_resource_id})
321
- rescue Aws::CloudFormation::Errors::Throttling => e
322
- output 'Throttling, retrying in 15 seconds'.red
323
- sleep 15
324
- resp = describe_stack_resource(cluster_stack_name, logical_resource_id)
325
- end
326
- end
327
-
328
- def describe_instances(instance_ids)
329
- begin
330
- resp = ec2_client.describe_instances({instance_ids: instance_ids})
331
- rescue Aws::CloudFormation::Errors::Throttling => e
332
- output 'Throttling, retrying in 15 seconds'.red
333
- sleep 15
334
- resp = describe_instances(instance_ids)
335
- end
336
- end
337
-
338
- def describe_auto_scaling_groups(auto_scaling_group_names, max_records)
339
- begin
340
- resp = asg_client.describe_auto_scaling_groups({
341
- auto_scaling_group_names: auto_scaling_group_names,
342
- max_records: max_records
343
- })
344
- rescue Aws::CloudFormation::Errors::Throttling => e
345
- output 'Throttling, retrying in 15 seconds'.red
346
- sleep 15
347
- resp = describe_auto_scaling_groups(auto_scaling_group_names, max_records)
348
- end
349
- end
350
-
351
- def describe_load_balancers(load_balancer_arns)
352
- begin
353
- resp = alb_client.describe_load_balancers({load_balancer_arns: load_balancer_arns})
354
- rescue Aws::CloudFormation::Errors::Throttling => e
355
- output 'Throttling, retrying in 15 seconds'.red
356
- sleep 15
357
- resp = describe_load_balancers(load_balancer_arns)
358
- end
359
- end
360
-
361
- def update_ecs_service(cluster, service, deployment_configuration)
362
- begin
363
- resp = ecs_client.update_service(
364
- cluster: cluster,
365
- service: service,
366
- deployment_configuration: deployment_configuration
367
- )
368
- rescue Aws::CloudFormation::Errors::Throttling => e
369
- output 'Throttling, retrying in 15 seconds'.red
370
- sleep 15
371
- resp = update_ecs_service(cluster, service, deployment_configuration)
372
- end
373
- end
374
-
375
- def describe_ecs_tasks(cluster, tasks)
376
- begin
377
- resp = ecs_client.describe_tasks({
378
- cluster: cluster,
379
- tasks: tasks
380
- })
381
- rescue Aws::CloudFormation::Errors::Throttling => e
382
- output 'Throttling, retrying in 15 seconds'.red
383
- sleep 15
384
- resp = describe_ecs_tasks(cluster, tasks)
385
- end
386
- end
387
-
388
- def run_ecs_task(cluster, task_definition, overrides, count)
389
- begin
390
- resp = ecs_client.run_task({
391
- cluster: cluster,
392
- task_definition: task_definition,
393
- overrides: overrides,
394
- count: count
395
- })
396
- rescue Aws::CloudFormation::Errors::Throttling => e
397
- output 'Throttling, retrying in 15 seconds'.red
398
- sleep 15
399
- resp = run_ecs_task(cluster, task_definition, overrides, count)
400
- end
401
- end
402
-
403
310
  def get_autoscaling_capacity(asg_name)
404
311
  resp = asg_client.describe_auto_scaling_groups(auto_scaling_group_names: [asg_name])
405
312
  resp.auto_scaling_groups[0].desired_capacity
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prima-twig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.56.82
4
+ version: 0.57.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Giachino
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2019-11-25 00:00:00.000000000 Z
17
+ date: 2019-11-22 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: aws-sdk