cloud-mu 2.0.0.pre.alpha2 → 2.0.0.pre.alpha3
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 +4 -4
- data/cloud-mu.gemspec +1 -1
- data/modules/mu/cleanup.rb +3 -3
- data/modules/mu/cloud.rb +2 -4
- data/modules/mu/clouds/aws.rb +19 -6
- data/modules/mu/clouds/aws/habitat.rb +11 -2
- data/modules/mu/clouds/azure.rb +2 -2
- data/modules/mu/config.rb +17 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 674e427624161a3b7026346a10320e7dcf5331222d8cc683d186c3d648fc0c77
|
4
|
+
data.tar.gz: 71c6ddb375bf199f767fa2b8143b98f7de422d6095921c5db0d0cf191bac39bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cac89b0d850377f39635f40aafc4fe148fc6b38c971da05592a55dba83a7f8847c3734eddbdb830724e2cda51c7c3968c38facd22eab15814b892913641b2ab
|
7
|
+
data.tar.gz: bce36278c7e00872d5f1f553d41f24abf0593d0a8f1bf076e071d472932e1aa727f196a8e34b37dc4ba3465068420305c3079cd472d9c8a26a9ed65edc06ddc0
|
data/cloud-mu.gemspec
CHANGED
data/modules/mu/cleanup.rb
CHANGED
@@ -91,7 +91,7 @@ module MU
|
|
91
91
|
if $MU_CFG[cloud.downcase] and $MU_CFG[cloud.downcase].size > 0
|
92
92
|
cloudclass = Object.const_get("MU").const_get("Cloud").const_get(cloud)
|
93
93
|
creds[cloud] ||= {}
|
94
|
-
|
94
|
+
cloudclass.listCredentials.each { |credset|
|
95
95
|
creds[cloud][credset] = cloudclass.listRegions(credentials: credset)
|
96
96
|
}
|
97
97
|
end
|
@@ -115,7 +115,8 @@ module MU
|
|
115
115
|
projects << $MU_CFG[provider.downcase][credset]["project"]
|
116
116
|
end
|
117
117
|
|
118
|
-
if projects == [
|
118
|
+
if projects == []
|
119
|
+
projects << "" # dummy
|
119
120
|
MU.log "Checking for #{provider}/#{credset} resources from #{MU.deploy_id} in #{r}", MU::NOTICE
|
120
121
|
end
|
121
122
|
|
@@ -160,7 +161,6 @@ module MU
|
|
160
161
|
|
161
162
|
if @mommacat.nil? or @mommacat.numKittens(types: [t]) > 0
|
162
163
|
begin
|
163
|
-
puts t if t == "Habitat"
|
164
164
|
resclass = Object.const_get("MU").const_get("Cloud").const_get(t)
|
165
165
|
resclass.cleanup(
|
166
166
|
noop: @noop,
|
data/modules/mu/cloud.rb
CHANGED
@@ -1434,12 +1434,10 @@ MU.log "in dependencies() and findLitterMate gave me "+sib_by_name.to_s+" on beh
|
|
1434
1434
|
begin
|
1435
1435
|
cloudclass = MU::Cloud.loadCloudType(cloud, shortname)
|
1436
1436
|
raise MuCloudResourceNotImplemented if !cloudclass.respond_to?(:cleanup) or cloudclass.method(:cleanup).owner.to_s != "#<Class:#{cloudclass}>"
|
1437
|
-
|
1438
|
-
MU.log "Invoking #{cloudclass}.cleanup from #{shortname}", MU::WARN, details: flags
|
1439
|
-
end
|
1437
|
+
MU.log "Invoking #{cloudclass}.cleanup from #{shortname}", MU::DEBUG, details: flags
|
1440
1438
|
cloudclass.cleanup(params)
|
1441
1439
|
rescue MuCloudResourceNotImplemented
|
1442
|
-
MU.log "No #{cloud} implementation of #{shortname}.cleanup, skipping", MU::
|
1440
|
+
MU.log "No #{cloud} implementation of #{shortname}.cleanup, skipping", MU::DEBUG, details: flags
|
1443
1441
|
end
|
1444
1442
|
}
|
1445
1443
|
MU::MommaCat.unlockAll
|
data/modules/mu/clouds/aws.rb
CHANGED
@@ -152,12 +152,24 @@ module MU
|
|
152
152
|
return nil
|
153
153
|
end
|
154
154
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
155
|
+
def self.validate_region(r)
|
156
|
+
MU::Cloud::AWS.ec2(region: r).describe_availability_zones.availability_zones.first.region_name
|
157
|
+
end
|
158
|
+
|
159
|
+
if $MU_CFG and $MU_CFG['aws']
|
160
|
+
$MU_CFG['aws'].each_pair { |credset, cfg|
|
161
|
+
next if !cfg['region']
|
162
|
+
if (cfg['default'] or !@@myRegion_var) and validate_region(cfg['region'])
|
163
|
+
@@myRegion_var = cfg['region']
|
164
|
+
break if cfg['default']
|
165
|
+
end
|
166
|
+
}
|
167
|
+
elsif ENV.has_key?("EC2_REGION") and !ENV['EC2_REGION'].empty? and
|
168
|
+
validate_region(ENV['EC2_REGION'])
|
169
|
+
# Make sure this string is valid by way of the API
|
170
|
+
@@myRegion_var = ENV['EC2_REGION']
|
159
171
|
else
|
160
|
-
# hacky, but useful in a pinch
|
172
|
+
# hacky, but useful in a pinch (and if we're hosted in AWS)
|
161
173
|
az_str = MU::Cloud::AWS.getAWSMetaData("placement/availability-zone")
|
162
174
|
@@myRegion_var = az_str.sub(/[a-z]$/i, "") if az_str
|
163
175
|
end
|
@@ -936,7 +948,8 @@ module MU
|
|
936
948
|
# Amazon's Organizations API
|
937
949
|
def self.orgs(credentials: nil)
|
938
950
|
@@organizations_api ||= {}
|
939
|
-
|
951
|
+
# XXX org api doesn't seem to work in many regions
|
952
|
+
@@organizations_api[credentials] ||= MU::Cloud::AWS::Endpoint.new(api: "Organizations", credentials: credentials, region: "us-east-1")
|
940
953
|
@@organizations_api[credentials]
|
941
954
|
end
|
942
955
|
|
@@ -62,6 +62,8 @@ module MU
|
|
62
62
|
end
|
63
63
|
end while resp.create_account_status.state == "IN_PROGRESS"
|
64
64
|
|
65
|
+
@cloud_id = resp.create_account_status.account_id
|
66
|
+
|
65
67
|
MU.log "Creation of account #{@mu_name} (#{resp.create_account_status.account_id}) complete"
|
66
68
|
end
|
67
69
|
|
@@ -96,14 +98,21 @@ module MU
|
|
96
98
|
# @param region [String]: The cloud provider region
|
97
99
|
# @return [void]
|
98
100
|
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
99
|
-
puts "IN HABITAT CLEANUP"
|
100
101
|
return if !orgMasterCreds?(credentials)
|
101
102
|
|
102
103
|
resp = MU::Cloud::AWS.orgs(credentials: credentials).list_accounts
|
103
104
|
|
104
105
|
if resp and resp.accounts
|
105
106
|
resp.accounts.each { |acct|
|
106
|
-
|
107
|
+
if acct.name.match(/^#{Regexp.quote(MU.deploy_id)}/)
|
108
|
+
MU.log "Would delete account #{acct.name} if that was a thing"
|
109
|
+
if !noop
|
110
|
+
pp acct
|
111
|
+
end
|
112
|
+
else
|
113
|
+
pp acct if acct.name.match(/BUNS/)
|
114
|
+
#https://687950501457.signin.aws.amazon.com/console/organizations/complete-signup
|
115
|
+
end
|
107
116
|
}
|
108
117
|
end
|
109
118
|
end
|
data/modules/mu/clouds/azure.rb
CHANGED
data/modules/mu/config.rb
CHANGED
@@ -33,17 +33,24 @@ module MU
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# The default cloud provider for new resources. Must exist in MU.supportedClouds
|
36
|
+
# return [String]
|
36
37
|
def self.defaultCloud
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
configured = {}
|
39
|
+
MU::Cloud.supportedClouds.each { |cloud|
|
40
|
+
cloudclass = Object.const_get("MU").const_get("Cloud").const_get(cloud)
|
41
|
+
if $MU_CFG[cloud.downcase] and !$MU_CFG[cloud.downcase].empty?
|
42
|
+
configured[cloud] = $MU_CFG[cloud.downcase].size
|
43
|
+
configured[cloud] += 0.5 if cloudclass.hosted? # tiebreaker
|
44
|
+
elsif cloudclass.hosted?
|
45
|
+
configured[cloud] = 1
|
46
|
+
end
|
47
|
+
}
|
48
|
+
if configured.size > 0
|
49
|
+
return configured.keys.sort { |a, b|
|
50
|
+
configured[b] <=> configured[a]
|
51
|
+
}.first
|
52
|
+
else
|
53
|
+
return MU::Cloud.supportedClouds.first
|
47
54
|
end
|
48
55
|
end
|
49
56
|
|