🚨 Add pre-commit

This commit is contained in:
Neill Cox 2023-10-19 17:57:12 +11:00
parent f85e69e08f
commit e62f806e86
17 changed files with 158 additions and 80 deletions

View file

@ -60,7 +60,9 @@ def destroy_user(args):
"""Delete the user if it exists"""
cmd = "user list -f json"
user_exists = [
x for x in json.loads(openstack_cmd(cmd, args)) if x["Name"] == args.username
x
for x in json.loads(openstack_cmd(cmd, args))
if x["Name"] == args.username
]
if user_exists:
@ -78,24 +80,26 @@ def destroy_public_network(args):
public_network_exists = [
network
for network in openstack_cmd("network list -f json", args, as_json=True)
for network in openstack_cmd(
"network list -f json", args, as_json=True
)
if network["Name"] == "public"
]
if public_network_exists:
routers = test_user_openstack_cmd(
"router list -f json", args, as_json=True
)
"router list -f json", args, as_json=True
)
for router in routers:
router_details = test_user_openstack_cmd(
f"router show -f json {router['ID']}", args, as_json=True
)
for interface in router_details["interfaces_info"]:
test_user_openstack_cmd(
f"router remove port {router['ID']} {interface['port_id']}",
f"router remove port {router['ID']} "
f"{interface['port_id']}",
args,
)
@ -108,7 +112,9 @@ def destroy_private_network(args):
"""Delete the private network"""
private_network_exists = [
network
for network in openstack_cmd("network list -f json", args, as_json=True)
for network in openstack_cmd(
"network list -f json", args, as_json=True
)
if network["Name"] == "private"
]
@ -176,7 +182,9 @@ def destroy_rhel_instance(args):
def get_project_id(args):
"""Get the id of the test project"""
result = openstack_cmd("project list -f json", args, as_json=True)
args.project_id = [r for r in result if r["Name"] == args.project_name][0]["ID"]
args.project_id = [r for r in result if r["Name"] == args.project_name][0][
"ID"
]
def main():