stackit 0.3.1 → 0.3.2

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
  SHA1:
3
- metadata.gz: b39c2acbc470ade26621ca98efb4022dc6a6fee1
4
- data.tar.gz: 399b7ae0ffe05e4eb97cc515ca8163ebf0f5efdb
3
+ metadata.gz: de939371b4c2853953a61ce1851f1ac00e2bad9a
4
+ data.tar.gz: 3b5b469c61b4a782c48c026b59b00f15b9bc315d
5
5
  SHA512:
6
- metadata.gz: bae425a405e846166d0a9e83b83f1ba9bf4dbe1b937943f0ddb463dab8f91bcb14eabe272910f14fb0477d8a023d605f39cfa5c6302f06ded70edfa9a9f9c8d4
7
- data.tar.gz: ebecc281df32b6392c39f1b217722fa27901a83c156acadc9d96c2503a0d5734c95f6194d5873f5d69fd3bfe82c42843a5eb4c4fc6eda751354a8909120bfdf2
6
+ metadata.gz: 0e41b598ae066cec28c01cf73671c8e624c633aae1c835f53035bf3934eef2c7b826371c149d6f8f1c1362005fe849a8be0f980e11f82b87dcc4b77523a2ab8d
7
+ data.tar.gz: 0b428e5bfb1a5b863bc2344624d9fd67b4ff3896bbe4abaa907bc7ddc61173dc49d375a09732fc4caa1aa920920482eae5122820866f01fadbd1116e451708b1
@@ -1,39 +1,36 @@
1
1
  module Stackit::Mixin::AvailabilityZone
2
2
 
3
- def selected_az_sym
4
- selected_az.keys[0].to_sym
3
+ attr_accessor :az_syms
4
+
5
+ def az_syms=(keys)
6
+ @az_syms = keys.each{ |key|
7
+ key = key.to_sym
8
+ }
5
9
  end
6
10
 
7
- def selected_az_value
8
- selected_az.values[0]
11
+ def selected_az_sym
12
+ selected_az_hash.keys[0].to_sym
9
13
  end
10
14
 
11
- def subnet_id_for_selected_az(tier, az_sym = selected_az_sym)
12
- az_subnet_mapping = az_subnet_map(tier)
13
- selected_subnet_key = az_subnet_mapping[az_sym]
14
- resolve_parameter(selected_subnet_key)
15
+ def selected_az
16
+ selected_az_hash.values[0]
15
17
  end
16
18
 
17
- def random_az(keys = default_az_keys)
18
- resolve_parameters(keys).split(',').sample
19
+ def random_az
20
+ resolve_parameters(az_syms).split(',').sample
19
21
  end
20
22
 
21
- def random_az_as_hash(keys = default_az_keys)
22
- sampled_az_key = default_az_keys.sample
23
- sampled_az_value = resolve_parameter(sampled_az_key.to_sym)
23
+ def random_az_hash
24
+ sampled_az_sym = az_syms.sample
24
25
  {
25
- sampled_az_key => sampled_az_value
26
+ sampled_az_sym => resolve_parameter(sampled_az_sym)
26
27
  }
27
28
  end
28
29
 
29
30
  private
30
31
 
31
- def default_az_keys
32
- [:VpcAvailabilityZone1, :VpcAvailabilityZone2, :VpcAvailabilityZone3]
33
- end
34
-
35
- def selected_az
36
- @selected_az ||= random_az_as_hash
32
+ def selected_az_hash
33
+ @selected_az_hash ||= random_az_hash
37
34
  end
38
35
 
39
36
  end
@@ -5,30 +5,44 @@ module Stackit::Mixin::Tier
5
5
  include Stackit::Mixin::AvailabilityZone
6
6
 
7
7
  attr_accessor :tier
8
+ attr_accessor :tier_map
8
9
 
9
10
  def tier=(tier)
10
11
  @tier = tier.to_sym
11
12
  end
12
13
 
13
- def random_tier_az
14
- random_az ||= random_az_as_hash
14
+ def tier_map=(map)
15
+ @tier_map = map
15
16
  end
16
17
 
17
- def random_tier_az_sym
18
- random_tier_az.keys[0].to_sym
18
+ def selected_subnet_sym
19
+ tier_map[tier][selected_az_sym]
19
20
  end
20
21
 
21
- def random_tier_az_value
22
- random_tier_az.values[0]
22
+ def selected_subnet
23
+ resolve_parameter(selected_subnet_sym)
24
+ end
25
+
26
+ def subnets
27
+ resolve_parameters(tier_map[tier].values)
28
+ end
29
+
30
+ def random_subnet
31
+ random_az_and_subnet[:subnet]
32
+ end
33
+
34
+ def random_subnet_sym
35
+ random_az = random_az_hash
36
+ random_az_sym = random_az.keys[0]
37
+ tier_map[tier][random_az_sym]
23
38
  end
24
39
 
25
40
  def random_az_and_subnet
26
- random_az = random_az_as_hash
27
- random_az_sym = random_az.keys[0].to_sym
41
+ random_az = random_az_hash
42
+ random_az_sym = random_az.keys[0]
28
43
  random_az_value = random_az.values[0]
29
- az_subnet_mapping = az_subnet_map(tier)
30
- selected_subnet_key = az_subnet_mapping[random_az_sym]
31
- resolved_subnet = resolve_parameter(selected_subnet_key)
44
+ selected_subnet_sym = tier_map[tier][random_az_sym]
45
+ resolved_subnet = resolve_parameter(selected_subnet_sym)
32
46
  {
33
47
  :az => random_az_value,
34
48
  :subnet => resolved_subnet
@@ -1,3 +1,3 @@
1
1
  module Stackit
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Hahn