src/indexOld.js
function addSnapshot(machineName, versionKey, instanceKey, info) {

        return co(function*() {
            debug("Adding a new snapshot to the " + instanceKey + " of the " + versionKey + " of the '" + machineName + "' machine");
            let manifest = getManifest();

            let machine = manifest.machines[machineName];
            if (!machine) {
                throw new Error("Machine does not exists");
            }

            let version = machine.versions[versionKey];
            if (!version) {
                throw new Error("Version does not exists");
            }

            let instance = version.instances[instanceKey];
            if (!instance) {
                throw new Error("Instance does not exists");
            }

            let newSnapshotKey = "snapshot" + (Object.keys(instance.snapshots).length + 1);
            let snapshotDirPath = instance.route + "/snapshots/" + newSnapshotKey;
            instance.snapshots[newSnapshotKey] = {
                "route": snapshotDirPath
            };

            let infoFile = snapshotDirPath + "/info.json";

            debug("Creating the directories");
            fs.mkdirSync(repositoryPath + "/" + snapshotDirPath);

            debug("Creating the snapshot info.json file");
            let info = {

            };
            jsonfile.writeFileSync(repositoryPath + "/" + infoFile, info);

            debug("Setting the manifest");
            setManifest(manifest);
            yield _commit(null, ["manifest.json", infoFile],
                "Created the "+newSnapshotKey+" for the "+instanceKey+" of the "+
                versionKey+" of the '" + machineName + "' machine");

            return newSnapshotKey;
        });
    }
function addSnapshot(machineName, versionKey, instanceKey, info) {

        return co(function*() {
            debug("Adding a new snapshot to the " + instanceKey + " of the " + versionKey + " of the '" + machineName + "' machine");
            let manifest = getManifest();

            let machine = manifest.machines[machineName];
            if (!machine) {
                throw new Error("Machine does not exists");
            }

            let version = machine.versions[versionKey];
            if (!version) {
                throw new Error("Version does not exists");
            }

            let instance = version.instances[instanceKey];
            if (!instance) {
                throw new Error("Instance does not exists");
            }

            let newSnapshotKey = "snapshot" + (Object.keys(instance.snapshots).length + 1);
            let snapshotDirPath = instance.route + "/snapshots/" + newSnapshotKey;
            instance.snapshots[newSnapshotKey] = {
                "route": snapshotDirPath
            };

            let infoFile = snapshotDirPath + "/info.json";

            debug("Creating the directories");
            fs.mkdirSync(repositoryPath + "/" + snapshotDirPath);

            debug("Creating the snapshot info.json file");
            let info = {

            };
            jsonfile.writeFileSync(repositoryPath + "/" + infoFile, info);

            debug("Setting the manifest");
            setManifest(manifest);
            yield _commit(null, ["manifest.json", infoFile],
                "Created the "+newSnapshotKey+" for the "+instanceKey+" of the "+
                versionKey+" of the '" + machineName + "' machine");

            return newSnapshotKey;
        });
    }
function addSnapshot ( machineName , versionKey , instanceKey , info ) { return co ( function * ( ) { debug ( "Adding a new snapshot to the " + instanceKey + " of the " + versionKey + " of the '" + machineName + "' machine" ) ; let manifest = getManifest ( ) ; let machine = manifest . machines [ machineName ] ; if ( ! machine ) { throw new Error ( "Machine does not exists" ) ; } let version = machine . versions [ versionKey ] ; if ( ! version ) { throw new Error ( "Version does not exists" ) ; } let instance = version . instances [ instanceKey ] ; if ( ! instance ) { throw new Error ( "Instance does not exists" ) ; } let newSnapshotKey = "snapshot" + ( Object . keys ( instance . snapshots ) . length + 1 ) ; let snapshotDirPath = instance . route + "/snapshots/" + newSnapshotKey ; instance . snapshots [ newSnapshotKey ] = { "route" : snapshotDirPath } ; let infoFile = snapshotDirPath + "/info.json" ; debug ( "Creating the directories" ) ; fs . mkdirSync ( repositoryPath + "/" + snapshotDirPath ) ; debug ( "Creating the snapshot info.json file" ) ; let info = { } ; jsonfile . writeFileSync ( repositoryPath + "/" + infoFile , info ) ; debug ( "Setting the manifest" ) ; setManifest ( manifest ) ; yield _commit ( null , [ "manifest.json" , infoFile ] , "Created the " + newSnapshotKey + " for the " + instanceKey + " of the " + versionKey + " of the '" + machineName + "' machine" ) ; return newSnapshotKey ; } ) ; }
Add a new snapshot to an instance of a version of a machine
@method addSnapshot
@param {String} machineName The name of the machine
@param {String} versionKey The key of the version
@param {String} instanceKey The key of the instance
@param {Object} info The info Object
@returns {Promise} The instance key
Add a new snapshot to an instance of a version of a machine