Пример #1
0
  private void syncVolumeVolumeSize(final ReturnValueCompletion<VolumeSize> completion) {
    SyncVolumeSizeOnPrimaryStorageMsg smsg = new SyncVolumeSizeOnPrimaryStorageMsg();
    smsg.setPrimaryStorageUuid(self.getPrimaryStorageUuid());
    smsg.setVolumeUuid(self.getUuid());
    smsg.setInstallPath(self.getInstallPath());
    bus.makeTargetServiceIdByResourceUuid(
        smsg, PrimaryStorageConstant.SERVICE_ID, self.getPrimaryStorageUuid());
    bus.send(
        smsg,
        new CloudBusCallBack(completion) {
          @Override
          public void run(MessageReply reply) {
            if (!reply.isSuccess()) {
              completion.fail(reply.getError());
              return;
            }

            SyncVolumeSizeOnPrimaryStorageReply r = reply.castReply();
            self.setActualSize(r.getActualSize());
            self.setSize(r.getSize());
            self = dbf.updateAndRefresh(self);

            VolumeSize size = new VolumeSize();
            size.actualSize = r.getActualSize();
            size.size = r.getSize();
            completion.success(size);
          }
        });
  }
Пример #2
0
  private void handle(final CreateDataVolumeTemplateFromDataVolumeMsg msg) {
    final CreateTemplateFromVolumeOnPrimaryStorageMsg cmsg =
        new CreateTemplateFromVolumeOnPrimaryStorageMsg();
    cmsg.setBackupStorageUuid(msg.getBackupStorageUuid());
    cmsg.setImageInventory(
        ImageInventory.valueOf(dbf.findByUuid(msg.getImageUuid(), ImageVO.class)));
    cmsg.setVolumeInventory(getSelfInventory());
    bus.makeTargetServiceIdByResourceUuid(
        cmsg, PrimaryStorageConstant.SERVICE_ID, self.getPrimaryStorageUuid());
    bus.send(
        cmsg,
        new CloudBusCallBack(msg) {
          @Override
          public void run(MessageReply r) {
            CreateDataVolumeTemplateFromDataVolumeReply reply =
                new CreateDataVolumeTemplateFromDataVolumeReply();
            if (!r.isSuccess()) {
              reply.setError(r.getError());
            } else {
              CreateTemplateFromVolumeOnPrimaryStorageReply creply = r.castReply();
              String backupStorageInstallPath = creply.getTemplateBackupStorageInstallPath();
              reply.setFormat(creply.getFormat());
              reply.setInstallPath(backupStorageInstallPath);
              reply.setMd5sum(null);
              reply.setBackupStorageUuid(msg.getBackupStorageUuid());
            }

            bus.reply(msg, reply);
          }
        });
  }
Пример #3
0
  private void expunge(final Completion completion) {
    if (self.getStatus() != VolumeStatus.Deleted) {
      throw new OperationFailureException(
          errf.stringToOperationError(
              String.format(
                  "the volume[uuid:%s, name:%s] is not deleted yet, can't expunge it",
                  self.getUuid(), self.getName())));
    }

    final VolumeInventory inv = getSelfInventory();
    CollectionUtils.safeForEach(
        pluginRgty.getExtensionList(VolumeBeforeExpungeExtensionPoint.class),
        new ForEachFunction<VolumeBeforeExpungeExtensionPoint>() {
          @Override
          public void run(VolumeBeforeExpungeExtensionPoint arg) {
            arg.volumeBeforeExpunge(inv);
          }
        });

    if (self.getPrimaryStorageUuid() != null) {
      DeleteVolumeOnPrimaryStorageMsg dmsg = new DeleteVolumeOnPrimaryStorageMsg();
      dmsg.setVolume(getSelfInventory());
      dmsg.setUuid(self.getPrimaryStorageUuid());
      bus.makeTargetServiceIdByResourceUuid(
          dmsg, PrimaryStorageConstant.SERVICE_ID, self.getPrimaryStorageUuid());
      bus.send(
          dmsg,
          new CloudBusCallBack(completion) {
            @Override
            public void run(MessageReply r) {
              if (!r.isSuccess()) {
                completion.fail(r.getError());
              } else {
                ReturnPrimaryStorageCapacityMsg msg = new ReturnPrimaryStorageCapacityMsg();
                msg.setPrimaryStorageUuid(self.getPrimaryStorageUuid());
                msg.setDiskSize(self.getSize());
                bus.makeTargetServiceIdByResourceUuid(
                    msg, PrimaryStorageConstant.SERVICE_ID, self.getPrimaryStorageUuid());
                bus.send(msg);

                CollectionUtils.safeForEach(
                    pluginRgty.getExtensionList(VolumeAfterExpungeExtensionPoint.class),
                    new ForEachFunction<VolumeAfterExpungeExtensionPoint>() {
                      @Override
                      public void run(VolumeAfterExpungeExtensionPoint arg) {
                        arg.volumeAfterExpunge(inv);
                      }
                    });

                dbf.remove(self);
                completion.success();
              }
            }
          });
    } else {
      CollectionUtils.safeForEach(
          pluginRgty.getExtensionList(VolumeAfterExpungeExtensionPoint.class),
          new ForEachFunction<VolumeAfterExpungeExtensionPoint>() {
            @Override
            public void run(VolumeAfterExpungeExtensionPoint arg) {
              arg.volumeAfterExpunge(inv);
            }
          });

      dbf.remove(self);
      completion.success();
    }
  }