def save(self): """ Updates the information regarding backup in the datastore. If the backup did not exist prior this call it will be automatically created. :return: None """ DB.upsert_backup(self.id, self.to_dict())
def load(cls, backup_id): """ Loads the backup information from the datastore used and returns a ready to use object. :param backup_id: the string identifier of the backup data to be loaded. :return: a fully initialised Backupset object with information loaded from the datastore. """ data = DB.get_backup(backup_id) if data: backupset = cls._from_json(data) return backupset raise BackupsetException('Could not retrieve backup information.')
from api.resources.job import Job from api.resources.monitor import Monitor from api.resources.mount import Mount logging.basicConfig( level=logging.DEBUG, format='%(asctime)s [%(name)s][%(levelname)s]: %(message)s', filename='/var/log/diskimage/node.log', filemode='w') log = logging.getLogger('werkzeug').setLevel( logging.WARNING) # Suppress HTTP request logging _logger = logging.getLogger(__name__) _logger.info("Initialising Disk Image Node v " + constants.VERSION + ".") app = Flask(__name__) api = Api(app) DB.remove_zombie_backups() _logger.info("Adding endpoints.") api.add_resource(Heartbeat, '/api/heartbeat') api.add_resource(Monitor, '/api/metric') api.add_resource(Disk, '/api/disk', '/api/disk/<disk_id>') api.add_resource(Job, '/api/job', '/api/job/<job_id>') api.add_resource(Mount, '/api/mount', '/api/mount/<backup_id>') _logger.info("Initialisation finished.") @app.after_request def after_request(response): """ Allow remote hosts to use the API.