Search in sources :

Example 1 with ListVolumeAnswer

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

the class VolumeServiceImpl method listVolume.

private Map<Long, TemplateProp> listVolume(DataStore store) {
    ListVolumeCommand cmd = new ListVolumeCommand(store.getTO(), store.getUri());
    EndPoint ep = _epSelector.select(store);
    Answer answer = null;
    if (ep == null) {
        String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        answer = new Answer(cmd, false, errMsg);
    } else {
        answer = ep.sendMessage(cmd);
    }
    if (answer != null && answer.getResult()) {
        ListVolumeAnswer tanswer = (ListVolumeAnswer) answer;
        return tanswer.getTemplateInfo();
    } else {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Can not list volumes for image store " + store.getId());
        }
    }
    return null;
}
Also used : CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) Answer(com.cloud.agent.api.Answer) ListVolumeCommand(com.cloud.agent.api.storage.ListVolumeCommand) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer)

Example 2 with ListVolumeAnswer

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

the class MockStorageManagerImpl method ListVolumes.

@Override
public Answer ListVolumes(ListVolumeCommand cmd) {
    TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
    MockSecStorageVO storage = null;
    try {
        txn.start();
        storage = _mockSecStorageDao.findByUrl(cmd.getSecUrl());
        if (storage == null) {
            return new Answer(cmd, false, "Failed to get secondary storage");
        }
        txn.commit();
    } catch (Exception ex) {
        txn.rollback();
        throw new CloudRuntimeException("Error when finding sec storage " + cmd.getSecUrl(), ex);
    } finally {
        txn.close();
        txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
        txn.close();
    }
    txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
    try {
        txn.start();
        List<MockVolumeVO> volumes = _mockVolumeDao.findByStorageIdAndType(storage.getId(), MockVolumeType.VOLUME);
        Map<Long, TemplateProp> templateInfos = new HashMap<Long, TemplateProp>();
        for (MockVolumeVO volume : volumes) {
            templateInfos.put(volume.getId(), new TemplateProp(volume.getName(), volume.getPath().replaceAll(storage.getMountPoint(), ""), volume.getSize(), volume.getSize(), true, false));
        }
        txn.commit();
        return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
    } catch (Exception ex) {
        txn.rollback();
        throw new CloudRuntimeException("Error when finding template on sec storage " + storage.getId(), ex);
    } finally {
        txn.close();
        txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
        txn.close();
    }
}
Also used : TemplateProp(com.cloud.storage.template.TemplateProp) TransactionLegacy(com.cloud.utils.db.TransactionLegacy) DownloadAnswer(com.cloud.agent.api.storage.DownloadAnswer) Answer(com.cloud.agent.api.Answer) BackupSnapshotAnswer(com.cloud.agent.api.BackupSnapshotAnswer) ListTemplateAnswer(com.cloud.agent.api.storage.ListTemplateAnswer) ManageSnapshotAnswer(com.cloud.agent.api.ManageSnapshotAnswer) CreatePrivateTemplateAnswer(com.cloud.agent.api.storage.CreatePrivateTemplateAnswer) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) CopyVolumeAnswer(com.cloud.agent.api.storage.CopyVolumeAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) GetVolumeStatsAnswer(com.cloud.agent.api.GetVolumeStatsAnswer) UploadStatusAnswer(org.apache.cloudstack.storage.command.UploadStatusAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) CreateVolumeFromSnapshotAnswer(com.cloud.agent.api.CreateVolumeFromSnapshotAnswer) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) SecStorageSetupAnswer(com.cloud.agent.api.SecStorageSetupAnswer) HashMap(java.util.HashMap) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) MockSecStorageVO(com.cloud.simulator.MockSecStorageVO) MockVolumeVO(com.cloud.simulator.MockVolumeVO) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) URISyntaxException(java.net.URISyntaxException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 3 with ListVolumeAnswer

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

the class NfsSecondaryStorageResource method execute.

private Answer execute(ListVolumeCommand cmd) {
    if (!_inSystemVM) {
        return new ListVolumeAnswer(cmd.getSecUrl(), null);
    }
    DataStoreTO store = cmd.getDataStore();
    if (store instanceof NfsTO) {
        String root = getRootDir(cmd.getSecUrl(), _nfsVersion);
        Map<Long, TemplateProp> templateInfos = _dlMgr.gatherVolumeInfo(root);
        return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
    } else if (store instanceof S3TO) {
        S3TO s3 = (S3TO) store;
        Map<Long, TemplateProp> templateInfos = s3ListVolume(s3);
        return new ListVolumeAnswer(s3.getBucketName(), templateInfos);
    } else {
        return new Answer(cmd, false, "Unsupported image data store: " + store);
    }
}
Also used : TemplateProp(com.cloud.storage.template.TemplateProp) GetDatadisksAnswer(com.cloud.agent.api.storage.GetDatadisksAnswer) CreateDatadiskTemplateAnswer(com.cloud.agent.api.storage.CreateDatadiskTemplateAnswer) ListTemplateAnswer(com.cloud.agent.api.storage.ListTemplateAnswer) HandleConfigDriveIsoAnswer(com.cloud.agent.api.HandleConfigDriveIsoAnswer) UploadStatusAnswer(org.apache.cloudstack.storage.command.UploadStatusAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) DownloadAnswer(com.cloud.agent.api.storage.DownloadAnswer) Answer(com.cloud.agent.api.Answer) CheckHealthAnswer(com.cloud.agent.api.CheckHealthAnswer) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) SecStorageSetupAnswer(com.cloud.agent.api.SecStorageSetupAnswer) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) NfsTO(com.cloud.agent.api.to.NfsTO) S3TO(com.cloud.agent.api.to.S3TO) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with ListVolumeAnswer

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

