Set FQDN to nodes

This commit is contained in:
a.pivkin 2025-01-03 23:56:22 +03:00
parent 7f197a8d79
commit fd5cd4cc9d
5 changed files with 710 additions and 0 deletions

108
pg_interception/ls1 Normal file
View File

@ -0,0 +1,108 @@
16.d
15.12
12.11
17.c
17.d
18.d
16.f
12.13
18.c
16.e
13.13
16.19
15.6
19.18
18.19
13.6
17.1a
16.15
15.a
14.b
19.17
18.16
16.14
15.b
14.a
19.14
18.15
13.a
14.9
18.14
15.9
13.b
14.8
18.10
15.d
17.13
12.d
18.1c
16.1e
17.1f
19.1c
15.0
12.3
13.2
19.1f
17.1d
17.33
17.3e
17.45
17.8
12.15
18.b
19.a
17.47
18.9
17.51
17.37
17.70
17.52
17.58
17.42
16.8
17.61
17.7f
17.43
17.7e
17.25
17.7c
17.3f
17.79
17.76
17.46
17.65
17.28
17.75
17.3a
17.74
17.54
15.f
17.11
17.6e
17.63
17.72
17.4a
17.31
17.69
17.2d
17.2b
17.27
12.16
15.1a
16.5
17.5
13.19
16.6
18.4
16.1
16.0
14.1d
16.3
17.3
14.1c
13.1f
12.1e
16.2
12.1
19.1e

262
pg_interception/ls2 Normal file
View File

@ -0,0 +1,262 @@
.f
17.37
2.3
2.e
13.b
17.2a
12.14
17.26
17.24
17.1e
16.5
17.2b
12.13
19.9
17.1a
17.40
17.19
17.16
15.6
13.19
17.13
16.18
2.19
16.6
17.49
16.4
16.1f
16.1e
12.15
19.7
17.22
2.14
16.1b
17.3a
15.2
17.69
16.1
17.36
17.27
16.15
17.1
16.13
16.0
17.3
18.0
15.f
17.11
17.7f
15.c
15.b
17.41
17.14
17.35
17.4a
17.1d
2.11
15.a
15.4
17.2
16.19
17.44
13.18
19.f
13.14
17.47
17.6b
17.23
17.5b
17.2f
17.48
12.1e
12.18
15.11
17.64
17.3b
12.d
13.3
16.9
13.7
12.0
17.74
19.5
2.7
17.28
2.d
12.11
17.3c
17.5a
13.a
15.1a
16.8
16.2
16.a
14.8
19.0
13.13
17.54
13.e
17.59
12.1
12.16
12.e
13.1c
19.12
16.16
17.5f
13.15
14.b
16.f
17.25
19.1a
14.1d
13.12
15.3
13.1e
13.9
17.9
13.2
15.8
13.6
17.34
13.0
17.1f
14.1f
18.1d
2.0
14.a
13.c
14.16
1.0
15.13
2.8
16.d
14.1c
14.1e
17.29
17.65
12.19
14.7
14.9
17.42
17.46
17.52
17.d
17.6f
16.14
14.f
16.10
2.10
15.0
15.9
2.1d
12.1f
18.19
16.3
15.12
17.75
13.1d
15.19
19.1e
12.3
17.3e
17.3f
17.8
17.45
17.4d
12.12
17.4e
17.51
14.15
17.53
18.3
18.10
17.58
18.4
17.5
17.56
17.5d
17.60
15.1d
17.57
17.61
17.33
19.1
2.1
17.62
17.3d
2.1f
17.63
19.4
17.67
17.68
17.6a
17.6c
17.43
17.6e
17.70
17.72
17.f
13.1f
17.73
17.76
17.77
19.14
17.79
17.7a
16.7
2.a
17.7c
18.6
2.6
17.7e
17.c
17.e
18.13
12.1c
18.14
18.15
18.16
18.18
17.2d
18.1
18.1c
18.1e
18.1f
17.31
18.9
18.b
13.1b
18.c
18.d
19.13
19.17
19.18
19.1f
19.1c
19.a
2.1b
2.b
19.b
19.c
2.12
17.2e
17.55
2.13
2.c
2.15
2.16
15.5
2.17
19.1d
2.18
15.d
2.1c
16.e
2.1e
2.2
2.1a
2.4
2.5
2.9

