mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Don't use cast to PrimarydataStoreTO on the resource code
This commit is contained in:
parent
b6576d7c98
commit
7c99b88926
@ -21,6 +21,7 @@ package com.cloud.agent.api.to;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
|
||||
public interface DataStoreTO {
|
||||
public DataStoreRole getRole();
|
||||
public String getUuid();
|
||||
DataStoreRole getRole();
|
||||
String getUuid();
|
||||
String getUrl();
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ public class NfsTO implements DataStoreTO {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return _url;
|
||||
}
|
||||
|
||||
@ -83,6 +83,11 @@ public class ImageStoreTO implements DataStoreTO {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return getUri();
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.storage.to;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||
|
||||
import com.cloud.agent.api.to.DataStoreTO;
|
||||
@ -31,8 +32,9 @@ public class PrimaryDataStoreTO implements DataStoreTO {
|
||||
private String host;
|
||||
private String path;
|
||||
private int port;
|
||||
private final String url;
|
||||
|
||||
public PrimaryDataStoreTO(PrimaryDataStoreInfo dataStore) {
|
||||
public PrimaryDataStoreTO(PrimaryDataStore dataStore) {
|
||||
this.uuid = dataStore.getUuid();
|
||||
this.name = dataStore.getName();
|
||||
this.id = dataStore.getId();
|
||||
@ -40,6 +42,7 @@ public class PrimaryDataStoreTO implements DataStoreTO {
|
||||
this.setHost(dataStore.getHostAddress());
|
||||
this.setPath(dataStore.getPath());
|
||||
this.setPort(dataStore.getPort());
|
||||
this.url = dataStore.getUri();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
@ -51,6 +54,11 @@ public class PrimaryDataStoreTO implements DataStoreTO {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -40,7 +40,7 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.framework.async.AsyncRpcContext;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
|
||||
|
||||
public interface PrimaryDataStoreProviderManager {
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
package org.apache.cloudstack.storage.volume;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||
|
||||
public interface TemplateOnPrimaryDataStoreInfo {
|
||||
public String getPath();
|
||||
|
||||
@ -103,7 +103,7 @@
|
||||
</display>
|
||||
</class>
|
||||
<interface id="9" corner="BOTTOM_RIGHT" language="java"
|
||||
name="org.apache.cloudstack.storage.datastore.PrimaryDataStore" project="cloud-engine-storage"
|
||||
name="org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore" project="cloud-engine-storage"
|
||||
file="/cloud-engine-storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java" binary="false">
|
||||
<position height="-1" width="-1" x="770" y="-4"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" visibility="true">
|
||||
|
||||
@ -23,23 +23,9 @@ import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.*;
|
||||
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;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
|
||||
@ -29,7 +29,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManag
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreImpl;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
|
||||
@ -76,7 +76,7 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
|
||||
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
|
||||
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
|
||||
|
||||
@ -37,7 +37,6 @@ import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||
import org.apache.cloudstack.storage.command.DettachCommand;
|
||||
import org.apache.cloudstack.storage.command.ForgetObjectCmd;
|
||||
import org.apache.cloudstack.storage.command.IntroduceObjectCmd;
|
||||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
||||
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
@ -194,7 +193,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
NfsTO nfsImageStore = (NfsTO)srcStore;
|
||||
DataTO destData = cmd.getDestTO();
|
||||
DataStoreTO destStore = destData.getDataStore();
|
||||
PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)destStore;
|
||||
DataStoreTO primaryStore = destStore;
|
||||
String secondaryStorageUrl = nfsImageStore.getUrl();
|
||||
assert (secondaryStorageUrl != null);
|
||||
|
||||
@ -310,8 +309,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
TemplateObjectTO template = (TemplateObjectTO)srcData;
|
||||
DataTO destData = cmd.getDestTO();
|
||||
VolumeObjectTO volume = (VolumeObjectTO)destData;
|
||||
PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)volume.getDataStore();
|
||||
PrimaryDataStoreTO srcStore = (PrimaryDataStoreTO)template.getDataStore();
|
||||
DataStoreTO primaryStore = volume.getDataStore();
|
||||
DataStoreTO srcStore = template.getDataStore();
|
||||
|
||||
try {
|
||||
VmwareContext context = hostService.getServiceContext(null);
|
||||
@ -450,20 +449,22 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
try {
|
||||
|
||||
NfsTO srcStore = (NfsTO)srcVolume.getDataStore();
|
||||
PrimaryDataStoreTO destStore = (PrimaryDataStoreTO)destVolume.getDataStore();
|
||||
DataStoreTO destStore = destVolume.getDataStore();
|
||||
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||
String uuid = destStore.getUuid();
|
||||
|
||||
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, uuid);
|
||||
if (morDatastore == null) {
|
||||
URI uri = new URI(destStore.getUrl());
|
||||
|
||||
morDatastore = hyperHost.mountDatastore(
|
||||
false,
|
||||
destStore.getHost(), 0, destStore.getPath(),
|
||||
uri.getHost(), 0, uri.getPath(),
|
||||
destStore.getUuid().replace("-", ""));
|
||||
|
||||
if (morDatastore == null) {
|
||||
throw new Exception("Unable to mount storage pool on host. storeUrl: " + destStore.getHost() + ":/" + destStore.getPath());
|
||||
throw new Exception("Unable to mount storage pool on host. storeUrl: " + uri.getHost() + ":/" + uri.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,7 +552,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
VmwareContext context = hostService.getServiceContext(cmd);
|
||||
try {
|
||||
PrimaryDataStoreTO primaryStorage = (PrimaryDataStoreTO)srcVolume.getDataStore();
|
||||
DataStoreTO primaryStorage = srcVolume.getDataStore();
|
||||
NfsTO destStore = (NfsTO)destVolume.getDataStore();
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||
|
||||
@ -998,7 +999,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
@Override
|
||||
public Answer backupSnapshot(CopyCommand cmd) {
|
||||
SnapshotObjectTO srcSnapshot = (SnapshotObjectTO)cmd.getSrcTO();
|
||||
PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)srcSnapshot.getDataStore();
|
||||
DataStoreTO primaryStore = srcSnapshot.getDataStore();
|
||||
SnapshotObjectTO destSnapshot = (SnapshotObjectTO)cmd.getDestTO();
|
||||
DataStoreTO destStore = destSnapshot.getDataStore();
|
||||
if (!(destStore instanceof NfsTO)) {
|
||||
@ -1180,7 +1181,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
private Answer attachVolume(Command cmd, DiskTO disk, boolean isAttach, boolean isManaged, String vmName, String iScsiName, String storageHost, int storagePort) {
|
||||
VolumeObjectTO volumeTO = (VolumeObjectTO)disk.getData();
|
||||
PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)volumeTO.getDataStore();
|
||||
DataStoreTO primaryStore = volumeTO.getDataStore();
|
||||
try {
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(hostService.getServiceContext(null), null);
|
||||
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
|
||||
@ -1382,7 +1383,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
public Answer createVolume(CreateObjectCommand cmd) {
|
||||
|
||||
VolumeObjectTO volume = (VolumeObjectTO)cmd.getData();
|
||||
PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)volume.getDataStore();
|
||||
DataStoreTO primaryStore = volume.getDataStore();
|
||||
|
||||
try {
|
||||
VmwareContext context = hostService.getServiceContext(null);
|
||||
@ -1459,11 +1460,11 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
VmwareContext context = hostService.getServiceContext(null);
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
|
||||
VolumeObjectTO vol = (VolumeObjectTO)cmd.getData();
|
||||
PrimaryDataStoreTO store = (PrimaryDataStoreTO)vol.getDataStore();
|
||||
DataStoreTO store = vol.getDataStore();
|
||||
|
||||
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, store.getUuid());
|
||||
if (morDs == null) {
|
||||
String msg = "Unable to find datastore based on volume mount point " + store.getPath();
|
||||
String msg = "Unable to find datastore based on volume mount point " + store.getUuid();
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
@ -1674,7 +1675,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
DataTO srcData = cmd.getSrcTO();
|
||||
SnapshotObjectTO snapshot = (SnapshotObjectTO)srcData;
|
||||
DataTO destData = cmd.getDestTO();
|
||||
PrimaryDataStoreTO pool = (PrimaryDataStoreTO)destData.getDataStore();
|
||||
DataStoreTO pool = destData.getDataStore();
|
||||
DataStoreTO imageStore = srcData.getDataStore();
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user