Package com.cloud.storage

Examples of com.cloud.storage.Volume


    }

    @Override
    public void create() throws ResourceAllocationException{

        Volume volume = this._volumeService.allocVolume(this);
        if (volume != null) {
            this.setEntityId(volume.getId());
            this.setEntityUuid(volume.getUuid());
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create volume");
        }
    }
View Full Code Here


    }

    @Override
    public void execute(){
        UserContext.current().setEventDetails("Volume Id: "+getEntityId()+((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()));
        Volume volume = _volumeService.createVolume(this);
        if (volume != null) {
            VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
            //FIXME - have to be moved to ApiResponseHelper
            if (getSnapshotId() != null) {
                Snapshot snap = _entityMgr.findById(Snapshot.class, getSnapshotId());
View Full Code Here

        return getId();
    }

    @Override
    public long getEntityOwnerId() {
        Volume volume = _responseGenerator.findVolumeById(getId());
        if (volume == null) {
            return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
        }
        return volume.getAccountId();
    }
View Full Code Here

    }

    @Override
    public void execute(){
        UserContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
        Volume result = _volumeService.attachVolumeToVM(this);
        if (result != null) {
            VolumeResponse response = _responseGenerator.createVolumeResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
View Full Code Here

        return getId();
    }

    @Override
    public long getEntityOwnerId() {
        Volume volume = _entityMgr.findById(Volume.class, getId());
        if (volume != null) {
            return volume.getAccountId();
        }

        // invalid id, parent this command to SYSTEM so ERROR events are tracked
        return Account.ACCOUNT_ID_SYSTEM;
    }
View Full Code Here

        String uploadUrl = _volumeService.extractVolume(this);
        if (uploadUrl != null) {
            ExtractResponse response = new ExtractResponse();
            response.setResponseName(getCommandName());
            response.setObjectName("volume");
            Volume vol = _entityMgr.findById(Volume.class, id);
            response.setId(vol.getUuid());
            response.setName(vol.getName());
            DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
            response.setZoneId(zone.getUuid());
            response.setZoneName(zone.getName());
            response.setMode(mode);
            response.setState(Upload.Status.DOWNLOAD_URL_CREATED.toString());
View Full Code Here

        return getId();
    }

    @Override
    public long getEntityOwnerId() {
        Volume volume = _responseGenerator.findVolumeById(getId());
        if (volume == null) {
            return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
        }
        return volume.getAccountId();
    }
View Full Code Here

    }

    @Override
    public void execute(){
        UserContext.current().setEventDetails("Volume Id: "+getId());
        Volume result = _volumeService.updateVolume(this);
        if (result != null) {
            VolumeResponse response = _responseGenerator.createVolumeResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
View Full Code Here

    }

   @Override
    public long getEntityOwnerId() {

        Volume volume = _entityMgr.findById(Volume.class, getEntityId());
        if (volume == null) {
                throw new InvalidParameterValueException("Unable to find volume by id=" + id);
        }

        Account account = _accountService.getAccount(volume.getAccountId());
        //Can resize volumes for enabled projects/accounts only
        if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
                Project project = _projectService.findByProjectAccountId(volume.getAccountId());
            if (project.getState() != Project.State.Active) {
                throw new PermissionDeniedException("Can't add resources to  project id=" + project.getId() + " in state=" + project.getState() + " as it's no longer active");
            }
        } else if (account.getState() == Account.State.disabled) {
            throw new PermissionDeniedException("The owner of volume " + id + "  is disabled: " + account);
        }

        return volume.getAccountId();
    }
View Full Code Here

    }

    @Override
    public void execute() throws ResourceAllocationException{
        UserContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
      Volume volume = _volumeService.resizeVolume(this);
      if (volume != null) {
            VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
            //FIXME - have to be moved to ApiResponseHelper
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
View Full Code Here

TOP

Related Classes of com.cloud.storage.Volume

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.