Used to create the dict required to create a new snapshot
770868
def _create_body(self, name, description=None, volume=None, force=False):
        
        body = {"snapshot": {
                "display_name": name,
                "display_description": description,
                "volume_id": volume.id,
                "force": str(force).lower(),
                }}
        return body
782033
private Snapshot createDiskSnapshot(SnapshotDescriptor descriptor) {
    SnapshotFile file = new SnapshotFile(SnapshotFile.createSnapshotFile(
        storage.directory(),
        storage.prefix(),
        descriptor.index()
    ));
    Snapshot snapshot = new FileSnapshot(file, descriptor, this);
    log.debug("Created disk snapshot: {}", snapshot);
    return snapshot;
  }
1202081
def _ensure_snapshot(connection, volume):
    
    if 'AutomatedEBSSnapshots' not in volume.tags:
        logger.warning(
            'Missing tag AutomatedEBSSnapshots for volume {}'.format(
                volume.id))
        return

    interval = volume.tags['AutomatedEBSSnapshots']
    if volume.tags['AutomatedEBSSnapshots'] not in VALID_INTERVALS:
        logger.warning(
            '"{}" is not a valid snapshotting interval for volume {}'.format(
                interval, volume.id))
        return

    snapshots = connection.get_all_snapshots(filters={'volume-id': volume.id})

    # Create a snapshot if we don't have any
    if not snapshots:
        _create_snapshot(volume)
        return

    min_delta = 3600*24*365*10  # 10 years :)
    for snapshot in snapshots:
        timestamp = datetime.datetime.strptime(
            snapshot.start_time,
            '%Y-%m-%dT%H:%M:%S.000Z')
        delta_seconds = int(
            (datetime.datetime.utcnow() - timestamp).total_seconds())

        if delta_seconds < min_delta:
            min_delta = delta_seconds

    logger.info('The newest snapshot for {} is {} seconds old'.format(
        volume.id, min_delta))
    if interval == 'hourly' and min_delta > 3600:
        _create_snapshot(volume)
    elif interval == 'daily' and min_delta > 3600*24:
        _create_snapshot(volume)
    elif interval == 'weekly' and min_delta > 3600*24*7:
        _create_snapshot(volume)
    elif interval == 'monthly' and min_delta > 3600*24*30:
        _create_snapshot(volume)
    elif interval == 'yearly' and min_delta > 3600*24*365:
        _create_snapshot(volume)
    else:
        logger.info('No need for a new snapshot of {}'.format(volume.id))
342721
function create () {
    if (dir && !opts.temp && !key && (opts.indexing !== false)) {
      // Only set opts.indexing if storage is dat-storage
      // TODO: this should be an import option instead, https://github.com/mafintosh/hyperdrive/issues/160
      opts.indexing = true
    }
    if (!key) return createArchive()

    resolveDatLink(key, function (err, resolvedKey) {
      if (err) return cb(err)
      key = resolvedKey
      createArchive()
    })

    function createArchive () {
      archive = hyperdrive(storage, key, opts)
      archive.on('error', cb)
      archive.ready(function () {
        debug('archive ready. version:', archive.version)
        if (hasDat || (archive.metadata.has(0) && archive.version)) {
          archive.resumed = true
        } else {
          archive.resumed = false
        }
        archive.removeListener('error', cb)

        cb(null, Dat(archive, opts))
      })
    }
  }
354655
def show_snapshot(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_snapshot function must be called with -f or --function.'
        )
    if not kwargs or 'name' not in kwargs:
        log.error(
            'Must specify name.'
        )
        return False

    conn = get_conn()
    return _expand_item(conn.ex_get_snapshot(kwargs['name']))
1343494
def saveViewSnapshot(self, view):
        '''
        
        '''

        if not view:
            raise ValueError("view must be provided to take snapshot")
        filename = self.snapshotDir + os.sep + '${serialno}-' + view.variableNameFromId() + '-${timestamp}' + '.' + self.snapshotFormat.lower()
        d = FileDialog(self, self.device.substituteDeviceTemplate(filename))
        saveAsFilename = d.askSaveAsFilename()
        if saveAsFilename:
            _format = os.path.splitext(saveAsFilename)[1][1:].upper()
            self.printOperation(view, Operation.VIEW_SNAPSHOT, filename, _format)
            view.writeImageToFile(saveAsFilename, _format)
960568
function knMergeSnapshots(snapshots)
{
	var rv, errors, srvname, i, snap;

	rv = new knSnapshot();
	errors = [];

	for (i = 0; i < snapshots.length; i++) {
		snap = snapshots[i];

		if (!('service' in snap)) {
			errors.push([ snap, 'missing "service" property' ]);
			continue;
		}

		srvname = snap['service']['name'];

		if ('component' in snap['service'])
			srvname += '.' + snap['service']['component'];

		snap['service']['source'] =
		    snap['source']['protocol'] + '://' +
		    snap['source']['host'] + ':' + snap['source']['port'] +
		    snap['source']['path'];
		srvname += '.' + snap['service']['ident'];
		rv.add('service', srvname, snap['service']);

		if ('stats' in snap)
			rv.add('stats', srvname, snap['stats']);

		if (!('types' in snap))
			continue;

		snap['types'].forEach(function (type) {
			var objects, key;

			objects = snap[type];

			for (key in objects) {
				objects[key]['origin'] = srvname;
				rv.add(type, key, objects[key]);
			}
		});
	}

	return (rv);
}
1105481
public Snapshot createSnapshot(long index) {
    SnapshotDescriptor descriptor = SnapshotDescriptor.builder()
      .withIndex(index)
      .withTimestamp(System.currentTimeMillis())
      .build();
    return createSnapshot(descriptor);
  }
