Esempio n. 1
0
def root_account(job):
    data = json.loads(job.body)
    cfg = Configuration(data['account_id'], root_path=sysconfig.get('worker', 'root'))
    success = False

    if cfg.is_valid():
        try:
            create_root(cfg)
            logger.info('Finished working on %d', job.jid)
            success = True
        except Exception, e:
            logger.exception(e)
Esempio n. 2
0
def root_site(job):
    data = json.loads(job.body)
    cfg = Configuration(data['account_id'], site=data['site'], root_path=sysconfig.get('worker', 'root'))
    if cfg.is_valid():
        create_root(cfg)
        pid = os.fork()
        if pid:
            (pid, status) = os.waitpid(pid, 0)
            logger.info('Finished working on %d (exit %s)', job.jid, os.WEXITSTATUS(status))

            if data['return_tube']:
                job.conn.use(data['return_tube'])
                job.conn.put(json.dumps({'success': True, 'original_job': job.body}))
        else:
            try:
                reroot(cfg)
                os._exit(0)
            except Exception, e:
                logger.exception(e)

            os._exit(1)
Esempio n. 3
0
from roboglue.Roborooter import reroot
from roboglue.Roborooter import create_root
import ConfigParser

sysconfig = ConfigParser.RawConfigParser()
sysconfig.read('/etc/roborooter.ini')


cli = CommandLineSite()

(options, args) = cli.parse()
if len(args) is not 2:
    cli.raise_help(
        'Pass exactly two arguments: account ID (integer), name of site.'
    )

cfg = Configuration(args[0], site=args[1], verbose=options.verbose, dry=options.dry, root_path=sysconfig.get('worker', 'root'))

if not cfg.is_valid():
    cli.raise_help(
        'Account ID must be integer, name of site must be alphanumeric and -\'s'
    )

if not os.path.isdir(cfg.get_account_path()):
    print("Root path %s is not a directory." % cfg.get_account_path())
    print("Creating root...")

create_root(cfg)
reroot(cfg)