the class VolumeServiceImpl method listVolume.

private Map<Long, TemplateProp> listVolume(final DataStore store) {
    final ListVolumeCommand cmd = new ListVolumeCommand(store.getTO(), store.getUri());
    final EndPoint ep = _epSelector.select(store);
    Answer answer = null;
    if (ep == null) {
        final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        answer = new Answer(cmd, false, errMsg);
    } else {
        answer = ep.sendMessage(cmd);
    }
    if (answer != null && answer.getResult()) {
        final ListVolumeAnswer tanswer = (ListVolumeAnswer) answer;
        return tanswer.getTemplateInfo();
    } else {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Can not list volumes for image store " + store.getId());
        }
    }
    return null;
}
Also used : Answer(com.cloud.agent.api.Answer) CopyCmdAnswer(com.cloud.storage.command.CopyCmdAnswer) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) ListVolumeCommand(com.cloud.agent.api.storage.ListVolumeCommand) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(com.cloud.storage.RemoteHostEndPoint) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer)

Example 5 with ListVolumeAnswer

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

the class NfsSecondaryStorageResource method execute.

private Answer execute(final ListVolumeCommand cmd) {
    if (!_inSystemVM) {
        return new ListVolumeAnswer(cmd.getSecUrl(), null);
    }
    final DataStoreTO store = cmd.getDataStore();
    if (store instanceof NfsTO) {
        final String root = getRootDir(cmd.getSecUrl());
        final Map<Long, TemplateProp> templateInfos = _dlMgr.gatherVolumeInfo(root);
        return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
    } else {
        return new Answer(cmd, false, "Unsupported image data store: " + store);
    }
}
Also used : TemplateProp(com.cloud.storage.template.TemplateProp) ListTemplateAnswer(com.cloud.agent.api.storage.ListTemplateAnswer) UploadStatusAnswer(com.cloud.storage.command.UploadStatusAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) CopyCmdAnswer(com.cloud.storage.command.CopyCmdAnswer) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) DownloadAnswer(com.cloud.agent.api.storage.DownloadAnswer) Answer(com.cloud.agent.api.Answer) CheckHealthAnswer(com.cloud.agent.api.CheckHealthAnswer) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) SecStorageSetupAnswer(com.cloud.agent.api.SecStorageSetupAnswer) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) ListVolumeAnswer(com.cloud.agent.api.storage.ListVolumeAnswer) NfsTO(com.cloud.agent.api.to.NfsTO)

Aggregations

Answer (com.cloud.agent.api.Answer)5 ListVolumeAnswer (com.cloud.agent.api.storage.ListVolumeAnswer)5 GetStorageStatsAnswer (com.cloud.agent.api.GetStorageStatsAnswer)3 SecStorageSetupAnswer (com.cloud.agent.api.SecStorageSetupAnswer)3 DownloadAnswer (com.cloud.agent.api.storage.DownloadAnswer)3 ListTemplateAnswer (com.cloud.agent.api.storage.ListTemplateAnswer)3 TemplateProp (com.cloud.storage.template.TemplateProp)3 CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)2 ReadyAnswer (com.cloud.agent.api.ReadyAnswer)2 ListVolumeCommand (com.cloud.agent.api.storage.ListVolumeCommand)2 DataStoreTO (com.cloud.agent.api.to.DataStoreTO)2 NfsTO (com.cloud.agent.api.to.NfsTO)2 CopyCmdAnswer (com.cloud.storage.command.CopyCmdAnswer)2 HashMap (java.util.HashMap)2 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)2 UploadStatusAnswer (org.apache.cloudstack.storage.command.UploadStatusAnswer)2 BackupSnapshotAnswer (com.cloud.agent.api.BackupSnapshotAnswer)1 CreateVolumeFromSnapshotAnswer (com.cloud.agent.api.CreateVolumeFromSnapshotAnswer)1 GetVolumeStatsAnswer (com.cloud.agent.api.GetVolumeStatsAnswer)1 HandleConfigDriveIsoAnswer (com.cloud.agent.api.HandleConfigDriveIsoAnswer)1