def start(self):
   if self.IsFederationLicensed() and os.path.exists(self.config_file):
     logging.info(' -- starting federation network -- ')
 
     # start logging only if federation is enabled
     log_file_name = ('/export/hda3/tmp/fed_network_client_%s' %
                      time.strftime('%d-%b-%y'))
     log_file = open(log_file_name, 'a+')
     logging.set_logfile(log_file)
     logging.set_verbosity(logging.DEBUG)
     sys_abstraction = stunnel_jail.GetSystemAbstraction()
     
     # setup the stunnel jail
     jail = stunnel_jail.StunnelJail(fed_stunnel_config.STUNNEL_CLIENT_CHROOT,
                                     sys_abstraction)
     (status_jail, message) = jail.Setup()
     if status_jail:
       logging.error('The CHROOT Jail could not be setup %s' % message)
       return 1
     try:
       fed_config = fed_network_config.FederationConfig(self.config_file,
                                                        None,
                                                        sys_abstraction)
       logging.info('Federation config read successfully')
       client = fed_network_util.SuperRootStunnelService(sys_abstraction,
                                                         fed_config)
     except fed_network_config.FederationConfigException, ex:
       logging.error('Exception in configuration %s' % ex.message)
       return 1
     else:
       # Connect to all the slaves
       (status_connect, message) = client.Start()
       
       # Create the config root
       (status_config, message) = CreateSuperRootConfig(self.ent_home)
 def start(self):
     if self.IsFederationLicensed() and self.corpus is not None:
         log_file_name = "/export/hda3/tmp/fed_network_%s" % time.strftime("%d-%b-%y")
         log_file = open(log_file_name, "a+")
         logging.set_logfile(log_file)
         logging.set_verbosity(logging.DEBUG)
         logging.info(" -- starting federation network -- ")
         self.corpus.Start()
     else:
         logging.info(" Federation network not started -- No License or Invalid Configuration")
     return 1
Exemplo n.º 3
0
def main():
    latest_version = install_utilities.get_latest_version()
    ent_home = '/export/hda3/%s' % latest_version
    backup_dir = '/export/hda3/%s/data/googleconfig.bak' % latest_version
    log_file_name = '/export/hda3/tmp/google_config_backup.log'

    log_file = open(log_file_name, 'a')
    logging.set_logfile(log_file)

    config = entconfig.EntConfig(ent_home)
    number_of_backups = 21
    return BackupGoogleConfigFile(config, backup_dir, number_of_backups)
def main():
  latest_version = install_utilities.get_latest_version()
  ent_home = '/export/hda3/%s' % latest_version
  backup_dir = '/export/hda3/%s/data/googleconfig.bak' % latest_version
  log_file_name = '/export/hda3/tmp/google_config_backup.log'

  log_file = open(log_file_name, 'a')
  logging.set_logfile(log_file)

  config = entconfig.EntConfig(ent_home)
  number_of_backups = 21
  return BackupGoogleConfigFile(config, backup_dir, number_of_backups)
 def start(self):
   if self.IsFederationLicensed() and self.corpus is not None:
     log_file_name = ('/export/hda3/tmp/fed_network_%s' %
                      time.strftime('%d-%b-%y'))
     log_file = open(log_file_name, 'a+')
     logging.set_logfile(log_file)
     logging.set_verbosity(logging.DEBUG)
     logging.info(" -- starting federation network -- ")
     self.corpus.Start()
   else:
     logging.info(" Federation network not started -- No License or Invalid Configuration")
   return 1
Exemplo n.º 6
0
import commands
import socket
import os

from google3.pyglib import logging


def run_command(command):
    status = os.system('( %s ) 2>&1 </dev/null' % (command))
    if status != 0:
        cmd_line = string.join(map(commands.mkarg, sys.argv), ' ')
        logging.error(
            'cron command failed on %s. Command run: %s, Status: %s' %
            (socket.gethostname(), cmd_line, status))


