#!/usr/bin/python

import openshift as oc
from openshift import Missing
import traceback

with oc.tracking() as t:
    with oc.client_host(hostname="18.222.71.125", username="******", auto_add_host=True):  # free-stg
        with oc.project("openshift-monitoring"):
            try:

                result = oc.selector('pod/alertmanager-main-0').object().execute(['cat'],
                                                                                 container_name='alertmanager',
                                                                                 stdin='stdin for cat')
                print(result.out())
                exit(0)

                cr_rules = oc.selector("prometheusrules")
                print("CR has the following rule sets: {}".format(cr_rules.qnames()))

                if cr_rules.object().model.metadata.labels.cr_generated is Missing:
                    print("Rule was not generated by CR")

                oc.selector('pods').annotate(annotations={
                    'cr_annotation_test': None,
                })

                oc.selector('node/pod_ip-172-31-79-85.us-east-2.compute.internal').object().patch({
                    'metadata': {
                        'annotations': {
                            'cr_patch': 'yes'
예제 #2
0
#!/usr/bin/env python

from __future__ import absolute_import
import openshift as oc

if __name__ == '__main__':
    with oc.client_host():
        with oc.project('openshift-monitoring'):
            oc.selector(['dc', 'build', 'configmap']).print_report()

예제 #3
0
    )
    parser.set_defaults(insecure_skip_tls_verify=False)

    args = vars(parser.parse_args())

    skip_tls_verify = args['insecure_skip_tls_verify']

    if skip_tls_verify:
        oc.set_default_skip_tls_verify(True)

    bastion_hostname = args['bastion']
    if not bastion_hostname:
        print('Running in local mode. Expecting "oc" in PATH')

    with oc.client_host(hostname=bastion_hostname,
                        username="******",
                        auto_add_host=True,
                        load_system_host_keys=False):
        # Ensure tests complete within 30 minutes and track all oc invocations
        with oc.timeout(60 * 30), oc.tracking() as t:
            try:
                check_online_network_multitenant()
                check_prevents_cron_jobs()
                check_online_project_constraints
            except:
                logging.fatal('Error occurred during tests')
                traceback.print_exc()
                # print out all oc interactions and do not redact secret information
                print("Tracking:\n{}\n\n".format(
                    t.get_result().as_json(redact_streams=False)))