3
# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
4
# This file is part of GlusterFS.
6
# This file is licensed to you under your choice of the GNU Lesser
7
# General Public License, version 3 or any later version (LGPLv3 or
8
# later), or the GNU General Public License, version 2 (GPLv2), in all
9
# cases as published by the Free Software Foundation.
11
# Generates unique epoch value on each gluster node to be used by
12
# nfs-ganesha service on that node.
14
# Configure 'EPOCH_EXEC' option to this script path in
15
# '/etc/sysconfig/ganesha' file used by nfs-ganesha service.
17
# Construct epoch as follows -
18
# first 32-bit contains the now() time
19
# rest 32-bit value contains the local glusterd node uuid
24
# Calculate the now() time into a 64-bit integer value
26
epoch_time = int(time.mktime(time.localtime())) << 32
29
# Read glusterd UUID and extract first 32-bit of it
31
file_name = '/var/lib/glusterd/glusterd.info'
33
for line in open(file_name):
35
glusterd_uuid = line.split('=')[1].strip()
37
uuid_bin = binascii.unhexlify(glusterd_uuid.replace("-",""))
39
epoch_uuid = int(binascii.hexlify(uuid_bin), 32) & 0xFFFF0000
42
# Construct epoch as follows -
43
# first 32-bit contains the now() time
44
# rest 32-bit value contains the local glusterd node uuid
45
epoch = (epoch_now() | epoch_uuid())