if __name__ == '__main__':
    if len(sys.argv) == 2:
        cmd = sys.argv[1]
        logfile = '/tmp/cron_command.log'
        if not os.path.exists(logfile):
            logging.set_logfile(open(logfile, 'w'))
            os.chmod(logfile, 0666)
        else:
            logging.set_logfile(open(logfile, 'a'))
        run_command(cmd)
    else:
        # Don't use sys.exit(__doc__) because this script must always return 0
        print __doc__
    sys.exit(0)
Exemplo n.º 7
0
  except flags.FlagsError, e:
    sys.exit('%s\n%s' % (e, __doc__))
  if (len(argv) < 2):
    sys.exit(__doc__)
  query_var = argv[1]

  if FLAGS.logdir:
    if E.access([E.LOCALHOST], FLAGS.logdir, 'rwd'):
      # One log file per day, so as not to clutter the log directory
      # if this process is run often.
      # We can use localtime since this does not surface to the user.
      logfile = '%s/snmphelper_%s' % (
          FLAGS.logdir,
          time.strftime('%Y%m%d', time.localtime(time.time())))
      logging.info('Writing log to %s' % logfile)
      logging.set_logfile(open(logfile, 'a'))
    else:
      logging.warn('Invalid log directory %s' % FLAGS.logdir)
  try:
    if query_var == 'crawlRunning':
      # special case, not a system status or borgmon variable
      print GetCrawlPauseStatus()
    else:
      # all getsystemstatus supported variables are in this dictionary
      systemStatusVars = {
        'diskHealth': ('SystemStatusValues', 'Disks'),
        'temperatureHealth': ('SystemStatusValues', 'Temperatures'),
        'machineHealth': ('SystemStatusValues', 'Machines'),
        'diskErrors': ('SystemStatusDescriptions', 'Disks'),
        'temperatureErrors': ('SystemStatusDescriptions', 'Temperatures'),
        'machineErrors' : ('SystemStatusDescriptions', 'Machines'),
Exemplo n.º 8
0
    if not FLAGS.configmgr_request_dir:
        sys.exit("Please specify --configmgr_request_dir")
    if not FLAGS.working_dir:
        sys.exit("Please specify --working_dir")

    if FLAGS.cwd != "":
        try:
            os.chdir(FLAGS.cwd)
        except:
            print "Couldnt open change the working dir to %s" % FLAGS.cwd

    try:
        fd = open(FLAGS.logfile, "a")
        sys.stdout = fd
        sys.stderr = fd
        logging.set_logfile(fd)
    except:
        print "Couldnt open the given logfile %s in append mode" % FLAGS.logfile

    # Create the autorunner object and register what to run for those requests.
    dispatcher = autorunner.AutorunnerDispatcher(
        FLAGS.configmgr_request_dir,
        FLAGS.working_dir,
        None,
        filter(None, string.split(FLAGS.replication_machines, ",")),
    )

    # Register handlers
    dispatcher.SetSuccessHandler(request_scheduling.HandleCompletion)
    dispatcher.SetFailureHandler(request_scheduling.HandleCompletion)
Exemplo n.º 9
0
    if not FLAGS.configmgr_request_dir:
        sys.exit("Please specify --configmgr_request_dir")
    if not FLAGS.working_dir:
        sys.exit("Please specify --working_dir")

    if FLAGS.cwd != "":
        try:
            os.chdir(FLAGS.cwd)
        except:
            print "Couldnt open change the working dir to %s" % FLAGS.cwd

    try:
        fd = open(FLAGS.logfile, 'a')
        sys.stdout = fd
        sys.stderr = fd
        logging.set_logfile(fd)
    except:
        print "Couldnt open the given logfile %s in append mode" % FLAGS.logfile

    # Create the autorunner object and register what to run for those requests.
    dispatcher = autorunner.AutorunnerDispatcher(
        FLAGS.configmgr_request_dir, FLAGS.working_dir, None,
        filter(None, string.split(FLAGS.replication_machines, ',')))

    # Register handlers
    dispatcher.SetSuccessHandler(request_scheduling.HandleCompletion)
    dispatcher.SetFailureHandler(request_scheduling.HandleCompletion)

    # Set the function that checks if the request is allowd
    dispatcher.SetAllowedRequestFilter(request_scheduling.AllowedFilter)