• Home
  • Raw
  • Download

Lines Matching +full:is +full:- +full:arguments

3 # Use of this source code is governed by a BSD-style license that can be
10 of spares. The command is meant primarily for replacing broken DUTs
16 positional arguments:
20 optional arguments:
21 -h, --help show this help message and exit
22 -t COUNT, --total COUNT
25 -a COUNT, --grow COUNT
28 -d COUNT, --shrink COUNT
31 -s POOL, --spare POOL
34 -p PHASE, --phase PHASE
36 --sku SKU The specific SKU we intend to swap with
37 -n, --dry-run Report actions to take in the form of shell commands
45 If no COUNT options are supplied (i.e. there are no --total, --grow,
46 or --shrink options), the command will maintain the current totals of
78 # This is the ratio of all models we should calculate the default max
87 # _VALID_POOL_PATTERN - Regular expression matching pool names that will
95 _VALID_POOL_PATTERN = re.compile('^[a-zA-z0-9_\-]+$')
99 """Log a message with optional format arguments to stdout.
105 the arguments.
108 @param args Format arguments. If empty, the message is logged
118 """Log information in a dry-run dependent fashion.
121 if necessary. When logging for a dry run, the message is
125 the arguments.
128 @param args Format arguments. If empty, the message is logged
138 """Log an error to stderr, with optional format arguments.
141 that it is an error message.
144 the arguments.
147 @param args Format arguments. If empty, the message is logged
161 + Working - the DUT is working for testing, and not locked.
162 + Broken - the DUT is unable to run tests, or it is locked.
163 + Ineligible - the DUT is not available to be removed from this pool. The
167 during balancing. This is done for the sake of chameleon hosts,
172 the `chameleon` label is a hack that should be eliminated.
247 DUTs, an error is logged, and the target total is adjusted
260 # TODO(jrbarnette) The 'board' field is a legacy. We need
277 '%s pool (%s): Target of %d is below minimum of %d DUTs.',
283 _log_message('%s %s pool: Target of %d is above minimum.',
285 adjustment = target_total - self.total_hosts
298 list will be empty. If this number is negative, it
313 self.working_hosts[:-num_broken])
322 If `dry_run` is true, perform no changes, but log the `atest`
325 @param dry_run Whether the logging is for a dry run or
339 # TODO(jrbarnette) The 'board' field is a legacy. We need to
368 _log_message('atest label remove -m %s %s',
370 _log_message('atest label add -m %s %s',
374 def _balance_model(arguments, afe, pool, labels, start_time, end_time): argument
375 """Balance one model as requested by command line arguments.
377 @param arguments Parsed command line arguments.
388 spare_pool = _DUTPool(afe, arguments.spare, labels, start_time, end_time)
392 if arguments.total is not None:
393 target_total = arguments.total
394 elif arguments.grow:
395 target_total += arguments.grow
396 elif arguments.shrink:
397 target_total -= arguments.shrink
402 shortfall = spares_needed - len(spare_duts)
409 if spares_needed or surplus_duts or arguments.verbose:
410 dry_run = arguments.dry_run
422 add_msg = 'shrink pool by %d DUTs' % -spares_needed
425 _log_info(dry_run, 'Target is %d working DUTs; %s.',
442 len(main_pool.broken_hosts) - len(surplus_duts))
448 len(main_pool.broken_hosts) - shortfall,
449 -shortfall)
451 if (len(main_pool.broken_hosts) > arguments.max_broken and
452 not arguments.force_rebalance):
456 _log_error('that is bricking devices. Once you have finished your ')
458 _log_error('--force-rebalance')
463 if arguments.verbose:
464 _log_info(arguments.dry_run, 'No exchange required.')
466 _exchange_labels(arguments.dry_run, surplus_duts,
468 _exchange_labels(arguments.dry_run, spare_duts,
473 """Parse the command line arguments.
479 @param argv Standard command line argument vector; `argv[0]` is
490 '-w', '--web', type=str, default=None,
494 count_group.add_argument('-t', '--total', type=int,
499 count_group.add_argument('-a', '--grow', type=int,
503 count_group.add_argument('-d', '--shrink', type=int,
508 parser.add_argument('-s', '--spare', default=_SPARE_DEFAULT,
512 parser.add_argument('-n', '--dry-run', action='store_true',
515 parser.add_argument('-v', '--verbose', action='store_true',
519 parser.add_argument('-m', '--max-broken', default=2, type=int,
523 parser.add_argument('-f', '--force-rebalance', action='store_true',
527 'there is a bug that is bricking devices in the '
529 parser.add_argument('--production', action='store_true',
534 '--all-models',
538 'To bypass that check, set --max-broken-models to 0.',
541 '--max-broken-models', default=None, type=int, metavar='COUNT',
543 'DUTs in the specified pool is less than COUNT.',
553 parser.add_argument('-p', '--phase', metavar='PHASE',
557 parser.add_argument('--sku', type=str,
560 arguments = parser.parse_args(argv[1:])
562 # Error-check arguments.
563 if arguments.models and arguments.all_models:
565 'when using --all-models.')
566 if (arguments.pool == _ALL_CRITICAL_POOLS and
567 arguments.spare != _SPARE_DEFAULT):
568 parser.error('Cannot specify --spare pool to be %s when balancing all '
570 for p in (arguments.spare, arguments.pool):
573 return arguments
576 def infer_balancer_targets(afe, arguments, pools): argument
577 """Take some arguments and translate them to a list of models to balance
581 @param arguments Parsed command line arguments.
590 if arguments.all_models:
595 if arguments.phase:
596 labels['phase'] = arguments.phase
599 for model in arguments.models:
602 if arguments.sku:
603 labels['sku'] = arguments.sku
604 if arguments.phase:
605 labels['phase'] = arguments.phase
613 @param argv Command line arguments including `sys.argv[0]`.
616 arguments = _parse_command(argv)
617 if arguments.production:
626 start_time = end_time - 24 * 60 * 60
627 afe = frontend_wrappers.RetryingAFE(server=arguments.web)
636 _balance_model(arguments, afe, pool, labels,
641 if arguments.pool == _ALL_CRITICAL_POOLS
642 else [arguments.pool])
643 balancer_targets = infer_balancer_targets(afe, arguments, pools)