-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathgather_odf_client
executable file
·112 lines (95 loc) · 4.16 KB
/
gather_odf_client
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
# Expect base collection path as an exported variable
# If it is not defined, use PWD instead
BASE_COLLECTION_PATH=${BASE_COLLECTION_PATH:-"$(pwd)"}
CLIENT_OPERATOR_NAMESPACE=$(oc get deploy -l app=ocs-client-operator -A --no-headers | awk '{print $1}')
# collection path for OC commands
mkdir -p "${BASE_COLLECTION_PATH}/odf-client/oc_output/"
mkdir -p "${BASE_COLLECTION_PATH}/csidriver"
# Command List
commands_get=()
commands_get+=("pods")
commands_get+=("deployments")
commands_get+=("secrets")
commands_get+=("configmaps")
commands_get+=("cronjobs")
commands_get+=("subscription")
commands_get+=("services")
client_commands_get=()
client_commands_get+=("storageclients")
client_commands_get+=("storageclaim")
client_commands_get+=("validatingwebhookconfiguration")
# YAML List
oc_yamls=()
oc_yamls+=("pods")
oc_yamls+=("deployments")
oc_yamls+=("secrets")
oc_yamls+=("configmaps")
oc_yamls+=("cronjobs")
oc_yamls+=("subscription")
oc_yamls+=("services")
client_oc_yamls=()
client_oc_yamls+=("storageclients")
client_oc_yamls+=("storageclaim")
# OC desc List
commands_desc=()
commands_desc+=("pods")
commands_desc+=("deployments")
commands_desc+=("secrets")
commands_desc+=("configmaps")
commands_desc+=("cronjobs")
commands_desc+=("subscription")
commands_desc+=("services")
commands_desc+=("storageclients")
client_commands_desc=()
client_commands_desc+=("storageclients")
client_commands_desc+=("storageclaim")
client_commands_desc+=("validatingwebhookconfiguration")
for INSTALL_NAMESPACE in $CLIENT_OPERATOR_NAMESPACE; do
dbglog "collecting dump of namespace ${INSTALL_NAMESPACE}"
{ oc adm inspect --dest-dir="${BASE_COLLECTION_PATH}" ${LOG_FILTER_ARGS:+"${LOG_FILTER_ARGS}"} ns/"${INSTALL_NAMESPACE}" 2>&1; } | dbglog
# Run the Collection of oc yaml outputs
for oc_yaml in "${oc_yamls[@]}"; do
# shellcheck disable=SC2129
{ oc adm inspect -n "${INSTALL_NAMESPACE}" --dest-dir="${BASE_COLLECTION_PATH}" ${LOG_FILTER_ARGS:+"${LOG_FILTER_ARGS}"} "${oc_yaml}" 2>&1; } | dbglog
done
# Create the dir for oc_output
mkdir -p "${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/"
# Run the Collection of Resources to list
for command_get in "${commands_get[@]}"; do
dbglog "collecting oc command ${command_get}"
COMMAND_OUTPUT_FILE=${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/${command_get// /_}
# shellcheck disable=SC2086
{ oc get ${command_get} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}"
done
# Run the Collection of OC desc commands
for command_desc in "${commands_desc[@]}"; do
dbglog "collecting oc describe command ${command_desc}"
COMMAND_OUTPUT_FILE=${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/${command_desc// /_}
# shellcheck disable=SC2086
{ oc describe ${command_desc} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}"
done
done
# Run the Collection of oc yaml outputs
for oc_yaml in "${client_oc_yamls[@]}"; do
# shellcheck disable=SC2129
{ oc adm inspect -n "${INSTALL_NAMESPACE}" --dest-dir="${BASE_COLLECTION_PATH}" ${LOG_FILTER_ARGS:+"${LOG_FILTER_ARGS}"} "${oc_yaml}" 2>&1; } | dbglog
done
# Run the Collection of Resources to list
for command_get in "${client_commands_get[@]}"; do
dbglog "collecting oc command ${command_get}"
COMMAND_OUTPUT_FILE=${BASE_COLLECTION_PATH}/${command_get// /_}
# shellcheck disable=SC2086
{ oc get ${command_get} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}"
done
# Run the Collection of OC desc commands
for command_desc in "${client_commands_desc[@]}"; do
dbglog "collecting oc describe command ${command_desc}"
COMMAND_OUTPUT_FILE=${BASE_COLLECTION_PATH}/${command_desc// /_}
# shellcheck disable=SC2086
{ oc describe ${command_desc} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}"
done
# collect csidriver details
{ oc get csidriver; } >"${BASE_COLLECTION_PATH}/csidriver/get_csidriver" 2>&1
{ oc describe csidriver; } >"${BASE_COLLECTION_PATH}/csidriver/desc_csidriver" 2>&1
{ oc get csidriver -o yaml; } >"${BASE_COLLECTION_PATH}/csidriver/csidriver.yaml" 2>&1