summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth/generate_action_types.py
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@10gen.com>2012-11-03 18:37:21 -0400
committerSpencer T Brody <spencer@10gen.com>2012-11-05 17:36:35 -0500
commit389613bb9727d1594f10ce1abe50a048fa062460 (patch)
treec647b7a0e0418891060cc95895cbf6cd40854c38 /src/mongo/db/auth/generate_action_types.py
parent73b14c23aecb50cc17c0043970c46cb1aba3ff29 (diff)
downloadmongo-389613bb9727d1594f10ce1abe50a048fa062460.tar.gz
SERVER-7126 Move ActionType definitions to their own file that is input to generate_action_types.py
Diffstat (limited to 'src/mongo/db/auth/generate_action_types.py')
-rwxr-xr-xsrc/mongo/db/auth/generate_action_types.py112
1 files changed, 17 insertions, 95 deletions
diff --git a/src/mongo/db/auth/generate_action_types.py b/src/mongo/db/auth/generate_action_types.py
index a24f9b9f11d..32f864ac736 100755
--- a/src/mongo/db/auth/generate_action_types.py
+++ b/src/mongo/db/auth/generate_action_types.py
@@ -18,95 +18,11 @@
"""Generate action_type.{h,cpp}
Usage:
- python generate_action_types.py <header file path> <source file path>
+ python generate_action_types.py <path to action_types.txt> <header file path> <source file path>
"""
import sys
-# List describing the ActionTypes that should be created.
-actionTypes = ["addShard",
- "applyOps",
- "captrunc",
- "clean",
- "closeAllDatabases",
- "collMod",
- "collStats",
- "compact",
- "connPoolStats",
- "connPoolSync",
- "convertToCapped",
- "cpuProfiler",
- "createCollection",
- "cursorInfo",
- "dbHash",
- "dbStats",
- "diagLogging",
- "dropCollection",
- "dropDatabase",
- "dropIndexes",
- "emptycapped",
- "enableSharding",
- "ensureIndex",
- "find",
- "flushRouterConfig",
- "fsync",
- "getCmdLineOpts",
- "getLog",
- "getParameter",
- "getShardMap",
- "getShardVersion",
- "handshake",
- "hostInfo",
- "insert",
- "listDatabases",
- "listShards",
- "logRotate",
- "moveChunk",
- "movePrimary",
- "netstat",
- "profile",
- "reIndex",
- "remove",
- "removeShard",
- "renameCollection",
- "repairDatabase",
- "replSetElect",
- "replSetFreeze",
- "replSetFresh",
- "replSetGetRBID",
- "replSetGetStatus",
- "replSetHeartbeat",
- "replSetInitiate",
- "replSetMaintenance",
- "replSetReconfig",
- "replSetStepDown",
- "replSetSyncFrom",
- "resync",
- "setParameter",
- "setShardVersion",
- "shardCollection",
- "shardingState",
- "shutdown",
- "split",
- "splitChunk",
- "splitVector",
- "top",
- "touch",
- "unsetSharding",
- "update",
- "userAdmin",
- "validate",
- "writebacklisten",
- "writeBacksQueued",
- "_migrateClone",
- "_recvChunkAbort",
- "_recvChunkCommit",
- "_recvChunkStart",
- "_recvChunkStatus",
- "_transferMods",
- "oldRead", # Temporary. For easing AuthorizationManager integration
- "oldWrite"] # Temporary. For easing AuthorizationManager integration
-
headerFileTemplate = """// AUTO-GENERATED FILE DO NOT EDIT
// See src/mongo/db/auth/generate_action_types.py
@@ -235,7 +151,7 @@ namespace mongo {
} // namespace mongo
"""
-def writeSourceFile(sourceOutputFile):
+def writeSourceFile(actionTypes, sourceOutputFile):
actionTypeConstants = ""
fromStringIfStatements = ""
toStringCaseStatements = ""
@@ -256,7 +172,7 @@ def writeSourceFile(sourceOutputFile):
pass
-def writeHeaderFile(headerOutputFile):
+def writeHeaderFile(actionTypes, headerOutputFile):
actionTypeConstants = ""
actionTypeIdentifiers = ""
for actionType in actionTypes:
@@ -266,7 +182,7 @@ def writeHeaderFile(headerOutputFile):
actionTypeIdentifiers=actionTypeIdentifiers)
headerOutputFile.write(formattedHeaderFile)
-def hasDuplicateActionTypes():
+def hasDuplicateActionTypes(actionTypes):
sortedActionTypes = sorted(actionTypes)
didFail = False
@@ -279,16 +195,22 @@ def hasDuplicateActionTypes():
return didFail
+def parseActionTypesFromFile(actionTypesFilename):
+ actionTypesFile = open(actionTypesFilename, 'r')
+ actionTypes = eval(actionTypesFile.read())
+ return actionTypes
+
if __name__ == "__main__":
- if len(sys.argv) != 3:
- print "Usage: generate_action_types.py <header file path> <source file path>"
+ if len(sys.argv) != 4:
+ print "Usage: generate_action_types.py <path to action_types.txt> <header file path> <source file path>"
sys.exit(-1)
- if hasDuplicateActionTypes():
+ actionTypes = parseActionTypesFromFile(sys.argv[1])
+ if hasDuplicateActionTypes(actionTypes):
sys.exit(-1)
- headerOutputFile = open(sys.argv[1], 'w')
- sourceOutputFile = open(sys.argv[2], 'w')
+ headerOutputFile = open(sys.argv[2], 'w')
+ sourceOutputFile = open(sys.argv[3], 'w')
- writeHeaderFile(headerOutputFile)
- writeSourceFile(sourceOutputFile)
+ writeHeaderFile(actionTypes, headerOutputFile)
+ writeSourceFile(actionTypes, sourceOutputFile)