Ejemplo n.º 1
0
    def create_user():
        if User.check_user_file():
            return User()

        # attempt to fetch password from GCS.
        storage_client = storage.Client()
        bucket_name = gce_funcs.get_gs_bucket().strip()
        bucket = storage_client.lookup_bucket(bucket_name)

        try:
            newpass = bucket.blob('ltm-pass').download_as_string().strip()
        except google.cloud.exceptions.NotFound as e:
            # need to error here. If this happens the user managed to delete
            # gs://$GS_BUCKET/ltm-pass between launch-ltm and the boot of the
            # webserver.
            print 'Could not find password.'
            raise e

        newusername = random_string(size=8)
        newsalt = random_string(size=20)

        # store the SHA512 hash in hex on the management server
        hashed_password = get_password_hash(newpass, newsalt)
        newuser = {
            'username': newusername,
            'password': hashed_password,
            'salt': newsalt
        }

        with open(User.user_data_file_path, 'w') as f:
            json.dump(newuser, f)
        return User()
Ejemplo n.º 2
0
 def __init__(self, cmd_json):
     logging.info('Starting new Build Run')
     launch_bldsrv_cmd = ['gce-xfstests', 'launch-bldsrv']
     self.launch_bldsrv_cmd = launch_bldsrv_cmd
     self.gce_proj_id = gce_funcs.get_proj_id()
     self.gce_project = gce_funcs.get_proj_id().strip()
     self.gce_zone = gce_funcs.get_gce_zone()
     self.gce_region = self.gce_zone[:-2]
     self.gs_bucket = gce_funcs.get_gs_bucket().strip()
     self.instance_name = 'xfstests-bldsrv'
     self.cmd_json = cmd_json
     self.compute = googleapiclient.discovery.build('compute', 'v1')
Ejemplo n.º 3
0
    def __init__(self, repository, commit, build_dir, build_id, log_dir_path):

        self.repository = repository
        self.commit = commit
        self.build_dir = build_dir
        self.id = build_id
        self.build_path = BLDSRV.repo_cache_path + self.build_dir
        self.image_file_path = self.build_path + BLDSRV.image_path
        self.build_log = self.build_path + '/build.log'
        self.gs_bucket = gce_funcs.get_gs_bucket().strip()

        # LOG/RESULTS VARIABLES
        self.log_file_path = log_dir_path + self.id
        self.buildlog_file_path = self.log_file_path + '.buildlog'

        logging.debug('Starting build %s', self.id)
    def __init__(self, orig_cmd, opts=None):
        logging.info('Building new Test Run')
        logging.info('Getting unique test run id..')
        test_run_id = get_unique_test_run_id()
        logging.info('Creating new TestRun with id %s', test_run_id)

        self.id = test_run_id
        self.orig_cmd = orig_cmd.strip()
        self.log_dir_path = LTM.test_log_dir + '%s/' % test_run_id
        self.log_file_path = self.log_dir_path + 'run.log'
        self.agg_results_dir = '%sresults-%s-%s/' % (self.log_dir_path,
                                                     LTM.ltm_username, self.id)
        self.agg_results_filename = '%sresults.%s-%s' % (
            self.log_dir_path, LTM.ltm_username, self.id)
        self.kernel_version = 'unknown_kernel_version'

        LTM.create_log_dir(self.log_dir_path)
        logging.info('Created new TestRun with id %s', self.id)
        self.shards = []

        region_shard = True
        self.gs_bucket = gce_funcs.get_gs_bucket().strip()
        self.bucket_subdir = gce_funcs.get_bucket_subdir().strip()
        self.gs_kernel = None
        self.report_receiver = None
        if opts and 'no_region_shard' in opts:
            region_shard = False
        if opts and 'bucket_subdir' in opts:
            self.bucket_subdir = opts['bucket_subdir'].strip()
        if opts and 'gs_kernel' in opts:
            self.gs_kernel = opts['gs_kernel'].strip()
        if opts and 'report_email' in opts:
            self.report_receiver = opts['report_email'].strip()
        # Other shard opts could be passed here.

        self.sharder = Sharder(self.orig_cmd, self.id, self.log_dir_path,
                               self.gs_bucket, self.bucket_subdir,
                               self.gs_kernel)
        self.shards = self.sharder.get_shards(region_shard=region_shard)
Ejemplo n.º 5
0
    def __init__(self, cmd_json, orig_cmd, opts=None):
        logging.info('Launching new build')
        logging.info('Getting unique build id..')
        build_id = get_datetime_build_id()
        logging.info('Creating new build with id %s', build_id)

        self.id = build_id
        self.orig_cmd = orig_cmd.strip()
        self.log_dir_path = BLDSRV.build_log_dir + '%s/' % build_id
        self.log_file_path = self.log_dir_path + 'run.log'

        BLDSRV.create_log_dir(self.log_dir_path)
        logging.info('Created new build with id %s', self.id)

        self.gs_bucket = gce_funcs.get_gs_bucket().strip()
        self.bucket_subdir = gce_funcs.get_bucket_subdir().strip()
        self.gs_kernel = None
        self.gce_proj_id = gce_funcs.get_proj_id()
        self.gce_project = gce_funcs.get_proj_id().strip()
        self.gce_zone = gce_funcs.get_gce_zone()
        self.gce_region = self.gce_zone[:-2]
        self.cmd_json = cmd_json

        if opts and 'commit_id' in opts:
            self.commit = opts['commit_id'].strip()
        if opts and 'git_repo' in opts:
            self.repository = opts['git_repo'].strip()
        self.build_dir = make_kernel_dir(self.repository)
        self.build_path = BLDSRV.repo_cache_path + self.build_dir
        self.kernel_build = self.build_path + BLDSRV.image_path
        self.kernel_build_filename = BLDSRV.image_name

        logging.info('Cloning repository to %s', self.build_path)

        self.kbuild = Kbuild(self.repository, self.commit, self.build_dir,
                             self.id, self.log_dir_path)
Ejemplo n.º 6
0
  def __init__(self, test_fs_cfg, extra_cmds, shard_id, test_run_id,
               log_dir_path, gce_zone=None, gs_bucket=None, gce_project=None,
               bucket_subdir=None, gs_kernel=None):
    if (not isinstance(extra_cmds, basestring) or
        not isinstance(shard_id, basestring) or
        not isinstance(test_run_id, basestring)):
      raise TypeError
    logging.debug('Creating Shard instance %s', shard_id)

    self.extra_cmds = extra_cmds
    self.test_run_id = test_run_id
    self.id = shard_id
    self.test_fs_cfg = test_fs_cfg
    self.config_cmd_arr = ['-c', test_fs_cfg]
    self.extra_cmd_arr = extra_cmds.strip().split(' ')
    if gce_zone:
      self.gce_zone = gce_zone
    else:
      self.gce_zone = gce_funcs.get_gce_zone().strip()
    if gs_bucket:
      self.gs_bucket = gs_bucket
    else:
      self.gs_bucket = gce_funcs.get_gs_bucket().strip()
    if bucket_subdir:
      self.bucket_subdir = bucket_subdir
    else:
      self.bucket_subdir = gce_funcs.get_bucket_subdir().strip()
    if gce_project:
      self.gce_project = gce_project
    else:
      self.gce_project = gce_funcs.get_proj_id().strip()
    self.keep_dead_vm = gce_funcs.get_keep_dead_vm()
    self.instance_name = 'xfstests-%s-%s-%s' % (
        LTM.ltm_username, self.test_run_id, self.id)

    gce_xfstests_cmd = ['gce-xfstests', '--instance-name', self.instance_name]
    if gce_zone:
      gce_xfstests_cmd.extend(['--gce-zone', gce_zone])
    if gs_bucket:
      gce_xfstests_cmd.extend(['--gs-bucket', gs_bucket])
    if bucket_subdir:
      gce_xfstests_cmd.extend(['--bucket-subdir', bucket_subdir])
    if gs_kernel:
      gce_xfstests_cmd.extend(['--kernel', gs_kernel])
    gce_xfstests_cmd.extend(['--image-project', self.gce_project])
    gce_xfstests_cmd.extend(['--no-email'])  # Shards shouldn't send emails.
    gce_xfstests_cmd.extend(self.config_cmd_arr)
    gce_xfstests_cmd.extend(self.extra_cmd_arr)
    self.gce_xfstests_cmd = gce_xfstests_cmd

    # LOG/RESULTS VARIABLES
    self.log_file_path = log_dir_path + self.id
    self.cmdlog_file_path = self.log_file_path + '.cmdlog'
    self.serial_output_file_path = self.log_file_path + '.serial'
    self.results_name = '%s-%s-%s' % (LTM.ltm_username, self.test_run_id,
                                      self.id)
    self.tmp_results_dir = '/tmp/results-%s-%s-%s' % (
        LTM.ltm_username, self.test_run_id, self.id)
    self.unpacked_results_dir = '%s/results-%s-%s-%s' % (
        log_dir_path, LTM.ltm_username, self.test_run_id, self.id)

    logging.debug('Created Shard instance %s', shard_id)