Skip to content

Instantly share code, notes, and snippets.

@vicenteg
Created April 17, 2013 20:10
Show Gist options
  • Save vicenteg/5407346 to your computer and use it in GitHub Desktop.
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.
#!/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