23
pg_interception/main.py Normal file
View File

@ -0,0 +1,23 @@
# import subprocess
import re
import sys
def process_lines(object):
for i in object:
if regexp.search(i):
# print(i)
yield i
if __name__ == '__main__':
regexp = re.compile(r"\d+..{1,}")
try:
with open(sys.argv[1],"r") as file1, open(sys.argv[2],"r") as file2, open(sys.argv[3],"w+") as res_file:
first = [y.strip() for y in process_lines(file1) if regexp.search(y)]
first = set(first)
second = [y.strip() for y in process_lines(file2) if regexp.search(y)]
second = set(second)
for kek in process_lines(second.intersection(first)):
res_file.write(kek + '\n')
# print(second.intersection(first))
except IndexError as e:
print("We need two files")

107
pg_interception/result Normal file
View File

@ -0,0 +1,107 @@
17.72
13.6
14.1c
17.61
16.14
17.13
16.2
17.5
17.76
19.a
18.9
17.70
13.2
18.10
19.18
17.7e
16.6
17.1f
17.1a
17.79
17.63
14.1d
12.13
13.b
14.a
15.b
17.7c
14.8
17.d
12.1e
17.25
16.3
18.c
15.a
18.16
14.9
15.f
17.3e
19.1f
17.52
15.0
19.17
17.3a
17.69
17.58
17.6e
13.1f
17.27
16.0
16.d
16.15
12.15
17.65
12.3
17.2b
16.1e
16.f
17.3f
18.4
17.2d
18.1c
17.c
18.d
18.b
18.14
15.9
17.8
15.12
17.74
14.b
17.7f
13.13
17.47
17.54
12.d
13.a
17.33
15.1a
16.19
16.5
16.e
18.15
17.75
17.45
17.31
17.4a
16.1
12.16
12.11
19.1c
18.19
17.11
19.14
12.1
17.43
17.37
17.3
17.51
17.46
17.28
13.19
17.1d
15.6
17.42
15.d
16.8
19.1e

210
rbdmap.sh Executable file
View File

