From fe6aebb1c8921b38a9f419ad7b90cdab8631e568 Mon Sep 17 00:00:00 2001 From: Brad Williams Date: Wed, 12 Jun 2024 12:27:59 -0400 Subject: [PATCH] Adding multiple contexts example --- examples/multiple_contexts.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/multiple_contexts.py diff --git a/examples/multiple_contexts.py b/examples/multiple_contexts.py new file mode 100644 index 0000000..2fba81c --- /dev/null +++ b/examples/multiple_contexts.py @@ -0,0 +1,16 @@ +import openshift_client as oc + +if __name__ == '__main__': + context1 = { + 'context': 'cluster1', + } + context2 = { + 'context': 'cluster2', + } + with oc.client_host(): + with oc.timeout(60 * 5): + for context in [context1, context2]: + with oc.options(context): + with oc.project('my-project'): + jobs_list = oc.selector('pods').objects() + print(f'Found: {len(jobs_list)} pods in: {context["context"]}')