Example #1
0
// NOTE: We only set the volume in DiskInfo if 'containerPath' is set.
// If volume mode is not specified, Volume::RW will be used (assuming
// 'containerPath' is set).
inline Resource::DiskInfo createDiskInfo(
    const Option<std::string>& persistenceId,
    const Option<std::string>& containerPath,
    const Option<Volume::Mode>& mode = None(),
    const Option<std::string>& hostPath = None())
{
  Resource::DiskInfo info;

  if (persistenceId.isSome()) {
    info.mutable_persistence()->set_id(persistenceId.get());
  }

  if (containerPath.isSome()) {
    Volume volume;
    volume.set_container_path(containerPath.get());
    volume.set_mode(mode.isSome() ? mode.get() : Volume::RW);

    if (hostPath.isSome()) {
      volume.set_host_path(hostPath.get());
    }

    info.mutable_volume()->CopyFrom(volume);
  }

  return info;
}
static Resource SHARD_PERSISTENT_VOLUME(
    const string& role,
    const string& persistenceId,
    const string& containerPath)
{
  Volume volume;
  volume.set_container_path(containerPath);
  volume.set_mode(Volume::RW);

  Resource::DiskInfo info;
  info.mutable_persistence()->set_id(persistenceId);
  info.mutable_volume()->CopyFrom(volume);

  Resource resource = Resources::parse("disk", "8", role).get();
  resource.mutable_disk()->CopyFrom(info);

  return resource;
}
Example #3
0
  Resource::DiskInfo createDiskInfo(
      const Option<string>& persistenceID,
      const Option<string>& containerPath)
  {
    Resource::DiskInfo info;

    if (persistenceID.isSome()) {
      Resource::DiskInfo::Persistence persistence;
      persistence.set_id(persistenceID.get());
      info.mutable_persistence()->CopyFrom(persistence);
    }

    if (containerPath.isSome()) {
      Volume volume;
      volume.set_container_path(containerPath.get());
      volume.set_mode(Volume::RW);
      info.mutable_volume()->CopyFrom(volume);
    }

    return info;
  }