Search in sources :

Example 1 with CreateGlusterVolumeVDSParameters

use of org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeVDSParameters in project ovirt-engine by oVirt.

the class CreateGlusterVolumeCommand method executeCommand.

/*
     * (non-Javadoc)
     *
     * @see org.ovirt.engine.core.bll.CommandBase#executeCommand()
     */
@Override
protected void executeCommand() {
    // set the gluster volume name for audit purpose
    setGlusterVolumeName(getVolume().getName());
    if (getVolume().getTransportTypes() == null || getVolume().getTransportTypes().isEmpty()) {
        getVolume().addTransportType(TransportType.TCP);
    }
    // GLUSTER access protocol is enabled by default
    getVolume().addAccessProtocol(AccessProtocol.GLUSTER);
    if (!getVolume().getAccessProtocols().contains(AccessProtocol.NFS)) {
        getVolume().disableNFS();
    }
    if (getVolume().getAccessProtocols().contains(AccessProtocol.CIFS)) {
        getVolume().enableCifs();
    }
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.CreateGlusterVolume, new CreateGlusterVolumeVDSParameters(upServer.getId(), getVolume(), upServer.getClusterCompatibilityVersion(), getParameters().isForce()));
    setSucceeded(returnValue.getSucceeded());
    if (!getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_CREATE_FAILED, returnValue.getVdsError().getMessage());
        return;
    }
    // Volume created successfully. Insert it to database.
    GlusterVolumeEntity createdVolume = (GlusterVolumeEntity) returnValue.getReturnValue();
    setVolumeType(createdVolume);
    setBrickOrder(createdVolume.getBricks());
    if (createdVolume.getIsArbiter()) {
        setArbiterFlag(createdVolume);
    }
    addVolumeToDb(createdVolume);
    // If we log successful volume creation at the end of this command,
    // the messages from SetGlusterVolumeOptionCommand appear first,
    // making it look like options were set before volume was created.
    // Hence we explicitly log the volume creation before setting the options.
    auditLogDirector.log(this, AuditLogType.GLUSTER_VOLUME_CREATE);
    // And don't log it at the end
    setCommandShouldBeLogged(false);
    // set all options of the volume
    setVolumeOptions(createdVolume);
    getReturnValue().setActionReturnValue(createdVolume.getId());
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) CreateGlusterVolumeVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeVDSParameters)

Aggregations

GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 CreateGlusterVolumeVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeVDSParameters)1