Skip to content

Commit f035cb6

Browse files
committed
Add marker to Secret, so we can clean up.
Signed-off-by: Kurt Garloff <[email protected]>
1 parent 4570296 commit f035cb6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: Tests/iaas/mandatory-services/mandatory-iaas-services.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222
TESTCONTNAME = "scs-test-container"
23+
EC2MARKER = "TmpMandSvcTest"
2324

2425
logger = logging.getLogger(__name__)
2526
mandatory_services = ["compute", "identity", "image", "network",
@@ -125,15 +126,19 @@ def s3_from_ostack(creds, conn, endpoint):
125126
project_id = conn.identity.get_project_id()
126127
ec2_creds = [cred for cred in conn.identity.credentials()
127128
if cred.type == "ec2" and cred.project_id == project_id]
128-
if len(ec2_creds):
129+
for cred in ec2_creds:
129130
# FIXME: Assume cloud is not evil
130-
ec2_dict = eval(ec2_creds[0].blob, {"null": None})
131+
ec2_dict = eval(cred.blob, {"null": None})
131132
creds["AK"] = ec2_dict["access"]
132133
creds["SK"] = ec2_dict["secret"]
134+
# Clean up old EC2 creds and jump over
135+
if creds["SK"][-len(EC2MARKER):] == EC2MARKER:
136+
conn.identity.delete_credential(cred)
137+
continue
133138
return None
134139
# Generate keyid and secret
135140
ak = uuid.uuid4().hex
136-
sk = uuid.uuid4().hex
141+
sk = uuid.uuid4().hex + EC2MARKER
137142
blob = f'{{"access": "{ak}", "secret": "{sk}"}}'
138143
try:
139144
crd = conn.identity.create_credential(type="ec2", blob=blob,

0 commit comments

Comments
 (0)