def __init__(self, enthome, installstate, port, box_keys_dir,
                 license_keys_dir):
        ent_config = entconfig.EntConfig(enthome)  # read-only entconfig object

        if not ent_config.Load():
            sys.exit('Cannot load configuration.')

        flags.FLAGS.gfs_aliases = ent_config.var('GFS_ALIASES')
        flags.FLAGS.bnsresolver_use_svelte = False
        flags.FLAGS.logtostderr = True
        gfile.Init()
        self.ss = pywrapselectserver.SelectServer()

        # Initialize the configurator.
        self.cfg = configurator.configurator(enthome,
                                             box_keys_dir=box_keys_dir,
                                             license_keys_dir=license_keys_dir,
                                             install_state=installstate,
                                             startup_mode=1)
        self.cfg.lm.setInWorking()

        self.thread_pool = pywrapthreadpool.ThreadPool(1, 5, 5, 0)
        self.thread_pool.StartWorkers()
        self.server = pywraphttpserver.HTTPServer(self.ss, port, '1.0')
        self.server.SetTrustedClients(
            string.join(
                self.cfg.globalParams.var('HTTPSERVER_TRUSTED_CLIENTS'), ','))
        self.handlers = []

        self.RegisterSimpleGetHandler('/', self.RootHandler)
        self.RegisterSimpleGetHandler('/healthz', self.HealthzHandler)
        self.RegisterSimpleGetHandler('/servers', self.ServersHandler)
        self.RegisterSimpleGetHandler('/configversion',
                                      self.ConfigVersionHandler)
        self.RegisterSimpleGetHandler('/flushlog', self.FlushLogHandler)
        self.RegisterGetOrPostHandler('/legacy', self.LegacyHandler)
        self.RegisterSimplePostHandler('/legacyCommand',
                                       self.LegacyCommandHandler)

        license_handler.NewLicenseHandler(self)
  def __init__(self, enthome, installstate, port, box_keys_dir, license_keys_dir):
    ent_config = entconfig.EntConfig(enthome) # read-only entconfig object

    if not ent_config.Load():
      sys.exit('Cannot load configuration.')

    flags.FLAGS.gfs_aliases = ent_config.var('GFS_ALIASES')
    flags.FLAGS.bnsresolver_use_svelte = False
    flags.FLAGS.logtostderr = True
    gfile.Init()
    self.ss = pywrapselectserver.SelectServer()

    # Initialize the configurator.
    self.cfg = configurator.configurator(enthome,
                                         box_keys_dir = box_keys_dir,
                                         license_keys_dir = license_keys_dir,
                                         install_state = installstate,
                                         startup_mode = 1)
    self.cfg.lm.setInWorking()

    self.thread_pool = pywrapthreadpool.ThreadPool(1, 5, 5, 0)
    self.thread_pool.StartWorkers()
    self.server = pywraphttpserver.HTTPServer(self.ss, port, '1.0')
    self.server.SetTrustedClients(
      string.join(self.cfg.globalParams.var('HTTPSERVER_TRUSTED_CLIENTS'), ','))
    self.handlers = []

    self.RegisterSimpleGetHandler('/', self.RootHandler)
    self.RegisterSimpleGetHandler('/healthz', self.HealthzHandler)
    self.RegisterSimpleGetHandler('/servers', self.ServersHandler)
    self.RegisterSimpleGetHandler('/configversion', self.ConfigVersionHandler)
    self.RegisterSimpleGetHandler('/flushlog', self.FlushLogHandler)
    self.RegisterGetOrPostHandler('/legacy', self.LegacyHandler)
    self.RegisterSimplePostHandler('/legacyCommand', self.LegacyCommandHandler)

    license_handler.NewLicenseHandler(self)
Esempio n. 3
0
    if not (FLAGS.do_import or FLAGS.do_export):
        sys.exit('Must specify --do_import or --do_export')

    ent_config = entconfig.EntConfig(FLAGS.enthome)
    if not ent_config.Load():
        sys.exit('Cannot load configuration.')

    pywrapbase.InitGoogleScript('', [
        'foo',
        '--gfs_aliases=%s' % ent_config.var('GFS_ALIASES'),
        '--bnsresolver_use_svelte=false', '--logtostderr', '--minloglevel=1'
    ], 0)
    gfile.Init()

    begin = time.time()
    cfg = configurator.configurator(FLAGS.enthome)

    if FLAGS.do_import:
        logging.info("initializing global default files")
        if not cfg.globalParams.InitGlobalDefaultFiles(overwrite=0):
            logging.fatal("failed to initialize global default files")

        config_xml_serialization.ImportConfiguration(cfg, open(FLAGS.xml_path))

    if FLAGS.do_export:
        f = open(FLAGS.xml_path, 'w')
        f.write(config_xml_serialization.ExportConfiguration(cfg))
        f.close()

    diff = (time.time() - begin) / 60
    logging.info('Migration operation took %.2f minutes.' % diff)
Esempio n. 4
0
  if not (FLAGS.do_import or FLAGS.do_export):
    sys.exit('Must specify --do_import or --do_export')

  ent_config = entconfig.EntConfig(FLAGS.enthome)
  if not ent_config.Load():
    sys.exit('Cannot load configuration.')

  pywrapbase.InitGoogleScript('', ['foo',
          '--gfs_aliases=%s' % ent_config.var('GFS_ALIASES'),
          '--bnsresolver_use_svelte=false',
          '--logtostderr', '--minloglevel=1'], 0)
  gfile.Init()

  begin = time.time()
  cfg = configurator.configurator(FLAGS.enthome)

  if FLAGS.do_import:
    logging.info("initializing global default files")
    if not cfg.globalParams.InitGlobalDefaultFiles(overwrite=0):
      logging.fatal("failed to initialize global default files")

    config_xml_serialization.ImportConfiguration(cfg, open(FLAGS.xml_path))

  if FLAGS.do_export:
    f = open(FLAGS.xml_path, 'w')
    f.write(config_xml_serialization.ExportConfiguration(cfg))
    f.close()

  diff = (time.time() - begin ) / 60
  logging.info('Migration operation took %.2f minutes.' % diff)