def run(self, productName, version, build_number, rule_ids, when, backgroundRate=None): name = get_release_blob_name(productName, version, build_number, self.dummy) for rule_id in rule_ids: data, data_version = Rule(api_root=self.api_root, auth=self.auth, rule_id=rule_id).get_data() data["fallbackMapping"] = data["mapping"] data["mapping"] = name data["data_verison"] = data_version data["rule_id"] = rule_id data["change_type"] = "update" # We receive an iso8601 datetime, but what Balrog needs is a to-the-millisecond epoch timestamp data["when"] = arrow.get(when).timestamp * 1000 if backgroundRate: data["backgroundRate"] = backgroundRate ScheduledRuleChange( api_root=self.api_root, auth=self.auth, rule_id=rule_id).add_scheduled_rule_change(**data)
def run(self, productName, version, build_number, rule_ids, backgroundRate=None): name = get_release_blob_name(productName, version, build_number, self.suffix) for rule_id in rule_ids: data = {"mapping": name} if backgroundRate: data["backgroundRate"] = backgroundRate Rule(api_root=self.api_root, auth=self.auth, rule_id=rule_id ).update_rule(**data)
def run(self, productName, version, build_number, rule_ids, when=None, backgroundRate=None): name = get_release_blob_name(productName, version, build_number, self.suffix) if when is not None: when = arrow.get(when) soon = arrow.now().shift(minutes=5) if when is None or when < soon: when = soon for rule_id in rule_ids: data, data_version = Rule(api_root=self.api_root, auth=self.auth, rule_id=rule_id).get_data() # If the _currently_ shipped release is at a background rate of # 100%, it's safe to set it as the fallback mapping. (Everyone # was getting it anyways, so it's OK for them to fall back to # it if they don't get the even newer one.) # If it was _not_ shipped at 100%, we can't set it as the fallback. # If we did, it would mean users on the wrong side of the die roll # would either get the even newer release, or the release that # previously wasn't shipped to everyone - which we can't assume is # safe. if data["backgroundRate"] == 100: data["fallbackMapping"] = data["mapping"] data["mapping"] = name data["data_verison"] = data_version data["rule_id"] = rule_id data["change_type"] = "update" # We receive an iso8601 datetime, but what Balrog needs is a to-the-millisecond epoch timestamp data["when"] = when.timestamp * 1000 if backgroundRate: data["backgroundRate"] = backgroundRate ScheduledRuleChange( api_root=self.api_root, auth=self.auth, rule_id=rule_id).add_scheduled_rule_change(**data)
def run(self, productName, version, build_number, rule_ids): name = get_release_blob_name(productName, version, build_number, self.dummy) api = Rule(auth=self.auth, api_root=self.api_root) for id_ in rule_ids: api.update_rule(id_, mapping=name)
execfile(args.credentials_file, credentials) auth = (args.username, credentials['balrog_credentials'][args.username]) if args.action == ["lock"]: my_args = args.action_args if len(my_args) > 1: parser.error("Unsupported number of args for the lock command.") for rule_id in args.rule_ids: release_name = None if len(my_args) == 1: release_name = args[0] if not release_name: rule_data, _ = Rule(api_root=args.api_root, auth=auth, rule_id=rule_id).get_data() latest_blob_name = rule_data["mapping"] release = Release(api_root=args.api_root, auth=auth, name=latest_blob_name) release_data, _ = release.get_data() buildid = None for p in release_data["platforms"].values(): enUS = p.get("locales", {}).get("en-US", {}) next_buildid = enUS.get("buildID") if next_buildid > buildid: buildid = next_buildid if not buildid: logging.error("Couldn't find latest buildid for rule %s", rule_id)
def run(self, productName, version, build_number, rule_ids): name = get_release_blob_name(productName, version, build_number, self.dummy) for rule_id in rule_ids: Rule(api_root=self.api_root, auth=self.auth, rule_id=rule_id).update_rule(mapping=name)
parser.add_argument("action_args", nargs=REMAINDER, help="""See help for "action". Only valid when "action" is "lock".""") args = parser.parse_args() logging_level = logging.INFO if args.verbose: logging_level = logging.DEBUG logging.basicConfig(stream=sys.stdout, level=logging_level, format="%(message)s") credentials = {} execfile(args.credentials_file, credentials) auth = (args.username, credentials['balrog_credentials'][args.username]) rule_api = Rule(args.api_root, auth) if args.action == ["lock"]: my_args = args.action_args if len(my_args) > 1: parser.error("Unsupported number of args for the lock command.") for rule_id in args.rule_ids: release_name = None if len(my_args) == 1: release_name = args[0] if not release_name: rule_data, _ = rule_api.get_data(rule_id) latest_blob_name = rule_data["mapping"] release_api = Release(args.api_root, auth)
if next_buildid > buildid: buildid = next_buildid if not buildid: logging.error("Couldn't find latest buildid for rule %s", rule_id) sys.exit(1) root_name = "-".join(latest_blob_name.split("-")[:-1]) release_name = "%s-%s" % (root_name, buildid) if not args.dry_run: logging.info("Locking rule %s to %s", rule_id, release_name) Rule(api_root=args.api_root, auth=auth, rule_id=rule_id).update_rule(mapping=release_name) else: logging.info("Would've locked rule %s to %s", rule_id, release_name) elif args.action == ["unlock"]: if args.action_args: parser.error("Unlock command does not accept any args.") for rule_id in args.rule_ids: rule = Rule(api_root=args.api_root, auth=auth, rule_id=rule_id) rule_data, _ = rule.get_data() root_name = "-".join(rule_data["mapping"].split("-")[:-1]) release_name = "%s-latest" % root_name if not args.dry_run: logging.info("Unlocking rule %s back to %s", rule_id, release_name) rule.update_rule(mapping=release_name) else: logging.info("Would've unlocked rule %s back to %s", rule_id, release_name)