protected ImageInfo(
     final OwnerFullName ownerFullName,
     final String imageId,
     final ImageMetadata.Type imageType,
     final String imageName,
     final String imageDescription,
     final Long imageSizeBytes,
     final ImageMetadata.Architecture arch,
     final ImageMetadata.Platform platform) {
   this(ownerFullName, ResourceIdentifiers.tryNormalize().apply(imageId));
   checkParam(imageName, notNullValue());
   checkParam(imageType, notNullValue());
   checkParam(imageSizeBytes, notNullValue());
   checkParam(arch, notNullValue());
   checkParam(platform, notNullValue());
   this.setState(ImageMetadata.State.pending);
   this.imageType = imageType;
   this.imageName = imageName;
   this.description = imageDescription;
   this.imageSizeBytes = imageSizeBytes;
   this.architecture = arch;
   this.platform = platform;
   this.imagePublic = ImageConfiguration.getInstance().getDefaultVisibility();
 }
Beispiel #2
0
  public static Volume createStorageVolume(
      final ServiceConfiguration sc,
      final UserFullName owner,
      final String snapId,
      final Integer newSize,
      final BaseMessage request)
      throws ExecutionException {
    final String newId = ResourceIdentifiers.generateString(ID_PREFIX);
    LOG.debug("Creating volume");
    final Volume newVol =
        Transactions.save(
            Volume.create(sc, owner, snapId, newSize, newId),
            new Callback<Volume>() {

              @Override
              public void fire(final Volume t) {
                t.setState(State.GENERATING);
                try {
                  final CreateStorageVolumeType req =
                      new CreateStorageVolumeType(t.getDisplayName(), t.getSize(), snapId, null)
                          .regarding(request);
                  final CreateStorageVolumeResponseType ret = AsyncRequests.sendSync(sc, req);
                  LOG.debug("Volume created");

                  if (t.getSize() != null && t.getSize() > 0) {
                    fireUsageEvent(t, VolumeEvent.forVolumeCreate());
                  }
                } catch (final Exception ex) {
                  LOG.error("Failed to create volume: " + t, ex);
                  t.setState(State.FAIL);
                  throw Exceptions.toUndeclared(ex);
                }
              }
            });
    return newVol;
  }
 ImageInfo(final String imageId) {
   this();
   this.setDisplayName(ResourceIdentifiers.tryNormalize().apply(imageId));
 }