Commit c008906b authored by Michael Hanselmann's avatar Michael Hanselmann

bootstrap: Factorize HMAC key generation

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent cd34faf2
......@@ -100,6 +100,16 @@ def GenerateSelfSignedSslCert(file_name, validity=(365 * 5)):
os.close(fd)
def GenerateHmacKey(file_name):
"""Writes a new HMAC key.
@type file_name: str
@param file_name: Path to output file
"""
utils.WriteFile(file_name, data=utils.GenerateSecret(), mode=0400)
def _InitGanetiServerSetup():
"""Setup the necessary configuration for the initial node daemon.
......@@ -114,9 +124,7 @@ def _InitGanetiServerSetup():
GenerateSelfSignedSslCert(constants.RAPI_CERT_FILE)
if not os.path.exists(constants.HMAC_CLUSTER_KEY):
utils.WriteFile(constants.HMAC_CLUSTER_KEY,
data=utils.GenerateSecret(),
mode=0400)
GenerateHmacKey(constants.HMAC_CLUSTER_KEY)
result = utils.RunCmd([constants.NODE_INITD_SCRIPT, "restart"])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment