コード例 #1
0
def PrepareGCDDataDir(args):
    """Prepares the given directory using gcd create.

  Raises:
    UnableToPrepareDataDir: If the gcd create execution fails.

  Args:
    args: The arguments passed to the command.
  """
    data_dir = args.data_dir
    if os.path.isdir(data_dir) and os.listdir(data_dir):
        log.warning('Reusing existing data in [{0}].'.format(data_dir))
        return

    gcd_create_args = ['create']
    project = properties.VALUES.core.project.Get(required=True)
    gcd_create_args.append('--project_id={0}'.format(project))
    gcd_create_args.append(data_dir)
    exec_args = ArgsForGCDEmulator(gcd_create_args, args)

    log.status.Print('Executing: {0}'.format(' '.join(exec_args)))
    with util.Exec(exec_args) as process:
        util.PrefixOutput(process, DATASTORE)
        failed = process.poll()
        if failed:
            raise UnableToPrepareDataDir()
コード例 #2
0
def StartFirestoreEmulator(args, log_file=None):
    """Starts the firestore emulator with the given arguments.

  Args:
    args: Arguments passed to the start command.
    log_file: optional file argument to reroute process's output.

  Returns:
    process, The handle of the child process running the datastore emulator.
  """
    start_args = ['start']
    start_args.append('--host={0}'.format(args.host_port.host))
    start_args.append('--port={0}'.format(args.host_port.port))
    if args.rules:
        start_args.append('--rules={0}'.format(args.rules))
    exec_args = ArgsForFirestoreEmulator(start_args)

    log.status.Print('Executing: {0}'.format(' '.join(exec_args)))
    return util.Exec(exec_args, log_file=log_file)
コード例 #3
0
def StartGCDEmulator(args, log_file=None):
    """Starts the datastore emulator with the given arguments.

  Args:
    args: Arguments passed to the start command.
    log_file: optional file argument to reroute process's output.

  Returns:
    process, The handle of the child process running the datastore emulator.
  """
    gcd_start_args = ['start']
    gcd_start_args.append('--host={0}'.format(args.host_port.host))
    gcd_start_args.append('--port={0}'.format(args.host_port.port))
    gcd_start_args.append('--store_on_disk={0}'.format(args.store_on_disk))
    gcd_start_args.append('--consistency={0}'.format(args.consistency))
    gcd_start_args.append('--allow_remote_shutdown')
    gcd_start_args.append(args.data_dir)
    exec_args = ArgsForGCDEmulator(gcd_start_args, args)

    log.status.Print('Executing: {0}'.format(' '.join(exec_args)))
    return util.Exec(exec_args, log_file=log_file)
コード例 #4
0
def Start(args, log_file=None):
  pubsub_args = BuildStartArgs(
      util.BuildArgsList(args), platforms.OperatingSystem.Current())
  log.status.Print('Executing: {0}'.format(' '.join(pubsub_args)))
  return util.Exec(pubsub_args, log_file=log_file)
コード例 #5
0
def Start(args):
    spanner_args = _BuildStartArgs(args)
    log.status.Print('Executing: {0}'.format(' '.join(spanner_args)))
    with util.Exec(spanner_args) as spanner_process:
        util.WriteEnvYaml(GetEnv(args), GetDataDir())
        util.PrefixOutput(spanner_process, SPANNER_EMULATOR_COMPONENT_ID)
コード例 #6
0
def Start(args):
    bigtable_args = BuildStartArgs(util.BuildArgsList(args))
    log.status.Print('Executing: {0}'.format(' '.join(bigtable_args)))
    with util.Exec(bigtable_args) as bigtable_process:
        util.WriteEnvYaml(GetEnv(args), GetDataDir())
        util.PrefixOutput(bigtable_process, BIGTABLE)