def take_action(self, args): groups = self.app.client_manager.auto_scaling.groups policies = self.app.client_manager.auto_scaling.policies launch_time = args.launch_time # validate launch time if args.type == 'RECURRENCE': parse = parsetypes.date_type('%H:%M') parse(args.launch_time) elif args.type == 'SCHEDULED': parse = parsetypes.date_type('%Y-%m-%dT%H:%M') parse(args.launch_time) launch_time += 'Z' group_id = groups.find(args.group).id kwargs = { "alarm_id": args.alarm_id, "start_time": args.start_time, "end_time": args.end_time, "cool_down": args.cool_down, "recurrence_type": args.recurrence_type, "recurrence_value": args.recurrence_value, "launch_time": launch_time, } if args.action: kwargs.update(args.action) created = policies.create(group_id, args.name, args.type, **kwargs) return "Policy %s created" % created.id
def take_action(self, args): policies = self.app.client_manager.auto_scaling.policies policy = policies.find(args.policy) launch_time = args.launch_time # validate launch time if args.type == 'RECURRENCE': parse = parsetypes.date_type('%H:%M') parse(args.launch_time) elif args.type == 'SCHEDULED': parse = parsetypes.date_type('%Y-%m-%dT%H:%M') parse(args.launch_time) launch_time += 'Z' kwargs = { "type_": args.type, "name": args.name, "alarm_id": args.alarm_id, "launch_time": launch_time, "start_time": args.start_time, "end_time": args.end_time, "recurrence_type": args.recurrence_type, "recurrence_value": args.recurrence_value, "cool_down": args.cool_down, } if args.action: kwargs.update(args.action) policies.edit(policy.id, **kwargs) return "done"
def add_end_time_opt(parser): parser.add_argument( '--end-time', metavar="<yyyy-MM-ddTHH:mm:ss>", type=parsetypes.date_type('%Y-%m-%dT%H:%M:%S'), help=_("list group activity logs after this time"), )
def add_end_time_opt(parser, required=False): parser.add_argument( '--end-time', required=required, metavar="<yyyy-MM-ddTHH:mm>", type=parsetypes.date_type('%Y-%m-%dT%H:%M'), help=_("Recurrence end UTC time " "(Effect only when policy-type is RECURRENCE)"), )
def add_launch_time_opt(parser, required=False): parser.add_argument( '--launch-time', required=required, metavar="<yyyy-MM-ddTHH:mm>", type=parsetypes.date_type('%Y-%m-%dT%H:%M'), help=_("Schedule launch time" "(Only Effect when policy-type is SCHEDULED)"), )