summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth
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
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')
-rw-r--r--src/mongo/db/auth/SConscript2
-rw-r--r--src/mongo/db/auth/action_types.txt89
-rwxr-xr-xsrc/mongo/db/auth/generate_action_types.py112
3 files changed, 107 insertions, 96 deletions
diff --git a/src/mongo/db/auth/SConscript b/src/mongo/db/auth/SConscript
index ce47be521ab..aaf670bb956 100644
--- a/src/mongo/db/auth/SConscript
+++ b/src/mongo/db/auth/SConscript
@@ -4,7 +4,7 @@ Import("env")
env.StaticLibrary('serverauth', ['mongo_authentication_session.cpp'])
-env.Command(['action_type.h', 'action_type.cpp'], ['generate_action_types.py'],
+env.Command(['action_type.h', 'action_type.cpp'], ['generate_action_types.py', 'action_types.txt'],
'$PYTHON $SOURCES $TARGETS')
# Just the data structures used
diff --git a/src/mongo/db/auth/action_types.txt b/src/mongo/db/auth/action_types.txt
new file mode 100644
index 00000000000..9c8c5be4b46
--- /dev/null
+++ b/src/mongo/db/auth/action_types.txt
@@ -0,0 +1,89 @@
+# -*- python-mode -*-
+
+# List describing the ActionTypes that should be created.
+# Please note that the order of the elements is not guaranteed to be the same across versions.
+# This means that the integer value assigned to each ActionType and used internally in ActionSet
+# also may change between versions.
+["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
+
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)