git://git.onelab.eu
/
nodemanager.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
expects the 'interfaces' key in GetSlivers - review logs to always mention module
[nodemanager.git]
/
plugins
/
specialaccounts.py
diff --git
a/plugins/specialaccounts.py
b/plugins/specialaccounts.py
index
23bd4ae
..
1fa15e1
100644
(file)
--- a/
plugins/specialaccounts.py
+++ b/
plugins/specialaccounts.py
@@
-1,5
+1,9
@@
#!/usr/bin/python -tt
# vim:set ts=4 sw=4 expandtab:
#!/usr/bin/python -tt
# vim:set ts=4 sw=4 expandtab:
+#
+# $Id$
+# $URL$
+#
# NodeManager plugin to create special accounts
"""
# NodeManager plugin to create special accounts
"""
@@
-19,10
+23,13
@@
import logger
import tools
def start(options, conf):
import tools
def start(options, conf):
- logger.log("personkeys plugin starting up...")
+ logger.log("personkeys: plugin starting up...")
+
+def GetSlivers(data, conf = None, plc = None):
+ if 'accounts' not in data:
+ logger.log_missing_data("specialaccounts.GetSlivers",'accounts')
+ return
-def GetSlivers(plc, data, conf):
- if 'accounts' not in data: return
for account in data['accounts']:
name = account['name']
new_keys = account['keys']
for account in data['accounts']:
name = account['name']
new_keys = account['keys']
@@
-30,24
+37,24
@@
def GetSlivers(plc, data, conf):
# look up account name, which must exist
pw_info = pwd.getpwnam(name)
uid = pw_info[2]
# look up account name, which must exist
pw_info = pwd.getpwnam(name)
uid = pw_info[2]
- gid = pw_info[3]
+
gid = pw_info[3]
pw_dir = pw_info[5]
# populate account's .ssh/authorized_keys file
dot_ssh = os.path.join(pw_dir,'.ssh')
if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
auth_keys = os.path.join(dot_ssh,'authorized_keys')
pw_dir = pw_info[5]
# populate account's .ssh/authorized_keys file
dot_ssh = os.path.join(pw_dir,'.ssh')
if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
auth_keys = os.path.join(dot_ssh,'authorized_keys')
- logger.log("new keys = %s" % auth_keys)
+ logger.log("specialaccounts: new keys = %s" % auth_keys)
fd, fname = tempfile.mkstemp('','authorized_keys',dot_ssh)
fd, fname = tempfile.mkstemp('','authorized_keys',dot_ssh)
- for key in new_keys:
+
+ for key in new_keys:
os.write(fd,key)
os.write(fd,'\n')
os.close(fd)
os.write(fd,key)
os.write(fd,'\n')
os.close(fd)
- if os.path.exists(auth_keys):
- os.unlink(auth_keys)
- os.rename(fname,auth_keys)
+ if os.path.exists(auth_keys): os.unlink(auth_keys)
+ os.rename(fname, auth_keys)
# set permissions properly
os.chmod(dot_ssh, 0700)
# set permissions properly
os.chmod(dot_ssh, 0700)