@ -0,0 +1,210 @@
#!/usr/bin/bash
create_cmd_params() {
local PARAMS="$1"
local CMDPARAMS=""
local STATE="START"
for (( i=0; i<${#PARAMS}; i++ )); do
CHAR="${PARAMS:$i:1}"
case $CHAR in
"#")
break
;;
"'")
if [ "$STATE" == "INQUOTE" ];then
STATE="NORMAL"
else
STATE="INQUOTE"
fi
;;
"=")
if [ "$STATE" == "INQUOTE" ]; then
CMDPARAMS="${CMDPARAMS}${CHAR}"
else
CMDPARAMS="${CMDPARAMS} "
fi
;;
",")
if [ "$STATE" == "INQUOTE" ]; then
CMDPARAMS="${CMDPARAMS}${CHAR}"
elif [ "$STATE" == "START" ]; then
STATE="NORMAL"
CMDPARAMS="${CMDPARAMS} --"
else
CMDPARAMS="${CMDPARAMS} --"
fi
;;
*)
if [ "$STATE" == "START" ];then
STATE="NORMAL"
CMDPARAMS="${CMDPARAMS}--${CHAR}"
else
CMDPARAMS="${CMDPARAMS}${CHAR}"
fi
;;
esac
done
echo -n "$CMDPARAMS"
}
do_map() {
# Read /etc/rbdtab to create non-existant mapping
RET=0
while read DEV PARAMS; do
case "$DEV" in
""|\#*)
continue
;;
*/*)
;;
*)
DEV=rbd/$DEV
;;
esac
CMDPARAMS="$(create_cmd_params "${PARAMS}")"
logger -p "daemon.debug" -t rbdmap "Mapping '${DEV}'"
newrbd=""
MAP_RV=""
if [ -b /dev/rbd/$DEV ]; then
MAP_RV="$(readlink -f /dev/rbd/$DEV)"
else
MAP_RV="$(rbd device map $DEV $CMDPARAMS 2>&1)"
if [ $? -eq 0 ]; then
newrbd="yes"
else
RET=$((${RET}+$?))
logger -p "daemon.warning" -t rbdmap "Failed to map '${DEV}"
continue
fi
fi
logger -p "daemon.debug" -t rbdmap "Mapped '${DEV}' to '${MAP_RV}'"
if [ "$newrbd" ]; then
## Mount new rbd
MNT_RV=""
mount --fake /dev/rbd/$DEV >>/dev/null 2>&1 \
&& MNT_RV=$(mount -vn /dev/rbd/$DEV 2>&1)
[ -n "${MNT_RV}" ] && logger -p "daemon.debug" -t rbdmap "Mounted '${MAP_RV}' to '${MNT_RV}'"
## post-mapping
if [ -x "/etc/ceph/rbd.d/${DEV}" ]; then
logger -p "daemon.debug" -t rbdmap "Running post-map hook '/etc/ceph/rbd.d/${DEV}'"
/etc/ceph/rbd.d/${DEV} map "/dev/rbd/${DEV}"
fi
fi
done < $RBDMAPFILE
exit ${RET}
}
unmount_unmap() {
local rbd_dev=$1
local mnts=$(findmnt --mtab --source ${rbd_dev} --noheadings \
| awk '{print $1}')
logger -p "daemon.debug" -t rbdmap "Unmapping '${rbd_dev}'"
for mnt in ${mnts}; do
logger -p "daemon.debug" -t rbdmap "Unmounting '${mnt}'"
umount "${mnt}" >>/dev/null 2>&1
if mountpoint -q "${mnt}"; then
## Un-mounting failed.
logger -p "daemon.warning" -t rbdmap "Failed to unmount '${mnt}'"
return 1
fi
done
## Un-mapping.
rbd device unmap $rbd_dev >>/dev/null 2>&1
if [ $? -ne 0 ]; then
logger -p "daemon.warning" -t rbdmap "Failed to unmap '${mnt}'"
return 1
fi
logger -p "daemon.debug" -t rbdmap "Unmapped '${rbd_dev}'"
return 0
}
do_unmap_all() {
RET=0
## Unmount and unmap all rbd devices
if ls /dev/rbd[0-9]* >/dev/null 2>&1; then
for DEV in /dev/rbd[0-9]*; do
## pre-unmapping
for L in $(find /dev/rbd -type l); do
LL="${L##/dev/rbd/}"
if [ "$(readlink -f $L)" = "${DEV}" ] \
&& [ -x "/etc/ceph/rbd.d/${LL}" ]; then
logger -p "daemon.debug" -t rbdmap "Running pre-unmap hook for '${DEV}': '/etc/ceph/rbd.d/${LL}'"
/etc/ceph/rbd.d/${LL} unmap "$L"
break
fi
done
unmount_unmap "$DEV" || RET=$((${RET}+$?))
done
fi
exit ${RET}
}
do_unmap() {
RET=0
## skip if nothing is mapped
ls /dev/rbd[0-9]* >/dev/null 2>&1 || exit ${RET}
# Read /etc/rbdtab to create non-existant mapping
while read DEV PARAMS; do
case "$DEV" in
""|\#*)
continue
;;
*/*)
;;
*)
DEV=rbd/$DEV
;;
esac
MAP_RV="$(readlink -f /dev/rbd/$DEV)"
if [ ! -b $MAP_RV ]; then
logger -p "daemon.debug" -t rbdmap "$DEV not mapped, skipping unmap"
continue
fi
## pre-unmapping
if [ -x "/etc/ceph/rbd.d/${DEV}" ]; then
logger -p "daemon.debug" -t rbdmap "Running pre-unmap hook '/etc/ceph/rbd.d/${DEV}'"
/etc/ceph/rbd.d/${DEV} unmap "/dev/rbd/${DEV}"
fi
unmount_unmap "$MAP_RV" || RET=$((${RET}+$?))
done < $RBDMAPFILE
exit ${RET}
}
# default to reasonable value if RBDMAPFILE not set in environment
RBDMAPFILE="${RBDMAPFILE:-/etc/ceph/rbdmap}"
if [ ! -f "$RBDMAPFILE" ]; then
logger -p "daemon.warning" -t rbdmap "No $RBDMAPFILE found."
exit 0
fi
case "$1" in
map)
do_map
;;
unmap)
do_unmap
;;
unmap-all)
do_unmap_all
;;
*)
echo "Usage: rbdmap map | unmap | unmap-all"
esac