def _scheduled_on(self, schedule): dt = datetime.datetime.utcnow() delta = datetime.timedelta(hours=1) for _ in xrange(0, 24 * 31 * 365): dt = dt + delta if schedule_parser.Schedule(schedule).intime(now=dt.timetuple()): return dt.replace(minute=0, second=0, microsecond=0)
def _get_servers_scheduled_for_update(self, servers): servers_scheduled_for_update = [] for server in servers: try: version = server['scalarizr.version'] if not version or parse_version(version) < parse_version('2.7.7'): continue if not schedule_parser.Schedule(server['schedule']).intime(): continue servers_scheduled_for_update.append(server) except: msg = "Server: {0}, reason: {1}".format(server['server_id'], helper.exc_info()) LOG.warning(msg) continue return servers_scheduled_for_update