|
| 1 | +#!/usr/bin/python |
| 2 | + |
| 3 | +import openshift_client as oc |
| 4 | + |
| 5 | +if __name__ == '__main__': |
| 6 | + with oc.client_host(): |
| 7 | + with oc.timeout(60 * 5): |
| 8 | + with oc.project('openshift-client-python'): |
| 9 | + resource_quotas = oc.selector('resourcequotas').objects() |
| 10 | + print(f'Found: {len(resource_quotas)} ResourceQuotas') |
| 11 | + |
| 12 | + for resource_quota in resource_quotas: |
| 13 | + print(f'Processing ResourceQuota: {resource_quota.name()}') |
| 14 | + for key in resource_quota.model.spec.hard: |
| 15 | + print(f' - {key}: {resource_quota.model.spec.hard[key]}') |
| 16 | + |
| 17 | + limit_ranges = oc.selector('limitranges').objects() |
| 18 | + print(f'\nFound: {len(limit_ranges)} LimitRanges') |
| 19 | + |
| 20 | + for limit_range in limit_ranges: |
| 21 | + print(f'Processing LimitRange: {limit_range.name()}') |
| 22 | + for limit in limit_range.model.spec.limits: |
| 23 | + print(f' Type: {limit.type}') |
| 24 | + print(f' Default CPU Limit: {limit.default.cpu}') |
| 25 | + print(f' Default Memory Limit: {limit.default.memory}') |
| 26 | + print(f' Default CPU Request: {limit.defaultRequest.cpu}') |
| 27 | + print(f' Default Memory Request: {limit.defaultRequest.memory}') |
| 28 | + |
| 29 | + pods = oc.selector('pods').objects() |
| 30 | + print(f'\nFound: {len(pods)} Pods') |
| 31 | + |
| 32 | + for pod in pods: |
| 33 | + print(f'Processing Pod: {pod.name()}') |
| 34 | + for container in pod.model.spec.containers: |
| 35 | + print(f' Processing Container: {container.name}') |
| 36 | + print(f' CPU Limit: {container.resources.limits.cpu}') |
| 37 | + print(f' CPU Request: {container.resources.requests.cpu}') |
| 38 | + print(f' Memory Limit: {container.resources.limits.memory}') |
| 39 | + print(f' Memory Request: {container.resources.requests.memory}') |
0 commit comments