Skip to content
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

Added setup-feeder option to distributed cleanup script #2897

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions templates/federated_reporting/distributed_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def interactive_setup_feeder(hub, email, fr_distributed_cleanup_password, force_
)
if response["status"] != 201:
print(
"Problem creating fr_distributed_cleanup role on superhub. {}".format(
"Problem creating fr_distributed_cleanup role on feeder. {}".format(
response
)
)
Expand Down Expand Up @@ -228,6 +228,7 @@ def main():
group.add_argument("--inform", action="store_true")

parser.add_argument("--force-interactive", action="store_true", help="force interactive mode even when no tty, good for automation")
parser.add_argument("--setup-feeder", help="Setup a single feeder by hostname")
args = parser.parse_args()

global logger
Expand All @@ -253,6 +254,12 @@ def main():
sys.exit(1)

fr_distributed_cleanup_password = read_secret(DISTRIBUTED_CLEANUP_SECRET_PATH)
if args.setup_feeder:
email = input("Enter email for fr_distributed_cleanup accounts: ")
print() # newline for easier reading
feeder = { "ui_name": args.setup_feeder }
interactive_setup_feeder(feeder, email, fr_distributed_cleanup_password, force_interactive=args.force_interactive)

api = NovaApi(
api_user="fr_distributed_cleanup", api_password=fr_distributed_cleanup_password
) # defaults to localhost
Expand Down Expand Up @@ -286,7 +293,11 @@ def main():
cert_path=CERT_PATH,
hostname=feeder_hostname,
)
response = feeder_api.status()
try:
response = feeder_api.status()
except Exception as e:
print("Could not connect to {}, error: {}".format(feeder_hostname, e));
sys.exit(1);
if response["status"] == 401 and sys.stdout.isatty():
# auth error when running interactively
# assume it's a new feeder and offer to set it up interactively
Expand Down
Loading