369828
private Snapshot createMemorySnapshot(SnapshotDescriptor descriptor) {
    HeapBuffer buffer = HeapBuffer.allocate(SnapshotDescriptor.BYTES, Integer.MAX_VALUE);
    Snapshot snapshot = new MemorySnapshot(buffer, descriptor.copyTo(buffer), this);
    LOGGER.debug("Created memory snapshot: {}", snapshot);
    return snapshot;
  }
1083319
public void createTrashSnapshot() throws IOException {
    FileStatus[] pathsInTrash = this.fs.listStatus(this.trashLocation, TRASH_NOT_SNAPSHOT_PATH_FILTER);

    if (pathsInTrash.length <= 0) {
      LOG.info("Nothing in trash. Will not create snapshot.");
      return;
    }

    Path snapshotDir = new Path(this.trashLocation, new DateTime().toString(TRASH_SNAPSHOT_NAME_FORMATTER));
    if (this.fs.exists(snapshotDir)) {
      throw new IOException("New snapshot directory " + snapshotDir.toString() + " already exists.");
    }

    if (!safeFsMkdir(fs, snapshotDir, PERM)) {
      throw new IOException("Failed to create new snapshot directory at " + snapshotDir.toString());
    }

    LOG.info(String.format("Moving %d paths in Trash directory to newly created snapshot at %s.", pathsInTrash.length,
        snapshotDir.toString()));

    int pathsFailedToMove = 0;
    for (FileStatus fileStatus : pathsInTrash) {
      Path pathRelativeToTrash = PathUtils.relativizePath(fileStatus.getPath(), this.trashLocation);
      Path targetPath = new Path(snapshotDir, pathRelativeToTrash);
      boolean movedThisPath = true;
      try {
        movedThisPath = this.fs.rename(fileStatus.getPath(), targetPath);
      } catch (IOException exception) {
        LOG.error("Failed to move path " + fileStatus.getPath().toString() + " to snapshot.", exception);
        pathsFailedToMove += 1;
        continue;
      }
      if (!movedThisPath) {
        LOG.error("Failed to move path " + fileStatus.getPath().toString() + " to snapshot.");
        pathsFailedToMove += 1;
      }
    }

    if (pathsFailedToMove > 0) {
      LOG.error(
          String.format("Failed to move %d paths to the snapshot at %s.", pathsFailedToMove, snapshotDir.toString()));
    }

  }
292092
def _create_snapshot(logger, snapshot_name, vm, save_vm_memory_to_snapshot):
        
        logger.info("Create virtual machine snapshot")
        dump_memory = save_vm_memory_to_snapshot
        quiesce = True
        task = vm.CreateSnapshot(snapshot_name, 'Created by CloudShell vCenterShell', dump_memory, quiesce)
        return task
49850
static File createSnapshotFile(String name, File directory, long index, long timestamp) {
    return new File(directory, String.format("%s-%d-%s.snapshot", Assert.notNull(name, "name"), index, TIMESTAMP_FORMAT.format(new Date(timestamp))));
  }
568171
def get_snapshot_brok(self, snap_output, exit_status):
        
        data = {
            'uuid': self.uuid,
            'snapshot_output': snap_output,
            'snapshot_time': int(time.time()),
            'snapshot_exit_status': exit_status,
        }
        self.fill_data_brok_from(data, 'check_result')
        return Brok({'type': self.my_type + '_snapshot', 'data': data})
478290
def update!(**kwords)
      kwords = kwords.map { |k, v| [k.to_s.capitalize, v] }.to_h
      response = @connection.send(:put,
                                  "/snapshots/#{self.Name}",
                                  body: JSON.generate(kwords))
      hash = JSON.parse(response.body, symbolize_names: true)
      return nil if hash == marshal_dump
      marshal_load(hash)
      self
    end
216186
def make_ops_snapshot( cls, serialized_ops ):
        
        record_hashes = []
        for serialized_op in serialized_ops:
            record_hash = bin_double_sha256( serialized_op ).encode('hex')
            record_hashes.append(record_hash)

        if len(record_hashes) == 0:
            record_hashes.append(bin_double_sha256("").encode('hex'))

        # put records into their own Merkle tree, and mix the root with the consensus hashes.
        record_hashes.sort()
        record_merkle_tree = MerkleTree( record_hashes )
        record_root_hash = record_merkle_tree.root()

        return record_root_hash
402807
def create(self, subid, params=None):
        ''' 
        '''
        params = update_params(params, {'SUBID': subid})
        return self.request('/v1/snapshot/create', params, 'POST')
337983
function Snaps (client, opts) {
  var self = this
  if (!(self instanceof Snaps)) return new Snaps(client, opts)
  if (!opts) opts = {}

  self.client = client
}