Esempio n. 1
0
  def __init__(self, yaml_conf):
    """Configures shopfloor xmlrpc server to FastCGI mode."""

    # ServiceBase inherits from Protocol, which is an old-style class and
    # cannot use super() to init.
    ServiceBase.__init__(self)

    shopfloor_server = os.path.abspath(
        os.path.join(env.runtime_dir, 'shopfloor_server'))
    svc_conf = {
      'executable': shopfloor_server,
      'name': 'fcgisvc',
      'args': ['-a', '127.0.0.1',
               '-p', str(env.fcgi_port),
               '-m', yaml_conf['shopfloor']['shopfloor_module'],
               '-f',
               '-v',
               '-u', 'cros.factory.shopfloor.launcher.update_state',
               '--updater-dir', env.GetUpdatesDir()],
      'auto_restart': True,
      'logpipe': True
    }
    self.SetConfig(svc_conf)

    # Creates shopfloor xmlrpc server symlink and folders.
    if not os.path.isfile(shopfloor_server):
      os.symlink(os.path.join(env.runtime_dir, constants.FACTORY_SOFTWARE),
                 shopfloor_server)
    shopfloor_data = os.path.join(env.runtime_dir, constants.SHOPFLOOR_DATA)
    TryMakeDirs(shopfloor_data)
    TryMakeDirs(os.path.join(shopfloor_data, REPORTS_DIR))
    TryMakeDirs(os.path.join(shopfloor_data, EVENTS_DIR))
    TryMakeDirs(os.path.join(shopfloor_data, AUX_LOGS_DIR))
Esempio n. 2
0
    def __init__(self, dummy_config):
        # ServiceBase is an old-style python class.
        ServiceBase.__init__(self)

        archiver_executable = os.path.join(env.runtime_dir, 'archive_reports')
        TryMakeDirs(os.path.join(env.runtime_dir, constants.SHOPFLOOR_DATA))
        svc_conf = {
            'executable':
            archiver_executable,
            'name':
            'archive_reports',
            'args': [
                '--period', '10', '--dir', REPORTS_DIR, '--dir',
                INCREMENTAL_EVENTS_DIR
            ],
            'path':
            env.runtime_dir,
            'logpipe':
            True,
            'auto_restart':
            True
        }
        self.SetConfig(svc_conf)

        # Creates archiver symlink and folders.
        if not os.path.isfile(archiver_executable):
            os.symlink(
                os.path.join(env.runtime_dir, constants.FACTORY_SOFTWARE),
                archiver_executable)
