mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-9252: Last refactor, passing nfs version to ssvm
This commit is contained in:
parent
5c0728a792
commit
db3e18df31
@ -47,7 +47,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
|||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||||
import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
import com.cloud.agent.Listener;
|
import com.cloud.agent.Listener;
|
||||||
@ -112,7 +111,6 @@ import com.cloud.storage.StorageLayer;
|
|||||||
import com.cloud.utils.FileUtil;
|
import com.cloud.utils.FileUtil;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.ComponentContext;
|
|
||||||
import com.cloud.utils.component.ManagerBase;
|
import com.cloud.utils.component.ManagerBase;
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
@ -170,6 +168,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
private ManagementServerHostPeerDao _mshostPeerDao;
|
private ManagementServerHostPeerDao _mshostPeerDao;
|
||||||
@Inject
|
@Inject
|
||||||
private ClusterManager _clusterMgr;
|
private ClusterManager _clusterMgr;
|
||||||
|
@Inject
|
||||||
private ImageStoreDetailsUtil imageStoreDetailsUtil;
|
private ImageStoreDetailsUtil imageStoreDetailsUtil;
|
||||||
|
|
||||||
private String _mountParent;
|
private String _mountParent;
|
||||||
@ -202,8 +201,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
private final ScheduledExecutorService _hostScanScheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vmware-Host-Scan"));
|
private final ScheduledExecutorService _hostScanScheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vmware-Host-Scan"));
|
||||||
|
|
||||||
public VmwareManagerImpl() {
|
public VmwareManagerImpl() {
|
||||||
ApplicationContext applicationContext = ComponentContext.getApplicationContext();
|
|
||||||
imageStoreDetailsUtil = applicationContext.getBean("imageStoreDetailsUtil", ImageStoreDetailsUtil.class);
|
|
||||||
_storageMgr = new VmwareStorageManagerImpl(this);
|
_storageMgr = new VmwareStorageManagerImpl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,6 @@ import com.vmware.vim25.VirtualDisk;
|
|||||||
|
|
||||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.BackupSnapshotAnswer;
|
import com.cloud.agent.api.BackupSnapshotAnswer;
|
||||||
@ -78,7 +77,6 @@ import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
|
|||||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||||
import com.cloud.storage.ImageStoreDetailsUtil;
|
|
||||||
import com.cloud.storage.JavaStorageLayer;
|
import com.cloud.storage.JavaStorageLayer;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.StorageLayer;
|
import com.cloud.storage.StorageLayer;
|
||||||
@ -95,7 +93,7 @@ import com.cloud.vm.snapshot.VMSnapshot;
|
|||||||
|
|
||||||
public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||||
|
|
||||||
private ImageStoreDetailsUtil imageStoreDetailsUtil;
|
private String _nfsVersion;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(VmwareHostService hostService, CreateEntityDownloadURLCommand cmd) {
|
public boolean execute(VmwareHostService hostService, CreateEntityDownloadURLCommand cmd) {
|
||||||
@ -141,8 +139,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
public VmwareStorageManagerImpl(VmwareStorageMount mountService) {
|
public VmwareStorageManagerImpl(VmwareStorageMount mountService) {
|
||||||
assert (mountService != null);
|
assert (mountService != null);
|
||||||
_mountService = mountService;
|
_mountService = mountService;
|
||||||
ApplicationContext applicationContext = com.cloud.utils.component.ComponentContext.getApplicationContext();
|
}
|
||||||
imageStoreDetailsUtil = applicationContext.getBean("imageStoreDetailsUtil", ImageStoreDetailsUtil.class);
|
|
||||||
|
public VmwareStorageManagerImpl(VmwareStorageMount mountService, String nfsVersion) {
|
||||||
|
assert (mountService != null);
|
||||||
|
_mountService = mountService;
|
||||||
|
_nfsVersion = nfsVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configure(Map<String, Object> params) {
|
public void configure(Map<String, Object> params) {
|
||||||
@ -163,7 +165,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
String secStorageUrl = nfsStore.getUrl();
|
String secStorageUrl = nfsStore.getUrl();
|
||||||
assert (secStorageUrl != null);
|
assert (secStorageUrl != null);
|
||||||
String installPath = template.getPath();
|
String installPath = template.getPath();
|
||||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl, imageStoreDetailsUtil.getNfsVersionByUuid(storeTO.getUuid()));
|
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl, _nfsVersion);
|
||||||
String installFullPath = secondaryMountPoint + "/" + installPath;
|
String installFullPath = secondaryMountPoint + "/" + installPath;
|
||||||
try {
|
try {
|
||||||
if (installFullPath.endsWith(".ova")) {
|
if (installFullPath.endsWith(".ova")) {
|
||||||
@ -201,7 +203,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
String installPath = volume.getPath();
|
String installPath = volume.getPath();
|
||||||
int index = installPath.lastIndexOf(File.separator);
|
int index = installPath.lastIndexOf(File.separator);
|
||||||
String volumeUuid = installPath.substring(index + 1);
|
String volumeUuid = installPath.substring(index + 1);
|
||||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl, imageStoreDetailsUtil.getNfsVersionByUuid(storeTO.getUuid()));
|
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl, _nfsVersion);
|
||||||
//The real volume path
|
//The real volume path
|
||||||
String volumePath = installPath + File.separator + volumeUuid + ".ova";
|
String volumePath = installPath + File.separator + volumeUuid + ".ova";
|
||||||
String installFullPath = secondaryMountPoint + "/" + installPath;
|
String installFullPath = secondaryMountPoint + "/" + installPath;
|
||||||
|
|||||||
@ -5197,8 +5197,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
value = (String)params.get("scripts.timeout");
|
value = (String)params.get("scripts.timeout");
|
||||||
int timeout = NumbersUtil.parseInt(value, 1440) * 1000;
|
int timeout = NumbersUtil.parseInt(value, 1440) * 1000;
|
||||||
_storageProcessor = new VmwareStorageProcessor((VmwareHostService)this, _fullCloneFlag, (VmwareStorageMount)mgr, timeout, this, _shutdownWaitMs, null);
|
_storageProcessor = new VmwareStorageProcessor((VmwareHostService)this, _fullCloneFlag, (VmwareStorageMount)mgr, timeout, this, _shutdownWaitMs, null, (String)params.get("nfsVersion"));
|
||||||
storageHandler = new VmwareStorageSubsystemCommandHandler(_storageProcessor);
|
storageHandler = new VmwareStorageSubsystemCommandHandler(_storageProcessor, (String)params.get("nfsVersion"));
|
||||||
|
|
||||||
_vrResource = new VirtualRoutingResource(this);
|
_vrResource = new VirtualRoutingResource(this);
|
||||||
if (!_vrResource.configure(name, params)) {
|
if (!_vrResource.configure(name, params)) {
|
||||||
|
|||||||
@ -102,7 +102,7 @@ public class PremiumSecondaryStorageResource extends NfsSecondaryStorageResource
|
|||||||
VmwareSecondaryStorageContextFactory.initFactoryEnvironment();
|
VmwareSecondaryStorageContextFactory.initFactoryEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
registerHandler(Hypervisor.HypervisorType.VMware, new VmwareSecondaryStorageResourceHandler(this));
|
registerHandler(Hypervisor.HypervisorType.VMware, new VmwareSecondaryStorageResourceHandler(this, (String)params.get("nfsVersion")));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,13 +66,13 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
|||||||
* private Map<String, HostMO> _activeHosts = new HashMap<String, HostMO>();
|
* private Map<String, HostMO> _activeHosts = new HashMap<String, HostMO>();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public VmwareSecondaryStorageResourceHandler(PremiumSecondaryStorageResource resource) {
|
public VmwareSecondaryStorageResourceHandler(PremiumSecondaryStorageResource resource, String nfsVersion) {
|
||||||
_resource = resource;
|
_resource = resource;
|
||||||
_storageMgr = new VmwareStorageManagerImpl(this);
|
_storageMgr = new VmwareStorageManagerImpl(this, nfsVersion);
|
||||||
_gson = GsonHelper.getGsonLogger();
|
_gson = GsonHelper.getGsonLogger();
|
||||||
|
|
||||||
VmwareStorageProcessor storageProcessor = new VmwareStorageProcessor(this, true, this, resource.getTimeout(), null, null, _resource);
|
VmwareStorageProcessor storageProcessor = new VmwareStorageProcessor(this, true, this, resource.getTimeout(), null, null, _resource, nfsVersion);
|
||||||
VmwareStorageSubsystemCommandHandler vmwareStorageSubsystemCommandHandler = new VmwareStorageSubsystemCommandHandler(storageProcessor);
|
VmwareStorageSubsystemCommandHandler vmwareStorageSubsystemCommandHandler = new VmwareStorageSubsystemCommandHandler(storageProcessor, nfsVersion);
|
||||||
vmwareStorageSubsystemCommandHandler.setStorageResource(_resource);
|
vmwareStorageSubsystemCommandHandler.setStorageResource(_resource);
|
||||||
vmwareStorageSubsystemCommandHandler.setStorageManager(_storageMgr);
|
vmwareStorageSubsystemCommandHandler.setStorageManager(_storageMgr);
|
||||||
storageSubsystemHandler = vmwareStorageSubsystemCommandHandler;
|
storageSubsystemHandler = vmwareStorageSubsystemCommandHandler;
|
||||||
|
|||||||
@ -67,7 +67,6 @@ import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
|||||||
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
|
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
|
||||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.Command;
|
import com.cloud.agent.api.Command;
|
||||||
@ -97,7 +96,6 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
|
|||||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||||
import com.cloud.serializer.GsonHelper;
|
import com.cloud.serializer.GsonHelper;
|
||||||
import com.cloud.storage.DataStoreRole;
|
import com.cloud.storage.DataStoreRole;
|
||||||
import com.cloud.storage.ImageStoreDetailsUtil;
|
|
||||||
import com.cloud.storage.JavaStorageLayer;
|
import com.cloud.storage.JavaStorageLayer;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.StorageLayer;
|
import com.cloud.storage.StorageLayer;
|
||||||
@ -112,8 +110,6 @@ import com.cloud.vm.VmDetailConstants;
|
|||||||
|
|
||||||
public class VmwareStorageProcessor implements StorageProcessor {
|
public class VmwareStorageProcessor implements StorageProcessor {
|
||||||
|
|
||||||
private ImageStoreDetailsUtil imageStoreDetailsUtil;
|
|
||||||
|
|
||||||
private static final Logger s_logger = Logger.getLogger(VmwareStorageProcessor.class);
|
private static final Logger s_logger = Logger.getLogger(VmwareStorageProcessor.class);
|
||||||
private static final int DEFAULT_NFS_PORT = 2049;
|
private static final int DEFAULT_NFS_PORT = 2049;
|
||||||
|
|
||||||
@ -125,9 +121,10 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
protected Integer _shutdownWaitMs;
|
protected Integer _shutdownWaitMs;
|
||||||
private final Gson _gson;
|
private final Gson _gson;
|
||||||
private final StorageLayer _storage = new JavaStorageLayer();
|
private final StorageLayer _storage = new JavaStorageLayer();
|
||||||
|
private String _nfsVersion;
|
||||||
|
|
||||||
public VmwareStorageProcessor(VmwareHostService hostService, boolean fullCloneFlag, VmwareStorageMount mountService, Integer timeout, VmwareResource resource,
|
public VmwareStorageProcessor(VmwareHostService hostService, boolean fullCloneFlag, VmwareStorageMount mountService, Integer timeout, VmwareResource resource,
|
||||||
Integer shutdownWaitMs, PremiumSecondaryStorageResource storageResource) {
|
Integer shutdownWaitMs, PremiumSecondaryStorageResource storageResource, String nfsVersion) {
|
||||||
this.hostService = hostService;
|
this.hostService = hostService;
|
||||||
_fullCloneFlag = fullCloneFlag;
|
_fullCloneFlag = fullCloneFlag;
|
||||||
this.mountService = mountService;
|
this.mountService = mountService;
|
||||||
@ -135,8 +132,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
_shutdownWaitMs = shutdownWaitMs;
|
_shutdownWaitMs = shutdownWaitMs;
|
||||||
_gson = GsonHelper.getGsonLogger();
|
_gson = GsonHelper.getGsonLogger();
|
||||||
ApplicationContext applicationContext = com.cloud.utils.component.ComponentContext.getApplicationContext();
|
_nfsVersion = nfsVersion;
|
||||||
imageStoreDetailsUtil = applicationContext.getBean("imageStoreDetailsUtil", ImageStoreDetailsUtil.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -323,7 +319,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
|
|
||||||
if (managed) {
|
if (managed) {
|
||||||
VirtualMachineMO vmMo = copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(),
|
VirtualMachineMO vmMo = copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(),
|
||||||
managedStoragePoolRootVolumeName, false, imageStoreDetailsUtil.getNfsVersionByUuid(destStore.getUuid()));
|
managedStoragePoolRootVolumeName, false, _nfsVersion);
|
||||||
|
|
||||||
vmMo.unregisterVm();
|
vmMo.unregisterVm();
|
||||||
|
|
||||||
@ -340,7 +336,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(),
|
copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(),
|
||||||
templateUuidName, true, imageStoreDetailsUtil.getNfsVersionByUuid(destStore.getUuid()));
|
templateUuidName, true, _nfsVersion);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s_logger.info("Template " + templateInfo.second() + " has already been setup, skip the template setup process in primary storage");
|
s_logger.info("Template " + templateInfo.second() + " has already been setup, skip the template setup process in primary storage");
|
||||||
@ -585,8 +581,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pair<String, String> result = copyVolumeFromSecStorage(hyperHost, srcVolume.getPath(), new DatastoreMO(context, morDatastore), srcStore.getUrl(), (long)cmd.getWait() * 1000, imageStoreDetailsUtil.getNfsVersionByUuid(destStore.getUuid()));
|
Pair<String, String> result = copyVolumeFromSecStorage(hyperHost, srcVolume.getPath(), new DatastoreMO(context, morDatastore), srcStore.getUrl(), (long)cmd.getWait() * 1000, _nfsVersion);
|
||||||
deleteVolumeDirOnSecondaryStorage(result.first(), srcStore.getUrl(), imageStoreDetailsUtil.getNfsVersionByUuid(uuid));
|
deleteVolumeDirOnSecondaryStorage(result.first(), srcStore.getUrl(), _nfsVersion);
|
||||||
VolumeObjectTO newVolume = new VolumeObjectTO();
|
VolumeObjectTO newVolume = new VolumeObjectTO();
|
||||||
newVolume.setPath(result.second());
|
newVolume.setPath(result.second());
|
||||||
return new CopyCmdAnswer(newVolume);
|
return new CopyCmdAnswer(newVolume);
|
||||||
@ -643,8 +639,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
|
|
||||||
vmMo.createSnapshot(exportName, "Temporary snapshot for copy-volume command", false, false);
|
vmMo.createSnapshot(exportName, "Temporary snapshot for copy-volume command", false, false);
|
||||||
|
|
||||||
exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, destVolumePath, exportName, hostService.getWorkerName(hyperHost.getContext(), cmd, 1),
|
exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, destVolumePath, exportName, hostService.getWorkerName(hyperHost.getContext(), cmd, 1), _nfsVersion);
|
||||||
imageStoreDetailsUtil.getNfsVersionByUuid(cmd.getDestTO().getDataStore().getUuid()));
|
|
||||||
return new Pair<String, String>(destVolumePath, exportName);
|
return new Pair<String, String>(destVolumePath, exportName);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
@ -846,7 +841,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
|
|
||||||
Ternary<String, Long, Long> result =
|
Ternary<String, Long, Long> result =
|
||||||
createTemplateFromVolume(vmMo, template.getPath(), template.getId(), template.getName(), secondaryStoragePoolURL, volumePath,
|
createTemplateFromVolume(vmMo, template.getPath(), template.getId(), template.getName(), secondaryStoragePoolURL, volumePath,
|
||||||
hostService.getWorkerName(context, cmd, 0), imageStoreDetailsUtil.getNfsVersionByUuid(imageStore.getUuid()));
|
hostService.getWorkerName(context, cmd, 0), _nfsVersion);
|
||||||
|
|
||||||
TemplateObjectTO newTemplate = new TemplateObjectTO();
|
TemplateObjectTO newTemplate = new TemplateObjectTO();
|
||||||
newTemplate.setPath(result.first());
|
newTemplate.setPath(result.first());
|
||||||
@ -1037,8 +1032,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NfsTO nfsSvr = (NfsTO)imageStore;
|
NfsTO nfsSvr = (NfsTO)imageStore;
|
||||||
Ternary<String, Long, Long> result = createTemplateFromSnapshot(template.getPath(), uniqeName, nfsSvr.getUrl(), snapshot.getPath(), template.getId(), (long)cmd.getWait() * 1000,
|
Ternary<String, Long, Long> result = createTemplateFromSnapshot(template.getPath(), uniqeName, nfsSvr.getUrl(), snapshot.getPath(), template.getId(), (long)cmd.getWait() * 1000, _nfsVersion);
|
||||||
imageStoreDetailsUtil.getNfsVersionByUuid(imageStore.getUuid()));
|
|
||||||
|
|
||||||
TemplateObjectTO newTemplate = new TemplateObjectTO();
|
TemplateObjectTO newTemplate = new TemplateObjectTO();
|
||||||
newTemplate.setPath(result.first());
|
newTemplate.setPath(result.first());
|
||||||
@ -1181,10 +1175,9 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
throw new Exception("Failed to take snapshot " + srcSnapshot.getName() + " on vm: " + vmName);
|
throw new Exception("Failed to take snapshot " + srcSnapshot.getName() + " on vm: " + vmName);
|
||||||
}
|
}
|
||||||
|
|
||||||
String nfsVersion = imageStoreDetailsUtil.getNfsVersionByUuid(destStore.getUuid());
|
|
||||||
backupResult =
|
backupResult =
|
||||||
backupSnapshotToSecondaryStorage(vmMo, destSnapshot.getPath(), srcSnapshot.getVolume().getPath(), snapshotUuid, secondaryStorageUrl,
|
backupSnapshotToSecondaryStorage(vmMo, destSnapshot.getPath(), srcSnapshot.getVolume().getPath(), snapshotUuid, secondaryStorageUrl,
|
||||||
prevSnapshotUuid, prevBackupUuid, hostService.getWorkerName(context, cmd, 1), nfsVersion);
|
prevSnapshotUuid, prevBackupUuid, hostService.getWorkerName(context, cmd, 1), _nfsVersion);
|
||||||
snapshotBackupUuid = backupResult.first();
|
snapshotBackupUuid = backupResult.first();
|
||||||
|
|
||||||
success = (snapshotBackupUuid != null);
|
success = (snapshotBackupUuid != null);
|
||||||
@ -1196,7 +1189,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
|
|
||||||
// Get snapshot physical size
|
// Get snapshot physical size
|
||||||
long physicalSize = 0l;
|
long physicalSize = 0l;
|
||||||
String secondaryMountPoint = mountService.getMountPoint(secondaryStorageUrl, nfsVersion);
|
String secondaryMountPoint = mountService.getMountPoint(secondaryStorageUrl, _nfsVersion);
|
||||||
String snapshotDir = destSnapshot.getPath() + "/" + snapshotBackupUuid;
|
String snapshotDir = destSnapshot.getPath() + "/" + snapshotBackupUuid;
|
||||||
File[] files = new File(secondaryMountPoint + "/" + snapshotDir).listFiles();
|
File[] files = new File(secondaryMountPoint + "/" + snapshotDir).listFiles();
|
||||||
if(files != null) {
|
if(files != null) {
|
||||||
@ -2258,7 +2251,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
backedUpSnapshotUuid = backedUpSnapshotUuid.replace(".ovf", "");
|
backedUpSnapshotUuid = backedUpSnapshotUuid.replace(".ovf", "");
|
||||||
}
|
}
|
||||||
DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
|
DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
|
||||||
restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, secondaryStorageUrl, backupPath, backedUpSnapshotUuid, (long)cmd.getWait() * 1000, imageStoreDetailsUtil.getNfsVersionByUuid(imageStore.getUuid()));
|
restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, secondaryStorageUrl, backupPath, backedUpSnapshotUuid, (long)cmd.getWait() * 1000, _nfsVersion);
|
||||||
|
|
||||||
VolumeObjectTO newVol = new VolumeObjectTO();
|
VolumeObjectTO newVol = new VolumeObjectTO();
|
||||||
newVol.setPath(newVolumeName);
|
newVol.setPath(newVolumeName);
|
||||||
|
|||||||
@ -27,7 +27,6 @@ import org.apache.cloudstack.storage.command.DeleteCommand;
|
|||||||
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
|
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
|
||||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.to.DataObjectType;
|
import com.cloud.agent.api.to.DataObjectType;
|
||||||
@ -38,15 +37,13 @@ import com.cloud.agent.api.to.S3TO;
|
|||||||
import com.cloud.agent.api.to.SwiftTO;
|
import com.cloud.agent.api.to.SwiftTO;
|
||||||
import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
|
import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
|
||||||
import com.cloud.storage.DataStoreRole;
|
import com.cloud.storage.DataStoreRole;
|
||||||
import com.cloud.storage.ImageStoreDetailsUtil;
|
|
||||||
|
|
||||||
public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemCommandHandlerBase {
|
public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemCommandHandlerBase {
|
||||||
|
|
||||||
private ImageStoreDetailsUtil imageStoreDetailsUtil;
|
|
||||||
|
|
||||||
private static final Logger s_logger = Logger.getLogger(VmwareStorageSubsystemCommandHandler.class);
|
private static final Logger s_logger = Logger.getLogger(VmwareStorageSubsystemCommandHandler.class);
|
||||||
private VmwareStorageManager storageManager;
|
private VmwareStorageManager storageManager;
|
||||||
private PremiumSecondaryStorageResource storageResource;
|
private PremiumSecondaryStorageResource storageResource;
|
||||||
|
private String _nfsVersion;
|
||||||
|
|
||||||
public PremiumSecondaryStorageResource getStorageResource() {
|
public PremiumSecondaryStorageResource getStorageResource() {
|
||||||
return storageResource;
|
return storageResource;
|
||||||
@ -64,10 +61,9 @@ public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemComman
|
|||||||
this.storageManager = storageManager;
|
this.storageManager = storageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VmwareStorageSubsystemCommandHandler(StorageProcessor processor) {
|
public VmwareStorageSubsystemCommandHandler(StorageProcessor processor, String nfsVersion) {
|
||||||
super(processor);
|
super(processor);
|
||||||
ApplicationContext applicationContext = com.cloud.utils.component.ComponentContext.getApplicationContext();
|
this._nfsVersion = nfsVersion;
|
||||||
imageStoreDetailsUtil = applicationContext.getBean("imageStoreDetailsUtil", ImageStoreDetailsUtil.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,12 +80,11 @@ public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemComman
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String nfsVersion = imageStoreDetailsUtil.getNfsVersionByUuid(srcDataStore.getUuid());
|
|
||||||
if (srcDataStore.getRole() == DataStoreRole.ImageCache && destDataStore.getRole() == DataStoreRole.Image) {
|
if (srcDataStore.getRole() == DataStoreRole.ImageCache && destDataStore.getRole() == DataStoreRole.Image) {
|
||||||
//need to take extra processing for vmware, such as packing to ova, before sending to S3
|
//need to take extra processing for vmware, such as packing to ova, before sending to S3
|
||||||
if (srcData.getObjectType() == DataObjectType.VOLUME) {
|
if (srcData.getObjectType() == DataObjectType.VOLUME) {
|
||||||
NfsTO cacheStore = (NfsTO)srcDataStore;
|
NfsTO cacheStore = (NfsTO)srcDataStore;
|
||||||
String parentPath = storageResource.getRootDir(cacheStore.getUrl(), nfsVersion);
|
String parentPath = storageResource.getRootDir(cacheStore.getUrl(), _nfsVersion);
|
||||||
VolumeObjectTO vol = (VolumeObjectTO)srcData;
|
VolumeObjectTO vol = (VolumeObjectTO)srcData;
|
||||||
String path = vol.getPath();
|
String path = vol.getPath();
|
||||||
int index = path.lastIndexOf(File.separator);
|
int index = path.lastIndexOf(File.separator);
|
||||||
@ -102,7 +97,7 @@ public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemComman
|
|||||||
} else if (srcData.getObjectType() == DataObjectType.SNAPSHOT) {
|
} else if (srcData.getObjectType() == DataObjectType.SNAPSHOT) {
|
||||||
// pack ova first
|
// pack ova first
|
||||||
// sync snapshot from NFS cache to S3 in NFS migration to S3 case
|
// sync snapshot from NFS cache to S3 in NFS migration to S3 case
|
||||||
String parentPath = storageResource.getRootDir(srcDataStore.getUrl(), nfsVersion);
|
String parentPath = storageResource.getRootDir(srcDataStore.getUrl(), _nfsVersion);
|
||||||
SnapshotObjectTO snap = (SnapshotObjectTO)srcData;
|
SnapshotObjectTO snap = (SnapshotObjectTO)srcData;
|
||||||
String path = snap.getPath();
|
String path = snap.getPath();
|
||||||
int index = path.lastIndexOf(File.separator);
|
int index = path.lastIndexOf(File.separator);
|
||||||
@ -145,7 +140,7 @@ public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemComman
|
|||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
NfsTO cacheStore = (NfsTO)cmd.getCacheTO().getDataStore();
|
NfsTO cacheStore = (NfsTO)cmd.getCacheTO().getDataStore();
|
||||||
String parentPath = storageResource.getRootDir(cacheStore.getUrl(), nfsVersion);
|
String parentPath = storageResource.getRootDir(cacheStore.getUrl(), _nfsVersion);
|
||||||
SnapshotObjectTO newSnapshot = (SnapshotObjectTO)answer.getNewData();
|
SnapshotObjectTO newSnapshot = (SnapshotObjectTO)answer.getNewData();
|
||||||
String path = newSnapshot.getPath();
|
String path = newSnapshot.getPath();
|
||||||
int index = path.lastIndexOf(File.separator);
|
int index = path.lastIndexOf(File.separator);
|
||||||
|
|||||||
@ -25,13 +25,11 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import com.cloud.user.User;
|
import com.cloud.user.User;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Matchers;
|
import org.mockito.Matchers;
|
||||||
@ -56,6 +54,8 @@ import org.apache.cloudstack.api.command.admin.zone.RemoveVmwareDcCmd;
|
|||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||||
|
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
||||||
|
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
||||||
import org.apache.cloudstack.test.utils.SpringUtils;
|
import org.apache.cloudstack.test.utils.SpringUtils;
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
@ -159,17 +159,6 @@ public class VmwareDatacenterApiUnitTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private static RemoveVmwareDcCmd removeCmd;
|
private static RemoveVmwareDcCmd removeCmd;
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void setUp() throws ConfigurationException {
|
|
||||||
ComponentContext ctx = new ComponentContext();
|
|
||||||
ImageStoreDetailsUtil imgSDUtil = Mockito.mock(ImageStoreDetailsUtil.class);
|
|
||||||
Mockito.when(imgSDUtil.getNfsVersion(Mockito.anyLong())).thenReturn("3");
|
|
||||||
Mockito.when(imgSDUtil.getNfsVersionByUuid(Mockito.anyString())).thenReturn("3");
|
|
||||||
ApplicationContext appCtx = Mockito.mock(ApplicationContext.class);
|
|
||||||
Mockito.when(appCtx.getBean(Mockito.anyString(), Mockito.any(ImageStoreDetailsUtil.class))).thenReturn(imgSDUtil);
|
|
||||||
ctx.setApplicationContext(appCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void testSetUp() {
|
public void testSetUp() {
|
||||||
Mockito.when(_configDao.isPremium()).thenReturn(true);
|
Mockito.when(_configDao.isPremium()).thenReturn(true);
|
||||||
@ -442,6 +431,22 @@ public class VmwareDatacenterApiUnitTest {
|
|||||||
return Mockito.mock(DataStoreManager.class);
|
return Mockito.mock(DataStoreManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ImageStoreDetailsUtil imageStoreDetailsUtil() {
|
||||||
|
return Mockito.mock(ImageStoreDetailsUtil.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mocks for ImageStoreDetailsUtil
|
||||||
|
@Bean
|
||||||
|
public ImageStoreDao imageStoreDao() {
|
||||||
|
return Mockito.mock(ImageStoreDao.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ImageStoreDetailsDao imageStoreDetailsDao() {
|
||||||
|
return Mockito.mock(ImageStoreDetailsDao.class);
|
||||||
|
}
|
||||||
|
|
||||||
public static class Library implements TypeFilter {
|
public static class Library implements TypeFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -199,7 +199,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
|||||||
@Inject
|
@Inject
|
||||||
private HostGpuGroupsDao _hostGpuGroupsDao;
|
private HostGpuGroupsDao _hostGpuGroupsDao;
|
||||||
@Inject
|
@Inject
|
||||||
ImageStoreDetailsUtil imageStoreDetailsUtil;
|
private ImageStoreDetailsUtil imageStoreDetailsUtil;
|
||||||
|
|
||||||
private ConcurrentHashMap<Long, HostStats> _hostStats = new ConcurrentHashMap<Long, HostStats>();
|
private ConcurrentHashMap<Long, HostStats> _hostStats = new ConcurrentHashMap<Long, HostStats>();
|
||||||
private final ConcurrentHashMap<Long, VmStats> _VmStats = new ConcurrentHashMap<Long, VmStats>();
|
private final ConcurrentHashMap<Long, VmStats> _VmStats = new ConcurrentHashMap<Long, VmStats>();
|
||||||
|
|||||||
@ -23,9 +23,7 @@ import javax.inject.Inject;
|
|||||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class ImageStoreDetailsUtil {
|
public class ImageStoreDetailsUtil {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@ -241,7 +241,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
@Inject
|
@Inject
|
||||||
VolumeDataStoreDao _volumeStoreDao;
|
VolumeDataStoreDao _volumeStoreDao;
|
||||||
@Inject
|
@Inject
|
||||||
ImageStoreDetailsUtil imageStoreDetailsUtil;
|
private ImageStoreDetailsUtil imageStoreDetailsUtil;
|
||||||
private long _capacityScanInterval = DEFAULT_CAPACITY_SCAN_INTERVAL;
|
private long _capacityScanInterval = DEFAULT_CAPACITY_SCAN_INTERVAL;
|
||||||
private int _secStorageVmMtuSize;
|
private int _secStorageVmMtuSize;
|
||||||
|
|
||||||
@ -1051,7 +1051,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) {
|
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) {
|
||||||
|
|
||||||
SecondaryStorageVmVO vm = _secStorageVmDao.findById(profile.getId());
|
SecondaryStorageVmVO vm = _secStorageVmDao.findById(profile.getId());
|
||||||
Map<String, String> details = _vmDetailsDao.listDetailsKeyPairs(vm.getId());
|
Map<String, String> details = _vmDetailsDao.listDetailsKeyPairs(vm.getId());
|
||||||
vm.setDetails(details);
|
vm.setDetails(details);
|
||||||
@ -1136,6 +1135,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
if (dc.getDns2() != null) {
|
if (dc.getDns2() != null) {
|
||||||
buf.append(" dns2=").append(dc.getDns2());
|
buf.append(" dns2=").append(dc.getDns2());
|
||||||
}
|
}
|
||||||
|
String nfsVersion = imageStoreDetailsUtil != null ? imageStoreDetailsUtil.getNfsVersion(secStore.getId()) : null;
|
||||||
|
buf.append(" nfsVersion=").append(nfsVersion);
|
||||||
|
|
||||||
String bootArgs = buf.toString();
|
String bootArgs = buf.toString();
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
|||||||
@ -44,7 +44,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
@ -94,8 +93,6 @@ import org.apache.cloudstack.storage.command.DownloadCommand;
|
|||||||
import org.apache.cloudstack.storage.command.DownloadProgressCommand;
|
import org.apache.cloudstack.storage.command.DownloadProgressCommand;
|
||||||
import org.apache.cloudstack.storage.command.UploadStatusAnswer;
|
import org.apache.cloudstack.storage.command.UploadStatusAnswer;
|
||||||
import org.apache.cloudstack.storage.command.UploadStatusAnswer.UploadStatus;
|
import org.apache.cloudstack.storage.command.UploadStatusAnswer.UploadStatus;
|
||||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
|
||||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
|
||||||
import org.apache.cloudstack.storage.command.UploadStatusCommand;
|
import org.apache.cloudstack.storage.command.UploadStatusCommand;
|
||||||
import org.apache.cloudstack.storage.template.DownloadManager;
|
import org.apache.cloudstack.storage.template.DownloadManager;
|
||||||
import org.apache.cloudstack.storage.template.DownloadManagerImpl;
|
import org.apache.cloudstack.storage.template.DownloadManagerImpl;
|
||||||
@ -145,7 +142,6 @@ import com.cloud.host.Host.Type;
|
|||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.resource.ServerResourceBase;
|
import com.cloud.resource.ServerResourceBase;
|
||||||
import com.cloud.storage.DataStoreRole;
|
import com.cloud.storage.DataStoreRole;
|
||||||
import com.cloud.storage.ImageStoreDetailsUtil;
|
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.StorageLayer;
|
import com.cloud.storage.StorageLayer;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||||
@ -173,9 +169,6 @@ import org.joda.time.format.ISODateTimeFormat;
|
|||||||
|
|
||||||
public class NfsSecondaryStorageResource extends ServerResourceBase implements SecondaryStorageResource {
|
public class NfsSecondaryStorageResource extends ServerResourceBase implements SecondaryStorageResource {
|
||||||
|
|
||||||
@Inject
|
|
||||||
ImageStoreDetailsUtil _imageStoreDetailsUtil;
|
|
||||||
|
|
||||||
private static final Logger s_logger = Logger.getLogger(NfsSecondaryStorageResource.class);
|
private static final Logger s_logger = Logger.getLogger(NfsSecondaryStorageResource.class);
|
||||||
|
|
||||||
private static final String TEMPLATE_ROOT_DIR = "template/tmpl";
|
private static final String TEMPLATE_ROOT_DIR = "template/tmpl";
|
||||||
@ -215,6 +208,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
private String _storageIp;
|
private String _storageIp;
|
||||||
private String _storageNetmask;
|
private String _storageNetmask;
|
||||||
private String _storageGateway;
|
private String _storageGateway;
|
||||||
|
private String _nfsVersion;
|
||||||
private final List<String> nfsIps = new ArrayList<String>();
|
private final List<String> nfsIps = new ArrayList<String>();
|
||||||
protected String _parent = "/mnt/SecStorage";
|
protected String _parent = "/mnt/SecStorage";
|
||||||
final private String _tmpltpp = "template.properties";
|
final private String _tmpltpp = "template.properties";
|
||||||
@ -222,12 +216,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
private HashMap<String,UploadEntity> uploadEntityStateMap = new HashMap<String,UploadEntity>();
|
private HashMap<String,UploadEntity> uploadEntityStateMap = new HashMap<String,UploadEntity>();
|
||||||
private String _ssvmPSK = null;
|
private String _ssvmPSK = null;
|
||||||
|
|
||||||
@Inject
|
|
||||||
ImageStoreDao dataStoreDao;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
ImageStoreDetailsDao detailsStoreDao;
|
|
||||||
|
|
||||||
public void setParentPath(String path) {
|
public void setParentPath(String path) {
|
||||||
_parent = path;
|
_parent = path;
|
||||||
}
|
}
|
||||||
@ -368,7 +356,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
final String storagePath = destImageStore.getUrl();
|
final String storagePath = destImageStore.getUrl();
|
||||||
final String destPath = destData.getPath();
|
final String destPath = destData.getPath();
|
||||||
try {
|
try {
|
||||||
String downloadPath = determineStorageTemplatePath(storagePath, destPath, _imageStoreDetailsUtil.getNfsVersionByUuid(destImageStore.getUuid()));
|
String downloadPath = determineStorageTemplatePath(storagePath, destPath, _nfsVersion);
|
||||||
final File downloadDirectory = _storage.getFile(downloadPath);
|
final File downloadDirectory = _storage.getFile(downloadPath);
|
||||||
|
|
||||||
if (downloadDirectory.exists()) {
|
if (downloadDirectory.exists()) {
|
||||||
@ -395,7 +383,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String downloadPath = determineStorageTemplatePath(storagePath, destPath, _imageStoreDetailsUtil.getNfsVersionByUuid(destImageStore.getUuid()));
|
String downloadPath = determineStorageTemplatePath(storagePath, destPath, _nfsVersion);
|
||||||
final File downloadDirectory = _storage.getFile(downloadPath);
|
final File downloadDirectory = _storage.getFile(downloadPath);
|
||||||
|
|
||||||
if (downloadDirectory.exists()) {
|
if (downloadDirectory.exists()) {
|
||||||
@ -428,7 +416,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
|
|
||||||
protected Answer copySnapshotToTemplateFromNfsToNfsXenserver(CopyCommand cmd, SnapshotObjectTO srcData, NfsTO srcDataStore, TemplateObjectTO destData,
|
protected Answer copySnapshotToTemplateFromNfsToNfsXenserver(CopyCommand cmd, SnapshotObjectTO srcData, NfsTO srcDataStore, TemplateObjectTO destData,
|
||||||
NfsTO destDataStore) {
|
NfsTO destDataStore) {
|
||||||
String srcMountPoint = getRootDir(srcDataStore.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(srcDataStore.getUuid()));
|
String srcMountPoint = getRootDir(srcDataStore.getUrl(), _nfsVersion);
|
||||||
String snapshotPath = srcData.getPath();
|
String snapshotPath = srcData.getPath();
|
||||||
int index = snapshotPath.lastIndexOf("/");
|
int index = snapshotPath.lastIndexOf("/");
|
||||||
String snapshotName = snapshotPath.substring(index + 1);
|
String snapshotName = snapshotPath.substring(index + 1);
|
||||||
@ -438,7 +426,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
snapshotPath = snapshotPath.substring(0, index);
|
snapshotPath = snapshotPath.substring(0, index);
|
||||||
|
|
||||||
snapshotPath = srcMountPoint + File.separator + snapshotPath;
|
snapshotPath = srcMountPoint + File.separator + snapshotPath;
|
||||||
String destMountPoint = getRootDir(destDataStore.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(destDataStore.getUuid()));
|
String destMountPoint = getRootDir(destDataStore.getUrl(), _nfsVersion);
|
||||||
String destPath = destMountPoint + File.separator + destData.getPath();
|
String destPath = destMountPoint + File.separator + destData.getPath();
|
||||||
|
|
||||||
String errMsg = null;
|
String errMsg = null;
|
||||||
@ -496,8 +484,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
if (srcData.getHypervisorType() == HypervisorType.XenServer) {
|
if (srcData.getHypervisorType() == HypervisorType.XenServer) {
|
||||||
return copySnapshotToTemplateFromNfsToNfsXenserver(cmd, srcData, srcDataStore, destData, destDataStore);
|
return copySnapshotToTemplateFromNfsToNfsXenserver(cmd, srcData, srcDataStore, destData, destDataStore);
|
||||||
} else if (srcData.getHypervisorType() == HypervisorType.KVM) {
|
} else if (srcData.getHypervisorType() == HypervisorType.KVM) {
|
||||||
File srcFile = getFile(srcData.getPath(), srcDataStore.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(srcDataStore.getUuid()));
|
File srcFile = getFile(srcData.getPath(), srcDataStore.getUrl(), _nfsVersion);
|
||||||
File destFile = getFile(destData.getPath(), destDataStore.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(destDataStore.getUuid()));
|
File destFile = getFile(destData.getPath(), destDataStore.getUrl(), _nfsVersion);
|
||||||
|
|
||||||
VolumeObjectTO volumeObjectTO = srcData.getVolume();
|
VolumeObjectTO volumeObjectTO = srcData.getVolume();
|
||||||
ImageFormat srcFormat = null;
|
ImageFormat srcFormat = null;
|
||||||
@ -614,7 +602,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
}
|
}
|
||||||
s_logger.debug("starting copy template to swift");
|
s_logger.debug("starting copy template to swift");
|
||||||
DataTO newTemplate = answer.getNewData();
|
DataTO newTemplate = answer.getNewData();
|
||||||
File templateFile = getFile(newTemplate.getPath(), ((NfsTO)srcDataStore).getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(srcDataStore.getUuid()));
|
File templateFile = getFile(newTemplate.getPath(), ((NfsTO)srcDataStore).getUrl(), _nfsVersion);
|
||||||
SwiftTO swift = (SwiftTO)destDataStore;
|
SwiftTO swift = (SwiftTO)destDataStore;
|
||||||
String containterName = SwiftUtil.getContainerName(destData.getObjectType().toString(), destData.getId());
|
String containterName = SwiftUtil.getContainerName(destData.getObjectType().toString(), destData.getId());
|
||||||
String swiftPath = SwiftUtil.putObject(swift, templateFile, containterName, templateFile.getName());
|
String swiftPath = SwiftUtil.putObject(swift, templateFile, containterName, templateFile.getName());
|
||||||
@ -736,7 +724,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
throw new CloudRuntimeException("Failed to get url: " + url);
|
throw new CloudRuntimeException("Failed to get url: " + url);
|
||||||
}
|
}
|
||||||
|
|
||||||
String nfsMountPath = getRootDir(nfs.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(nfs.getUuid()));
|
String nfsMountPath = getRootDir(nfs.getUrl(), _nfsVersion);
|
||||||
|
|
||||||
String filePath = nfsMountPath + File.separator + path;
|
String filePath = nfsMountPath + File.separator + path;
|
||||||
File directory = new File(filePath);
|
File directory = new File(filePath);
|
||||||
@ -901,7 +889,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
final S3TO s3 = (S3TO)destDataStore;
|
final S3TO s3 = (S3TO)destDataStore;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final String templatePath = determineStorageTemplatePath(srcStore.getUrl(), srcData.getPath(), _imageStoreDetailsUtil.getNfsVersionByUuid(srcDataStore.getUuid()));
|
final String templatePath = determineStorageTemplatePath(srcStore.getUrl(), srcData.getPath(), _nfsVersion);
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Found " + srcData.getObjectType() + " from directory " + templatePath + " to upload to S3.");
|
s_logger.debug("Found " + srcData.getObjectType() + " from directory " + templatePath + " to upload to S3.");
|
||||||
@ -1114,7 +1102,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
if (dstore instanceof NfsTO) {
|
if (dstore instanceof NfsTO) {
|
||||||
NfsTO nfs = (NfsTO)dstore;
|
NfsTO nfs = (NfsTO)dstore;
|
||||||
String relativeSnapshotPath = cmd.getDirectory();
|
String relativeSnapshotPath = cmd.getDirectory();
|
||||||
String parent = getRootDir(nfs.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(dstore.getUuid()));
|
String parent = getRootDir(nfs.getUrl(), _nfsVersion);
|
||||||
|
|
||||||
if (relativeSnapshotPath.startsWith(File.separator)) {
|
if (relativeSnapshotPath.startsWith(File.separator)) {
|
||||||
relativeSnapshotPath = relativeSnapshotPath.substring(1);
|
relativeSnapshotPath = relativeSnapshotPath.substring(1);
|
||||||
@ -1192,7 +1180,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
return new Answer(cmd, false, "can't handle non nfs data store");
|
return new Answer(cmd, false, "can't handle non nfs data store");
|
||||||
}
|
}
|
||||||
NfsTO nfsStore = (NfsTO)store;
|
NfsTO nfsStore = (NfsTO)store;
|
||||||
String parent = getRootDir(nfsStore.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(store.getUuid()));
|
String parent = getRootDir(nfsStore.getUrl(), _nfsVersion);
|
||||||
|
|
||||||
if (relativeTemplatePath.startsWith(File.separator)) {
|
if (relativeTemplatePath.startsWith(File.separator)) {
|
||||||
relativeTemplatePath = relativeTemplatePath.substring(1);
|
relativeTemplatePath = relativeTemplatePath.substring(1);
|
||||||
@ -1403,7 +1391,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
DataStoreTO dstore = obj.getDataStore();
|
DataStoreTO dstore = obj.getDataStore();
|
||||||
if (dstore instanceof NfsTO) {
|
if (dstore instanceof NfsTO) {
|
||||||
NfsTO nfs = (NfsTO)dstore;
|
NfsTO nfs = (NfsTO)dstore;
|
||||||
String parent = getRootDir(nfs.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(dstore.getUuid()));
|
String parent = getRootDir(nfs.getUrl(), _nfsVersion);
|
||||||
if (!parent.endsWith(File.separator)) {
|
if (!parent.endsWith(File.separator)) {
|
||||||
parent += File.separator;
|
parent += File.separator;
|
||||||
}
|
}
|
||||||
@ -1596,7 +1584,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
}
|
}
|
||||||
DataStoreTO store = cmd.getDataStore();
|
DataStoreTO store = cmd.getDataStore();
|
||||||
if (store instanceof NfsTO) {
|
if (store instanceof NfsTO) {
|
||||||
String root = getRootDir(cmd.getSecUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(store.getUuid()));
|
String root = getRootDir(cmd.getSecUrl(), _nfsVersion);
|
||||||
Map<Long, TemplateProp> templateInfos = _dlMgr.gatherVolumeInfo(root);
|
Map<Long, TemplateProp> templateInfos = _dlMgr.gatherVolumeInfo(root);
|
||||||
return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
|
return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
|
||||||
} else if (store instanceof S3TO) {
|
} else if (store instanceof S3TO) {
|
||||||
@ -1765,7 +1753,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
if (dstore instanceof NfsTO) {
|
if (dstore instanceof NfsTO) {
|
||||||
NfsTO nfs = (NfsTO)dstore;
|
NfsTO nfs = (NfsTO)dstore;
|
||||||
String relativeTemplatePath = obj.getPath();
|
String relativeTemplatePath = obj.getPath();
|
||||||
String parent = getRootDir(nfs.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(dstore.getUuid()));
|
String parent = getRootDir(nfs.getUrl(), _nfsVersion);
|
||||||
|
|
||||||
if (relativeTemplatePath.startsWith(File.separator)) {
|
if (relativeTemplatePath.startsWith(File.separator)) {
|
||||||
relativeTemplatePath = relativeTemplatePath.substring(1);
|
relativeTemplatePath = relativeTemplatePath.substring(1);
|
||||||
@ -1869,7 +1857,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
if (dstore instanceof NfsTO) {
|
if (dstore instanceof NfsTO) {
|
||||||
NfsTO nfs = (NfsTO)dstore;
|
NfsTO nfs = (NfsTO)dstore;
|
||||||
String relativeVolumePath = obj.getPath();
|
String relativeVolumePath = obj.getPath();
|
||||||
String parent = getRootDir(nfs.getUrl(), _imageStoreDetailsUtil.getNfsVersionByUuid(dstore.getUuid()));
|
String parent = getRootDir(nfs.getUrl(), _nfsVersion);
|
||||||
|
|
||||||
if (relativeVolumePath.startsWith(File.separator)) {
|
if (relativeVolumePath.startsWith(File.separator)) {
|
||||||
relativeVolumePath = relativeVolumePath.substring(1);
|
relativeVolumePath = relativeVolumePath.substring(1);
|
||||||
@ -2134,6 +2122,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
startAdditionalServices();
|
startAdditionalServices();
|
||||||
_params.put("install.numthreads", "50");
|
_params.put("install.numthreads", "50");
|
||||||
_params.put("secondary.storage.vm", "true");
|
_params.put("secondary.storage.vm", "true");
|
||||||
|
_nfsVersion = (String)params.get("nfsVersion");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -46,7 +46,6 @@ import org.apache.cloudstack.storage.command.DownloadProgressCommand;
|
|||||||
import org.apache.cloudstack.storage.command.DownloadProgressCommand.RequestType;
|
import org.apache.cloudstack.storage.command.DownloadProgressCommand.RequestType;
|
||||||
import org.apache.cloudstack.storage.resource.SecondaryStorageResource;
|
import org.apache.cloudstack.storage.resource.SecondaryStorageResource;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.storage.DownloadAnswer;
|
import com.cloud.agent.api.storage.DownloadAnswer;
|
||||||
import com.cloud.utils.net.Proxy;
|
import com.cloud.utils.net.Proxy;
|
||||||
@ -54,7 +53,6 @@ import com.cloud.agent.api.to.DataStoreTO;
|
|||||||
import com.cloud.agent.api.to.NfsTO;
|
import com.cloud.agent.api.to.NfsTO;
|
||||||
import com.cloud.agent.api.to.S3TO;
|
import com.cloud.agent.api.to.S3TO;
|
||||||
import com.cloud.exception.InternalErrorException;
|
import com.cloud.exception.InternalErrorException;
|
||||||
import com.cloud.storage.ImageStoreDetailsUtil;
|
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.StorageLayer;
|
import com.cloud.storage.StorageLayer;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
@ -91,7 +89,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
|
|||||||
StorageLayer _storage;
|
StorageLayer _storage;
|
||||||
public Map<String, Processor> _processors;
|
public Map<String, Processor> _processors;
|
||||||
|
|
||||||
private ImageStoreDetailsUtil imageStoreDetailsUtil;
|
private String _nfsVersion;
|
||||||
|
|
||||||
public class Completion implements DownloadCompleteCallback {
|
public class Completion implements DownloadCompleteCallback {
|
||||||
private final String jobId;
|
private final String jobId;
|
||||||
@ -712,7 +710,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
|
|||||||
String installPathPrefix = cmd.getInstallPath();
|
String installPathPrefix = cmd.getInstallPath();
|
||||||
// for NFS, we need to get mounted path
|
// for NFS, we need to get mounted path
|
||||||
if (dstore instanceof NfsTO) {
|
if (dstore instanceof NfsTO) {
|
||||||
installPathPrefix = resource.getRootDir(((NfsTO)dstore).getUrl(), imageStoreDetailsUtil.getNfsVersionByUuid(dstore.getUuid())) + File.separator + installPathPrefix;
|
installPathPrefix = resource.getRootDir(((NfsTO)dstore).getUrl(), _nfsVersion) + File.separator + installPathPrefix;
|
||||||
}
|
}
|
||||||
String user = null;
|
String user = null;
|
||||||
String password = null;
|
String password = null;
|
||||||
@ -954,8 +952,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DownloadManagerImpl() {
|
public DownloadManagerImpl() {
|
||||||
ApplicationContext applicationContext = com.cloud.utils.component.ComponentContext.getApplicationContext();
|
|
||||||
imageStoreDetailsUtil = applicationContext.getBean("imageStoreDetailsUtil", ImageStoreDetailsUtil.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -988,6 +984,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
|
|||||||
String inSystemVM = (String)params.get("secondary.storage.vm");
|
String inSystemVM = (String)params.get("secondary.storage.vm");
|
||||||
if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) {
|
if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) {
|
||||||
s_logger.info("DownloadManager: starting additional services since we are inside system vm");
|
s_logger.info("DownloadManager: starting additional services since we are inside system vm");
|
||||||
|
_nfsVersion = (String)params.get("nfsVersion");
|
||||||
startAdditionalServices();
|
startAdditionalServices();
|
||||||
blockOutgoingOnPrivate();
|
blockOutgoingOnPrivate();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user