zuul-operator/roles/zuul-restart-when-zuul-conf-changed/module_utils/gearlib.py
Tristan Cacqueray 3c0f9ea989 Handle service restart when connections are changed
This change adds tasks to reload tenant queues when the configuration
changes.

Change-Id: Ia404d85d57e76202ac7381ae7cdc51aaf809e07b
2020-02-04 00:58:10 +00:00

39 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright 2020 Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
import time
from typing import Any
import gear # type: ignore
def connect(host : str) -> Any:
client = gear.Client()
client.addServer(host, 4730, 'client.key', 'client.pem', 'ca.pem')
client.waitForServer(timeout=10)
return client
def run(client : Any, job_name : str, args : Any = dict()) -> Any:
job = gear.Job(job_name.encode('utf-8'), json.dumps(args).encode('utf-8'))
client.submitJob(job, timeout=300)
while not job.complete:
time.sleep(0.1)
return json.loads(job.data[0])
if __name__ == '__main__':
print(run(connect("scheduler"), "status"))