Search in sources :

Example 1 with UploadCommand

use of com.cloud.agent.api.storage.UploadCommand in project cosmic by MissionCriticalCloud.

the class UploadMonitorImpl method extractTemplate.

@Override
public Long extractTemplate(final VMTemplateVO template, final String url, final TemplateDataStoreVO vmTemplateHost, final Long dataCenterId, final long eventId, final long asyncJobId, final AsyncJobManager asyncMgr) {
    final Type type = (template.getFormat() == ImageFormat.ISO) ? Type.ISO : Type.TEMPLATE;
    final DataStore secStore = storeMgr.getImageStore(dataCenterId);
    final UploadVO uploadTemplateObj = new UploadVO(secStore.getId(), template.getId(), new Date(), Upload.Status.NOT_UPLOADED, type, url, Mode.FTP_UPLOAD);
    _uploadDao.persist(uploadTemplateObj);
    if (vmTemplateHost != null) {
        start();
        final UploadCommand ucmd = new UploadCommand(template, url, vmTemplateHost.getInstallPath(), vmTemplateHost.getSize());
        final UploadListener ul = new UploadListener(secStore, _timer, _uploadDao, uploadTemplateObj, this, ucmd, template.getAccountId(), template.getName(), type, eventId, asyncJobId, asyncMgr);
        _listenerMap.put(uploadTemplateObj, ul);
        try {
            final EndPoint ep = _epSelector.select(secStore);
            if (ep == null) {
                final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
                s_logger.error(errMsg);
                return null;
            }
            ep.sendMessageAsync(ucmd, new UploadListener.Callback(ep.getId(), ul));
        } catch (final Exception e) {
            s_logger.warn("Unable to start upload of " + template.getUniqueName() + " from " + secStore.getName() + " to " + url, e);
            ul.setDisconnected();
            ul.scheduleStatusCheck(RequestType.GET_OR_RESTART);
        }
        return uploadTemplateObj.getId();
    }
    return null;
}
Also used : Type(com.cloud.storage.Upload.Type) RequestType(com.cloud.agent.api.storage.UploadProgressCommand.RequestType) UploadCommand(com.cloud.agent.api.storage.UploadCommand) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) UploadVO(com.cloud.storage.UploadVO) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) Date(java.util.Date) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 2 with UploadCommand

use of com.cloud.agent.api.storage.UploadCommand in project cloudstack by apache.

the class UploadMonitorImpl method extractTemplate.

@Override
public Long extractTemplate(VMTemplateVO template, String url, TemplateDataStoreVO vmTemplateHost, Long dataCenterId, long eventId, long asyncJobId, AsyncJobManager asyncMgr) {
    Type type = (template.getFormat() == ImageFormat.ISO) ? Type.ISO : Type.TEMPLATE;
    DataStore secStore = storeMgr.getImageStoreWithFreeCapacity(dataCenterId);
    if (secStore == null) {
        s_logger.error("Unable to extract template, secondary storage to satisfy storage needs cannot be found!");
        return null;
    }
    UploadVO uploadTemplateObj = new UploadVO(secStore.getId(), template.getId(), new Date(), Upload.Status.NOT_UPLOADED, type, url, Mode.FTP_UPLOAD);
    _uploadDao.persist(uploadTemplateObj);
    if (vmTemplateHost != null) {
        start();
        UploadCommand ucmd = new UploadCommand(template, url, vmTemplateHost.getInstallPath(), vmTemplateHost.getSize());
        UploadListener ul = new UploadListener(secStore, _timer, _uploadDao, uploadTemplateObj, this, ucmd, template.getAccountId(), template.getName(), type, eventId, asyncJobId, asyncMgr);
        _listenerMap.put(uploadTemplateObj, ul);
        try {
            EndPoint ep = _epSelector.select(secStore);
            if (ep == null) {
                String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
                s_logger.error(errMsg);
                return null;
            }
            ep.sendMessageAsync(ucmd, new UploadListener.Callback(ep.getId(), ul));
        } catch (Exception e) {
            s_logger.warn("Unable to start upload of " + template.getUniqueName() + " from " + secStore.getName() + " to " + url, e);
            ul.setDisconnected();
            ul.scheduleStatusCheck(RequestType.GET_OR_RESTART);
        }
        return uploadTemplateObj.getId();
    }
    return null;
}
Also used : Type(com.cloud.storage.Upload.Type) RequestType(com.cloud.agent.api.storage.UploadProgressCommand.RequestType) UploadCommand(com.cloud.agent.api.storage.UploadCommand) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) UploadVO(com.cloud.storage.UploadVO) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) Date(java.util.Date) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 3 with UploadCommand

