Created
April 17, 2013 20:10
-
-
Save vicenteg/5407346 to your computer and use it in GitHub Desktop.
A hack to allow power fencing to work with cobbler and a SeaMicro chassis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import re | |
import sys | |
import os | |
import pwd | |
import grp | |
import subprocess | |
import logging | |
from logging import handlers | |
# drop root privs, if necessary | |
if os.getuid() == 0: | |
nobody = pwd.getpwnam('nobody').pw_uid | |
nogroup = grp.getgrnam('nobody').gr_gid | |
os.setgroups([]) | |
os.setgid(nogroup) | |
os.setuid(nobody) | |
logger = logging.getLogger('fence_seamicro') | |
logger.setLevel(logging.DEBUG) | |
logger.addHandler(handlers.SysLogHandler('/dev/log')) | |
logger.warn('SeaMicro fence hack, running as %s' % os.getuid()) | |
to_run = sys.stdin.readlines()[0] | |
args = re.split('\s+', to_run.strip()) | |
logger.info('fence hack running: %s' % args) | |
subprocess.call(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment