Example #1
0
def get_custom_schedules():
    """
    Finds custom schedules ie. not the factory default
    'monthly', 'weekly', 'hourly', 'daily' and 'frequent' schedules
    """
    _customSchedules = []
    config = Config()
    for section in config.sections():
        if section.startswith(base.BASESVC[5:]):
            frmi = section.rsplit(":", 1)
            label = frmi[1]
            state = config.get(section, "state")

            if label not in base.factoryDefaultSchedules:
            # Note that the schedules, being dependent on the time-slider service
            # itself will typically be in an offline state when enabled. They will
            # transition to an "online" state once time-slider itself comes
            # "online" to satisfy it's dependency
                if state == "online" or state == "offline" or state == "degraded":
                    instance = AutoSnap(label)
                    try:
                        _customSchedules.append(instance.get_schedule_details())
                    except RuntimeError, message:
                        raise RuntimeError, "Error getting schedule details " + \
                                            "for custom auto-snapshot SMF " + \
                                            "instance:\n\t" + label + "\n" + \
                                            "Details:\n" + str(message)
Example #2
0
def get_default_schedules():
    """
    Finds the default schedules that are enabled (online, offline or degraded)
    """
    #This is not the fastest method but it is the safest, we need
    #to ensure that default schedules are processed in the pre-defined
    #order to ensure that the overlap between them is adhered to
    #correctly. monthly->weekly->daily->hourly->frequent. They have
    #to be processed first and they HAVE to be in the correct order.
    _defaultSchedules = []
    for s in base.factoryDefaultSchedules:
        instanceName = "%s:%s" % (base.BASESVC,s)
        config = Config()
        result = config.get(instanceName[5:], "state")
        #
        # Note that the schedules, being dependent on the time-slider service
        # itself will typically be in an offline state when enabled. They will
        # transition to an "online" state once time-slider itself comes
        # "online" to satisfy it's dependency
        if result == "online" or result == "offline" or result == "degraded":
            instance = AutoSnap(s)
            try:
                _defaultSchedules.append(instance.get_schedule_details())
            except RuntimeError, message:
                raise RuntimeError, "Error getting schedule details for " + \
                                    "default auto-snapshot SMF instance:" + \
                                    "\n\t" + instanceName + "\nDetails:\n" + \
                                    str(message)