use of com.cloud.agent.api.storage.UploadCommand in project cosmic by MissionCriticalCloud.

the class UploadMonitorImpl method extractVolume.

@Override
public void extractVolume(final UploadVO uploadVolumeObj, final DataStore secStore, final VolumeVO volume, final String url, final Long dataCenterId, final String installPath, final long eventId, final long asyncJobId, final AsyncJobManager asyncMgr) {
    uploadVolumeObj.setUploadState(Upload.Status.NOT_UPLOADED);
    _uploadDao.update(uploadVolumeObj.getId(), uploadVolumeObj);
    start();
    final UploadCommand ucmd = new UploadCommand(url, volume.getId(), volume.getSize(), installPath, Type.VOLUME);
    final UploadListener ul = new UploadListener(secStore, _timer, _uploadDao, uploadVolumeObj, this, ucmd, volume.getAccountId(), volume.getName(), Type.VOLUME, eventId, asyncJobId, asyncMgr);
    _listenerMap.put(uploadVolumeObj, ul);
    try {
        final EndPoint ep = _epSelector.select(secStore);
        if (ep == null) {
            final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
            s_logger.error(errMsg);
            return;
        }
        ep.sendMessageAsync(ucmd, new UploadListener.Callback(ep.getId(), ul));
    } catch (final Exception e) {
        s_logger.warn("Unable to start upload of volume " + volume.getName() + " from " + secStore.getName() + " to " + url, e);
        ul.setDisconnected();
        ul.scheduleStatusCheck(RequestType.GET_OR_RESTART);
    }
}
Also used : UploadCommand(com.cloud.agent.api.storage.UploadCommand) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 4 with UploadCommand

use of com.cloud.agent.api.storage.UploadCommand in project cloudstack by apache.

the class UploadMonitorImpl method extractVolume.

@Override
public void extractVolume(UploadVO uploadVolumeObj, DataStore secStore, VolumeVO volume, String url, Long dataCenterId, String installPath, long eventId, long asyncJobId, AsyncJobManager asyncMgr) {
    uploadVolumeObj.setUploadState(Upload.Status.NOT_UPLOADED);
    _uploadDao.update(uploadVolumeObj.getId(), uploadVolumeObj);
    start();
    UploadCommand ucmd = new UploadCommand(url, volume.getId(), volume.getSize(), installPath, Type.VOLUME);
    UploadListener ul = new UploadListener(secStore, _timer, _uploadDao, uploadVolumeObj, this, ucmd, volume.getAccountId(), volume.getName(), Type.VOLUME, eventId, asyncJobId, asyncMgr);
    _listenerMap.put(uploadVolumeObj, ul);
    try {
        EndPoint ep = _epSelector.select(secStore);
        if (ep == null) {
            String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
            s_logger.error(errMsg);
            return;
        }
        ep.sendMessageAsync(ucmd, new UploadListener.Callback(ep.getId(), ul));
    } catch (Exception e) {
        s_logger.warn("Unable to start upload of volume " + volume.getName() + " from " + secStore.getName() + " to " + url, e);
        ul.setDisconnected();
        ul.scheduleStatusCheck(RequestType.GET_OR_RESTART);
    }
}
Also used : UploadCommand(com.cloud.agent.api.storage.UploadCommand) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

UploadCommand (com.cloud.agent.api.storage.UploadCommand)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 ConfigurationException (javax.naming.ConfigurationException)4 RequestType (com.cloud.agent.api.storage.UploadProgressCommand.RequestType)2 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)2 Type (com.cloud.storage.Upload.Type)2 UploadVO (com.cloud.storage.UploadVO)2 Date (java.util.Date)2 EndPoint (org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)2 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)1 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)1