forked from SeattleTestbed/nodemanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createnodekeys.py
59 lines (38 loc) · 1.49 KB
/
createnodekeys.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
Author: Justin Cappos
Module: Node Manager key pair initializer.
Start date: October 17rd, 2008
Adapted from nminit.py
"""
# need repy portability
from repyportability import *
_context = locals()
add_dy_support(_context)
# need to generate a public key
dy_import_module_symbols('rsa.r2py')
import os
import persist
# init the keys...
# Zack Boka: Added the functionality of changing directories so the parent
# funciton would not have to worry about doing this.
def initialize_keys(keybitsize,nodemanager_directory="."):
# nodemanager_directory: The directory in which the nodeman.cfg file is
# located.
# initialize my configuration file. This involves a few variables:
# pollfrequency -- the amount of time to sleep after a check when "busy
# waiting". This trades CPU load for responsiveness.
# ports -- the ports the node manager could listen on.
# publickey -- the public key used to identify the node...
# privatekey -- the corresponding private key for the node...
#
# Only the public key and private key are set here...
configuration = persist.restore_object('nodeman.cfg')
curdir = os.getcwd()
os.chdir(nodemanager_directory)
keys = rsa_gen_pubpriv_keys(keybitsize)
configuration['publickey'] = keys[0]
configuration['privatekey'] = keys[1]
persist.commit_object(configuration,"nodeman.cfg")
os.chdir(curdir)
if __name__ == '__main__':
initialize_keys()