-
Notifications
You must be signed in to change notification settings - Fork 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
Improve management of CAPI images #978
Changes from 7 commits
a9dbbaf
a4f5bf4
8c91f7b
5c1c2cb
11865bb
e53db3c
2028134
2548698
fbb4613
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 |
---|---|---|
|
@@ -27,7 +27,18 @@ def get_parser(self, prog_name): | |
default="https://swift.services.a.regiocloud.tech/swift/v1/AUTH_b182637428444b9aa302bb8d5a5a418c/openstack-k8s-capi-images/", | ||
) | ||
parser.add_argument( | ||
"--cloud", type=str, help="Cloud name in clouds.yaml", default="openstack" | ||
"--cloud", type=str, help="Cloud name in clouds.yaml (will be overruled by OS_AUTH_URL envvar)", default="admin" | ||
) | ||
parser.add_argument( | ||
"--dry-run", | ||
action="store_true", | ||
help="Do not perform any changes (--dry-run passed to openstack-image-manager)", | ||
) | ||
parser.add_argument( | ||
"--tag", | ||
type=str, | ||
help="Name of the tag used to identify managed images (use openstack-image-manager's default if unset)", | ||
default=None, | ||
) | ||
parser.add_argument( | ||
"--filter", | ||
|
@@ -41,6 +52,7 @@ def take_action(self, parsed_args): | |
base_url = parsed_args.base_url | ||
cloud = parsed_args.cloud | ||
filter = parsed_args.filter | ||
tag = parsed_args.tag | ||
|
||
if filter: | ||
supported_cluterapi_k8s_images = [filter] | ||
|
@@ -78,10 +90,19 @@ def take_action(self, parsed_args): | |
with open(f"/tmp/clusterapi/k8s-{kubernetes_release}.yml", "w+") as fp: | ||
fp.write(result) | ||
|
||
subprocess.call( | ||
"/usr/local/bin/openstack-image-manager --images=/tmp/clusterapi --cloud admin --filter 'Kubernetes CAPI'", | ||
shell=True, | ||
) | ||
args = [ | ||
"openstack-image-manager", | ||
"--images=/tmp/clusterapi", | ||
"--cloud", | ||
cloud, | ||
"--filter", | ||
"ubuntu-capi-image", | ||
] | ||
if tag is not None: | ||
args.extend(["--tag", tag]) | ||
if parsed_args.dry_run: | ||
args.append("--dry-run") | ||
subprocess.call(args) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of Recommended Solution: Replace |
||
|
||
|
||
class ImageOctavia(Command): | ||
|
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.
The variable name
filter
shadows the built-in Python functionfilter()
. This can lead to unexpected behavior and bugs, especially if the built-in function is needed later in the code.Recommended Solution: Rename the variable to something more descriptive, such as
image_filter
.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.
This probably makes sense and can be tackled In a separate PR.