Esempio n. 3
0
  def __init__(self, config):
    # ServiceBase inherits from an old-style python class.
    ServiceBase.__init__(self)

    config_file = os.path.join(env.runtime_dir, 'rsyncd.conf')
    log_file = os.path.join(env.runtime_dir, 'log', 'rsync.log')
    pid_file = os.path.join(env.runtime_dir, 'run', 'rsync.pid')
    if os.path.exists(pid_file):
      os.unlink(pid_file)

    rsync_config = RSYNCD_CONFIG_TEMPLATE % dict(
        port=constants.DEFAULT_RSYNC_PORT,
        pidfile=pid_file,
        logfile=log_file)

    # Factory update module
    hwid_files = glob.glob(os.path.join(env.GetUpdatesDir(), 'hwid_*.sh'))
    update_bundle_path = os.path.join(env.GetUpdatesDir(), 'factory')
    map(os.unlink, hwid_files)
    if 'updater' in config:
      TryMakeDirs(env.GetUpdatesDir())
      TryMakeDirs(update_bundle_path)
      rsync_config += RSYNCD_CONFIG_MODULE_PATH_TEMPLATE % dict(
          module='factory',
          path=update_bundle_path,
          read_only='yes')
      if 'update_bundle' in config['updater']:
        self._PrepareUpdateBundle(config['updater']['update_bundle'])
      if 'hwid_bundle' in config['updater']:
        self._PrepareHwidBundle(config['updater']['hwid_bundle'])
    else:
      latest_md5file = os.path.join(update_bundle_path, LATEST_MD5FILE)
      if os.path.isfile(latest_md5file):
        os.unlink(latest_md5file)


    # Log upload module
    upload_path = os.path.join(env.runtime_dir, 'upload_logs')
    TryMakeDirs(upload_path)
    rsync_config += RSYNCD_CONFIG_MODULE_PATH_TEMPLATE % dict(
        module='system_logs',
        path=upload_path,
        read_only='no')

    with open(config_file, 'w') as f:
      f.write(rsync_config)

    svc_conf = {
      'executable': 'rsync',
      'name': 'rsyncsvc',
      'args': [
        '--daemon',
        '--no-detach',
        '--config=%s' % config_file],
      'path': env.runtime_dir,
      'logpipe': False,
      'auto_restart': True}
    self.SetConfig(svc_conf)
    def __init__(self, dummy_config):
        # ServiceBase inherits from old-style ProcessProtocol.
        ServiceBase.__init__(self)

        mjfe_executable = os.path.join(env.runtime_dir, 'minijack_frontend')
        self.SetConfig({
            'executable': mjfe_executable,
            'name': 'minijackfesvc',
            'args': [''],
            'path': env.runtime_dir,
            'logpipe': False,
            'auto_restart': True
        })

        # Create symlink and folders.
        factory_software = os.path.join(env.runtime_dir, FACTORY_SOFTWARE)
        if not os.path.isfile(mjfe_executable):
            os.symlink(factory_software, mjfe_executable)
        frontend_dir = os.path.join(env.runtime_dir, FRONTEND_DIR)
        static_dir = os.path.join(frontend_dir, STATIC_DIR)
        templates_dir = os.path.join(frontend_dir, TEMPLATES_DIR)
        TryMakeDirs(frontend_dir)
        if os.path.isdir(static_dir):
            shutil.rmtree(static_dir)
        if os.path.isdir(templates_dir):
            shutil.rmtree(templates_dir)

        # Extract frontend static files and rendering templates.
        with TempDirectory() as temp_dir:
            # zipfile extracts full pathname, the frontend dir inside temp folder is
            # [temp]/cros/factory/minijack/frontend
            extracted_frontend = os.path.join(temp_dir, 'cros', 'factory',
                                              'minijack', 'frontend')
            extracted_static = os.path.join(extracted_frontend, STATIC_DIR)
            extracted_templates = os.path.join(extracted_frontend,
                                               TEMPLATES_DIR)
            with zipfile.ZipFile(factory_software) as par:
                members = filter(_IsFrontendFile, par.namelist())
                par.extractall(temp_dir, members)
                # Move static and templates folder to destination folder, or create
                # them.
                if os.path.isdir(extracted_static):
                    shutil.move(extracted_static, static_dir)
                else:
                    logging.warning(
                        'MJFE: factory.par static folder not found.')
                    TryMakeDirs(static_dir)
                if os.path.isdir(extracted_templates):
                    shutil.move(extracted_templates, templates_dir)
                else:
                    logging.warning(
                        'MJFE: factory.par template folder not found.')
                    TryMakeDirs(templates_dir)
  def __init__(self, dummy_config):
    # ServiceBase inherits from old-style ProcessProtocol.
    ServiceBase.__init__(self)

    mjfe_executable = os.path.join(env.runtime_dir, 'minijack_frontend')
    self.SetConfig({
        'executable': mjfe_executable,
        'name': 'minijackfesvc',
        'args': [''],
        'path': env.runtime_dir,
        'logpipe': False,
        'auto_restart': True})

    # Create symlink and folders.
    factory_software = os.path.join(env.runtime_dir, FACTORY_SOFTWARE)
    if not os.path.isfile(mjfe_executable):
      os.symlink(factory_software, mjfe_executable)
    frontend_dir = os.path.join(env.runtime_dir, FRONTEND_DIR)
    static_dir = os.path.join(frontend_dir, STATIC_DIR)
    templates_dir = os.path.join(frontend_dir, TEMPLATES_DIR)
    TryMakeDirs(frontend_dir)
    if os.path.isdir(static_dir):
      shutil.rmtree(static_dir)
    if os.path.isdir(templates_dir):
      shutil.rmtree(templates_dir)

    # Extract frontend static files and rendering templates.
    with TempDirectory() as temp_dir:
      # zipfile extracts full pathname, the frontend dir inside temp folder is
      # [temp]/cros/factory/minijack/frontend
      extracted_frontend = os.path.join(temp_dir, 'cros', 'factory',
                                        'minijack', 'frontend')
      extracted_static = os.path.join(extracted_frontend, STATIC_DIR)
      extracted_templates = os.path.join(extracted_frontend, TEMPLATES_DIR)
      with zipfile.ZipFile(factory_software) as par:
        members = filter(_IsFrontendFile, par.namelist())
        par.extractall(temp_dir, members)
        # Move static and templates folder to destination folder, or create
        # them.
        if os.path.isdir(extracted_static):
          shutil.move(extracted_static, static_dir)
        else:
          logging.warning('MJFE: factory.par static folder not found.')
          TryMakeDirs(static_dir)
        if os.path.isdir(extracted_templates):
          shutil.move(extracted_templates, templates_dir)
        else:
          logging.warning('MJFE: factory.par template folder not found.')
          TryMakeDirs(templates_dir)
Esempio n. 6
0
    def __init__(self, yamlconf):
        """Generates http server configuration file and sets service args"""
        # Old-style python class, cannot use super() to init.
        ServiceBase.__init__(self)

        self._indent = 0
        httpd_conf = os.path.join(env.runtime_dir, 'lighttpd.conf')
        self._GenerateConfigFile(yamlconf, httpd_conf)
        # Setup a non-daemon mode lighttpd
        svc_conf = {
            'executable': '/usr/sbin/lighttpd',
            'name': 'httpsvc',
            'args': ['-D', '-f', httpd_conf]
        }
        self.SetConfig(svc_conf)
