"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/events/eventskeygen.py" (16 Sep 2020, 7280 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "eventskeygen.py" see the Fossies "Dox" file reference documentation.

    1 #!/usr/bin/python3
    2 # -*- coding: utf-8 -*-
    3 #
    4 #  Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
    5 #  This file is part of GlusterFS.
    6 #
    7 #  This file is licensed to you under your choice of the GNU Lesser
    8 #  General Public License, version 3 or any later version (LGPLv3 or
    9 #  later), or the GNU General Public License, version 2 (GPLv2), in all
   10 #  cases as published by the Free Software Foundation.
   11 #
   12 
   13 import os
   14 import sys
   15 
   16 GLUSTER_SRC_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
   17 eventtypes_h = os.path.join(GLUSTER_SRC_ROOT, "libglusterfs/src/eventtypes.h")
   18 eventtypes_py = os.path.join(GLUSTER_SRC_ROOT, "events/src/eventtypes.py")
   19 
   20 gen_header_type = sys.argv[1]
   21 
   22 # When adding new keys add it to the END
   23 keys = (
   24     # user driven events
   25     #peer and volume management events
   26     "EVENT_PEER_ATTACH",
   27     "EVENT_PEER_DETACH",
   28     "EVENT_VOLUME_CREATE",
   29     "EVENT_VOLUME_START",
   30     "EVENT_VOLUME_STOP",
   31     "EVENT_VOLUME_DELETE",
   32     "EVENT_VOLUME_SET",
   33     "EVENT_VOLUME_RESET",
   34     "EVENT_BRICK_RESET_START",
   35     "EVENT_BRICK_RESET_COMMIT",
   36     "EVENT_BRICK_REPLACE",
   37 
   38     #geo-rep events
   39     "EVENT_GEOREP_CREATE",
   40     "EVENT_GEOREP_START",
   41     "EVENT_GEOREP_STOP",
   42     "EVENT_GEOREP_PAUSE",
   43     "EVENT_GEOREP_RESUME",
   44     "EVENT_GEOREP_DELETE",
   45     "EVENT_GEOREP_CONFIG_SET",
   46     "EVENT_GEOREP_CONFIG_RESET",
   47 
   48     #bitrot events
   49     "EVENT_BITROT_ENABLE",
   50     "EVENT_BITROT_DISABLE",
   51     "EVENT_BITROT_SCRUB_THROTTLE",
   52     "EVENT_BITROT_SCRUB_FREQ",
   53     "EVENT_BITROT_SCRUB_OPTION",
   54     "EVENT_BITROT_SCRUB_ONDEMAND",
   55 
   56     #quota events
   57     "EVENT_QUOTA_ENABLE",
   58     "EVENT_QUOTA_DISABLE",
   59     "EVENT_QUOTA_SET_USAGE_LIMIT",
   60     "EVENT_QUOTA_SET_OBJECTS_LIMIT",
   61     "EVENT_QUOTA_REMOVE_USAGE_LIMIT",
   62     "EVENT_QUOTA_REMOVE_OBJECTS_LIMIT",
   63     "EVENT_QUOTA_ALERT_TIME",
   64     "EVENT_QUOTA_SOFT_TIMEOUT",
   65     "EVENT_QUOTA_HARD_TIMEOUT",
   66     "EVENT_QUOTA_DEFAULT_SOFT_LIMIT",
   67 
   68     #snapshot events
   69     "EVENT_SNAPSHOT_CREATED",
   70     "EVENT_SNAPSHOT_CREATE_FAILED",
   71     "EVENT_SNAPSHOT_ACTIVATED",
   72     "EVENT_SNAPSHOT_ACTIVATE_FAILED",
   73     "EVENT_SNAPSHOT_DEACTIVATED",
   74     "EVENT_SNAPSHOT_DEACTIVATE_FAILED",
   75     "EVENT_SNAPSHOT_SOFT_LIMIT_REACHED",
   76     "EVENT_SNAPSHOT_HARD_LIMIT_REACHED",
   77     "EVENT_SNAPSHOT_RESTORED",
   78     "EVENT_SNAPSHOT_RESTORE_FAILED",
   79     "EVENT_SNAPSHOT_DELETED",
   80     "EVENT_SNAPSHOT_DELETE_FAILED",
   81     "EVENT_SNAPSHOT_CLONED",
   82     "EVENT_SNAPSHOT_CLONE_FAILED",
   83     "EVENT_SNAPSHOT_CONFIG_UPDATED",
   84     "EVENT_SNAPSHOT_CONFIG_UPDATE_FAILED",
   85     "EVENT_SNAPSHOT_SCHEDULER_INITIALISED",
   86     "EVENT_SNAPSHOT_SCHEDULER_INIT_FAILED",
   87     "EVENT_SNAPSHOT_SCHEDULER_ENABLED",
   88     "EVENT_SNAPSHOT_SCHEDULER_ENABLE_FAILED",
   89     "EVENT_SNAPSHOT_SCHEDULER_DISABLED",
   90     "EVENT_SNAPSHOT_SCHEDULER_DISABLE_FAILED",
   91     "EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_ADDED",
   92     "EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_ADD_FAILED",
   93     "EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_EDITED",
   94     "EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_EDIT_FAILED",
   95     "EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_DELETED",
   96     "EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_DELETE_FAILED",
   97 
   98     #async events
   99     #glusterd events
  100     "EVENT_SVC_MANAGER_FAILED",
  101     "EVENT_SVC_RECONFIGURE_FAILED",
  102     "EVENT_SVC_CONNECTED",
  103     "EVENT_SVC_DISCONNECTED",
  104     "EVENT_PEER_STORE_FAILURE",
  105     "EVENT_PEER_RPC_CREATE_FAILED",
  106     "EVENT_PEER_REJECT",
  107     "EVENT_PEER_CONNECT",
  108     "EVENT_PEER_DISCONNECT",
  109     "EVENT_PEER_NOT_FOUND",
  110     "EVENT_UNKNOWN_PEER",
  111     "EVENT_BRICK_START_FAILED",
  112     "EVENT_BRICK_STOP_FAILED",
  113     "EVENT_BRICK_DISCONNECTED",
  114     "EVENT_BRICK_CONNECTED",
  115     "EVENT_BRICKPATH_RESOLVE_FAILED",
  116     "EVENT_NOTIFY_UNKNOWN_OP",
  117     "EVENT_QUORUM_LOST",
  118     "EVENT_QUORUM_REGAINED",
  119     "EVENT_REBALANCE_START_FAILED",
  120     "EVENT_REBALANCE_STATUS_UPDATE_FAILED",
  121     "EVENT_IMPORT_QUOTA_CONF_FAILED",
  122     "EVENT_IMPORT_VOLUME_FAILED",
  123     "EVENT_IMPORT_BRICK_FAILED",
  124     "EVENT_COMPARE_FRIEND_VOLUME_FAILED",
  125     "EVENT_NFS_GANESHA_EXPORT_FAILED",
  126     #ec events
  127     "EVENT_EC_MIN_BRICKS_NOT_UP",
  128     "EVENT_EC_MIN_BRICKS_UP",
  129     #georep async events
  130     "EVENT_GEOREP_FAULTY",
  131     "EVENT_GEOREP_CHECKPOINT_COMPLETED",
  132     "EVENT_GEOREP_ACTIVE",
  133     "EVENT_GEOREP_PASSIVE",
  134 
  135     #quota async events
  136     "EVENT_QUOTA_CROSSED_SOFT_LIMIT",
  137     #bitrot async events
  138     "EVENT_BITROT_BAD_FILE",
  139     #protocol-server events
  140     "EVENT_CLIENT_CONNECT",
  141     "EVENT_CLIENT_AUTH_REJECT",
  142     "EVENT_CLIENT_DISCONNECT",
  143     #posix events
  144     "EVENT_POSIX_SAME_GFID",
  145     "EVENT_POSIX_ALREADY_PART_OF_VOLUME",
  146     "EVENT_POSIX_BRICK_NOT_IN_VOLUME",
  147     "EVENT_POSIX_BRICK_VERIFICATION_FAILED",
  148     "EVENT_POSIX_ACL_NOT_SUPPORTED",
  149     "EVENT_POSIX_HEALTH_CHECK_FAILED",
  150     #afr events
  151     "EVENT_AFR_QUORUM_MET",
  152     "EVENT_AFR_QUORUM_FAIL",
  153     "EVENT_AFR_SUBVOL_UP",
  154     "EVENT_AFR_SUBVOLS_DOWN",
  155     "EVENT_AFR_SPLIT_BRAIN",
  156 
  157     #tier events
  158     "EVENT_TIER_ATTACH",
  159     "EVENT_TIER_ATTACH_FORCE",
  160     "EVENT_TIER_DETACH_START",
  161     "EVENT_TIER_DETACH_STOP",
  162     "EVENT_TIER_DETACH_COMMIT",
  163     "EVENT_TIER_DETACH_FORCE",
  164     "EVENT_TIER_PAUSE",
  165     "EVENT_TIER_RESUME",
  166     "EVENT_TIER_WATERMARK_HI",
  167     "EVENT_TIER_WATERMARK_DROPPED_TO_MID",
  168     "EVENT_TIER_WATERMARK_RAISED_TO_MID",
  169     "EVENT_TIER_WATERMARK_DROPPED_TO_LOW",
  170 
  171     #dht events
  172     #add/remove brick events
  173     "EVENT_VOLUME_ADD_BRICK",
  174     "EVENT_VOLUME_ADD_BRICK_FAILED",
  175     "EVENT_VOLUME_REMOVE_BRICK_START",
  176     "EVENT_VOLUME_REMOVE_BRICK_START_FAILED",
  177     "EVENT_VOLUME_REMOVE_BRICK_COMMIT",
  178     "EVENT_VOLUME_REMOVE_BRICK_COMMIT_FAILED",
  179     "EVENT_VOLUME_REMOVE_BRICK_STOP",
  180     "EVENT_VOLUME_REMOVE_BRICK_STOP_FAILED",
  181     "EVENT_VOLUME_REMOVE_BRICK_FORCE",
  182     "EVENT_VOLUME_REMOVE_BRICK_FORCE_FAILED",
  183     "EVENT_VOLUME_REMOVE_BRICK_FAILED",
  184 
  185     #rebalance events
  186     "EVENT_VOLUME_REBALANCE_START",
  187     "EVENT_VOLUME_REBALANCE_STOP",
  188     "EVENT_VOLUME_REBALANCE_FAILED",
  189     "EVENT_VOLUME_REBALANCE_COMPLETE",
  190 
  191     #tier events
  192     "EVENT_TIER_START",
  193     "EVENT_TIER_START_FORCE",
  194 
  195     #brick/inodes events
  196     "EVENT_DHT_DISK_USAGE",
  197     "EVENT_DHT_INODES_USAGE",
  198 )
  199 
  200 LAST_EVENT = "EVENT_LAST"
  201 
  202 ERRORS = (
  203     "EVENT_SEND_OK",
  204     "EVENT_ERROR_INVALID_INPUTS",
  205     "EVENT_ERROR_SOCKET",
  206     "EVENT_ERROR_CONNECT",
  207     "EVENT_ERROR_SEND",
  208     "EVENT_ERROR_RESOLVE",
  209     "EVENT_ERROR_MSG_FORMAT",
  210 )
  211 
  212 if gen_header_type == "C_HEADER":
  213     # Generate eventtypes.h
  214     with open(eventtypes_h, "w") as f:
  215         f.write("#ifndef __EVENTTYPES_H__\n")
  216         f.write("#define __EVENTTYPES_H__\n\n")
  217         f.write("typedef enum {\n")
  218         for k in ERRORS:
  219             f.write("    {0},\n".format(k))
  220         f.write("} event_errors_t;\n")
  221 
  222         f.write("\n")
  223 
  224         f.write("typedef enum {\n")
  225         for k in keys:
  226             f.write("    {0},\n".format(k))
  227 
  228         f.write("    {0}\n".format(LAST_EVENT))
  229         f.write("} eventtypes_t;\n")
  230         f.write("\n#endif /* __EVENTTYPES_H__ */\n")
  231 
  232 if gen_header_type == "PY_HEADER":
  233     # Generate eventtypes.py
  234     with open(eventtypes_py, "w") as f:
  235         f.write("# -*- coding: utf-8 -*-\n")
  236         f.write("all_events = [\n")
  237         for ev in keys:
  238             f.write('    "{0}",\n'.format(ev))
  239 
  240         f.write("]\n\n")
  241 
  242         for idx, ev in enumerate(keys):
  243             f.write("{0} = {1}\n".format(ev.replace("EVENT_", ""), idx))