mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
fix build
This commit is contained in:
parent
578d2f62f1
commit
25a6234a5b
@ -18,10 +18,10 @@ package com.cloud.storage;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
|
||||
public interface StoragePool extends Identity, InternalIdentity {
|
||||
@ -99,13 +99,9 @@ public interface StoragePool extends Identity, InternalIdentity {
|
||||
|
||||
Long getPodId();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getStorageProviderName();
|
||||
|
||||
boolean isInMaintenance();
|
||||
String getStorageProviderName();
|
||||
|
||||
boolean isInMaintenance();
|
||||
|
||||
Hypervisor.HypervisorType getHypervisor();
|
||||
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ import org.junit.Test;
|
||||
|
||||
import com.cloud.agent.api.BackupSnapshotCommand;
|
||||
import com.cloud.agent.api.to.SwiftTO;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
@ -145,7 +146,14 @@ public class BackupSnapshotCommandTest {
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hypervisor.HypervisorType getHypervisor() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
|
||||
BackupSnapshotCommand bsc = new BackupSnapshotCommand("http://secondary.Storage.Url", 101L, 102L, 103L, 104L, 105L, "vPath", pool,
|
||||
|
||||
@ -32,6 +32,7 @@ import com.cloud.agent.api.CheckNetworkAnswer;
|
||||
import com.cloud.agent.api.CheckNetworkCommand;
|
||||
import com.cloud.agent.api.storage.ResizeVolumeCommand;
|
||||
import com.cloud.agent.api.to.StorageFilerTO;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
@ -184,7 +185,14 @@ public class CheckNetworkAnswerTest {
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hypervisor.HypervisorType getHypervisor() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
|
||||
Long newSize = 4194304L;
|
||||
|
||||
@ -28,6 +28,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.cloud.agent.api.SnapshotCommand;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
@ -146,7 +147,14 @@ public class SnapshotCommandTest {
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hypervisor.HypervisorType getHypervisor() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
|
||||
SnapshotCommand ssc = new SnapshotCommand(pool, "http://secondary.Storage.Url", "420fa39c-4ef1-a83c-fd93-46dc1ff515ae", "snapshotName", 101L, 102L, 103L);
|
||||
|
||||
@ -24,8 +24,6 @@ import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
|
||||
@ -47,6 +45,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
||||
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.to.DataObjectType;
|
||||
import com.cloud.agent.api.to.DataStoreTO;
|
||||
@ -391,6 +390,11 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
|
||||
getStatus() == StoragePoolStatus.ErrorInMaintenance || getRemoved() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisor() {
|
||||
return pdsv.getHypervisor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageProviderName() {
|
||||
return pdsv.getStorageProviderName();
|
||||
|
||||
@ -23,7 +23,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.ws.rs.HEAD;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
@ -118,13 +117,13 @@ public class XcpOssResource extends CitrixResourceBase {
|
||||
|
||||
@Override
|
||||
protected String getGuestOsType(String stdType, boolean bootFromCD) {
|
||||
if (stdType.equalsIgnoreCase("Debian GNU/Linux 6(64-bit)")) {
|
||||
return "Debian Squeeze 6.0 (64-bit)";
|
||||
} else if (stdType.equalsIgnoreCase("CentOS 5.6 (64-bit)")) {
|
||||
if (stdType.equalsIgnoreCase("Debian GNU/Linux 6(64-bit)")) {
|
||||
return "Debian Squeeze 6.0 (64-bit)";
|
||||
} else if (stdType.equalsIgnoreCase("CentOS 5.6 (64-bit)")) {
|
||||
return "CentOS 5 (64-bit)";
|
||||
} else {
|
||||
return CitrixHelper.getXcpGuestOsType(stdType);
|
||||
}
|
||||
return CitrixHelper.getXcpGuestOsType(stdType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -177,7 +176,7 @@ public class XcpOssResource extends CitrixResourceBase {
|
||||
@Override
|
||||
public Answer executeRequest(Command cmd) {
|
||||
if (cmd instanceof NetworkUsageCommand) {
|
||||
return execute((NetworkUsageCommand)cmd);
|
||||
return execute((NetworkUsageCommand) cmd);
|
||||
} else {
|
||||
return super.executeRequest(cmd);
|
||||
}
|
||||
|
||||
@ -30,8 +30,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.HEAD;
|
||||
|
||||
import org.apache.cloudstack.storage.command.AttachAnswer;
|
||||
import org.apache.cloudstack.storage.command.AttachCommand;
|
||||
import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreAnswer;
|
||||
@ -106,14 +104,14 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
String isoURL = null;
|
||||
if (store == null) {
|
||||
TemplateObjectTO iso = (TemplateObjectTO)disk.getData();
|
||||
TemplateObjectTO iso = (TemplateObjectTO) disk.getData();
|
||||
isoURL = iso.getName();
|
||||
} else {
|
||||
if (!(store instanceof NfsTO)) {
|
||||
s_logger.debug("Can't attach a iso which is not created on nfs: ");
|
||||
return new AttachAnswer("Can't attach a iso which is not created on nfs: ");
|
||||
}
|
||||
NfsTO nfsStore = (NfsTO)store;
|
||||
NfsTO nfsStore = (NfsTO) store;
|
||||
isoURL = nfsStore.getUrl() + File.separator + data.getPath();
|
||||
}
|
||||
|
||||
@ -183,8 +181,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
VM.Record vmr = vm.getRecord(conn);
|
||||
|
||||
vmNotRunning = vmr.powerState != VmPowerState.RUNNING;
|
||||
}
|
||||
catch (CloudRuntimeException ex) {
|
||||
} catch (CloudRuntimeException ex) {
|
||||
}
|
||||
|
||||
Map<String, String> details = disk.getDetails();
|
||||
@ -206,8 +203,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
return new AttachAnswer(newDisk);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
vdi = hypervisorResource.mount(conn, null, null, data.getPath());
|
||||
}
|
||||
|
||||
@ -289,14 +285,14 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
String isoURL = null;
|
||||
if (store == null) {
|
||||
TemplateObjectTO iso = (TemplateObjectTO)disk.getData();
|
||||
TemplateObjectTO iso = (TemplateObjectTO) disk.getData();
|
||||
isoURL = iso.getName();
|
||||
} else {
|
||||
if (!(store instanceof NfsTO)) {
|
||||
s_logger.debug("Can't attach a iso which is not created on nfs: ");
|
||||
return new AttachAnswer("Can't attach a iso which is not created on nfs: ");
|
||||
}
|
||||
NfsTO nfsStore = (NfsTO)store;
|
||||
NfsTO nfsStore = (NfsTO) store;
|
||||
isoURL = nfsStore.getUrl() + File.separator + data.getPath();
|
||||
}
|
||||
|
||||
@ -364,8 +360,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
VM.Record vmr = vm.getRecord(conn);
|
||||
|
||||
vmNotRunning = vmr.powerState != VmPowerState.RUNNING;
|
||||
}
|
||||
catch (CloudRuntimeException ex) {
|
||||
} catch (CloudRuntimeException ex) {
|
||||
}
|
||||
|
||||
// if the VM is not running and we're not dealing with managed storage, just return success (nothing to do here)
|
||||
@ -450,7 +445,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
@Override
|
||||
public Answer createSnapshot(CreateObjectCommand cmd) {
|
||||
Connection conn = hypervisorResource.getConnection();
|
||||
SnapshotObjectTO snapshotTO = (SnapshotObjectTO)cmd.getData();
|
||||
SnapshotObjectTO snapshotTO = (SnapshotObjectTO) cmd.getData();
|
||||
long snapshotId = snapshotTO.getId();
|
||||
String snapshotName = snapshotTO.getName();
|
||||
String details = "create snapshot operation Failed for snapshotId: " + snapshotId;
|
||||
@ -478,12 +473,12 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
try {
|
||||
String preSnapshotParentUUID = getVhdParent(conn, srUUID, preSnapshotUUID, isISCSI);
|
||||
if( snapshotParentUUID != null && snapshotParentUUID.equals(preSnapshotParentUUID)) {
|
||||
if (snapshotParentUUID != null && snapshotParentUUID.equals(preSnapshotParentUUID)) {
|
||||
// this is empty snapshot, remove it
|
||||
snapshot.destroy(conn);
|
||||
snapshotUUID = preSnapshotUUID;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Failed to get parent snapshot", e);
|
||||
}
|
||||
}
|
||||
@ -558,7 +553,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
if (server.equals(dc.get("server")) && serverpath.equals(dc.get("serverpath"))) {
|
||||
throw new CloudRuntimeException("There is a SR using the same configuration server:" + dc.get("server") + ", serverpath:" + dc.get("serverpath") +
|
||||
" for pool " + pool.getUuid() + "on host:" + hypervisorResource.getHost().uuid);
|
||||
" for pool " + pool.getUuid() + "on host:" + hypervisorResource.getHost().uuid);
|
||||
}
|
||||
|
||||
}
|
||||
@ -622,7 +617,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
if (target.equals(dc.get("target")) && targetiqn.equals(dc.get("targetIQN")) && lunid.equals(dc.get("lunid"))) {
|
||||
throw new CloudRuntimeException("There is a SR using the same configuration target:" + dc.get("target") + ", targetIQN:" + dc.get("targetIQN") +
|
||||
", lunid:" + dc.get("lunid") + " for pool " + pool.getUuid() + "on host:" + hypervisorResource.getHost().uuid);
|
||||
", lunid:" + dc.get("lunid") + " for pool " + pool.getUuid() + "on host:" + hypervisorResource.getHost().uuid);
|
||||
}
|
||||
}
|
||||
deviceConfig.put("target", target);
|
||||
@ -713,8 +708,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
return new Answer(cmd, true, "success");
|
||||
} catch (Exception e) {
|
||||
String msg =
|
||||
"Catch Exception " + e.getClass().getName() + ", create StoragePool failed due to " + e.toString() + " on host:" +
|
||||
hypervisorResource.getHost().uuid + " pool: " + pool.getHost() + pool.getPath();
|
||||
"Catch Exception " + e.getClass().getName() + ", create StoragePool failed due to " + e.toString() + " on host:" +
|
||||
hypervisorResource.getHost().uuid + " pool: " + pool.getHost() + pool.getPath();
|
||||
s_logger.warn(msg, e);
|
||||
return new Answer(cmd, false, msg);
|
||||
}
|
||||
@ -829,8 +824,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
private String copy_vhd_from_secondarystorage(Connection conn, String mountpoint, String sruuid, int wait) {
|
||||
String nameLabel = "cloud-" + UUID.randomUUID().toString();
|
||||
String results =
|
||||
hypervisorResource.callHostPluginAsync(conn, "vmopspremium", "copy_vhd_from_secondarystorage", wait, "mountpoint", mountpoint, "sruuid", sruuid, "namelabel",
|
||||
nameLabel);
|
||||
hypervisorResource.callHostPluginAsync(conn, "vmopspremium", "copy_vhd_from_secondarystorage", wait, "mountpoint", mountpoint, "sruuid", sruuid, "namelabel",
|
||||
nameLabel);
|
||||
String errMsg = null;
|
||||
if (results == null || results.isEmpty()) {
|
||||
errMsg = "copy_vhd_from_secondarystorage return null";
|
||||
@ -880,8 +875,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
protected String getVhdParent(Connection conn, String primaryStorageSRUuid, String snapshotUuid, Boolean isISCSI) {
|
||||
String parentUuid =
|
||||
hypervisorResource.callHostPlugin(conn, "vmopsSnapshot", "getVhdParent", "primaryStorageSRUuid", primaryStorageSRUuid, "snapshotUuid", snapshotUuid,
|
||||
"isISCSI", isISCSI.toString());
|
||||
hypervisorResource.callHostPlugin(conn, "vmopsSnapshot", "getVhdParent", "primaryStorageSRUuid", primaryStorageSRUuid, "snapshotUuid", snapshotUuid,
|
||||
"isISCSI", isISCSI.toString());
|
||||
|
||||
if (parentUuid == null || parentUuid.isEmpty() || parentUuid.equalsIgnoreCase("None")) {
|
||||
s_logger.debug("Unable to get parent of VHD " + snapshotUuid + " in SR " + primaryStorageSRUuid);
|
||||
@ -900,8 +895,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
try {
|
||||
if ((srcDataStoreTo instanceof NfsTO) && (srcDataTo.getObjectType() == DataObjectType.TEMPLATE)) {
|
||||
NfsTO srcImageStore = (NfsTO)srcDataStoreTo;
|
||||
TemplateObjectTO srcTemplateObjectTo = (TemplateObjectTO)srcDataTo;
|
||||
NfsTO srcImageStore = (NfsTO) srcDataStoreTo;
|
||||
TemplateObjectTO srcTemplateObjectTo = (TemplateObjectTO) srcDataTo;
|
||||
String storeUrl = srcImageStore.getUrl();
|
||||
URI uri = new URI(storeUrl);
|
||||
String tmplPath = uri.getHost() + ":" + uri.getPath() + "/" + srcDataTo.getPath();
|
||||
@ -916,7 +911,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
String chapInitiatorSecret = null;
|
||||
|
||||
if (destDataStoreTo instanceof PrimaryDataStoreTO) {
|
||||
PrimaryDataStoreTO destPrimaryDataStoreTo = (PrimaryDataStoreTO)destDataStoreTo;
|
||||
PrimaryDataStoreTO destPrimaryDataStoreTo = (PrimaryDataStoreTO) destDataStoreTo;
|
||||
|
||||
Map<String, String> details = destPrimaryDataStoreTo.getDetails();
|
||||
|
||||
@ -948,8 +943,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
details.put(DiskTO.CHAP_INITIATOR_SECRET, chapInitiatorSecret);
|
||||
|
||||
sr = hypervisorResource.prepareManagedSr(conn, details);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
String srName = destDataStoreTo.getUuid();
|
||||
Set<SR> srs = SR.getByNameLabel(conn, srName);
|
||||
|
||||
@ -974,8 +968,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
uuidToReturn = tmplUuid;
|
||||
|
||||
tmplVdi.setNameLabel(conn, managedStoragePoolRootVolumeName);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
VDI snapshotVdi = tmplVdi.snapshot(conn, new HashMap<String, String>());
|
||||
|
||||
uuidToReturn = snapshotVdi.getUuid(conn);
|
||||
@ -1014,7 +1007,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
@Override
|
||||
public Answer createVolume(CreateObjectCommand cmd) {
|
||||
DataTO data = cmd.getData();
|
||||
VolumeObjectTO volume = (VolumeObjectTO)data;
|
||||
VolumeObjectTO volume = (VolumeObjectTO) data;
|
||||
|
||||
try {
|
||||
Connection conn = hypervisorResource.getConnection();
|
||||
@ -1046,7 +1039,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
Connection conn = hypervisorResource.getConnection();
|
||||
DataTO srcData = cmd.getSrcTO();
|
||||
DataTO destData = cmd.getDestTO();
|
||||
VolumeObjectTO volume = (VolumeObjectTO)destData;
|
||||
VolumeObjectTO volume = (VolumeObjectTO) destData;
|
||||
VDI vdi = null;
|
||||
try {
|
||||
VDI tmpltvdi = null;
|
||||
@ -1077,12 +1070,12 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
DataTO srcData = cmd.getSrcTO();
|
||||
DataTO destData = cmd.getDestTO();
|
||||
int wait = cmd.getWait();
|
||||
VolumeObjectTO srcVolume = (VolumeObjectTO)srcData;
|
||||
VolumeObjectTO destVolume = (VolumeObjectTO)destData;
|
||||
VolumeObjectTO srcVolume = (VolumeObjectTO) srcData;
|
||||
VolumeObjectTO destVolume = (VolumeObjectTO) destData;
|
||||
DataStoreTO srcStore = srcVolume.getDataStore();
|
||||
|
||||
if (srcStore instanceof NfsTO) {
|
||||
NfsTO nfsStore = (NfsTO)srcStore;
|
||||
NfsTO nfsStore = (NfsTO) srcStore;
|
||||
try {
|
||||
SR primaryStoragePool = hypervisorResource.getStorageRepository(conn, destVolume.getDataStore().getUuid());
|
||||
String srUuid = primaryStoragePool.getUuid(conn);
|
||||
@ -1108,15 +1101,15 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
@Override
|
||||
public Answer copyVolumeFromPrimaryToSecondary(CopyCommand cmd) {
|
||||
Connection conn = hypervisorResource.getConnection();
|
||||
VolumeObjectTO srcVolume = (VolumeObjectTO)cmd.getSrcTO();
|
||||
VolumeObjectTO destVolume = (VolumeObjectTO)cmd.getDestTO();
|
||||
VolumeObjectTO srcVolume = (VolumeObjectTO) cmd.getSrcTO();
|
||||
VolumeObjectTO destVolume = (VolumeObjectTO) cmd.getDestTO();
|
||||
int wait = cmd.getWait();
|
||||
DataStoreTO destStore = destVolume.getDataStore();
|
||||
|
||||
if (destStore instanceof NfsTO) {
|
||||
SR secondaryStorage = null;
|
||||
try {
|
||||
NfsTO nfsStore = (NfsTO)destStore;
|
||||
NfsTO nfsStore = (NfsTO) destStore;
|
||||
URI uri = new URI(nfsStore.getUrl());
|
||||
// Create the volume folder
|
||||
if (!hypervisorResource.createSecondaryStorageFolder(conn, uri.getHost() + ":" + uri.getPath(), destVolume.getPath())) {
|
||||
@ -1149,8 +1142,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
String result = null;
|
||||
try {
|
||||
result =
|
||||
hypervisorResource.callHostPluginAsync(conn, "swiftxen", "swift", wait, "op", "upload", "url", swift.getUrl(), "account", swift.getAccount(), "username",
|
||||
swift.getUserName(), "key", swift.getKey(), "container", container, "ldir", ldir, "lfilename", lfilename, "isISCSI", isISCSI.toString());
|
||||
hypervisorResource.callHostPluginAsync(conn, "swiftxen", "swift", wait, "op", "upload", "url", swift.getUrl(), "account", swift.getAccount(), "username",
|
||||
swift.getUserName(), "key", swift.getKey(), "container", container, "ldir", ldir, "lfilename", lfilename, "isISCSI", isISCSI.toString());
|
||||
if (result != null && result.equals("true")) {
|
||||
return true;
|
||||
}
|
||||
@ -1164,8 +1157,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
// If anybody modifies the formatting below again, I'll skin them
|
||||
String result =
|
||||
hypervisorResource.callHostPlugin(conn, "vmopsSnapshot", "deleteSnapshotBackup", "backupUUID", backupUUID, "path", path, "secondaryStorageMountPath",
|
||||
secondaryStorageMountPath, "localMountPoint", localMountPoint);
|
||||
hypervisorResource.callHostPlugin(conn, "vmopsSnapshot", "deleteSnapshotBackup", "backupUUID", backupUUID, "path", path, "secondaryStorageMountPath",
|
||||
secondaryStorageMountPath, "localMountPoint", localMountPoint);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1185,7 +1178,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
|
||||
protected String backupSnapshotToS3(final Connection connection, final S3TO s3, final String srUuid, final String folder, final String snapshotUuid,
|
||||
final Boolean iSCSIFlag, final int wait) {
|
||||
final Boolean iSCSIFlag, final int wait) {
|
||||
|
||||
final String filename = iSCSIFlag ? "VHD-" + snapshotUuid : snapshotUuid + ".vhd";
|
||||
final String dir = (iSCSIFlag ? "/dev/VG_XenStorage-" : "/var/run/sr-mount/") + srUuid;
|
||||
@ -1198,7 +1191,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
// recognize Boolean accessor methods ...
|
||||
|
||||
parameters.addAll(Arrays.asList("operation", "put", "filename", dir + "/" + filename, "iSCSIFlag", iSCSIFlag.toString(), "bucket", s3.getBucketName(), "key",
|
||||
key, "https", s3.isHttps() != null ? s3.isHttps().toString() : "null", "maxSingleUploadSizeInBytes", String.valueOf(s3.getMaxSingleUploadSizeInBytes())));
|
||||
key, "https", s3.isHttps() != null ? s3.isHttps().toString() : "null", "maxSingleUploadSizeInBytes", String.valueOf(s3.getMaxSingleUploadSizeInBytes())));
|
||||
final String result = hypervisorResource.callHostPluginAsync(connection, "s3xen", "s3", wait, parameters.toArray(new String[parameters.size()]));
|
||||
|
||||
if (result != null && result.equals("true")) {
|
||||
@ -1225,7 +1218,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
|
||||
protected String backupSnapshot(Connection conn, String primaryStorageSRUuid, String localMountPoint, String path, String secondaryStorageMountPath,
|
||||
String snapshotUuid, String prevBackupUuid, Boolean isISCSI, int wait) {
|
||||
String snapshotUuid, String prevBackupUuid, Boolean isISCSI, int wait) {
|
||||
String backupSnapshotUuid = null;
|
||||
|
||||
if (prevBackupUuid == null) {
|
||||
@ -1236,14 +1229,14 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
// Using more lines does not harm the environment.
|
||||
String backupUuid = UUID.randomUUID().toString();
|
||||
String results =
|
||||
hypervisorResource.callHostPluginAsync(conn, "vmopsSnapshot", "backupSnapshot", wait, "primaryStorageSRUuid", primaryStorageSRUuid, "path", path,
|
||||
"secondaryStorageMountPath", secondaryStorageMountPath, "snapshotUuid", snapshotUuid, "prevBackupUuid", prevBackupUuid, "backupUuid", backupUuid,
|
||||
"isISCSI", isISCSI.toString(), "localMountPoint", localMountPoint);
|
||||
hypervisorResource.callHostPluginAsync(conn, "vmopsSnapshot", "backupSnapshot", wait, "primaryStorageSRUuid", primaryStorageSRUuid, "path", path,
|
||||
"secondaryStorageMountPath", secondaryStorageMountPath, "snapshotUuid", snapshotUuid, "prevBackupUuid", prevBackupUuid, "backupUuid", backupUuid,
|
||||
"isISCSI", isISCSI.toString(), "localMountPoint", localMountPoint);
|
||||
String errMsg = null;
|
||||
if (results == null || results.isEmpty()) {
|
||||
errMsg =
|
||||
"Could not copy backupUuid: " + backupSnapshotUuid + " from primary storage " + primaryStorageSRUuid + " to secondary storage " +
|
||||
secondaryStorageMountPath + " due to null";
|
||||
"Could not copy backupUuid: " + backupSnapshotUuid + " from primary storage " + primaryStorageSRUuid + " to secondary storage " +
|
||||
secondaryStorageMountPath + " due to null";
|
||||
} else {
|
||||
|
||||
String[] tmp = results.split("#");
|
||||
@ -1257,8 +1250,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
return results;
|
||||
} else {
|
||||
errMsg =
|
||||
"Could not copy backupUuid: " + backupSnapshotUuid + " from primary storage " + primaryStorageSRUuid + " to secondary storage " +
|
||||
secondaryStorageMountPath + " due to " + tmp[1];
|
||||
"Could not copy backupUuid: " + backupSnapshotUuid + " from primary storage " + primaryStorageSRUuid + " to secondary storage " +
|
||||
secondaryStorageMountPath + " due to " + tmp[1];
|
||||
}
|
||||
}
|
||||
String source = backupUuid + ".vhd";
|
||||
@ -1329,17 +1322,17 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
NfsTO cacheStore = null;
|
||||
String destPath = null;
|
||||
if (cacheData != null) {
|
||||
cacheStore = (NfsTO)cacheData.getDataStore();
|
||||
cacheStore = (NfsTO) cacheData.getDataStore();
|
||||
secondaryStorageUrl = cacheStore.getUrl();
|
||||
destPath = cacheData.getPath();
|
||||
} else {
|
||||
cacheStore = (NfsTO)destData.getDataStore();
|
||||
cacheStore = (NfsTO) destData.getDataStore();
|
||||
secondaryStorageUrl = cacheStore.getUrl();
|
||||
destPath = destData.getPath();
|
||||
}
|
||||
|
||||
SnapshotObjectTO snapshotTO = (SnapshotObjectTO)srcData;
|
||||
SnapshotObjectTO snapshotOnImage = (SnapshotObjectTO)destData;
|
||||
SnapshotObjectTO snapshotTO = (SnapshotObjectTO) srcData;
|
||||
SnapshotObjectTO snapshotOnImage = (SnapshotObjectTO) destData;
|
||||
String snapshotUuid = snapshotTO.getPath();
|
||||
String volumeUuid = snapshotTO.getVolume().getPath();
|
||||
|
||||
@ -1357,7 +1350,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
SR primaryStorageSR = hypervisorResource.getSRByNameLabelandHost(conn, primaryStorageNameLabel);
|
||||
if (primaryStorageSR == null) {
|
||||
throw new InternalErrorException("Could not backup snapshot because the primary Storage SR could not be created from the name label: " +
|
||||
primaryStorageNameLabel);
|
||||
primaryStorageNameLabel);
|
||||
}
|
||||
String psUuid = primaryStorageSR.getUuid(conn);
|
||||
Boolean isISCSI = IsISCSI(primaryStorageSR.getType(conn));
|
||||
@ -1365,7 +1358,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
VDI snapshotVdi = getVDIbyUuid(conn, snapshotUuid);
|
||||
String snapshotPaUuid = null;
|
||||
|
||||
if ( prevSnapshotUuid != null && !fullbackup) {
|
||||
if (prevSnapshotUuid != null && !fullbackup) {
|
||||
try {
|
||||
snapshotPaUuid = getVhdParent(conn, psUuid, snapshotUuid, isISCSI);
|
||||
if (snapshotPaUuid != null) {
|
||||
@ -1410,7 +1403,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
if (destStore instanceof SwiftTO) {
|
||||
try {
|
||||
String container = "S-" + snapshotTO.getVolume().getVolumeId().toString();
|
||||
String destSnapshotName = swiftBackupSnapshot(conn, (SwiftTO)destStore, snapshotSr.getUuid(conn), snapshotBackupUuid, container, false, wait);
|
||||
String destSnapshotName = swiftBackupSnapshot(conn, (SwiftTO) destStore, snapshotSr.getUuid(conn), snapshotBackupUuid, container, false, wait);
|
||||
String swiftPath = container + File.separator + destSnapshotName;
|
||||
finalPath = swiftPath;
|
||||
} finally {
|
||||
@ -1423,7 +1416,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
} else if (destStore instanceof S3TO) {
|
||||
try {
|
||||
finalPath = backupSnapshotToS3(conn, (S3TO)destStore, snapshotSr.getUuid(conn), folder, snapshotBackupUuid, isISCSI, wait);
|
||||
finalPath = backupSnapshotToS3(conn, (S3TO) destStore, snapshotSr.getUuid(conn), folder, snapshotBackupUuid, isISCSI, wait);
|
||||
if (finalPath == null) {
|
||||
throw new CloudRuntimeException("S3 upload of snapshots " + snapshotBackupUuid + " failed");
|
||||
}
|
||||
@ -1449,17 +1442,17 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
if (destStore instanceof SwiftTO) {
|
||||
String container = "S-" + snapshotTO.getVolume().getVolumeId().toString();
|
||||
snapshotBackupUuid =
|
||||
swiftBackupSnapshot(conn, (SwiftTO)destStore, primaryStorageSRUuid, snapshotPaUuid, "S-" + snapshotTO.getVolume().getVolumeId().toString(),
|
||||
isISCSI, wait);
|
||||
swiftBackupSnapshot(conn, (SwiftTO) destStore, primaryStorageSRUuid, snapshotPaUuid, "S-" + snapshotTO.getVolume().getVolumeId().toString(),
|
||||
isISCSI, wait);
|
||||
finalPath = container + File.separator + snapshotBackupUuid;
|
||||
} else if (destStore instanceof S3TO) {
|
||||
finalPath = backupSnapshotToS3(conn, (S3TO)destStore, primaryStorageSRUuid, folder, snapshotPaUuid, isISCSI, wait);
|
||||
finalPath = backupSnapshotToS3(conn, (S3TO) destStore, primaryStorageSRUuid, folder, snapshotPaUuid, isISCSI, wait);
|
||||
if (finalPath == null) {
|
||||
throw new CloudRuntimeException("S3 upload of snapshots " + snapshotPaUuid + " failed");
|
||||
}
|
||||
} else {
|
||||
String results =
|
||||
backupSnapshot(conn, primaryStorageSRUuid, localMountPoint, folder, secondaryStorageMountPath, snapshotUuid, prevBackupUuid, isISCSI, wait);
|
||||
backupSnapshot(conn, primaryStorageSRUuid, localMountPoint, folder, secondaryStorageMountPath, snapshotUuid, prevBackupUuid, isISCSI, wait);
|
||||
|
||||
String[] tmp = results.split("#");
|
||||
snapshotBackupUuid = tmp[1];
|
||||
@ -1503,9 +1496,9 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
@Override
|
||||
public Answer createTemplateFromVolume(CopyCommand cmd) {
|
||||
Connection conn = hypervisorResource.getConnection();
|
||||
VolumeObjectTO volume = (VolumeObjectTO)cmd.getSrcTO();
|
||||
TemplateObjectTO template = (TemplateObjectTO)cmd.getDestTO();
|
||||
NfsTO destStore = (NfsTO)cmd.getDestTO().getDataStore();
|
||||
VolumeObjectTO volume = (VolumeObjectTO) cmd.getSrcTO();
|
||||
TemplateObjectTO template = (TemplateObjectTO) cmd.getDestTO();
|
||||
NfsTO destStore = (NfsTO) cmd.getDestTO().getDataStore();
|
||||
int wait = cmd.getWait();
|
||||
|
||||
String secondaryStoragePoolURL = destStore.getUrl();
|
||||
@ -1548,8 +1541,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
// create the template.properties file
|
||||
String templatePath = secondaryStorageMountPath + "/" + installPath;
|
||||
result =
|
||||
hypervisorResource.postCreatePrivateTemplate(conn, templatePath, tmpltFilename, tmpltUUID, userSpecifiedName, null, physicalSize, virtualSize,
|
||||
template.getId());
|
||||
hypervisorResource.postCreatePrivateTemplate(conn, templatePath, tmpltFilename, tmpltUUID, userSpecifiedName, null, physicalSize, virtualSize,
|
||||
template.getId());
|
||||
if (!result) {
|
||||
throw new CloudRuntimeException("Could not create the template.properties file on secondary storage dir: " + tmpltURI);
|
||||
}
|
||||
@ -1586,7 +1579,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
public Answer createVolumeFromSnapshot(CopyCommand cmd) {
|
||||
Connection conn = hypervisorResource.getConnection();
|
||||
DataTO srcData = cmd.getSrcTO();
|
||||
SnapshotObjectTO snapshot = (SnapshotObjectTO)srcData;
|
||||
SnapshotObjectTO snapshot = (SnapshotObjectTO) srcData;
|
||||
DataTO destData = cmd.getDestTO();
|
||||
DataStoreTO imageStore = srcData.getDataStore();
|
||||
|
||||
@ -1594,7 +1587,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
return new CopyCmdAnswer("unsupported protocol");
|
||||
}
|
||||
|
||||
NfsTO nfsImageStore = (NfsTO)imageStore;
|
||||
NfsTO nfsImageStore = (NfsTO) imageStore;
|
||||
String primaryStorageNameLabel = destData.getDataStore().getUuid();
|
||||
String secondaryStorageUrl = nfsImageStore.getUrl();
|
||||
int wait = cmd.getWait();
|
||||
@ -1611,7 +1604,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
SR primaryStorageSR = hypervisorResource.getSRByNameLabelandHost(conn, primaryStorageNameLabel);
|
||||
if (primaryStorageSR == null) {
|
||||
throw new InternalErrorException("Could not create volume from snapshot because the primary Storage SR could not be created from the name label: " +
|
||||
primaryStorageNameLabel);
|
||||
primaryStorageNameLabel);
|
||||
}
|
||||
// Get the absolute path of the snapshot on the secondary storage.
|
||||
String snapshotInstallPath = snapshot.getPath();
|
||||
@ -1650,7 +1643,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
||||
|
||||
@Override
|
||||
public Answer deleteSnapshot(DeleteCommand cmd) {
|
||||
SnapshotObjectTO snapshot = (SnapshotObjectTO)cmd.getData();
|
||||
SnapshotObjectTO snapshot = (SnapshotObjectTO) cmd.getData();
|
||||
DataStoreTO store = snapshot.getDataStore();
|
||||
if (store.getRole() == DataStoreRole.Primary) {
|
||||
Connection conn = hypervisorResource.getConnection();
|
||||
|
||||
@ -24,7 +24,6 @@ import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||
@ -149,10 +148,13 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean connectVolumeToHost(VolumeInfo volumeInfo, Host host, DataStore dataStore) { return false; }
|
||||
public boolean connectVolumeToHost(VolumeInfo volumeInfo, Host host, DataStore dataStore) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore) {}
|
||||
public void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool pool) {
|
||||
@ -166,7 +168,7 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
|
||||
CreateCmdResult result = new CreateCmdResult(null, null);
|
||||
if (data.getType() == DataObjectType.VOLUME) {
|
||||
try {
|
||||
answer = createVolume((VolumeInfo)data);
|
||||
answer = createVolume((VolumeInfo) data);
|
||||
if ((answer == null) || (!answer.getResult())) {
|
||||
result.setSuccess(false);
|
||||
if (answer != null) {
|
||||
@ -258,7 +260,7 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
|
||||
DataStore store = destData.getDataStore();
|
||||
if (store.getRole() == DataStoreRole.Primary) {
|
||||
if ((srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.TEMPLATE) ||
|
||||
(srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.VOLUME)) {
|
||||
(srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.VOLUME)) {
|
||||
StoragePoolVO storagePoolVO = primaryStoreDao.findById(store.getId());
|
||||
if (storagePoolVO != null && storagePoolVO.getPoolType() == Storage.StoragePoolType.CLVM) {
|
||||
return true;
|
||||
@ -272,10 +274,10 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
|
||||
public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback) {
|
||||
CreateCmdResult result = null;
|
||||
try {
|
||||
SnapshotObjectTO snapshotTO = (SnapshotObjectTO)snapshot.getTO();
|
||||
SnapshotObjectTO snapshotTO = (SnapshotObjectTO) snapshot.getTO();
|
||||
Object payload = snapshot.getPayload();
|
||||
if (payload != null && payload instanceof CreateSnapshotPayload) {
|
||||
CreateSnapshotPayload snapshotPayload = (CreateSnapshotPayload)payload;
|
||||
CreateSnapshotPayload snapshotPayload = (CreateSnapshotPayload) payload;
|
||||
snapshotTO.setQuiescevm(snapshotPayload.getQuiescevm());
|
||||
}
|
||||
|
||||
@ -283,7 +285,7 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
|
||||
EndPoint ep = this.epSelector.select(snapshot, StorageAction.TAKESNAPSHOT);
|
||||
Answer answer = null;
|
||||
|
||||
if ( ep == null ){
|
||||
if (ep == null) {
|
||||
String errMsg = "No remote endpoint to send createObjectCommand, check if host or ssvm is down?";
|
||||
s_logger.error(errMsg);
|
||||
answer = new Answer(cmd, false, errMsg);
|
||||
@ -312,16 +314,16 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
|
||||
|
||||
@Override
|
||||
public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
|
||||
VolumeObject vol = (VolumeObject)data;
|
||||
StoragePool pool = (StoragePool)data.getDataStore();
|
||||
ResizeVolumePayload resizeParameter = (ResizeVolumePayload)vol.getpayload();
|
||||
VolumeObject vol = (VolumeObject) data;
|
||||
StoragePool pool = (StoragePool) data.getDataStore();
|
||||
ResizeVolumePayload resizeParameter = (ResizeVolumePayload) vol.getpayload();
|
||||
|
||||
ResizeVolumeCommand resizeCmd =
|
||||
new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), vol.getSize(), resizeParameter.newSize, resizeParameter.shrinkOk,
|
||||
resizeParameter.instanceName);
|
||||
new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), vol.getSize(), resizeParameter.newSize, resizeParameter.shrinkOk,
|
||||
resizeParameter.instanceName);
|
||||
CreateCmdResult result = new CreateCmdResult(null, null);
|
||||
try {
|
||||
ResizeVolumeAnswer answer = (ResizeVolumeAnswer)storageMgr.sendToPool(pool, resizeParameter.hosts, resizeCmd);
|
||||
ResizeVolumeAnswer answer = (ResizeVolumeAnswer) storageMgr.sendToPool(pool, resizeParameter.hosts, resizeCmd);
|
||||
if (answer != null && answer.getResult()) {
|
||||
long finalSize = answer.getNewSize();
|
||||
s_logger.debug("Resize: volume started at size " + vol.getSize() + " and ended at size " + finalSize);
|
||||
|
||||
@ -26,10 +26,6 @@ import java.util.Set;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
@ -92,8 +88,15 @@ import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.query.QueryService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.api.query.dao.AccountJoinDao;
|
||||
import com.cloud.api.query.dao.AffinityGroupJoinDao;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user