Esempio n. 7
0
  def __init__(self, yamlconf):
    """Generates http server configuration file and sets service args"""
    # Old-style python class, cannot use super() to init.
    ServiceBase.__init__(self)

    self._indent = 0
    httpd_conf = os.path.join(env.runtime_dir, 'lighttpd.conf')
    self._GenerateConfigFile(yamlconf, httpd_conf)
    # Setup a non-daemon mode lighttpd
    svc_conf = {
      'executable': '/usr/sbin/lighttpd',
      'name': 'httpsvc',
      'args': ['-D', '-f', httpd_conf]
    }
    self.SetConfig(svc_conf)
Esempio n. 8
0
  def __init__(self, yaml_config):  # pylint: disable=W0613
    # ServiceBase is an old-style python class. Initialize it the old-way.
    ServiceBase.__init__(self)

    update_server = os.path.abspath(
        os.path.join(env.runtime_dir, 'factory_update_server'))
    svc_conf = {
        'executable': update_server,
        'name': 'updatersvc',
        'args': [
            '-d', env.GetUpdatesDir(),
            '-p', str(constants.DEFAULT_RSYNC_PORT)],
        'path': env.GetUpdatesDir(),
        'logpipe': True,
        'auto_restart': True}
    self.SetConfig(svc_conf)
Esempio n. 9
0
    def __init__(self, yaml_conf):
        """Configures shopfloor xmlrpc server to FastCGI mode."""

        # ServiceBase inherits from Protocol, which is an old-style class and
        # cannot use super() to init.
        ServiceBase.__init__(self)

        shopfloor_server = os.path.abspath(
            os.path.join(env.runtime_dir, 'shopfloor_server'))
        svc_conf = {
            'executable':
            shopfloor_server,
            'name':
            'fcgisvc',
            'args': [
                '-a', '127.0.0.1', '-p',
                str(env.fcgi_port), '-m',
                yaml_conf['shopfloor']['shopfloor_module'], '-f', '-v', '-u',
                'cros.factory.shopfloor.launcher.update_state',
                '--updater-dir',
                env.GetUpdatesDir()
            ],
            'auto_restart':
            True,
            'logpipe':
            True
        }
        self.SetConfig(svc_conf)

        # Creates shopfloor xmlrpc server symlink and folders.
        if not os.path.isfile(shopfloor_server):
            os.symlink(
                os.path.join(env.runtime_dir, constants.FACTORY_SOFTWARE),
                shopfloor_server)
        shopfloor_data = os.path.join(env.runtime_dir,
                                      constants.SHOPFLOOR_DATA)
        TryMakeDirs(shopfloor_data)
        TryMakeDirs(os.path.join(shopfloor_data, REPORTS_DIR))
        TryMakeDirs(os.path.join(shopfloor_data, EVENTS_DIR))
        TryMakeDirs(os.path.join(shopfloor_data, AUX_LOGS_DIR))
Esempio n. 10
0
    def __init__(self, dummy_config):
        # ServiceBase inherits from twisted ProcessProtocol, which is an old-
        # style python class.
        ServiceBase.__init__(self)

        minijack_executable = os.path.join(env.runtime_dir, 'minijack')
        shopfloor_data = os.path.join(env.runtime_dir,
                                      constants.SHOPFLOOR_DATA)
        events_dir = os.path.join(shopfloor_data, EVENTS_DIR)
        svc_conf = {
            'executable':
            minijack_executable,
            'name':
            'minijacksvc',
            'args': [
                '--event_log_dir', events_dir, '--log',
                os.path.join(env.runtime_dir, constants.LOGS_DIR, MINIJACK_LOG)
            ],
            'path':
            env.runtime_dir,
            'logpipe':
            False,
            'auto_restart':
            True
        }
        self.SetConfig(svc_conf)

        # Prepares minijack symlink and folder.
        if not os.path.isfile(minijack_executable):
            os.symlink(
                os.path.join(env.runtime_dir, constants.FACTORY_SOFTWARE),
                minijack_executable)
        # Minijack reads from [install dir]/shopfloor_data/events
        shopfloor_data = os.path.join(env.runtime_dir,
                                      constants.SHOPFLOOR_DATA)
        TryMakeDirs(shopfloor_data)
        TryMakeDirs(events_dir)
Esempio n. 11
0
    def __init__(self, yaml_config):  # pylint: disable=W0613
        # ServiceBase is an old-style python class. Initialize it the old-way.
        ServiceBase.__init__(self)

        update_server = os.path.abspath(
            os.path.join(env.runtime_dir, 'factory_update_server'))
        svc_conf = {
            'executable':
            update_server,
            'name':
            'updatersvc',
            'args': [
                '-d',
                env.GetUpdatesDir(), '-p',
                str(constants.DEFAULT_RSYNC_PORT)
            ],
            'path':
            env.GetUpdatesDir(),
            'logpipe':
            True,
            'auto_restart':
            True
        }
        self.SetConfig(svc_conf)