Search in sources :

Example 96 with DataStore

use of com.cloud.engine.subsystem.api.storage.DataStore in project cosmic by MissionCriticalCloud.

the class SecondaryStorageManagerImpl method generateSetupCommand.

@Override
public boolean generateSetupCommand(final Long ssHostId) {
    final HostVO cssHost = _hostDao.findById(ssHostId);
    final Long zoneId = cssHost.getDataCenterId();
    if (cssHost.getType() == Host.Type.SecondaryStorageVM) {
        final SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findByInstanceName(cssHost.getName());
        if (secStorageVm == null) {
            logger.warn("secondary storage VM " + cssHost.getName() + " doesn't exist");
            return false;
        }
        final List<DataStore> ssStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
        for (final DataStore ssStore : ssStores) {
            if (!(ssStore.getTO() instanceof NfsTO)) {
                // only do this for Nfs
                continue;
            }
            final String secUrl = ssStore.getUri();
            final SecStorageSetupCommand setupCmd;
            if (!_useSSlCopy) {
                setupCmd = new SecStorageSetupCommand(ssStore.getTO(), secUrl, null);
            } else {
                final KeystoreManager.Certificates certs = _keystoreMgr.getCertificates(ConsoleProxyManager.CERTIFICATE_NAME);
                setupCmd = new SecStorageSetupCommand(ssStore.getTO(), secUrl, certs);
            }
            // template/volume file upload key
            final String postUploadKey = _configDao.getValue(Config.SSVMPSK.key());
            setupCmd.setPostUploadKey(postUploadKey);
            final Answer answer = _agentMgr.easySend(ssHostId, setupCmd);
            if (answer != null && answer.getResult()) {
                final SecStorageSetupAnswer an = (SecStorageSetupAnswer) answer;
                if (an.get_dir() != null) {
                    // update the parent path in image_store table for this image store
                    final ImageStoreVO svo = _imageStoreDao.findById(ssStore.getId());
                    svo.setParent(an.get_dir());
                    _imageStoreDao.update(ssStore.getId(), svo);
                }
                logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName());
            } else {
                logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName());
                return false;
            }
        }
    }
    return true;
}
Also used : SecondaryStorageVmVO(com.cloud.vm.SecondaryStorageVmVO) KeystoreManager(com.cloud.framework.security.keystore.KeystoreManager) SecStorageSetupCommand(com.cloud.agent.api.SecStorageSetupCommand) SecStorageSetupAnswer(com.cloud.agent.api.SecStorageSetupAnswer) NfsTO(com.cloud.agent.api.to.NfsTO) HostVO(com.cloud.host.HostVO) ZoneScope(com.cloud.engine.subsystem.api.storage.ZoneScope) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) Answer(com.cloud.agent.api.Answer) SecStorageSetupAnswer(com.cloud.agent.api.SecStorageSetupAnswer) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) ImageStoreVO(com.cloud.storage.datastore.db.ImageStoreVO)

Aggregations

DataStore (com.cloud.engine.subsystem.api.storage.DataStore)96 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)43 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)23 ExecutionException (java.util.concurrent.ExecutionException)23 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)19 ZoneScope (com.cloud.engine.subsystem.api.storage.ZoneScope)17 TemplateDataStoreVO (com.cloud.storage.datastore.db.TemplateDataStoreVO)17 ArrayList (java.util.ArrayList)17 VolumeVO (com.cloud.storage.VolumeVO)16 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)15 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)14 PrimaryDataStore (com.cloud.engine.subsystem.api.storage.PrimaryDataStore)14 DB (com.cloud.utils.db.DB)14 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)12 SnapshotDataStoreVO (com.cloud.storage.datastore.db.SnapshotDataStoreVO)12 StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)12 VolumeDataStoreVO (com.cloud.storage.datastore.db.VolumeDataStoreVO)12 ConfigurationException (javax.naming.ConfigurationException)12 Answer (com.cloud.agent.api.Answer)10 VMTemplateVO (com.cloud.storage.VMTemplateVO)10