We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello,
is there a way to share a context with subprocess library, for example:
subprocess
import openshift as oc import subprocess HOST = 'https://localhost:6443' USER = 'ocuser' PASSWORD = 'password' PROJECT = 'my-proj' with oc.api_server(HOST): with oc.login(USER, PASSWORD): with oc.project(PROJECT): subprocess.run('oc get pods | grep ABCD')
I would like to execute some commands directly from the subprocess library, making sure I'm in the correct server/project context
The text was updated successfully, but these errors were encountered:
Hi @MartykQ, The majority of the actions performed by this library are already issued through the subprocess library: https://github.com/openshift/openshift-client-python/blob/main/packages/openshift/action.py#L351
To accomplish what you've asked above, you could simply do something like:
import openshift as oc HOST = 'https://localhost:6443' USER = 'ocuser' PASSWORD = 'password' PROJECT = 'my-proj' with oc.api_server(HOST): with oc.login(USER, PASSWORD): with oc.project(PROJECT): pods = oc.selector('pods').objects() for pod in pods: if 'abcd' in pod.name(): result = pod.execute(cmd_to_exec=['ls', '-al']) print(f'Result: {result.out()}')
Sorry, something went wrong.
Thanks @bradmwilliams! I think that one combined with oc.invoke will be enough for my use case
oc.invoke
No branches or pull requests
Hello,
is there a way to share a context with
subprocess
library, for example:I would like to execute some commands directly from the subprocess library, making sure I'm in the correct server/project context
The text was updated successfully, but these errors were encountered: