Add helpers to restore/reconfigure all apps

This commit is contained in:
Girish Ramakrishnan
2016-05-24 10:33:10 -07:00
parent ffacf17a42
commit a100837e69
2 changed files with 88 additions and 0 deletions

View File

@@ -32,6 +32,9 @@ exports = module.exports = {
autoupdateApps: autoupdateApps,
restoreInstalledApps: restoreInstalledApps,
configureInstalledApps: configureInstalledApps,
// exported for testing
_validateHostname: validateHostname,
_validatePortBindings: validatePortBindings,
@@ -873,3 +876,35 @@ function listBackups(page, perPage, appId, callback) {
});
});
}
function restoreInstalledApps(callback) {
assert.strictEqual(typeof callback, 'function');
appdb.getAll(function (error, apps) {
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
async.map(apps, function (app, iteratorDone) {
if (app.installationState !== appdb.ISTATE_INSTALLED) return iteratorDone();
debug('marking %s for restore', app.location || app.id);
appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_RESTORE, { oldConfig: null }, iteratorDone);
}, callback);
});
}
function configureInstalledApps(callback) {
assert.strictEqual(typeof callback, 'function');
appdb.getAll(function (error, apps) {
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
async.map(apps, function (app, iteratorDone) {
if (app.installationState !== appdb.ISTATE_INSTALLED) return iteratorDone();
debug('marking %s for reconfigure', app.location || app.id);
appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_CONFIGURE, { oldConfig: null }, iteratorDone);
}, callback);
});
}