-
Notifications
You must be signed in to change notification settings - Fork 0
code review #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
code review #2
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,79 @@ | ||||||||||||||||||||||||||||||
import os | ||||||||||||||||||||||||||||||
import subprocess | ||||||||||||||||||||||||||||||
import json | ||||||||||||||||||||||||||||||
import argparse | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
def main(): | ||||||||||||||||||||||||||||||
parser = argparse.ArgumentParser() | ||||||||||||||||||||||||||||||
parser.add_argument('--stream', dest='stream', type=str, help='Fedora stream', required=True) | ||||||||||||||||||||||||||||||
args = parser.parse_args() | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
builds = getBuildsForStream(args.stream) | ||||||||||||||||||||||||||||||
for build in builds: | ||||||||||||||||||||||||||||||
build_id=build['id'] | ||||||||||||||||||||||||||||||
arches=build['arches'] | ||||||||||||||||||||||||||||||
for arch in arches: | ||||||||||||||||||||||||||||||
print(f"The build is {build_id}") | ||||||||||||||||||||||||||||||
buildFetch(args.stream, build_id, arch) | ||||||||||||||||||||||||||||||
meta = open('builds/'+build_id+'/'+arch+'/meta.json') | ||||||||||||||||||||||||||||||
data = json.load(meta) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
# Delete this when actually running. Just here while I make this script | ||||||||||||||||||||||||||||||
data ={"amis":[{ | ||||||||||||||||||||||||||||||
"name": "us-east-1", | ||||||||||||||||||||||||||||||
"hvm": "ami-0016d5df3041499f9", | ||||||||||||||||||||||||||||||
"snapshot": "snap-0c1ca4850fcd5e573" | ||||||||||||||||||||||||||||||
}]} | ||||||||||||||||||||||||||||||
amis = data['amis'] | ||||||||||||||||||||||||||||||
gursewak1997 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||
for ami in amis: | ||||||||||||||||||||||||||||||
checkAndAddTag(ami["hvm"], ami["name"]) | ||||||||||||||||||||||||||||||
checkAndAddTag(ami["snapshot"], ami["name"]) | ||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
def checkAndAddTag(resourceId, region): | ||||||||||||||||||||||||||||||
tagExists = checkTag(resourceId) | ||||||||||||||||||||||||||||||
if tagExists: | ||||||||||||||||||||||||||||||
print(f"{resourceId} already tagged with FedoraUser=coreos tag") | ||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||
addTag(resourceId, region) | ||||||||||||||||||||||||||||||
print(f"FedoraUser=coreos tag successfully added to {resourceId}") | ||||||||||||||||||||||||||||||
|
if tagExists: | |
print(f"{resourceId} already tagged with FedoraUser=coreos tag") | |
else: | |
addTag(resourceId, region) | |
print(f"FedoraUser=coreos tag successfully added to {resourceId}") | |
if tagExists: | |
print(f"{resourceId} already tagged with FedoraUser=coreos tag") | |
return | |
if dryrun: | |
print(f"--dry-run specified. Would add FedoraUser=coreos tag to {resourceId}") | |
else: | |
addTag(resourceId, region) | |
print(f"FedoraUser=coreos tag successfully added to {resourceId}") |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does the Name=value,Values=coreos
do here?
Also do we need to add --region
to this command too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need --region
when we are giving --resource-id as an arg.
And for Name=value,Values=coreos
, that's the way to filter out data where Name is basically "key" and Values is well "value" from tags json data that's spit out from aws ec2 describe tags
An example of what I get from this ami is this:
{
"Tags": [
{
"Key": "FedoraUser",
"ResourceId": "ami-xyx12345",
"ResourceType": "image",
"Value": "coreos"
}
]
}
gursewak1997 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should drop catching these exceptions
gursewak1997 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe for consistency with other vars
buildFetch = 'cosa buildfetch --stream='+ stream + ' --arch=all' | |
buildFetchCmd = 'cosa buildfetch --stream='+ stream + ' --arch=all' | |
Uh oh!
There was an error while loading. Please reload this page.