mirror of https://github.com/apache/cloudstack.git
clean up storage related coded
This commit is contained in:
parent
2616115ff9
commit
0a5228922b
|
|
@ -20,19 +20,18 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import com.cloud.storage.ScopeType;
|
||||
|
||||
|
||||
public class ClusterScope extends AbstractScope {
|
||||
private ScopeType type = ScopeType.CLUSTER;
|
||||
private Long clusterId;
|
||||
private Long podId;
|
||||
private Long zoneId;
|
||||
|
||||
|
||||
public ClusterScope(Long clusterId, Long podId, Long zoneId) {
|
||||
this.clusterId = clusterId;
|
||||
this.podId = podId;
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ScopeType getScopeType() {
|
||||
return this.type;
|
||||
|
|
@ -42,11 +41,11 @@ public class ClusterScope extends AbstractScope {
|
|||
public Long getScopeId() {
|
||||
return this.clusterId;
|
||||
}
|
||||
|
||||
|
||||
public Long getPodId() {
|
||||
return this.podId;
|
||||
}
|
||||
|
||||
|
||||
public Long getZoneId() {
|
||||
return this.zoneId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,17 +25,18 @@ import com.cloud.agent.api.Answer;
|
|||
public class CopyCommandResult extends CommandResult {
|
||||
private final String path;
|
||||
private final Answer answer;
|
||||
|
||||
public CopyCommandResult(String path, Answer answer) {
|
||||
super();
|
||||
this.path = path;
|
||||
this.answer = answer;
|
||||
}
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
|
||||
public Answer getAnswer() {
|
||||
return this.answer;
|
||||
return this.answer;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,12 +25,13 @@ import com.cloud.agent.api.Answer;
|
|||
public class CreateCmdResult extends CommandResult {
|
||||
private String path;
|
||||
private Answer answer;
|
||||
|
||||
public CreateCmdResult(String path, Answer answer) {
|
||||
super();
|
||||
this.path = path;
|
||||
this.answer = answer;
|
||||
}
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,5 +25,6 @@ import com.cloud.org.Grouping;
|
|||
public interface DataMigrationSubSystem {
|
||||
|
||||
Class<? extends Grouping> getScopeCoverage();
|
||||
|
||||
void migrate(URI source, URI dest, String reservationId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
|
|
@ -27,10 +26,9 @@ import com.cloud.agent.api.to.VirtualMachineTO;
|
|||
import com.cloud.host.Host;
|
||||
|
||||
public interface DataMotionService {
|
||||
public void copyAsync(DataObject srcData, DataObject destData,
|
||||
public void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
|
||||
|
||||
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
|
||||
AsyncCompletionCallback<CopyCommandResult> callback);
|
||||
|
||||
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo,
|
||||
Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
|
|
@ -26,14 +25,12 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
|||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.host.Host;
|
||||
|
||||
|
||||
public interface DataMotionStrategy {
|
||||
public boolean canHandle(DataObject srcData, DataObject destData);
|
||||
|
||||
public boolean canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost);
|
||||
|
||||
public Void copyAsync(DataObject srcData, DataObject destData,
|
||||
AsyncCompletionCallback<CopyCommandResult> callback);
|
||||
public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
|
||||
|
||||
public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
|
||||
AsyncCompletionCallback<CopyCommandResult> callback);
|
||||
|
|
|
|||
|
|
@ -24,13 +24,21 @@ import com.cloud.agent.api.to.DataTO;
|
|||
|
||||
public interface DataObject {
|
||||
public long getId();
|
||||
|
||||
public String getUri();
|
||||
|
||||
public DataTO getTO();
|
||||
|
||||
public DataStore getDataStore();
|
||||
|
||||
public Long getSize();
|
||||
|
||||
public DataObjectType getType();
|
||||
//public DiskFormat getFormat();
|
||||
|
||||
// public DiskFormat getFormat();
|
||||
public String getUuid();
|
||||
|
||||
public void processEvent(ObjectInDataStoreStateMachine.Event event);
|
||||
|
||||
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,14 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
|
||||
public interface DataObjectInStore extends StateObject<ObjectInDataStoreStateMachine.State> {
|
||||
public String getInstallPath();
|
||||
|
||||
public void setInstallPath(String path);
|
||||
|
||||
public long getObjectId();
|
||||
|
||||
public long getDataStoreId();
|
||||
|
||||
public ObjectInDataStoreStateMachine.State getObjectInStoreState();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,22 @@ import com.cloud.storage.DataStoreRole;
|
|||
|
||||
public interface DataStore {
|
||||
DataStoreDriver getDriver();
|
||||
|
||||
DataStoreRole getRole();
|
||||
|
||||
long getId();
|
||||
|
||||
String getUuid();
|
||||
|
||||
String getUri();
|
||||
|
||||
Scope getScope();
|
||||
|
||||
String getName();
|
||||
|
||||
DataObject create(DataObject obj);
|
||||
|
||||
boolean delete(DataObject obj);
|
||||
|
||||
DataStoreTO getTO();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,22 @@ import com.cloud.agent.api.to.DataTO;
|
|||
|
||||
public interface DataStoreDriver {
|
||||
public String grantAccess(DataObject data, EndPoint ep);
|
||||
|
||||
public boolean revokeAccess(DataObject data, EndPoint ep);
|
||||
|
||||
public Set<DataObject> listObjects(DataStore store);
|
||||
|
||||
public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
|
||||
|
||||
public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback);
|
||||
|
||||
public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
|
||||
|
||||
public boolean canCopy(DataObject srcData, DataObject destData);
|
||||
|
||||
public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
|
||||
|
||||
public DataTO getTO(DataObject data);
|
||||
|
||||
public DataStoreTO getStoreTO(DataStore store);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,13 @@ import java.util.Map;
|
|||
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
|
||||
|
||||
public interface DataStoreLifeCycle {
|
||||
public DataStore initialize(Map<String, Object> dsInfos);
|
||||
|
||||
public boolean attachCluster(DataStore store, ClusterScope scope);
|
||||
|
||||
public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo);
|
||||
|
||||
boolean attachZone(DataStore dataStore, ZoneScope scope);
|
||||
|
||||
public boolean dettach();
|
||||
|
|
|
|||
|
|
@ -23,15 +23,22 @@ import java.util.Map;
|
|||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
|
||||
|
||||
public interface DataStoreManager {
|
||||
public DataStore getDataStore(long storeId, DataStoreRole role);
|
||||
|
||||
public DataStore getPrimaryDataStore(long storeId);
|
||||
|
||||
public DataStore getDataStore(String uuid, DataStoreRole role);
|
||||
|
||||
public List<DataStore> getImageStoresByScope(ZoneScope scope);
|
||||
|
||||
public DataStore getImageStore(long zoneId);
|
||||
|
||||
public List<DataStore> getImageStoresByProvider(String provider);
|
||||
|
||||
public List<DataStore> getImageCacheStores(Scope scope);
|
||||
|
||||
public DataStore registerDataStore(Map<String, String> params, String providerUuid);
|
||||
|
||||
public List<DataStore> listImageStores();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
||||
|
||||
public interface DataStoreProvider {
|
||||
// constants for provider names
|
||||
public static final String NFS_IMAGE = "NFS";
|
||||
|
|
@ -34,16 +31,19 @@ public interface DataStoreProvider {
|
|||
public static final String DEFAULT_PRIMARY = "DefaultPrimary";
|
||||
|
||||
public static enum DataStoreProviderType {
|
||||
PRIMARY,
|
||||
IMAGE,
|
||||
ImageCache
|
||||
PRIMARY, IMAGE, ImageCache
|
||||
}
|
||||
|
||||
public DataStoreLifeCycle getDataStoreLifeCycle();
|
||||
|
||||
public DataStoreDriver getDataStoreDriver();
|
||||
|
||||
public HypervisorHostListener getHostListener();
|
||||
|
||||
public String getName();
|
||||
|
||||
public boolean configure(Map<String, Object> params);
|
||||
|
||||
public Set<DataStoreProviderType> getTypes();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,13 @@ import com.cloud.utils.component.Manager;
|
|||
|
||||
public interface DataStoreProviderManager extends Manager, DataStoreProviderApiService {
|
||||
public DataStoreProvider getDataStoreProvider(String name);
|
||||
|
||||
public DataStoreProvider getDefaultPrimaryDataStoreProvider();
|
||||
|
||||
public DataStoreProvider getDefaultImageDataStoreProvider();
|
||||
|
||||
public DataStoreProvider getDefaultCacheDataStoreProvider();
|
||||
|
||||
public List<DataStoreProvider> getDataStoreProviders();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,12 @@ import com.cloud.agent.api.Command;
|
|||
|
||||
public interface EndPoint {
|
||||
public long getId();
|
||||
|
||||
public String getHostAddr();
|
||||
|
||||
public String getPublicAddr();
|
||||
public Answer sendMessage(Command cmd);
|
||||
public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback);
|
||||
|
||||
public Answer sendMessage(Command cmd);
|
||||
|
||||
public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface EndPointSelector {
|
||||
public EndPoint select(DataObject srcData, DataObject destData);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import com.cloud.storage.ScopeType;
|
||||
|
||||
|
||||
public class HostScope extends AbstractScope {
|
||||
private ScopeType type = ScopeType.HOST;
|
||||
private Long hostId;
|
||||
private Long zoneId;
|
||||
|
||||
|
|
@ -30,9 +28,10 @@ public class HostScope extends AbstractScope {
|
|||
this.hostId = hostId;
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScopeType getScopeType() {
|
||||
return this.type;
|
||||
return ScopeType.HOST;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,5 +20,6 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
public interface HypervisorHostListener {
|
||||
boolean hostConnect(long hostId, long poolId);
|
||||
|
||||
boolean hostDisconnected(long hostId, long poolId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import com.cloud.storage.ScopeType;
|
||||
|
||||
|
||||
public interface ImageStoreProvider extends DataStoreProvider {
|
||||
|
||||
public boolean isScopeSupported(ScopeType scope);
|
||||
|
|
|
|||
|
|
@ -22,16 +22,11 @@ import com.cloud.utils.fsm.StateObject;
|
|||
|
||||
public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataStoreStateMachine.State> {
|
||||
enum State {
|
||||
Allocated("The initial state"),
|
||||
Creating2("This is only used with createOnlyRequested event"),
|
||||
Creating("The object is being creating on data store"),
|
||||
Created("The object is created"),
|
||||
Ready("Template downloading is accomplished"),
|
||||
Copying("The object is being coping"),
|
||||
Migrating("The object is being migrated"),
|
||||
Destroying("Template is destroying"),
|
||||
Destroyed("Template is destroyed"),
|
||||
Failed("Failed to download template");
|
||||
Allocated("The initial state"), Creating2("This is only used with createOnlyRequested event"), Creating(
|
||||
"The object is being creating on data store"), Created("The object is created"), Ready(
|
||||
"Template downloading is accomplished"), Copying("The object is being coping"), Migrating(
|
||||
"The object is being migrated"), Destroying("Template is destroying"), Destroyed(
|
||||
"Template is destroyed"), Failed("Failed to download template");
|
||||
String _description;
|
||||
|
||||
private State(String description) {
|
||||
|
|
@ -42,17 +37,9 @@ public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataS
|
|||
return _description;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum Event {
|
||||
CreateRequested,
|
||||
CreateOnlyRequested,
|
||||
DestroyRequested,
|
||||
OperationSuccessed,
|
||||
OperationFailed,
|
||||
CopyingRequested,
|
||||
MigrationRequested,
|
||||
ResizeRequested,
|
||||
ExpungeRequested
|
||||
|
||||
CreateRequested, CreateOnlyRequested, DestroyRequested, OperationSuccessed, OperationFailed, CopyingRequested, MigrationRequested, ResizeRequested, ExpungeRequested
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@ import org.apache.cloudstack.storage.command.CommandResult;
|
|||
|
||||
public interface PrimaryDataStoreDriver extends DataStoreDriver {
|
||||
public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
|
||||
|
||||
public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
|
@ -26,12 +25,15 @@ import com.cloud.storage.Storage.StoragePoolType;
|
|||
import com.cloud.storage.StoragePool;
|
||||
|
||||
public interface PrimaryDataStoreInfo extends StoragePool {
|
||||
public boolean isHypervisorSupported(HypervisorType hypervisor);
|
||||
public boolean isLocalStorageSupported();
|
||||
public boolean isVolumeDiskTypeSupported(DiskFormat diskType);
|
||||
public boolean isHypervisorSupported(HypervisorType hypervisor);
|
||||
|
||||
public String getUuid();
|
||||
public boolean isLocalStorageSupported();
|
||||
|
||||
public StoragePoolType getPoolType();
|
||||
public PrimaryDataStoreLifeCycle getLifeCycle();
|
||||
public boolean isVolumeDiskTypeSupported(DiskFormat diskType);
|
||||
|
||||
public String getUuid();
|
||||
|
||||
public StoragePoolType getPoolType();
|
||||
|
||||
public PrimaryDataStoreLifeCycle getLifeCycle();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,5 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
|
||||
public interface PrimaryDataStoreLifeCycle extends DataStoreLifeCycle {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public class PrimaryDataStoreParameters {
|
|||
private String uuid;
|
||||
private String name;
|
||||
private String userInfo;
|
||||
|
||||
/**
|
||||
* @return the userInfo
|
||||
*/
|
||||
|
|
@ -44,7 +45,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param userInfo the userInfo to set
|
||||
* @param userInfo
|
||||
* the userInfo to set
|
||||
*/
|
||||
public void setUserInfo(String userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
|
|
@ -58,7 +60,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
|
|
@ -72,7 +75,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param uuid the uuid to set
|
||||
* @param uuid
|
||||
* the uuid to set
|
||||
*/
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
|
|
@ -86,7 +90,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param port the port to set
|
||||
* @param port
|
||||
* the port to set
|
||||
*/
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
|
|
@ -100,7 +105,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param path the path to set
|
||||
* @param path
|
||||
* the path to set
|
||||
*/
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
|
|
@ -114,7 +120,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param host the host to set
|
||||
* @param host
|
||||
* the host to set
|
||||
*/
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
|
|
@ -128,7 +135,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param type the type to set
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(StoragePoolType type) {
|
||||
this.type = type;
|
||||
|
|
@ -142,7 +150,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param tags the tags to set
|
||||
* @param tags
|
||||
* the tags to set
|
||||
*/
|
||||
public void setTags(String tags) {
|
||||
this.tags = tags;
|
||||
|
|
@ -156,7 +165,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param details the details to set
|
||||
* @param details
|
||||
* the details to set
|
||||
*/
|
||||
public void setDetails(Map<String, String> details) {
|
||||
this.details = details;
|
||||
|
|
@ -170,7 +180,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param providerName the providerName to set
|
||||
* @param providerName
|
||||
* the providerName to set
|
||||
*/
|
||||
public void setProviderName(String providerName) {
|
||||
this.providerName = providerName;
|
||||
|
|
@ -184,7 +195,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param clusterId the clusterId to set
|
||||
* @param clusterId
|
||||
* the clusterId to set
|
||||
*/
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
|
|
@ -198,7 +210,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param podId the podId to set
|
||||
* @param podId
|
||||
* the podId to set
|
||||
*/
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
|
|
@ -212,7 +225,8 @@ public class PrimaryDataStoreParameters {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param zoneId the zoneId to set
|
||||
* @param zoneId
|
||||
* the zoneId to set
|
||||
*/
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import com.cloud.storage.ScopeType;
|
|||
|
||||
public interface Scope {
|
||||
public ScopeType getScopeType();
|
||||
|
||||
public boolean isSameScope(Scope scope);
|
||||
|
||||
public Long getScopeId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
|
||||
|
||||
public interface SnapshotDataFactory {
|
||||
public SnapshotInfo getSnapshot(long snapshotId, DataStore store);
|
||||
|
||||
public SnapshotInfo getSnapshot(DataObject obj, DataStore store);
|
||||
|
||||
public SnapshotInfo getSnapshot(long snapshotId, DataStoreRole role);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,18 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import com.cloud.storage.Snapshot;
|
||||
|
||||
|
||||
public interface SnapshotInfo extends DataObject, Snapshot {
|
||||
public SnapshotInfo getParent();
|
||||
public String getPath();
|
||||
public SnapshotInfo getChild();
|
||||
public VolumeInfo getBaseVolume();
|
||||
public void addPayload(Object data);
|
||||
public SnapshotInfo getParent();
|
||||
|
||||
public String getPath();
|
||||
|
||||
public SnapshotInfo getChild();
|
||||
|
||||
public VolumeInfo getBaseVolume();
|
||||
|
||||
public void addPayload(Object data);
|
||||
|
||||
Long getDataCenterId();
|
||||
|
||||
ObjectInDataStoreStateMachine.State getStatus();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@
|
|||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public class SnapshotProfile {
|
||||
private String _uri;
|
||||
public String getURI() {
|
||||
return _uri;
|
||||
}
|
||||
private String _uri;
|
||||
|
||||
public String getURI() {
|
||||
return _uri;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,28 +16,33 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
||||
public class SnapshotResult extends CommandResult {
|
||||
private SnapshotInfo snashot;
|
||||
private Answer answer;
|
||||
public SnapshotResult(SnapshotInfo snapshot, Answer answer) {
|
||||
this.setSnashot(snapshot);
|
||||
this.setAnswer(answer);
|
||||
}
|
||||
public SnapshotInfo getSnashot() {
|
||||
return snashot;
|
||||
}
|
||||
public void setSnashot(SnapshotInfo snashot) {
|
||||
this.snashot = snashot;
|
||||
}
|
||||
public Answer getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
public void setAnswer(Answer answer) {
|
||||
this.answer = answer;
|
||||
}
|
||||
private SnapshotInfo snashot;
|
||||
private Answer answer;
|
||||
|
||||
public SnapshotResult(SnapshotInfo snapshot, Answer answer) {
|
||||
super();
|
||||
this.setSnashot(snapshot);
|
||||
this.setAnswer(answer);
|
||||
}
|
||||
|
||||
public SnapshotInfo getSnashot() {
|
||||
return snashot;
|
||||
}
|
||||
|
||||
public void setSnashot(SnapshotInfo snashot) {
|
||||
this.snashot = snashot;
|
||||
}
|
||||
|
||||
public Answer getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
|
||||
public void setAnswer(Answer answer) {
|
||||
this.answer = answer;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@
|
|||
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
|
||||
|
||||
public interface SnapshotService {
|
||||
public SnapshotResult takeSnapshot(SnapshotInfo snapshot);
|
||||
public SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
|
||||
public boolean deleteSnapshot(SnapshotInfo snapshot);
|
||||
public boolean revertSnapshot(SnapshotInfo snapshot);
|
||||
public SnapshotResult takeSnapshot(SnapshotInfo snapshot);
|
||||
|
||||
public SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
|
||||
|
||||
public boolean deleteSnapshot(SnapshotInfo snapshot);
|
||||
|
||||
public boolean revertSnapshot(SnapshotInfo snapshot);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,13 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import com.cloud.storage.Snapshot;
|
||||
|
||||
|
||||
|
||||
public interface SnapshotStrategy {
|
||||
public SnapshotInfo takeSnapshot(SnapshotInfo snapshot);
|
||||
public SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
|
||||
public boolean deleteSnapshot(Long snapshotId);
|
||||
public SnapshotInfo takeSnapshot(SnapshotInfo snapshot);
|
||||
|
||||
public SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
|
||||
|
||||
public boolean deleteSnapshot(Long snapshotId);
|
||||
|
||||
/**
|
||||
* @param snapshot
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -18,15 +18,19 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
|
||||
public interface StorageCacheManager {
|
||||
public DataStore getCacheStorage(Scope scope);
|
||||
|
||||
public DataObject createCacheObject(DataObject data, Scope scope);
|
||||
/** only create cache object in db
|
||||
|
||||
/**
|
||||
* only create cache object in db
|
||||
*
|
||||
* @param data
|
||||
* @param scope
|
||||
* @return
|
||||
*/
|
||||
DataObject getCacheObject(DataObject data, Scope scope);
|
||||
|
||||
boolean deleteCacheObject(DataObject data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,5 @@
|
|||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public enum StorageEvent {
|
||||
DownloadTemplateToPrimary,
|
||||
RegisterTemplate,
|
||||
CreateVolumeFromTemplate;
|
||||
DownloadTemplateToPrimary, RegisterTemplate, CreateVolumeFromTemplate;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public interface StorageOrchestrator {
|
|||
|
||||
/**
|
||||
* Prepares all storage ready for a VM to start
|
||||
*
|
||||
* @param vm
|
||||
* @param reservationId
|
||||
*/
|
||||
|
|
@ -38,6 +39,7 @@ public interface StorageOrchestrator {
|
|||
|
||||
/**
|
||||
* Releases all storage that were used for a VM shutdown
|
||||
*
|
||||
* @param vm
|
||||
* @param disks
|
||||
* @param reservationId
|
||||
|
|
@ -46,6 +48,7 @@ public interface StorageOrchestrator {
|
|||
|
||||
/**
|
||||
* Destroy all disks
|
||||
*
|
||||
* @param disks
|
||||
* @param reservationId
|
||||
*/
|
||||
|
|
@ -53,16 +56,21 @@ public interface StorageOrchestrator {
|
|||
|
||||
/**
|
||||
* Cancel a reservation
|
||||
* @param reservationId reservation to
|
||||
*
|
||||
* @param reservationId
|
||||
* reservation to
|
||||
*/
|
||||
void cancel(String reservationId);
|
||||
|
||||
|
||||
/**
|
||||
* If attaching a volume in allocated state to a running vm, need to create this volume
|
||||
* If attaching a volume in allocated state to a running vm, need to create
|
||||
* this volume
|
||||
*/
|
||||
void prepareAttachDiskToVM(long diskId, long vmId, String reservationId);
|
||||
|
||||
|
||||
boolean createVolume(VolumeEntity volume, long dataStoreId, DiskFormat diskType);
|
||||
|
||||
boolean createVolumeFromTemplate(VolumeEntity volume, long dataStoreId, DiskFormat dis, TemplateEntity template);
|
||||
VolumeEntity allocateVolumeInDb(long size, VolumeType type,String volName, Long templateId);
|
||||
|
||||
VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,17 +29,23 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
/**
|
||||
*/
|
||||
public interface StoragePoolAllocator extends Adapter {
|
||||
/**
|
||||
* Determines which storage pools are suitable for the guest virtual machine
|
||||
*
|
||||
* @param DiskProfile dskCh
|
||||
* @param VirtualMachineProfile vmProfile
|
||||
* @param DeploymentPlan plan
|
||||
* @param ExcludeList avoid
|
||||
* @param int returnUpTo (use -1 to return all possible pools)
|
||||
* @return List<StoragePool> List of storage pools that are suitable for the VM
|
||||
**/
|
||||
List<StoragePool> allocateToPool(DiskProfile dskCh, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo);
|
||||
|
||||
public static int RETURN_UPTO_ALL = -1;
|
||||
/**
|
||||
* Determines which storage pools are suitable for the guest virtual machine
|
||||
*
|
||||
* @param DiskProfile
|
||||
* dskCh
|
||||
* @param VirtualMachineProfile
|
||||
* vmProfile
|
||||
* @param DeploymentPlan
|
||||
* plan
|
||||
* @param ExcludeList
|
||||
* avoid
|
||||
* @param int returnUpTo (use -1 to return all possible pools)
|
||||
* @return List<StoragePool> List of storage pools that are suitable for the
|
||||
* VM
|
||||
**/
|
||||
List<StoragePool> allocateToPool(DiskProfile dskCh, VirtualMachineProfile<? extends VirtualMachine> vmProfile,
|
||||
DeploymentPlan plan, ExcludeList avoid, int returnUpTo);
|
||||
|
||||
public static int RETURN_UPTO_ALL = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ import com.cloud.org.Grouping;
|
|||
|
||||
public interface StorageSubSystem {
|
||||
String getType();
|
||||
|
||||
Class<? extends Grouping> getScope();
|
||||
|
||||
URI grantAccess(String vol, String reservationId);
|
||||
|
||||
URI RemoveAccess(String vol, String reservationId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,12 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
|
||||
|
||||
public interface TemplateDataFactory {
|
||||
TemplateInfo getTemplate(long templateId, DataStore store);
|
||||
|
||||
TemplateInfo getTemplate(DataObject obj, DataStore store);
|
||||
|
||||
TemplateInfo getTemplate(long templateId, DataStoreRole storeRole);
|
||||
|
||||
TemplateInfo getTemplate(long templateId, DataStoreRole storeRole, Long zoneId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,5 @@
|
|||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public enum TemplateEvent {
|
||||
CreateRequested,
|
||||
OperationFailed,
|
||||
OperationSucceeded,
|
||||
DestroyRequested;
|
||||
CreateRequested, OperationFailed, OperationSucceeded, DestroyRequested;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,5 +22,6 @@ import com.cloud.template.VirtualMachineTemplate;
|
|||
|
||||
public interface TemplateInfo extends DataObject, VirtualMachineTemplate {
|
||||
public String getUniqueName();
|
||||
|
||||
public String getInstallPath();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,266 +22,291 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
|
||||
public class TemplateProfile {
|
||||
Long userId;
|
||||
String name;
|
||||
String displayText;
|
||||
Integer bits;
|
||||
Boolean passwordEnabled;
|
||||
Boolean sshKeyEnbaled;
|
||||
Boolean requiresHvm;
|
||||
String url;
|
||||
Boolean isPublic;
|
||||
Boolean featured;
|
||||
Boolean isExtractable;
|
||||
ImageFormat format;
|
||||
Long guestOsId;
|
||||
Long zoneId;
|
||||
HypervisorType hypervisorType;
|
||||
String accountName;
|
||||
Long domainId;
|
||||
Long accountId;
|
||||
String chksum;
|
||||
Boolean bootable;
|
||||
Long templateId;
|
||||
VirtualMachineTemplate template;
|
||||
String templateTag;
|
||||
Map details;
|
||||
|
||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
|
||||
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
|
||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, Map details, Boolean sshKeyEnabled) {
|
||||
this.templateId = templateId;
|
||||
this.userId = userId;
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.bits = bits;
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
this.requiresHvm = requiresHvm;
|
||||
this.url = url;
|
||||
this.isPublic = isPublic;
|
||||
this.featured = featured;
|
||||
this.isExtractable = isExtractable;
|
||||
this.format = format;
|
||||
this.guestOsId = guestOsId;
|
||||
this.zoneId = zoneId;
|
||||
this.hypervisorType = hypervisorType;
|
||||
this.accountName = accountName;
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
this.chksum = chksum;
|
||||
this.bootable = bootable;
|
||||
this.details = details;
|
||||
this.sshKeyEnbaled = sshKeyEnabled;
|
||||
}
|
||||
|
||||
public TemplateProfile(Long userId, VirtualMachineTemplate template, Long zoneId) {
|
||||
this.userId = userId;
|
||||
this.template = template;
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
|
||||
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
|
||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details, Boolean sshKeyEnabled) {
|
||||
this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured, isExtractable, format, guestOsId, zoneId,
|
||||
hypervisorType, accountName, domainId, accountId, chksum, bootable, details, sshKeyEnabled);
|
||||
public class TemplateProfile {
|
||||
Long userId;
|
||||
String name;
|
||||
String displayText;
|
||||
Integer bits;
|
||||
Boolean passwordEnabled;
|
||||
Boolean sshKeyEnbaled;
|
||||
Boolean requiresHvm;
|
||||
String url;
|
||||
Boolean isPublic;
|
||||
Boolean featured;
|
||||
Boolean isExtractable;
|
||||
ImageFormat format;
|
||||
Long guestOsId;
|
||||
Long zoneId;
|
||||
HypervisorType hypervisorType;
|
||||
String accountName;
|
||||
Long domainId;
|
||||
Long accountId;
|
||||
String chksum;
|
||||
Boolean bootable;
|
||||
Long templateId;
|
||||
VirtualMachineTemplate template;
|
||||
String templateTag;
|
||||
Map details;
|
||||
|
||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits,
|
||||
Boolean passwordEnabled, Boolean requiresHvm, String url, Boolean isPublic, Boolean featured,
|
||||
Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId, HypervisorType hypervisorType,
|
||||
String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, Map details,
|
||||
Boolean sshKeyEnabled) {
|
||||
this.templateId = templateId;
|
||||
this.userId = userId;
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.bits = bits;
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
this.requiresHvm = requiresHvm;
|
||||
this.url = url;
|
||||
this.isPublic = isPublic;
|
||||
this.featured = featured;
|
||||
this.isExtractable = isExtractable;
|
||||
this.format = format;
|
||||
this.guestOsId = guestOsId;
|
||||
this.zoneId = zoneId;
|
||||
this.hypervisorType = hypervisorType;
|
||||
this.accountName = accountName;
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
this.chksum = chksum;
|
||||
this.bootable = bootable;
|
||||
this.details = details;
|
||||
this.sshKeyEnbaled = sshKeyEnabled;
|
||||
}
|
||||
|
||||
public TemplateProfile(Long userId, VirtualMachineTemplate template, Long zoneId) {
|
||||
this.userId = userId;
|
||||
this.template = template;
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits,
|
||||
Boolean passwordEnabled, Boolean requiresHvm, String url, Boolean isPublic, Boolean featured,
|
||||
Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId, HypervisorType hypervisorType,
|
||||
String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag,
|
||||
Map details, Boolean sshKeyEnabled) {
|
||||
this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured,
|
||||
isExtractable, format, guestOsId, zoneId, hypervisorType, accountName, domainId, accountId, chksum,
|
||||
bootable, details, sshKeyEnabled);
|
||||
this.templateTag = templateTag;
|
||||
}
|
||||
|
||||
public Long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
public void setTemplateId(Long id) {
|
||||
this.templateId = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
public void setDisplayText(String text) {
|
||||
this.displayText = text;
|
||||
}
|
||||
|
||||
public Integer getBits() {
|
||||
return bits;
|
||||
}
|
||||
public void setBits(Integer bits) {
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public Boolean getPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
public void setPasswordEnabled(Boolean enabled) {
|
||||
this.passwordEnabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getRequiresHVM() {
|
||||
return requiresHvm;
|
||||
}
|
||||
public void setRequiresHVM(Boolean hvm) {
|
||||
this.requiresHvm = hvm;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Boolean getIsPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
public void setIsPublic(Boolean is) {
|
||||
this.isPublic = is;
|
||||
}
|
||||
|
||||
public Boolean getFeatured() {
|
||||
return featured;
|
||||
}
|
||||
public void setFeatured(Boolean featured) {
|
||||
this.featured = featured;
|
||||
}
|
||||
|
||||
public Boolean getIsExtractable() {
|
||||
return isExtractable;
|
||||
}
|
||||
public void setIsExtractable(Boolean is) {
|
||||
this.isExtractable = is;
|
||||
}
|
||||
|
||||
public ImageFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
public void setFormat(ImageFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public Long getGuestOsId() {
|
||||
return guestOsId;
|
||||
}
|
||||
public void setGuestOsId(Long id) {
|
||||
this.guestOsId = id;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
public void setZoneId(Long id) {
|
||||
this.zoneId = id;
|
||||
}
|
||||
|
||||
public HypervisorType getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
public void setHypervisorType(HypervisorType type) {
|
||||
this.hypervisorType = type;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
public void setDomainId(Long id) {
|
||||
this.domainId = id;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
public void setAccountId(Long id) {
|
||||
this.accountId = id;
|
||||
}
|
||||
|
||||
public String getCheckSum() {
|
||||
return chksum;
|
||||
}
|
||||
public void setCheckSum(String chksum) {
|
||||
this.chksum = chksum;
|
||||
}
|
||||
|
||||
public Boolean getBootable() {
|
||||
return this.bootable;
|
||||
}
|
||||
public void setBootable(Boolean bootable) {
|
||||
this.bootable = bootable;
|
||||
}
|
||||
|
||||
public VirtualMachineTemplate getTemplate() {
|
||||
return template;
|
||||
}
|
||||
public void setTemplate(VirtualMachineTemplate template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(Long id) {
|
||||
this.templateId = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public void setDisplayText(String text) {
|
||||
this.displayText = text;
|
||||
}
|
||||
|
||||
public Integer getBits() {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public void setBits(Integer bits) {
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public Boolean getPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
|
||||
public void setPasswordEnabled(Boolean enabled) {
|
||||
this.passwordEnabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getRequiresHVM() {
|
||||
return requiresHvm;
|
||||
}
|
||||
|
||||
public void setRequiresHVM(Boolean hvm) {
|
||||
this.requiresHvm = hvm;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Boolean getIsPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public void setIsPublic(Boolean is) {
|
||||
this.isPublic = is;
|
||||
}
|
||||
|
||||
public Boolean getFeatured() {
|
||||
return featured;
|
||||
}
|
||||
|
||||
public void setFeatured(Boolean featured) {
|
||||
this.featured = featured;
|
||||
}
|
||||
|
||||
public Boolean getIsExtractable() {
|
||||
return isExtractable;
|
||||
}
|
||||
|
||||
public void setIsExtractable(Boolean is) {
|
||||
this.isExtractable = is;
|
||||
}
|
||||
|
||||
public ImageFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(ImageFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public Long getGuestOsId() {
|
||||
return guestOsId;
|
||||
}
|
||||
|
||||
public void setGuestOsId(Long id) {
|
||||
this.guestOsId = id;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(Long id) {
|
||||
this.zoneId = id;
|
||||
}
|
||||
|
||||
public HypervisorType getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
|
||||
public void setHypervisorType(HypervisorType type) {
|
||||
this.hypervisorType = type;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(Long id) {
|
||||
this.domainId = id;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(Long id) {
|
||||
this.accountId = id;
|
||||
}
|
||||
|
||||
public String getCheckSum() {
|
||||
return chksum;
|
||||
}
|
||||
|
||||
public void setCheckSum(String chksum) {
|
||||
this.chksum = chksum;
|
||||
}
|
||||
|
||||
public Boolean getBootable() {
|
||||
return this.bootable;
|
||||
}
|
||||
|
||||
public void setBootable(Boolean bootable) {
|
||||
this.bootable = bootable;
|
||||
}
|
||||
|
||||
public VirtualMachineTemplate getTemplate() {
|
||||
return template;
|
||||
}
|
||||
|
||||
public void setTemplate(VirtualMachineTemplate template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public String getTemplateTag() {
|
||||
return templateTag;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTemplateTag(String templateTag) {
|
||||
this.templateTag = templateTag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Map getDetails() {
|
||||
return this.details;
|
||||
return this.details;
|
||||
}
|
||||
|
||||
|
||||
public void setDetails(Map details) {
|
||||
this.details = details;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
|
||||
public void setSshKeyEnabled(Boolean enabled) {
|
||||
this.sshKeyEnbaled = enabled;
|
||||
this.sshKeyEnbaled = enabled;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getSshKeyEnabled() {
|
||||
return this.sshKeyEnbaled;
|
||||
return this.sshKeyEnbaled;
|
||||
}
|
||||
|
||||
|
||||
public String getImageStorageUri() {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void setLocalPath(String path) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getLocalPath() {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String getJobId() {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void setTemplatePoolRefId(long id) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public long getTemplatePoolRefId() {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public long getSize() {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import org.apache.cloudstack.framework.async.AsyncCallFuture;
|
|||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
|
||||
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
||||
|
|
@ -31,7 +29,9 @@ public interface TemplateService {
|
|||
|
||||
public class TemplateApiResult extends CommandResult {
|
||||
private final TemplateInfo template;
|
||||
|
||||
public TemplateApiResult(TemplateInfo template) {
|
||||
super();
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
|
|
@ -40,16 +40,25 @@ public interface TemplateService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void createTemplateAsync(TemplateInfo template, DataStore store, AsyncCompletionCallback<TemplateApiResult> callback);
|
||||
AsyncCallFuture<TemplateApiResult> createTemplateFromSnapshotAsync(SnapshotInfo snapshot, TemplateInfo template, DataStore store);
|
||||
AsyncCallFuture<TemplateApiResult> createTemplateFromVolumeAsync(VolumeInfo volume, TemplateInfo template, DataStore store);
|
||||
|
||||
AsyncCallFuture<TemplateApiResult> createTemplateFromSnapshotAsync(SnapshotInfo snapshot, TemplateInfo template,
|
||||
DataStore store);
|
||||
|
||||
AsyncCallFuture<TemplateApiResult> createTemplateFromVolumeAsync(VolumeInfo volume, TemplateInfo template,
|
||||
DataStore store);
|
||||
|
||||
AsyncCallFuture<TemplateApiResult> deleteTemplateAsync(TemplateInfo template);
|
||||
|
||||
AsyncCallFuture<TemplateApiResult> copyTemplate(TemplateInfo srcTemplate, DataStore destStore);
|
||||
AsyncCallFuture<TemplateApiResult> prepareTemplateOnPrimary(TemplateInfo srcTemplate, StoragePool pool );
|
||||
|
||||
AsyncCallFuture<TemplateApiResult> prepareTemplateOnPrimary(TemplateInfo srcTemplate, StoragePool pool);
|
||||
|
||||
void handleSysTemplateDownload(HypervisorType hostHyper, Long dcId);
|
||||
|
||||
void handleTemplateSync(DataStore store);
|
||||
|
||||
void downloadBootstrapSysTemplate(DataStore store);
|
||||
|
||||
void addSystemVMTemplatesToSecondary(DataStore store);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,5 @@
|
|||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public enum TemplateState {
|
||||
Allocated,
|
||||
Creating,
|
||||
Destroying,
|
||||
Destroyed,
|
||||
Ready;
|
||||
Allocated, Creating, Destroying, Destroyed, Ready;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
|
||||
public interface VolumeDataFactory {
|
||||
VolumeInfo getVolume(long volumeId, DataStore store);
|
||||
|
||||
VolumeInfo getVolume(DataObject volume, DataStore store);
|
||||
|
||||
VolumeInfo getVolume(long volumeId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,15 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|||
import com.cloud.storage.Volume;
|
||||
|
||||
public interface VolumeInfo extends DataObject, Volume {
|
||||
public boolean isAttachedVM();
|
||||
public void addPayload(Object data);
|
||||
public Object getpayload();
|
||||
public HypervisorType getHypervisorType();
|
||||
public Long getLastPoolId();
|
||||
public String getAttachedVmName();
|
||||
public boolean isAttachedVM();
|
||||
|
||||
public void addPayload(Object data);
|
||||
|
||||
public Object getpayload();
|
||||
|
||||
public HypervisorType getHypervisorType();
|
||||
|
||||
public Long getLastPoolId();
|
||||
|
||||
public String getAttachedVmName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,16 +19,17 @@
|
|||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public class VolumeProfile {
|
||||
private String _uri;
|
||||
public String getURI() {
|
||||
return _uri;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return 0;
|
||||
}
|
||||
private String _uri;
|
||||
|
||||
public String getURI() {
|
||||
return _uri;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallFuture;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
|
|
@ -31,7 +32,9 @@ public interface VolumeService {
|
|||
|
||||
public class VolumeApiResult extends CommandResult {
|
||||
private final VolumeInfo volume;
|
||||
|
||||
public VolumeApiResult(VolumeInfo volume) {
|
||||
super();
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
|
|
@ -42,16 +45,16 @@ public interface VolumeService {
|
|||
|
||||
/**
|
||||
* Creates the volume based on the given criteria
|
||||
*
|
||||
*
|
||||
* @param cmd
|
||||
*
|
||||
*
|
||||
* @return the volume object
|
||||
*/
|
||||
AsyncCallFuture<VolumeApiResult> createVolumeAsync(VolumeInfo volume, DataStore store);
|
||||
|
||||
/**
|
||||
* Delete volume
|
||||
*
|
||||
*
|
||||
* @param volumeId
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
|
|
@ -66,15 +69,19 @@ public interface VolumeService {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
AsyncCallFuture<VolumeApiResult> createVolumeFromSnapshot(VolumeInfo volume, DataStore store, SnapshotInfo snapshot);
|
||||
|
||||
AsyncCallFuture<VolumeApiResult> createVolumeFromSnapshot(VolumeInfo volume, DataStore store, SnapshotInfo snapshot);
|
||||
|
||||
VolumeEntity getVolumeEntity(long volumeId);
|
||||
|
||||
AsyncCallFuture<VolumeApiResult> createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, TemplateInfo template);
|
||||
AsyncCallFuture<VolumeApiResult> createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId,
|
||||
TemplateInfo template);
|
||||
|
||||
AsyncCallFuture<VolumeApiResult> copyVolume(VolumeInfo srcVolume, DataStore destStore);
|
||||
|
||||
AsyncCallFuture<VolumeApiResult> migrateVolume(VolumeInfo srcVolume, DataStore destStore);
|
||||
AsyncCallFuture<CommandResult> migrateVolumes(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost);
|
||||
|
||||
AsyncCallFuture<CommandResult> migrateVolumes(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo,
|
||||
Host srcHost, Host destHost);
|
||||
|
||||
boolean destroyVolume(long volumeId) throws ConcurrentOperationException;
|
||||
|
||||
|
|
@ -84,6 +91,6 @@ public interface VolumeService {
|
|||
|
||||
void handleVolumeSync(DataStore store);
|
||||
|
||||
SnapshotInfo takeSnapshot(VolumeInfo volume);
|
||||
SnapshotInfo takeSnapshot(VolumeInfo volume);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,15 +20,14 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
|
||||
import com.cloud.storage.ScopeType;
|
||||
|
||||
|
||||
public class ZoneScope extends AbstractScope {
|
||||
private ScopeType type = ScopeType.ZONE;
|
||||
private Long zoneId;
|
||||
|
||||
|
||||
public ZoneScope(Long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ScopeType getScopeType() {
|
||||
return this.type;
|
||||
|
|
|
|||
|
|
@ -19,10 +19,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
|
|||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public enum DiskFormat {
|
||||
VMDK,
|
||||
VHD,
|
||||
ISO,
|
||||
QCOW2;
|
||||
VMDK, VHD, ISO, QCOW2;
|
||||
public static DiskFormat getFormat(String format) {
|
||||
if (VMDK.toString().equalsIgnoreCase(format)) {
|
||||
return VMDK;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||
|
||||
public class BaseImage extends VolumeTypeBase {
|
||||
public BaseImage() {
|
||||
this.type = "BaseImage";
|
||||
}
|
||||
public BaseImage() {
|
||||
this.type = "BaseImage";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
@Component
|
||||
public class DataDisk extends VolumeTypeBase {
|
||||
public DataDisk() {
|
||||
this.type = "DataDisk";
|
||||
}
|
||||
public DataDisk() {
|
||||
this.type = "DataDisk";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
@Component
|
||||
public class Iso extends VolumeTypeBase {
|
||||
public Iso() {
|
||||
this.type = "iso";
|
||||
}
|
||||
public Iso() {
|
||||
this.type = "iso";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
@Component
|
||||
public class RootDisk extends VolumeTypeBase {
|
||||
public RootDisk() {
|
||||
this.type = "Root";
|
||||
}
|
||||
public RootDisk() {
|
||||
this.type = "Root";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||
|
||||
public class Unknown extends VolumeTypeBase {
|
||||
public Unknown() {
|
||||
this.type = "Unknown";
|
||||
}
|
||||
public Unknown() {
|
||||
this.type = "Unknown";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,31 +17,31 @@
|
|||
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||
|
||||
public class VolumeTypeBase implements VolumeType {
|
||||
protected String type = "Unknown";
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that instanceof String) {
|
||||
if (this.toString().equalsIgnoreCase((String)that)) {
|
||||
return true;
|
||||
}
|
||||
} else if (that instanceof VolumeTypeBase) {
|
||||
VolumeTypeBase th = (VolumeTypeBase)that;
|
||||
if (this.toString().equalsIgnoreCase(th.toString())) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return type;
|
||||
}
|
||||
|
||||
protected String type = "Unknown";
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that instanceof String) {
|
||||
if (this.toString().equalsIgnoreCase((String) that)) {
|
||||
return true;
|
||||
}
|
||||
} else if (that instanceof VolumeTypeBase) {
|
||||
VolumeTypeBase th = (VolumeTypeBase) that;
|
||||
if (this.toString().equalsIgnoreCase(th.toString())) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,21 +24,21 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
@Component
|
||||
public class VolumeTypeHelper {
|
||||
static private List<VolumeType> types;
|
||||
private static VolumeType defaultType = new Unknown();
|
||||
|
||||
@Inject
|
||||
public void setTypes(List<VolumeType> types) {
|
||||
VolumeTypeHelper.types = types;
|
||||
}
|
||||
|
||||
public static VolumeType getType(String type) {
|
||||
for (VolumeType ty : types) {
|
||||
if (ty.equals(type)) {
|
||||
return ty;
|
||||
}
|
||||
}
|
||||
return VolumeTypeHelper.defaultType;
|
||||
}
|
||||
|
||||
static private List<VolumeType> types;
|
||||
private static VolumeType defaultType = new Unknown();
|
||||
|
||||
@Inject
|
||||
public void setTypes(List<VolumeType> types) {
|
||||
VolumeTypeHelper.types = types;
|
||||
}
|
||||
|
||||
public static VolumeType getType(String type) {
|
||||
for (VolumeType ty : types) {
|
||||
if (ty.equals(type)) {
|
||||
return ty;
|
||||
}
|
||||
}
|
||||
return VolumeTypeHelper.defaultType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.cloud.agent.api.to.DiskTO;
|
|||
|
||||
public class AttachAnswer extends Answer {
|
||||
private DiskTO disk;
|
||||
|
||||
public AttachAnswer() {
|
||||
super(null);
|
||||
}
|
||||
|
|
@ -31,6 +32,7 @@ public class AttachAnswer extends Answer {
|
|||
super(null);
|
||||
this.setDisk(disk);
|
||||
}
|
||||
|
||||
public AttachAnswer(String errMsg) {
|
||||
super(null, false, errMsg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,33 +18,36 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.to.DiskTO;
|
||||
|
||||
public class AttachCommand extends Command implements StorageSubSystemCommand {
|
||||
public final class AttachCommand extends Command implements StorageSubSystemCommand {
|
||||
private DiskTO disk;
|
||||
private String vmName;
|
||||
|
||||
|
||||
public AttachCommand(DiskTO disk, String vmName) {
|
||||
super();
|
||||
this.disk = disk;
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public DiskTO getDisk() {
|
||||
return disk;
|
||||
}
|
||||
|
||||
public void setDisk(DiskTO disk) {
|
||||
this.disk = disk;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public void setVmName(String vmName) {
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,30 +25,31 @@ public class AttachPrimaryDataStoreAnswer extends Answer {
|
|||
private String uuid;
|
||||
private long capacity;
|
||||
private long avail;
|
||||
|
||||
public AttachPrimaryDataStoreAnswer(Command cmd) {
|
||||
super(cmd);
|
||||
}
|
||||
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
|
||||
public void setCapacity(long capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
|
||||
public long getCapacity() {
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
|
||||
public void setAvailable(long avail) {
|
||||
this.avail = avail;
|
||||
}
|
||||
|
||||
|
||||
public long getAvailable() {
|
||||
return this.avail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,22 +18,22 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
|
||||
public final class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
|
||||
private final String dataStore;
|
||||
|
||||
public AttachPrimaryDataStoreCmd(String uri) {
|
||||
super();
|
||||
this.dataStore = uri;
|
||||
}
|
||||
|
||||
|
||||
public String getDataStore() {
|
||||
return this.dataStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,27 +21,28 @@ package org.apache.cloudstack.storage.command;
|
|||
public class CommandResult {
|
||||
private boolean success;
|
||||
private String result;
|
||||
|
||||
public CommandResult() {
|
||||
this.success = true;
|
||||
this.result = "";
|
||||
}
|
||||
|
||||
|
||||
public boolean isSuccess() {
|
||||
return this.success;
|
||||
}
|
||||
|
||||
|
||||
public boolean isFailed() {
|
||||
return !this.success;
|
||||
}
|
||||
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
|
||||
public String getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
if (result != null) {
|
||||
|
|
@ -49,4 +50,3 @@ public class CommandResult {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -16,23 +16,21 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
|
||||
public class CopyCmdAnswer extends Answer {
|
||||
private DataTO newData;
|
||||
|
||||
|
||||
public CopyCmdAnswer(DataTO newData) {
|
||||
super(null);
|
||||
this.newData = newData;
|
||||
}
|
||||
|
||||
|
||||
public DataTO getNewData() {
|
||||
return this.newData;
|
||||
}
|
||||
|
||||
|
||||
public CopyCmdAnswer(String errMsg) {
|
||||
super(null, false, errMsg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,10 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
|
||||
public class CopyCommand extends Command implements StorageSubSystemCommand {
|
||||
public final class CopyCommand extends Command implements StorageSubSystemCommand {
|
||||
private DataTO srcTO;
|
||||
private DataTO destTO;
|
||||
private DataTO cacheTO;
|
||||
|
|
@ -31,11 +30,11 @@ public class CopyCommand extends Command implements StorageSubSystemCommand {
|
|||
this.destTO = destData;
|
||||
this.setWait(timeout);
|
||||
}
|
||||
|
||||
|
||||
public DataTO getDestTO() {
|
||||
return this.destTO;
|
||||
}
|
||||
|
||||
|
||||
public DataTO getSrcTO() {
|
||||
return this.srcTO;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
|
||||
public class CreateObjectAnswer extends Answer {
|
||||
public final class CreateObjectAnswer extends Answer {
|
||||
private DataTO data;
|
||||
|
||||
protected CreateObjectAnswer() {
|
||||
super();
|
||||
}
|
||||
|
|
@ -32,12 +32,12 @@ public class CreateObjectAnswer extends Answer {
|
|||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
public DataTO getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
|
||||
public CreateObjectAnswer(String errMsg) {
|
||||
super(null, false, errMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,10 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
|
||||
public class CreateObjectCommand extends Command implements StorageSubSystemCommand {
|
||||
public final class CreateObjectCommand extends Command implements StorageSubSystemCommand {
|
||||
private DataTO data;
|
||||
|
||||
public CreateObjectCommand(DataTO obj) {
|
||||
|
|
@ -39,7 +38,7 @@ public class CreateObjectCommand extends Command implements StorageSubSystemComm
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public DataTO getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,22 +16,22 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class CreatePrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
|
||||
public final class CreatePrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
|
||||
private final String dataStore;
|
||||
|
||||
public CreatePrimaryDataStoreCmd(String uri) {
|
||||
super();
|
||||
this.dataStore = uri;
|
||||
}
|
||||
|
||||
|
||||
public String getDataStore() {
|
||||
return this.dataStore;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,25 +18,26 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
|
||||
public class DeleteCommand extends Command implements StorageSubSystemCommand {
|
||||
private DataTO data;
|
||||
public final class DeleteCommand extends Command implements StorageSubSystemCommand {
|
||||
private DataTO data;
|
||||
|
||||
public DeleteCommand(DataTO data) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
protected DeleteCommand() {
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public DataTO getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@ package org.apache.cloudstack.storage.command;
|
|||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.to.DiskTO;
|
||||
|
||||
public class DettachAnswer extends Answer {
|
||||
public final class DettachAnswer extends Answer {
|
||||
private DiskTO disk;
|
||||
|
||||
public DettachAnswer() {
|
||||
super(null);
|
||||
}
|
||||
|
|
@ -31,6 +32,7 @@ public class DettachAnswer extends Answer {
|
|||
super(null);
|
||||
this.setDisk(disk);
|
||||
}
|
||||
|
||||
public DettachAnswer(String errMsg) {
|
||||
super(null, false, errMsg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,29 +24,32 @@ import com.cloud.agent.api.to.DiskTO;
|
|||
public class DettachCommand extends Command implements StorageSubSystemCommand {
|
||||
private DiskTO disk;
|
||||
private String vmName;
|
||||
|
||||
|
||||
public DettachCommand(DiskTO disk, String vmName) {
|
||||
super();
|
||||
this.disk = disk;
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public DiskTO getDisk() {
|
||||
return disk;
|
||||
}
|
||||
|
||||
public void setDisk(DiskTO disk) {
|
||||
this.disk = disk;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public void setVmName(String vmName) {
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,138 +16,114 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.storage.command;
|
||||
|
||||
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.storage.PasswordAuth;
|
||||
import com.cloud.agent.api.storage.Proxy;
|
||||
import com.cloud.agent.api.to.DataStoreTO;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
|
||||
|
||||
public class DownloadSystemTemplateCommand extends Command {
|
||||
|
||||
|
||||
private PasswordAuth auth;
|
||||
private Proxy _proxy;
|
||||
private DataStoreTO _store;
|
||||
private PasswordAuth auth;
|
||||
private Proxy _proxy;
|
||||
private DataStoreTO _store;
|
||||
private Long resourceId;
|
||||
private Long accountId;
|
||||
private String url;
|
||||
private Long maxDownloadSizeInBytes;
|
||||
private String name;
|
||||
|
||||
protected DownloadSystemTemplateCommand() {
|
||||
}
|
||||
protected DownloadSystemTemplateCommand() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, VirtualMachineTemplate template, Long maxDownloadSizeInBytes) {
|
||||
this._store = store;
|
||||
this.accountId = template.getAccountId();
|
||||
this.url = secUrl;
|
||||
this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
|
||||
this.resourceId = template.getId();
|
||||
this.name = template.getUniqueName();
|
||||
}
|
||||
|
||||
|
||||
public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, String url, VirtualMachineTemplate template, String user, String passwd, Long maxDownloadSizeInBytes) {
|
||||
public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, VirtualMachineTemplate template,
|
||||
Long maxDownloadSizeInBytes) {
|
||||
super();
|
||||
this._store = store;
|
||||
this.accountId = template.getAccountId();
|
||||
this.url = secUrl;
|
||||
this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
|
||||
this.resourceId = template.getId();
|
||||
auth = new PasswordAuth(user, passwd);
|
||||
this.name = template.getUniqueName();
|
||||
}
|
||||
this.name = template.getUniqueName();
|
||||
}
|
||||
|
||||
public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, String url, VirtualMachineTemplate template,
|
||||
String user, String passwd, Long maxDownloadSizeInBytes) {
|
||||
super();
|
||||
this._store = store;
|
||||
this.accountId = template.getAccountId();
|
||||
this.url = secUrl;
|
||||
this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
|
||||
this.resourceId = template.getId();
|
||||
auth = new PasswordAuth(user, passwd);
|
||||
this.name = template.getUniqueName();
|
||||
}
|
||||
|
||||
public PasswordAuth getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
public void setCreds(String userName, String passwd) {
|
||||
auth = new PasswordAuth(userName, passwd);
|
||||
}
|
||||
|
||||
public PasswordAuth getAuth() {
|
||||
return auth;
|
||||
}
|
||||
public Proxy getProxy() {
|
||||
return _proxy;
|
||||
}
|
||||
|
||||
public void setCreds(String userName, String passwd) {
|
||||
auth = new PasswordAuth(userName, passwd);
|
||||
}
|
||||
|
||||
public Proxy getProxy() {
|
||||
return _proxy;
|
||||
}
|
||||
|
||||
public void setProxy(Proxy proxy) {
|
||||
_proxy = proxy;
|
||||
}
|
||||
|
||||
public Long getMaxDownloadSizeInBytes() {
|
||||
return maxDownloadSizeInBytes;
|
||||
}
|
||||
public void setProxy(Proxy proxy) {
|
||||
_proxy = proxy;
|
||||
}
|
||||
|
||||
public Long getMaxDownloadSizeInBytes() {
|
||||
return maxDownloadSizeInBytes;
|
||||
}
|
||||
|
||||
public DataStoreTO getDataStore() {
|
||||
return _store;
|
||||
}
|
||||
|
||||
|
||||
public void setDataStore(DataStoreTO _store) {
|
||||
this._store = _store;
|
||||
}
|
||||
|
||||
|
||||
public Long getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
|
||||
public void setResourceId(Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setAccountId(Long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,16 +20,18 @@ package org.apache.cloudstack.storage.datastore.db;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface ImageStoreDao extends GenericDao<ImageStoreVO, Long> {
|
||||
public ImageStoreVO findByName(String name);
|
||||
|
||||
public List<ImageStoreVO> findByProvider(String provider);
|
||||
|
||||
public List<ImageStoreVO> findByScope(ZoneScope scope);
|
||||
|
||||
public List<ImageStoreVO> findImageCacheByScope(ZoneScope scope);
|
||||
|
||||
public List<ImageStoreVO> listImageStores();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,20 +26,20 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="image_store_details")
|
||||
@Table(name = "image_store_details")
|
||||
public class ImageStoreDetailVO implements InternalIdentity {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
long id;
|
||||
|
||||
@Column(name="store_id")
|
||||
@Column(name = "store_id")
|
||||
long storeId;
|
||||
|
||||
@Column(name="name")
|
||||
@Column(name = "name")
|
||||
String name;
|
||||
|
||||
@Column(name="value")
|
||||
@Column(name = "value")
|
||||
String value;
|
||||
|
||||
public ImageStoreDetailVO() {
|
||||
|
|
@ -79,5 +79,4 @@ public class ImageStoreDetailVO implements InternalIdentity {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package org.apache.cloudstack.storage.datastore.db;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface ImageStoreDetailsDao extends GenericDao<ImageStoreDetailVO, Long> {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ import com.cloud.utils.db.GenericDao;
|
|||
@Table(name = "image_store")
|
||||
public class ImageStoreVO implements ImageStore {
|
||||
@Id
|
||||
@TableGenerator(name = "image_store_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "image_store_seq", allocationSize = 1)
|
||||
@TableGenerator(name = "image_store_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
|
||||
pkColumnValue = "image_store_seq", allocationSize = 1)
|
||||
@Column(name = "id", nullable = false)
|
||||
private long id;
|
||||
|
||||
|
|
@ -76,7 +77,7 @@ public class ImageStoreVO implements ImageStore {
|
|||
@Column(name = "parent")
|
||||
private String parent;
|
||||
|
||||
@Column(name="total_size")
|
||||
@Column(name = "total_size")
|
||||
private Long totalSize;
|
||||
|
||||
public DataStoreRole getRole() {
|
||||
|
|
@ -179,5 +180,4 @@ public class ImageStoreVO implements ImageStore {
|
|||
this.totalSize = totalSize;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,93 +20,104 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
/**
|
||||
* Data Access Object for storage_pool table
|
||||
*/
|
||||
public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
|
||||
|
||||
/**
|
||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
||||
*/
|
||||
List<StoragePoolVO> listByDataCenterId(long datacenterId);
|
||||
|
||||
/**
|
||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
||||
*/
|
||||
List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId, ScopeType scope);
|
||||
|
||||
/**
|
||||
* Set capacity of storage pool in bytes
|
||||
* @param id pool id.
|
||||
* @param capacity capacity in bytes
|
||||
*/
|
||||
/**
|
||||
* @param datacenterId
|
||||
* -- the id of the datacenter (availability zone)
|
||||
*/
|
||||
List<StoragePoolVO> listByDataCenterId(long datacenterId);
|
||||
|
||||
/**
|
||||
* @param datacenterId
|
||||
* -- the id of the datacenter (availability zone)
|
||||
*/
|
||||
List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId, ScopeType scope);
|
||||
|
||||
/**
|
||||
* Set capacity of storage pool in bytes
|
||||
*
|
||||
* @param id
|
||||
* pool id.
|
||||
* @param capacity
|
||||
* capacity in bytes
|
||||
*/
|
||||
void updateCapacity(long id, long capacity);
|
||||
|
||||
/**
|
||||
* Set available bytes of storage pool in bytes
|
||||
* @param id pool id.
|
||||
* @param available available capacity in bytes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set available bytes of storage pool in bytes
|
||||
*
|
||||
* @param id
|
||||
* pool id.
|
||||
* @param available
|
||||
* available capacity in bytes
|
||||
*/
|
||||
void updateAvailable(long id, long available);
|
||||
|
||||
|
||||
|
||||
StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details);
|
||||
|
||||
|
||||
/**
|
||||
* Find pool by name.
|
||||
*
|
||||
* @param name name of pool.
|
||||
* @return the single StoragePoolVO
|
||||
* @param name
|
||||
* name of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
List<StoragePoolVO> findPoolByName(String name);
|
||||
|
||||
|
||||
/**
|
||||
* Find pools by the pod that matches the details.
|
||||
*
|
||||
* @param podId pod id to find the pools in.
|
||||
* @param details details to match. All must match for the pool to be returned.
|
||||
* @param podId
|
||||
* pod id to find the pools in.
|
||||
* @param details
|
||||
* details to match. All must match for the pool to be returned.
|
||||
* @return List of StoragePoolVO
|
||||
*/
|
||||
List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details, ScopeType scope);
|
||||
|
||||
List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details,
|
||||
ScopeType scope);
|
||||
|
||||
List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags);
|
||||
|
||||
|
||||
/**
|
||||
* Find pool by UUID.
|
||||
*
|
||||
* @param uuid uuid of pool.
|
||||
* @return the single StoragePoolVO
|
||||
* @param uuid
|
||||
* uuid of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
StoragePoolVO findPoolByUUID(String uuid);
|
||||
|
||||
List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp);
|
||||
|
||||
StoragePoolVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
|
||||
|
||||
|
||||
List<StoragePoolVO> listPoolByHostPath(String host, String path);
|
||||
|
||||
|
||||
void updateDetails(long poolId, Map<String, String> details);
|
||||
|
||||
|
||||
Map<String, String> getDetails(long poolId);
|
||||
|
||||
List<String> searchForStoragePoolDetails(long poolId, String value);
|
||||
|
||||
List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid);
|
||||
List<String> searchForStoragePoolDetails(long poolId, String value);
|
||||
|
||||
List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid);
|
||||
|
||||
List<StoragePoolVO> listByStatus(StoragePoolStatus status);
|
||||
|
||||
long countPoolsByStatus(StoragePoolStatus... statuses);
|
||||
|
||||
List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status);
|
||||
|
||||
List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status);
|
||||
|
||||
List<StoragePoolVO> listPoolsByCluster(long clusterId);
|
||||
|
||||
List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId,
|
||||
Long clusterId, String[] tags);
|
||||
List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags);
|
||||
|
||||
List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags);
|
||||
List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,141 +48,136 @@ import com.cloud.utils.db.Transaction;
|
|||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
@Local(value={PrimaryDataStoreDao.class}) @DB(txn=false)
|
||||
public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements PrimaryDataStoreDao {
|
||||
@Local(value = { PrimaryDataStoreDao.class })
|
||||
@DB(txn = false)
|
||||
public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements PrimaryDataStoreDao {
|
||||
protected final SearchBuilder<StoragePoolVO> AllFieldSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DcPodSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DcPodSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
|
||||
protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
|
||||
|
||||
@Inject protected StoragePoolDetailsDao _detailsDao;
|
||||
|
||||
|
||||
@Inject
|
||||
protected StoragePoolDetailsDao _detailsDao;
|
||||
|
||||
private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.status = 'Up' and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and storage_pool.scope = ? and (";
|
||||
private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
|
||||
private final String ZoneWideDetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.status = 'Up' and storage_pool.data_center_id = ? and storage_pool.scope = ? and (";
|
||||
private final String ZoneWideDetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
|
||||
|
||||
private final String FindPoolTagDetails = "SELECT storage_pool_details.name FROM storage_pool_details WHERE pool_id = ? and value = ?";
|
||||
|
||||
private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
|
||||
private final String ZoneWideDetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.status = 'Up' and storage_pool.data_center_id = ? and storage_pool.scope = ? and (";
|
||||
private final String ZoneWideDetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
|
||||
|
||||
private final String FindPoolTagDetails = "SELECT storage_pool_details.name FROM storage_pool_details WHERE pool_id = ? and value = ?";
|
||||
|
||||
public PrimaryDataStoreDaoImpl() {
|
||||
AllFieldSearch = createSearchBuilder();
|
||||
AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("status",AllFieldSearch.entity().getStatus(),SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("status", AllFieldSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
|
||||
AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ);
|
||||
AllFieldSearch.done();
|
||||
|
||||
DcPodSearch = createSearchBuilder();
|
||||
DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.and("status", DcPodSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.and("scope", DcPodSearch.entity().getScope(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.and().op("nullpod", DcPodSearch.entity().getPodId(), SearchCriteria.Op.NULL);
|
||||
DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.cp();
|
||||
DcPodSearch.and().op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL);
|
||||
DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.cp();
|
||||
DcPodSearch.done();
|
||||
|
||||
DcPodAnyClusterSearch = createSearchBuilder();
|
||||
DcPodAnyClusterSearch.and("datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.done();
|
||||
|
||||
DcPodSearch = createSearchBuilder();
|
||||
DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.and("status", DcPodSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.and("scope", DcPodSearch.entity().getScope(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.and().op("nullpod", DcPodSearch.entity().getPodId(), SearchCriteria.Op.NULL);
|
||||
DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.cp();
|
||||
DcPodSearch.and().op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL);
|
||||
DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||
DcPodSearch.cp();
|
||||
DcPodSearch.done();
|
||||
|
||||
DcPodAnyClusterSearch = createSearchBuilder();
|
||||
DcPodAnyClusterSearch.and("datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(),
|
||||
SearchCriteria.Op.EQ);
|
||||
DcPodAnyClusterSearch.and("status", DcPodAnyClusterSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
DcPodAnyClusterSearch.and("scope", DcPodAnyClusterSearch.entity().getScope(), SearchCriteria.Op.EQ);
|
||||
DcPodAnyClusterSearch.and().op("nullpod", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.NULL);
|
||||
DcPodAnyClusterSearch.or("podId", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
DcPodAnyClusterSearch.cp();
|
||||
DcPodAnyClusterSearch.done();
|
||||
|
||||
|
||||
DeleteLvmSearch = createSearchBuilder();
|
||||
DeleteLvmSearch.and("ids", DeleteLvmSearch.entity().getId(), SearchCriteria.Op.IN);
|
||||
DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
|
||||
DeleteLvmSearch.or("Filesystem", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
|
||||
DeleteLvmSearch.cp();
|
||||
DeleteLvmSearch.done();
|
||||
DeleteLvmSearch.done();
|
||||
|
||||
|
||||
|
||||
StatusCountSearch = createSearchBuilder(Long.class);
|
||||
StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
|
||||
StatusCountSearch.select(null, Func.COUNT, null);
|
||||
StatusCountSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findPoolByName(String name) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findPoolByName(String name) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("name", name);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StoragePoolVO findPoolByUUID(String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
@Override
|
||||
public StoragePoolVO findPoolByUUID(String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
@Override
|
||||
public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listByDataCenterId(long datacenterId) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
@Override
|
||||
public List<StoragePoolVO> listByDataCenterId(long datacenterId) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAvailable(long id, long available) {
|
||||
StoragePoolVO pool = createForUpdate(id);
|
||||
pool.setAvailableBytes(available);
|
||||
update(id, pool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAvailable(long id, long available) {
|
||||
StoragePoolVO pool = createForUpdate(id);
|
||||
pool.setAvailableBytes(available);
|
||||
update(id, pool);
|
||||
}
|
||||
@Override
|
||||
public void updateCapacity(long id, long capacity) {
|
||||
StoragePoolVO pool = createForUpdate(id);
|
||||
pool.setCapacityBytes(capacity);
|
||||
update(id, pool);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCapacity(long id, long capacity) {
|
||||
StoragePoolVO pool = createForUpdate(id);
|
||||
pool.setCapacityBytes(capacity);
|
||||
update(id, pool);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", hostFqdnOrIp);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listByStatus(StoragePoolStatus status){
|
||||
public List<StoragePoolVO> listByStatus(StoragePoolStatus status) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("status", status);
|
||||
return listBy(sc);
|
||||
sc.setParameters("status", status);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status){
|
||||
public List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("status", status);
|
||||
sc.setParameters("datacenterId", dcId);
|
||||
return listBy(sc);
|
||||
sc.setParameters("status", status);
|
||||
sc.setParameters("datacenterId", dcId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -193,238 +188,239 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
|
|||
sc.setParameters("datacenterId", datacenterId);
|
||||
sc.setParameters("podId", podId);
|
||||
sc.setParameters("uuid", uuid);
|
||||
|
||||
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId, ScopeType scope) {
|
||||
if (clusterId != null) {
|
||||
SearchCriteria<StoragePoolVO> sc = DcPodSearch.create();
|
||||
@Override
|
||||
public List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId, ScopeType scope) {
|
||||
if (clusterId != null) {
|
||||
SearchCriteria<StoragePoolVO> sc = DcPodSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
sc.setParameters("podId", podId);
|
||||
sc.setParameters("status", Status.Up);
|
||||
sc.setParameters("scope", scope);
|
||||
|
||||
|
||||
sc.setParameters("cluster", clusterId);
|
||||
return listBy(sc);
|
||||
} else {
|
||||
SearchCriteria<StoragePoolVO> sc = DcPodAnyClusterSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
sc.setParameters("podId", podId);
|
||||
sc.setParameters("status", Status.Up);
|
||||
sc.setParameters("scope", scope);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SearchCriteria<StoragePoolVO> sc = DcPodAnyClusterSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
sc.setParameters("podId", podId);
|
||||
sc.setParameters("status", Status.Up);
|
||||
sc.setParameters("scope", scope);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listPoolByHostPath(String host, String path) {
|
||||
@Override
|
||||
public List<StoragePoolVO> listPoolByHostPath(String host, String path) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", host);
|
||||
sc.setParameters("path", path);
|
||||
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
public StoragePoolVO listById(Integer id)
|
||||
{
|
||||
}
|
||||
|
||||
public StoragePoolVO listById(Integer id) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("id", id);
|
||||
|
||||
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
pool = super.persist(pool);
|
||||
if (details != null) {
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue());
|
||||
_detailsDao.persist(vo);
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
return pool;
|
||||
}
|
||||
|
||||
@DB
|
||||
@Override
|
||||
public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details, ScopeType scope) {
|
||||
StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
|
||||
if (clusterId != null) {
|
||||
sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND (");
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
sql.append("((storage_pool_details.name='").append(detail.getKey()).append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
|
||||
}
|
||||
sql.delete(sql.length() - 4, sql.length());
|
||||
sql.append(DetailsSqlSuffix);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
int i = 1;
|
||||
pstmt.setLong(i++, dcId);
|
||||
pstmt.setLong(i++, podId);
|
||||
pstmt.setString(i++, scope.toString());
|
||||
if (clusterId != null) {
|
||||
pstmt.setLong(i++, clusterId);
|
||||
}
|
||||
pstmt.setInt(i++, details.size());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
|
||||
while (rs.next()) {
|
||||
pools.add(toEntityBean(rs, false));
|
||||
}
|
||||
return pools;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + pstmt, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, String> tagsToDetails(String[] tags) {
|
||||
Map<String, String> details = new HashMap<String, String>(tags.length);
|
||||
for (String tag: tags) {
|
||||
details.put(tag, "true");
|
||||
}
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
|
||||
List<StoragePoolVO> storagePools = null;
|
||||
if (tags == null || tags.length == 0) {
|
||||
storagePools = listBy(dcId, podId, clusterId, ScopeType.CLUSTER);
|
||||
} else {
|
||||
Map<String, String> details = tagsToDetails(tags);
|
||||
storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.CLUSTER);
|
||||
}
|
||||
|
||||
return storagePools;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
|
||||
List<StoragePoolVO> storagePools = null;
|
||||
if (tags == null || tags.length == 0) {
|
||||
storagePools = listBy(dcId, podId, clusterId, ScopeType.HOST);
|
||||
} else {
|
||||
Map<String, String> details = tagsToDetails(tags);
|
||||
storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.HOST);
|
||||
}
|
||||
|
||||
return storagePools;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags) {
|
||||
List<StoragePoolVO> storagePools = null;
|
||||
if (tags == null || tags.length == 0) {
|
||||
SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc = SearchCriteria2.create(StoragePoolVO.class);
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
|
||||
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
|
||||
sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
|
||||
return sc.list();
|
||||
} else {
|
||||
Map<String, String> details = tagsToDetails(tags);
|
||||
|
||||
StringBuilder sql = new StringBuilder(ZoneWideDetailsSqlPrefix);
|
||||
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
sql.append("((storage_pool_details.name='").append(detail.getKey()).append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
|
||||
}
|
||||
sql.delete(sql.length() - 4, sql.length());
|
||||
sql.append(ZoneWideDetailsSqlSuffix);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
int i = 1;
|
||||
pstmt.setLong(i++, dcId);
|
||||
pstmt.setString(i++, ScopeType.ZONE.toString());
|
||||
pstmt.setInt(i++, details.size());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
|
||||
while (rs.next()) {
|
||||
pools.add(toEntityBean(rs, false));
|
||||
}
|
||||
return pools;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + pstmt, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public List<String> searchForStoragePoolDetails(long poolId, String value){
|
||||
|
||||
StringBuilder sql = new StringBuilder(FindPoolTagDetails);
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
pstmt.setLong(1, poolId);
|
||||
pstmt.setString(2, value);
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
List<String> tags = new ArrayList<String>();
|
||||
|
||||
while (rs.next()) {
|
||||
tags.add(rs.getString("name"));
|
||||
}
|
||||
return tags;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetails(long poolId, Map<String, String> details) {
|
||||
if (details != null) {
|
||||
_detailsDao.update(poolId, details);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDetails(long poolId) {
|
||||
return _detailsDao.getDetails(poolId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
_detailsDao.configure("DetailsDao", params);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public long countPoolsByStatus( StoragePoolStatus... statuses) {
|
||||
@DB
|
||||
public StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
pool = super.persist(pool);
|
||||
if (details != null) {
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue());
|
||||
_detailsDao.persist(vo);
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
return pool;
|
||||
}
|
||||
|
||||
@DB
|
||||
@Override
|
||||
public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details,
|
||||
ScopeType scope) {
|
||||
StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
|
||||
if (clusterId != null) {
|
||||
sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND (");
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
sql.append("((storage_pool_details.name='").append(detail.getKey())
|
||||
.append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
|
||||
}
|
||||
sql.delete(sql.length() - 4, sql.length());
|
||||
sql.append(DetailsSqlSuffix);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
int i = 1;
|
||||
pstmt.setLong(i++, dcId);
|
||||
pstmt.setLong(i++, podId);
|
||||
pstmt.setString(i++, scope.toString());
|
||||
if (clusterId != null) {
|
||||
pstmt.setLong(i++, clusterId);
|
||||
}
|
||||
pstmt.setInt(i++, details.size());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
|
||||
while (rs.next()) {
|
||||
pools.add(toEntityBean(rs, false));
|
||||
}
|
||||
return pools;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + pstmt, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, String> tagsToDetails(String[] tags) {
|
||||
Map<String, String> details = new HashMap<String, String>(tags.length);
|
||||
for (String tag : tags) {
|
||||
details.put(tag, "true");
|
||||
}
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
|
||||
List<StoragePoolVO> storagePools = null;
|
||||
if (tags == null || tags.length == 0) {
|
||||
storagePools = listBy(dcId, podId, clusterId, ScopeType.CLUSTER);
|
||||
} else {
|
||||
Map<String, String> details = tagsToDetails(tags);
|
||||
storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.CLUSTER);
|
||||
}
|
||||
|
||||
return storagePools;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
|
||||
List<StoragePoolVO> storagePools = null;
|
||||
if (tags == null || tags.length == 0) {
|
||||
storagePools = listBy(dcId, podId, clusterId, ScopeType.HOST);
|
||||
} else {
|
||||
Map<String, String> details = tagsToDetails(tags);
|
||||
storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.HOST);
|
||||
}
|
||||
|
||||
return storagePools;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags) {
|
||||
List<StoragePoolVO> storagePools = null;
|
||||
if (tags == null || tags.length == 0) {
|
||||
SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc = SearchCriteria2.create(StoragePoolVO.class);
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
|
||||
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
|
||||
sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
|
||||
return sc.list();
|
||||
} else {
|
||||
Map<String, String> details = tagsToDetails(tags);
|
||||
|
||||
StringBuilder sql = new StringBuilder(ZoneWideDetailsSqlPrefix);
|
||||
|
||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||
sql.append("((storage_pool_details.name='").append(detail.getKey())
|
||||
.append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
|
||||
}
|
||||
sql.delete(sql.length() - 4, sql.length());
|
||||
sql.append(ZoneWideDetailsSqlSuffix);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
int i = 1;
|
||||
pstmt.setLong(i++, dcId);
|
||||
pstmt.setString(i++, ScopeType.ZONE.toString());
|
||||
pstmt.setInt(i++, details.size());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
|
||||
while (rs.next()) {
|
||||
pools.add(toEntityBean(rs, false));
|
||||
}
|
||||
return pools;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + pstmt, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public List<String> searchForStoragePoolDetails(long poolId, String value) {
|
||||
|
||||
StringBuilder sql = new StringBuilder(FindPoolTagDetails);
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
pstmt.setLong(1, poolId);
|
||||
pstmt.setString(2, value);
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
List<String> tags = new ArrayList<String>();
|
||||
|
||||
while (rs.next()) {
|
||||
tags.add(rs.getString("name"));
|
||||
}
|
||||
return tags;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetails(long poolId, Map<String, String> details) {
|
||||
if (details != null) {
|
||||
_detailsDao.update(poolId, details);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDetails(long poolId) {
|
||||
return _detailsDao.getDetails(poolId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
_detailsDao.configure("DetailsDao", params);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countPoolsByStatus(StoragePoolStatus... statuses) {
|
||||
SearchCriteria<Long> sc = StatusCountSearch.create();
|
||||
|
||||
sc.setParameters("status", (Object[])statuses);
|
||||
|
||||
|
||||
sc.setParameters("status", (Object[]) statuses);
|
||||
|
||||
List<Long> rs = customSearchIncludingRemoved(sc, null);
|
||||
if (rs.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return rs.get(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listPoolsByCluster(long clusterId) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("clusterId", clusterId);
|
||||
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,28 +24,28 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="storage_pool_details")
|
||||
@Table(name = "storage_pool_details")
|
||||
public class PrimaryDataStoreDetailVO {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
long id;
|
||||
|
||||
@Column(name="pool_id")
|
||||
|
||||
@Column(name = "pool_id")
|
||||
long poolId;
|
||||
|
||||
@Column(name="name")
|
||||
|
||||
@Column(name = "name")
|
||||
String name;
|
||||
|
||||
@Column(name="value")
|
||||
|
||||
@Column(name = "value")
|
||||
String value;
|
||||
|
||||
|
||||
public PrimaryDataStoreDetailVO(long poolId, String name, String value) {
|
||||
this.poolId = poolId;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ import java.util.Map;
|
|||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface PrimaryDataStoreDetailsDao extends GenericDao<PrimaryDataStoreDetailVO, Long> {
|
||||
|
||||
|
||||
void update(long poolId, Map<String, String> details);
|
||||
|
||||
Map<String, String> getDetails(long poolId);
|
||||
}
|
||||
|
|
@ -16,18 +16,17 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.storage.datastore.db;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
|
||||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.fsm.StateDao;
|
||||
|
||||
public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
|
||||
public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>,
|
||||
StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
|
||||
|
||||
public List<SnapshotDataStoreVO> listByStoreId(long id, DataStoreRole role);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,49 +40,48 @@ import com.cloud.utils.fsm.StateObject;
|
|||
|
||||
/**
|
||||
* Join table for image_data_store and snapshots
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="snapshot_store_ref")
|
||||
@Table(name = "snapshot_store_ref")
|
||||
public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
Long id;
|
||||
|
||||
@Column(name="store_id")
|
||||
private long dataStoreId;
|
||||
@Column(name = "store_id")
|
||||
private long dataStoreId;
|
||||
|
||||
@Column(name="store_role")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private DataStoreRole role;
|
||||
@Column(name = "store_role")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private DataStoreRole role;
|
||||
|
||||
@Column(name="snapshot_id")
|
||||
private long snapshotId;
|
||||
@Column(name = "snapshot_id")
|
||||
private long snapshotId;
|
||||
|
||||
@Column(name=GenericDaoBase.CREATED_COLUMN)
|
||||
private Date created = null;
|
||||
@Column(name = GenericDaoBase.CREATED_COLUMN)
|
||||
private Date created = null;
|
||||
|
||||
@Column(name="last_updated")
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
private Date lastUpdated = null;
|
||||
@Column(name = "last_updated")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
private Date lastUpdated = null;
|
||||
|
||||
@Column (name="size")
|
||||
private long size;
|
||||
@Column(name = "size")
|
||||
private long size;
|
||||
|
||||
@Column (name="physical_size")
|
||||
private long physicalSize;
|
||||
@Column(name = "physical_size")
|
||||
private long physicalSize;
|
||||
|
||||
@Column(name="parent_snapshot_id")
|
||||
private long parentSnapshotId;
|
||||
@Column(name = "parent_snapshot_id")
|
||||
private long parentSnapshotId;
|
||||
|
||||
@Column (name="job_id")
|
||||
private String jobId;
|
||||
@Column(name = "job_id")
|
||||
private String jobId;
|
||||
|
||||
@Column (name="install_path")
|
||||
@Column(name = "install_path")
|
||||
private String installPath;
|
||||
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
@Column(name = "update_count", updatable = true, nullable = false)
|
||||
protected long updatedCount;
|
||||
|
||||
@Column(name = "updated")
|
||||
|
|
@ -94,97 +93,78 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
ObjectInDataStoreStateMachine.State state;
|
||||
|
||||
public String getInstallPath() {
|
||||
return installPath;
|
||||
}
|
||||
return installPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataStoreId() {
|
||||
return dataStoreId;
|
||||
}
|
||||
|
||||
public void setDataStoreId(long storeId) {
|
||||
this.dataStoreId = storeId;
|
||||
}
|
||||
public long getDataStoreId() {
|
||||
return dataStoreId;
|
||||
}
|
||||
|
||||
public void setDataStoreId(long storeId) {
|
||||
this.dataStoreId = storeId;
|
||||
}
|
||||
|
||||
public long getSnapshotId() {
|
||||
return snapshotId;
|
||||
}
|
||||
|
||||
return snapshotId;
|
||||
}
|
||||
|
||||
public void setSnapshotId(long snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.snapshotId = snapshotId;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
return created;
|
||||
}
|
||||
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public void setLastUpdated(Date date) {
|
||||
lastUpdated = date;
|
||||
}
|
||||
|
||||
lastUpdated = date;
|
||||
}
|
||||
|
||||
public void setInstallPath(String installPath) {
|
||||
this.installPath = installPath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SnapshotDataStoreVO(long hostId, long snapshotId) {
|
||||
super();
|
||||
this.dataStoreId = hostId;
|
||||
this.snapshotId = snapshotId;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SnapshotDataStoreVO() {
|
||||
|
||||
}
|
||||
this.installPath = installPath;
|
||||
}
|
||||
|
||||
public SnapshotDataStoreVO(long hostId, long snapshotId) {
|
||||
super();
|
||||
this.dataStoreId = hostId;
|
||||
this.snapshotId = snapshotId;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
}
|
||||
|
||||
public SnapshotDataStoreVO() {
|
||||
|
||||
}
|
||||
|
||||
public void setJobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof SnapshotDataStoreVO) {
|
||||
SnapshotDataStoreVO other = (SnapshotDataStoreVO) obj;
|
||||
return (this.snapshotId == other.getSnapshotId() && this.dataStoreId == other.getDataStoreId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof SnapshotDataStoreVO) {
|
||||
SnapshotDataStoreVO other = (SnapshotDataStoreVO)obj;
|
||||
return (this.snapshotId==other.getSnapshotId() && this.dataStoreId==other.getDataStoreId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public int hashCode() {
|
||||
Long tid = new Long(snapshotId);
|
||||
Long hid = new Long(dataStoreId);
|
||||
return tid.hashCode()+hid.hashCode();
|
||||
}
|
||||
public int hashCode() {
|
||||
Long tid = new Long(snapshotId);
|
||||
Long hid = new Long(dataStoreId);
|
||||
return tid.hashCode() + hid.hashCode();
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
|
|
@ -194,7 +174,6 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
return size;
|
||||
}
|
||||
|
||||
|
||||
public void setPhysicalSize(long physicalSize) {
|
||||
this.physicalSize = physicalSize;
|
||||
}
|
||||
|
|
@ -203,14 +182,14 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
return physicalSize;
|
||||
}
|
||||
|
||||
public long getVolumeSize() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public long getVolumeSize() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new StringBuilder("VolumeHost[").append(id).append("-").append(snapshotId).append("-").append(dataStoreId).append(installPath).append("]").toString();
|
||||
}
|
||||
return new StringBuilder("VolumeHost[").append(id).append("-").append(snapshotId).append("-")
|
||||
.append(dataStoreId).append(installPath).append("]").toString();
|
||||
}
|
||||
|
||||
public long getUpdatedCount() {
|
||||
return this.updatedCount;
|
||||
|
|
@ -234,7 +213,6 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
return this.state;
|
||||
}
|
||||
|
||||
|
||||
public void setState(ObjectInDataStoreStateMachine.State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
|
@ -254,14 +232,14 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
|
||||
@Override
|
||||
public State getObjectInStoreState() {
|
||||
return this.state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public long getParentSnapshotId() {
|
||||
return parentSnapshotId;
|
||||
}
|
||||
public long getParentSnapshotId() {
|
||||
return parentSnapshotId;
|
||||
}
|
||||
|
||||
public void setParentSnapshotId(long parentSnapshotId) {
|
||||
this.parentSnapshotId = parentSnapshotId;
|
||||
}
|
||||
public void setParentSnapshotId(long parentSnapshotId) {
|
||||
this.parentSnapshotId = parentSnapshotId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,28 +26,28 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="storage_pool_details")
|
||||
@Table(name = "storage_pool_details")
|
||||
public class StoragePoolDetailVO implements InternalIdentity {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
long id;
|
||||
|
||||
@Column(name="pool_id")
|
||||
|
||||
@Column(name = "pool_id")
|
||||
long poolId;
|
||||
|
||||
@Column(name="name")
|
||||
|
||||
@Column(name = "name")
|
||||
String name;
|
||||
|
||||
@Column(name="value")
|
||||
|
||||
@Column(name = "value")
|
||||
String value;
|
||||
|
||||
|
||||
public StoragePoolDetailVO(long poolId, String name, String value) {
|
||||
this.poolId = poolId;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,13 @@ package org.apache.cloudstack.storage.datastore.db;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface StoragePoolDetailsDao extends GenericDao<StoragePoolDetailVO, Long> {
|
||||
|
||||
|
||||
void update(long poolId, Map<String, String> details);
|
||||
|
||||
Map<String, String> getDetails(long poolId);
|
||||
|
||||
StoragePoolDetailVO findDetail(long poolId, String name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import javax.persistence.TableGenerator;
|
|||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
|
@ -37,10 +36,11 @@ import com.cloud.storage.StoragePoolStatus;
|
|||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name="storage_pool")
|
||||
public class StoragePoolVO implements StoragePool{
|
||||
@Table(name = "storage_pool")
|
||||
public class StoragePoolVO implements StoragePool {
|
||||
@Id
|
||||
@TableGenerator(name = "storage_pool_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "storage_pool_seq", allocationSize = 1)
|
||||
@TableGenerator(name = "storage_pool_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
|
||||
pkColumnValue = "storage_pool_seq", allocationSize = 1)
|
||||
@Column(name = "id", updatable = false, nullable = false)
|
||||
private long id;
|
||||
|
||||
|
|
@ -113,10 +113,10 @@ public class StoragePoolVO implements StoragePool{
|
|||
public StoragePoolVO() {
|
||||
this.status = StoragePoolStatus.Initial;
|
||||
}
|
||||
|
||||
public StoragePoolVO(long poolId, String name, String uuid, StoragePoolType type,
|
||||
long dataCenterId, Long podId, long availableBytes, long capacityBytes, String hostAddress, int port, String hostPath) {
|
||||
this.name = name;
|
||||
|
||||
public StoragePoolVO(long poolId, String name, String uuid, StoragePoolType type, long dataCenterId, Long podId,
|
||||
long availableBytes, long capacityBytes, String hostAddress, int port, String hostPath) {
|
||||
this.name = name;
|
||||
this.id = poolId;
|
||||
this.uuid = uuid;
|
||||
this.poolType = type;
|
||||
|
|
@ -131,7 +131,8 @@ public class StoragePoolVO implements StoragePool{
|
|||
}
|
||||
|
||||
public StoragePoolVO(StoragePoolVO that) {
|
||||
this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.availableBytes, that.capacityBytes, that.hostAddress, that.port, that.path);
|
||||
this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.availableBytes,
|
||||
that.capacityBytes, that.hostAddress, that.port, that.path);
|
||||
}
|
||||
|
||||
public StoragePoolVO(StoragePoolType type, String hostAddress, int port, String path) {
|
||||
|
|
@ -143,7 +144,6 @@ public class StoragePoolVO implements StoragePool{
|
|||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
@ -294,11 +294,11 @@ public class StoragePoolVO implements StoragePool{
|
|||
public String toString() {
|
||||
return new StringBuilder("Pool[").append(id).append("|").append(poolType).append("]").toString();
|
||||
}
|
||||
|
||||
|
||||
public boolean isShared() {
|
||||
return this.scope == ScopeType.HOST ? false : true;
|
||||
}
|
||||
|
||||
|
||||
public boolean isLocal() {
|
||||
return !isShared();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,13 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreState
|
|||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
|
||||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.fsm.StateDao;
|
||||
|
||||
public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
|
||||
|
||||
public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>,
|
||||
StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
|
||||
|
||||
public List<TemplateDataStoreVO> listByStoreId(long id);
|
||||
|
||||
|
|
@ -43,11 +42,14 @@ public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Lo
|
|||
|
||||
List<TemplateDataStoreVO> listByTemplateStoreStatus(long templateId, long storeId, State... states);
|
||||
|
||||
List<TemplateDataStoreVO> listByTemplateStoreDownloadStatus(long templateId, long storeId, VMTemplateStorageResourceAssoc.Status... status);
|
||||
List<TemplateDataStoreVO> listByTemplateStoreDownloadStatus(long templateId, long storeId,
|
||||
VMTemplateStorageResourceAssoc.Status... status);
|
||||
|
||||
List<TemplateDataStoreVO> listByTemplateZoneDownloadStatus(long templateId, Long zoneId, VMTemplateStorageResourceAssoc.Status... status);
|
||||
List<TemplateDataStoreVO> listByTemplateZoneDownloadStatus(long templateId, Long zoneId,
|
||||
VMTemplateStorageResourceAssoc.Status... status);
|
||||
|
||||
TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId, VMTemplateStorageResourceAssoc.Status... status);
|
||||
TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId,
|
||||
VMTemplateStorageResourceAssoc.Status... status);
|
||||
|
||||
TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,67 +41,67 @@ import com.cloud.utils.fsm.StateObject;
|
|||
|
||||
/**
|
||||
* Join table for image_data_store and templates
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="template_store_ref")
|
||||
@Table(name = "template_store_ref")
|
||||
public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
Long id;
|
||||
|
||||
@Column(name="store_id")
|
||||
private Long dataStoreId; // this can be null for baremetal templates
|
||||
@Column(name = "store_id")
|
||||
private Long dataStoreId; // this can be null for baremetal templates
|
||||
|
||||
@Column(name="template_id")
|
||||
private long templateId;
|
||||
@Column(name = "template_id")
|
||||
private long templateId;
|
||||
|
||||
@Column(name="store_role")
|
||||
@Column(name = "store_role")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private DataStoreRole dataStoreRole;
|
||||
|
||||
@Column(name=GenericDaoBase.CREATED_COLUMN)
|
||||
private Date created = null;
|
||||
@Column(name = GenericDaoBase.CREATED_COLUMN)
|
||||
private Date created = null;
|
||||
|
||||
@Column(name="last_updated")
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
private Date lastUpdated = null;
|
||||
@Column(name = "last_updated")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
private Date lastUpdated = null;
|
||||
|
||||
@Column (name="download_pct")
|
||||
private int downloadPercent;
|
||||
@Column(name = "download_pct")
|
||||
private int downloadPercent;
|
||||
|
||||
@Column (name="size")
|
||||
private long size;
|
||||
@Column(name = "size")
|
||||
private long size;
|
||||
|
||||
@Column (name="physical_size")
|
||||
private long physicalSize;
|
||||
@Column(name = "physical_size")
|
||||
private long physicalSize;
|
||||
|
||||
@Column (name="download_state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status downloadState;
|
||||
@Column(name = "download_state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status downloadState;
|
||||
|
||||
@Column (name="local_path")
|
||||
private String localDownloadPath;
|
||||
@Column(name = "local_path")
|
||||
private String localDownloadPath;
|
||||
|
||||
@Column (name="error_str")
|
||||
private String errorString;
|
||||
@Column(name = "error_str")
|
||||
private String errorString;
|
||||
|
||||
@Column (name="job_id")
|
||||
private String jobId;
|
||||
@Column(name = "job_id")
|
||||
private String jobId;
|
||||
|
||||
@Column (name="install_path")
|
||||
@Column(name = "install_path")
|
||||
private String installPath;
|
||||
|
||||
@Column (name="url")
|
||||
private String downloadUrl;
|
||||
@Column(name = "url")
|
||||
private String downloadUrl;
|
||||
|
||||
@Column(name="is_copy")
|
||||
private boolean isCopy = false;
|
||||
@Column(name = "is_copy")
|
||||
private boolean isCopy = false;
|
||||
|
||||
@Column(name="destroyed")
|
||||
@Column(name = "destroyed")
|
||||
boolean destroyed = false;
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
@Column(name = "update_count", updatable = true, nullable = false)
|
||||
protected long updatedCount;
|
||||
|
||||
@Column(name = "updated")
|
||||
|
|
@ -112,31 +112,27 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
@Enumerated(EnumType.STRING)
|
||||
ObjectInDataStoreStateMachine.State state;
|
||||
|
||||
public TemplateDataStoreVO(Long hostId, long templateId) {
|
||||
super();
|
||||
this.dataStoreId = hostId;
|
||||
this.templateId = templateId;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TemplateDataStoreVO(Long hostId, long templateId) {
|
||||
super();
|
||||
this.dataStoreId = hostId;
|
||||
this.templateId = templateId;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
}
|
||||
|
||||
public TemplateDataStoreVO(Long hostId, long templateId, Date lastUpdated,
|
||||
int downloadPercent, Status downloadState,
|
||||
String localDownloadPath, String errorString, String jobId,
|
||||
String installPath, String downloadUrl) {
|
||||
super();
|
||||
this.dataStoreId = hostId;
|
||||
this.templateId = templateId;
|
||||
this.lastUpdated = lastUpdated;
|
||||
this.downloadPercent = downloadPercent;
|
||||
this.downloadState = downloadState;
|
||||
this.localDownloadPath = localDownloadPath;
|
||||
this.errorString = errorString;
|
||||
this.jobId = jobId;
|
||||
this.installPath = installPath;
|
||||
this.setDownloadUrl(downloadUrl);
|
||||
public TemplateDataStoreVO(Long hostId, long templateId, Date lastUpdated, int downloadPercent,
|
||||
Status downloadState, String localDownloadPath, String errorString, String jobId, String installPath,
|
||||
String downloadUrl) {
|
||||
super();
|
||||
this.dataStoreId = hostId;
|
||||
this.templateId = templateId;
|
||||
this.lastUpdated = lastUpdated;
|
||||
this.downloadPercent = downloadPercent;
|
||||
this.downloadState = downloadState;
|
||||
this.localDownloadPath = localDownloadPath;
|
||||
this.errorString = errorString;
|
||||
this.jobId = jobId;
|
||||
this.installPath = installPath;
|
||||
this.setDownloadUrl(downloadUrl);
|
||||
switch (downloadState) {
|
||||
case DOWNLOADED:
|
||||
this.state = ObjectInDataStoreStateMachine.State.Ready;
|
||||
|
|
@ -157,18 +153,17 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TemplateDataStoreVO() {
|
||||
public TemplateDataStoreVO() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstallPath() {
|
||||
return installPath;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getDataStoreId() {
|
||||
return dataStoreId;
|
||||
|
|
@ -224,44 +219,44 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
}
|
||||
|
||||
public void setLocalDownloadPath(String localPath) {
|
||||
this.localDownloadPath = localPath;
|
||||
}
|
||||
this.localDownloadPath = localPath;
|
||||
}
|
||||
|
||||
public String getLocalDownloadPath() {
|
||||
return localDownloadPath;
|
||||
}
|
||||
return localDownloadPath;
|
||||
}
|
||||
|
||||
public void setErrorString(String errorString) {
|
||||
this.errorString = errorString;
|
||||
}
|
||||
this.errorString = errorString;
|
||||
}
|
||||
|
||||
public String getErrorString() {
|
||||
return errorString;
|
||||
}
|
||||
return errorString;
|
||||
}
|
||||
|
||||
public void setJobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
return jobId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof TemplateDataStoreVO) {
|
||||
TemplateDataStoreVO other = (TemplateDataStoreVO)obj;
|
||||
return (this.templateId==other.getTemplateId() && this.dataStoreId==other.getDataStoreId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof TemplateDataStoreVO) {
|
||||
TemplateDataStoreVO other = (TemplateDataStoreVO) obj;
|
||||
return (this.templateId == other.getTemplateId() && this.dataStoreId == other.getDataStoreId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
Long tid = new Long(templateId);
|
||||
Long hid = new Long(dataStoreId);
|
||||
return tid.hashCode()+hid.hashCode();
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
Long tid = new Long(templateId);
|
||||
Long hid = new Long(dataStoreId);
|
||||
return tid.hashCode() + hid.hashCode();
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
|
|
@ -271,7 +266,6 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
return size;
|
||||
}
|
||||
|
||||
|
||||
public void setPhysicalSize(long physicalSize) {
|
||||
this.physicalSize = physicalSize;
|
||||
}
|
||||
|
|
@ -281,37 +275,38 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
}
|
||||
|
||||
public void setDestroyed(boolean destroyed) {
|
||||
this.destroyed = destroyed;
|
||||
this.destroyed = destroyed;
|
||||
}
|
||||
|
||||
public boolean getDestroyed() {
|
||||
return destroyed;
|
||||
return destroyed;
|
||||
}
|
||||
|
||||
public void setDownloadUrl(String downloadUrl) {
|
||||
this.downloadUrl = downloadUrl;
|
||||
}
|
||||
public void setDownloadUrl(String downloadUrl) {
|
||||
this.downloadUrl = downloadUrl;
|
||||
}
|
||||
|
||||
public String getDownloadUrl() {
|
||||
return downloadUrl;
|
||||
}
|
||||
public String getDownloadUrl() {
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
public void setCopy(boolean isCopy) {
|
||||
this.isCopy = isCopy;
|
||||
}
|
||||
public void setCopy(boolean isCopy) {
|
||||
this.isCopy = isCopy;
|
||||
}
|
||||
|
||||
public boolean isCopy() {
|
||||
return isCopy;
|
||||
}
|
||||
public boolean isCopy() {
|
||||
return isCopy;
|
||||
}
|
||||
|
||||
public long getTemplateSize() {
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("TmplHost[").append(id).append("-").append(templateId).append("-").append(dataStoreId).append(installPath).append("]").toString();
|
||||
}
|
||||
return new StringBuilder("TmplHost[").append(id).append("-").append(templateId).append("-").append(dataStoreId)
|
||||
.append(installPath).append("]").toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectInDataStoreStateMachine.State getState() {
|
||||
|
|
@ -319,12 +314,10 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
return this.state;
|
||||
}
|
||||
|
||||
|
||||
public void setState(ObjectInDataStoreStateMachine.State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
public long getUpdatedCount() {
|
||||
return this.updatedCount;
|
||||
}
|
||||
|
|
@ -341,7 +334,6 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
return updated;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getObjectId() {
|
||||
return this.getTemplateId();
|
||||
|
|
@ -349,7 +341,7 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
|
||||
@Override
|
||||
public State getObjectInStoreState() {
|
||||
return this.state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public DataStoreRole getDataStoreRole() {
|
||||
|
|
@ -360,6 +352,4 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
|||
this.dataStoreRole = dataStoreRole;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,16 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.storage.datastore.db;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.fsm.StateDao;
|
||||
|
||||
public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
|
||||
public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
|
||||
StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
|
||||
|
||||
public List<VolumeDataStoreVO> listByStoreId(long id);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,66 +41,66 @@ import com.cloud.utils.fsm.StateObject;
|
|||
|
||||
/**
|
||||
* Join table for image_data_store and volumes
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="volume_store_ref")
|
||||
@Table(name = "volume_store_ref")
|
||||
public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
Long id;
|
||||
|
||||
@Column(name="store_id")
|
||||
private long dataStoreId;
|
||||
@Column(name = "store_id")
|
||||
private long dataStoreId;
|
||||
|
||||
@Column(name="volume_id")
|
||||
private long volumeId;
|
||||
@Column(name = "volume_id")
|
||||
private long volumeId;
|
||||
|
||||
@Column(name="zone_id")
|
||||
private long zoneId;
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
||||
@Column(name=GenericDaoBase.CREATED_COLUMN)
|
||||
private Date created = null;
|
||||
@Column(name = GenericDaoBase.CREATED_COLUMN)
|
||||
private Date created = null;
|
||||
|
||||
@Column(name="last_updated")
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
private Date lastUpdated = null;
|
||||
@Column(name = "last_updated")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
private Date lastUpdated = null;
|
||||
|
||||
@Column (name="download_pct")
|
||||
private int downloadPercent;
|
||||
@Column(name = "download_pct")
|
||||
private int downloadPercent;
|
||||
|
||||
@Column (name="size")
|
||||
private long size;
|
||||
@Column(name = "size")
|
||||
private long size;
|
||||
|
||||
@Column (name="physical_size")
|
||||
private long physicalSize;
|
||||
@Column(name = "physical_size")
|
||||
private long physicalSize;
|
||||
|
||||
@Column (name="download_state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status downloadState;
|
||||
@Column(name = "download_state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status downloadState;
|
||||
|
||||
@Column(name="checksum")
|
||||
@Column(name = "checksum")
|
||||
private String checksum;
|
||||
|
||||
@Column (name="local_path")
|
||||
private String localDownloadPath;
|
||||
@Column(name = "local_path")
|
||||
private String localDownloadPath;
|
||||
|
||||
@Column (name="error_str")
|
||||
private String errorString;
|
||||
@Column(name = "error_str")
|
||||
private String errorString;
|
||||
|
||||
@Column (name="job_id")
|
||||
private String jobId;
|
||||
@Column(name = "job_id")
|
||||
private String jobId;
|
||||
|
||||
@Column (name="install_path")
|
||||
@Column(name = "install_path")
|
||||
private String installPath;
|
||||
|
||||
@Column (name="url")
|
||||
private String downloadUrl;
|
||||
@Column(name = "url")
|
||||
private String downloadUrl;
|
||||
|
||||
@Column(name="destroyed")
|
||||
@Column(name = "destroyed")
|
||||
boolean destroyed = false;
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
@Column(name = "update_count", updatable = true, nullable = false)
|
||||
protected long updatedCount;
|
||||
|
||||
@Column(name = "updated")
|
||||
|
|
@ -112,164 +112,144 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
|
|||
ObjectInDataStoreStateMachine.State state;
|
||||
|
||||
public String getInstallPath() {
|
||||
return installPath;
|
||||
}
|
||||
return installPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataStoreId() {
|
||||
return dataStoreId;
|
||||
}
|
||||
|
||||
public void setDataStoreId(long storeId) {
|
||||
this.dataStoreId = storeId;
|
||||
}
|
||||
public long getDataStoreId() {
|
||||
return dataStoreId;
|
||||
}
|
||||
|
||||
public void setDataStoreId(long storeId) {
|
||||
this.dataStoreId = storeId;
|
||||
}
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public void setVolumeId(long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public int getDownloadPercent() {
|
||||
return downloadPercent;
|
||||
}
|
||||
public void setZoneId(long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public int getDownloadPercent() {
|
||||
return downloadPercent;
|
||||
}
|
||||
|
||||
public void setDownloadPercent(int downloadPercent) {
|
||||
this.downloadPercent = downloadPercent;
|
||||
}
|
||||
|
||||
this.downloadPercent = downloadPercent;
|
||||
}
|
||||
|
||||
public void setDownloadState(Status downloadState) {
|
||||
this.downloadState = downloadState;
|
||||
}
|
||||
|
||||
this.downloadState = downloadState;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
return created;
|
||||
}
|
||||
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public void setLastUpdated(Date date) {
|
||||
lastUpdated = date;
|
||||
}
|
||||
|
||||
lastUpdated = date;
|
||||
}
|
||||
|
||||
public void setInstallPath(String installPath) {
|
||||
this.installPath = installPath;
|
||||
}
|
||||
|
||||
this.installPath = installPath;
|
||||
}
|
||||
|
||||
public Status getDownloadState() {
|
||||
return downloadState;
|
||||
}
|
||||
return downloadState;
|
||||
}
|
||||
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public void setChecksum(String checksum) {
|
||||
this.checksum = checksum;
|
||||
}
|
||||
public void setChecksum(String checksum) {
|
||||
this.checksum = checksum;
|
||||
}
|
||||
|
||||
public VolumeDataStoreVO(long hostId, long volumeId) {
|
||||
super();
|
||||
this.dataStoreId = hostId;
|
||||
this.volumeId = volumeId;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
}
|
||||
public VolumeDataStoreVO(long hostId, long volumeId) {
|
||||
super();
|
||||
this.dataStoreId = hostId;
|
||||
this.volumeId = volumeId;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
}
|
||||
|
||||
public VolumeDataStoreVO(long hostId, long volumeId, Date lastUpdated,
|
||||
int downloadPercent, Status downloadState,
|
||||
String localDownloadPath, String errorString, String jobId,
|
||||
String installPath, String downloadUrl, String checksum) {
|
||||
//super();
|
||||
this.dataStoreId = hostId;
|
||||
this.volumeId = volumeId;
|
||||
//this.zoneId = zoneId;
|
||||
this.lastUpdated = lastUpdated;
|
||||
this.downloadPercent = downloadPercent;
|
||||
this.downloadState = downloadState;
|
||||
this.localDownloadPath = localDownloadPath;
|
||||
this.errorString = errorString;
|
||||
this.jobId = jobId;
|
||||
this.installPath = installPath;
|
||||
this.setDownloadUrl(downloadUrl);
|
||||
this.checksum = checksum;
|
||||
}
|
||||
public VolumeDataStoreVO(long hostId, long volumeId, Date lastUpdated, int downloadPercent, Status downloadState,
|
||||
String localDownloadPath, String errorString, String jobId, String installPath, String downloadUrl,
|
||||
String checksum) {
|
||||
// super();
|
||||
this.dataStoreId = hostId;
|
||||
this.volumeId = volumeId;
|
||||
// this.zoneId = zoneId;
|
||||
this.lastUpdated = lastUpdated;
|
||||
this.downloadPercent = downloadPercent;
|
||||
this.downloadState = downloadState;
|
||||
this.localDownloadPath = localDownloadPath;
|
||||
this.errorString = errorString;
|
||||
this.jobId = jobId;
|
||||
this.installPath = installPath;
|
||||
this.setDownloadUrl(downloadUrl);
|
||||
this.checksum = checksum;
|
||||
}
|
||||
|
||||
public VolumeDataStoreVO() {
|
||||
|
||||
}
|
||||
public VolumeDataStoreVO() {
|
||||
|
||||
}
|
||||
|
||||
public void setLocalDownloadPath(String localPath) {
|
||||
this.localDownloadPath = localPath;
|
||||
}
|
||||
|
||||
this.localDownloadPath = localPath;
|
||||
}
|
||||
|
||||
public String getLocalDownloadPath() {
|
||||
return localDownloadPath;
|
||||
}
|
||||
|
||||
return localDownloadPath;
|
||||
}
|
||||
|
||||
public void setErrorString(String errorString) {
|
||||
this.errorString = errorString;
|
||||
}
|
||||
|
||||
this.errorString = errorString;
|
||||
}
|
||||
|
||||
public String getErrorString() {
|
||||
return errorString;
|
||||
}
|
||||
|
||||
return errorString;
|
||||
}
|
||||
|
||||
public void setJobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof VolumeDataStoreVO) {
|
||||
VolumeDataStoreVO other = (VolumeDataStoreVO) obj;
|
||||
return (this.volumeId == other.getVolumeId() && this.dataStoreId == other.getDataStoreId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof VolumeDataStoreVO) {
|
||||
VolumeDataStoreVO other = (VolumeDataStoreVO)obj;
|
||||
return (this.volumeId==other.getVolumeId() && this.dataStoreId==other.getDataStoreId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public int hashCode() {
|
||||
Long tid = new Long(volumeId);
|
||||
Long hid = new Long(dataStoreId);
|
||||
return tid.hashCode()+hid.hashCode();
|
||||
}
|
||||
public int hashCode() {
|
||||
Long tid = new Long(volumeId);
|
||||
Long hid = new Long(dataStoreId);
|
||||
return tid.hashCode() + hid.hashCode();
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
|
|
@ -279,7 +259,6 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
|
|||
return size;
|
||||
}
|
||||
|
||||
|
||||
public void setPhysicalSize(long physicalSize) {
|
||||
this.physicalSize = physicalSize;
|
||||
}
|
||||
|
|
@ -289,29 +268,29 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
|
|||
}
|
||||
|
||||
public void setDestroyed(boolean destroyed) {
|
||||
this.destroyed = destroyed;
|
||||
this.destroyed = destroyed;
|
||||
}
|
||||
|
||||
public boolean getDestroyed() {
|
||||
return destroyed;
|
||||
return destroyed;
|
||||
}
|
||||
|
||||
public void setDownloadUrl(String downloadUrl) {
|
||||
this.downloadUrl = downloadUrl;
|
||||
}
|
||||
public void setDownloadUrl(String downloadUrl) {
|
||||
this.downloadUrl = downloadUrl;
|
||||
}
|
||||
|
||||
public String getDownloadUrl() {
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
public long getVolumeSize() {
|
||||
return -1;
|
||||
}
|
||||
public String getDownloadUrl() {
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
public long getVolumeSize() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(dataStoreId).append(installPath).append("]").toString();
|
||||
}
|
||||
return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(dataStoreId)
|
||||
.append(installPath).append("]").toString();
|
||||
}
|
||||
|
||||
public long getUpdatedCount() {
|
||||
return this.updatedCount;
|
||||
|
|
@ -335,7 +314,6 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
|
|||
return this.state;
|
||||
}
|
||||
|
||||
|
||||
public void setState(ObjectInDataStoreStateMachine.State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
|
@ -350,5 +328,4 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
|
|||
return this.state;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,14 @@ import com.cloud.storage.ImageStore;
|
|||
|
||||
public interface ImageStoreEntity extends DataStore, ImageStore {
|
||||
TemplateInfo getTemplate(long templateId);
|
||||
|
||||
VolumeInfo getVolume(long volumeId);
|
||||
|
||||
SnapshotInfo getSnapshot(long snapshotId);
|
||||
|
||||
boolean exists(DataObject object);
|
||||
|
||||
Set<TemplateInfo> listTemplates();
|
||||
|
||||
String getMountPoint(); // get the mount point on ssvm.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,5 +22,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
|||
|
||||
public interface ImageStoreInfo extends DataStore {
|
||||
public long getImageStoreId();
|
||||
|
||||
public String getType();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class ImageStoreTO implements DataStoreTO {
|
|||
private String providerName;
|
||||
private DataStoreRole role;
|
||||
|
||||
public ImageStoreTO(){
|
||||
public ImageStoreTO() {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,6 @@ public class ImageStoreTO implements DataStoreTO {
|
|||
return providerName;
|
||||
}
|
||||
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.storage.to;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||
|
||||
public class NfsPrimaryDataStoreTO extends PrimaryDataStoreTO {
|
||||
private String server;
|
||||
private String path;
|
||||
|
||||
public NfsPrimaryDataStoreTO(PrimaryDataStoreInfo dataStore) {
|
||||
super(dataStore);
|
||||
}
|
||||
|
||||
public void setServer(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
}
|
||||
|
|
@ -25,35 +25,35 @@ import com.cloud.storage.Storage.StoragePoolType;
|
|||
public class PrimaryDataStoreTO implements DataStoreTO {
|
||||
private final String uuid;
|
||||
private final String name;
|
||||
private String type;
|
||||
private String type;
|
||||
private final long id;
|
||||
private StoragePoolType poolType;
|
||||
private String host;
|
||||
private String path;
|
||||
private int port;
|
||||
|
||||
public PrimaryDataStoreTO(PrimaryDataStoreInfo dataStore) {
|
||||
this.uuid = dataStore.getUuid();
|
||||
this.name = dataStore.getName();
|
||||
// this.type = dataStore.getType();
|
||||
this.id = dataStore.getId();
|
||||
this.setPoolType(dataStore.getPoolType());
|
||||
this.setHost(dataStore.getHostAddress());
|
||||
this.setPath(dataStore.getPath());
|
||||
this.setPort(dataStore.getPort());
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,50 +24,50 @@ import com.cloud.agent.api.to.DataTO;
|
|||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
public class SnapshotObjectTO implements DataTO {
|
||||
private String path;
|
||||
private VolumeObjectTO volume;
|
||||
private String parentSnapshotPath;
|
||||
private DataStoreTO dataStore;
|
||||
private String vmName;
|
||||
private String name;
|
||||
private HypervisorType hypervisorType;
|
||||
private long id;
|
||||
|
||||
public SnapshotObjectTO() {
|
||||
|
||||
}
|
||||
|
||||
public SnapshotObjectTO(SnapshotInfo snapshot) {
|
||||
this.path = snapshot.getPath();
|
||||
this.setId(snapshot.getId());
|
||||
this.volume = (VolumeObjectTO)snapshot.getBaseVolume().getTO();
|
||||
this.setVmName(snapshot.getBaseVolume().getAttachedVmName());
|
||||
if (snapshot.getParent() != null) {
|
||||
this.parentSnapshotPath = snapshot.getParent().getPath();
|
||||
}
|
||||
this.dataStore = snapshot.getDataStore().getTO();
|
||||
this.setName(snapshot.getName());
|
||||
this.hypervisorType = snapshot.getHypervisorType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObjectType getObjectType() {
|
||||
return DataObjectType.SNAPSHOT;
|
||||
}
|
||||
private String path;
|
||||
private VolumeObjectTO volume;
|
||||
private String parentSnapshotPath;
|
||||
private DataStoreTO dataStore;
|
||||
private String vmName;
|
||||
private String name;
|
||||
private HypervisorType hypervisorType;
|
||||
private long id;
|
||||
|
||||
@Override
|
||||
public DataStoreTO getDataStore() {
|
||||
return this.dataStore;
|
||||
}
|
||||
public SnapshotObjectTO() {
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
||||
|
||||
public SnapshotObjectTO(SnapshotInfo snapshot) {
|
||||
this.path = snapshot.getPath();
|
||||
this.setId(snapshot.getId());
|
||||
this.volume = (VolumeObjectTO) snapshot.getBaseVolume().getTO();
|
||||
this.setVmName(snapshot.getBaseVolume().getAttachedVmName());
|
||||
if (snapshot.getParent() != null) {
|
||||
this.parentSnapshotPath = snapshot.getParent().getPath();
|
||||
}
|
||||
this.dataStore = snapshot.getDataStore().getTO();
|
||||
this.setName(snapshot.getName());
|
||||
this.hypervisorType = snapshot.getHypervisorType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObjectType getObjectType() {
|
||||
return DataObjectType.SNAPSHOT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStoreTO getDataStore() {
|
||||
return this.dataStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public VolumeObjectTO getVolume() {
|
||||
return volume;
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
package org.apache.cloudstack.storage.to;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo;
|
||||
|
||||
import com.cloud.agent.api.to.DataObjectType;
|
||||
import com.cloud.agent.api.to.DataStoreTO;
|
||||
|
|
@ -27,17 +25,17 @@ import com.cloud.storage.Storage.ImageFormat;
|
|||
import com.cloud.template.VirtualMachineTemplate;
|
||||
|
||||
public class TemplateObjectTO implements DataTO {
|
||||
private String path;
|
||||
private String path;
|
||||
private String origUrl;
|
||||
private String uuid;
|
||||
private String uuid;
|
||||
private long id;
|
||||
private ImageFormat format;
|
||||
private long accountId;
|
||||
private String checksum;
|
||||
private boolean hvm;
|
||||
private String displayText;
|
||||
private DataStoreTO imageDataStore;
|
||||
private String name;
|
||||
private DataStoreTO imageDataStore;
|
||||
private String name;
|
||||
private String guestOsType;
|
||||
private Long size;
|
||||
|
||||
|
|
@ -45,7 +43,7 @@ public class TemplateObjectTO implements DataTO {
|
|||
|
||||
}
|
||||
|
||||
public TemplateObjectTO(VirtualMachineTemplate template){
|
||||
public TemplateObjectTO(VirtualMachineTemplate template) {
|
||||
this.uuid = template.getUuid();
|
||||
this.id = template.getId();
|
||||
this.origUrl = template.getUrl();
|
||||
|
|
@ -69,7 +67,7 @@ public class TemplateObjectTO implements DataTO {
|
|||
this.name = template.getUniqueName();
|
||||
this.format = template.getFormat();
|
||||
if (template.getDataStore() != null) {
|
||||
this.imageDataStore = template.getDataStore().getTO();
|
||||
this.imageDataStore = template.getDataStore().getTO();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,28 +83,35 @@ public class TemplateObjectTO implements DataTO {
|
|||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ImageFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public boolean isRequiresHvm() {
|
||||
return hvm;
|
||||
}
|
||||
public void setRequiresHvm(boolean hvm){
|
||||
|
||||
public void setRequiresHvm(boolean hvm) {
|
||||
this.hvm = hvm;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public void setDescription(String desc){
|
||||
public void setDescription(String desc) {
|
||||
this.displayText = desc;
|
||||
}
|
||||
|
||||
public DataStoreTO getImageDataStore() {
|
||||
return this.imageDataStore;
|
||||
}
|
||||
|
|
@ -118,7 +123,7 @@ public class TemplateObjectTO implements DataTO {
|
|||
|
||||
@Override
|
||||
public DataStoreTO getDataStore() {
|
||||
return (DataStoreTO)this.imageDataStore;
|
||||
return (DataStoreTO) this.imageDataStore;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -127,30 +132,39 @@ public class TemplateObjectTO implements DataTO {
|
|||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getOrigUrl() {
|
||||
return origUrl;
|
||||
}
|
||||
public void setOrigUrl(String origUrl) {
|
||||
this.origUrl = origUrl;
|
||||
}
|
||||
|
||||
public String getOrigUrl() {
|
||||
return origUrl;
|
||||
}
|
||||
|
||||
public void setOrigUrl(String origUrl) {
|
||||
this.origUrl = origUrl;
|
||||
}
|
||||
|
||||
public void setFormat(ImageFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public void setChecksum(String checksum) {
|
||||
this.checksum = checksum;
|
||||
}
|
||||
|
||||
public void setImageDataStore(DataStoreTO imageDataStore) {
|
||||
this.imageDataStore = imageDataStore;
|
||||
}
|
||||
|
|
@ -163,11 +177,11 @@ public class TemplateObjectTO implements DataTO {
|
|||
this.guestOsType = guestOsType;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class VolumeObjectTO implements DataTO {
|
|||
public Volume.Type getVolumeType() {
|
||||
return this.volumeType;
|
||||
}
|
||||
|
||||
|
||||
public DataStoreTO getDataStore() {
|
||||
return this.dataStore;
|
||||
}
|
||||
|
|
@ -133,29 +133,28 @@ public class VolumeObjectTO implements DataTO {
|
|||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
public String getChainInfo() {
|
||||
return chainInfo;
|
||||
}
|
||||
public String getChainInfo() {
|
||||
return chainInfo;
|
||||
}
|
||||
|
||||
public void setChainInfo(String chainInfo) {
|
||||
this.chainInfo = chainInfo;
|
||||
}
|
||||
public void setChainInfo(String chainInfo) {
|
||||
this.chainInfo = chainInfo;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Storage.ImageFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(Storage.ImageFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
public Storage.ImageFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(Storage.ImageFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,80 +34,78 @@ import javax.persistence.Temporal;
|
|||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name="disk_offering")
|
||||
@Inheritance(strategy=InheritanceType.JOINED)
|
||||
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
|
||||
@Table(name = "disk_offering")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING, length = 32)
|
||||
public class DiskOfferingVO implements DiskOffering {
|
||||
public enum Type {
|
||||
Disk,
|
||||
Service
|
||||
Disk, Service
|
||||
};
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
long id;
|
||||
|
||||
@Column(name="domain_id")
|
||||
@Column(name = "domain_id")
|
||||
Long domainId;
|
||||
|
||||
@Column(name="unique_name")
|
||||
@Column(name = "unique_name")
|
||||
private String uniqueName;
|
||||
|
||||
@Column(name="name")
|
||||
@Column(name = "name")
|
||||
private String name = null;
|
||||
|
||||
@Column(name="display_text", length=4096)
|
||||
@Column(name = "display_text", length = 4096)
|
||||
private String displayText = null;
|
||||
|
||||
@Column(name="disk_size")
|
||||
@Column(name = "disk_size")
|
||||
long diskSize;
|
||||
|
||||
@Column(name="tags", length=4096)
|
||||
@Column(name = "tags", length = 4096)
|
||||
String tags;
|
||||
|
||||
@Column(name="type")
|
||||
@Column(name = "type")
|
||||
Type type;
|
||||
|
||||
@Column(name=GenericDao.REMOVED)
|
||||
@Column(name = GenericDao.REMOVED)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date removed;
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
@Column(name = GenericDao.CREATED_COLUMN)
|
||||
private Date created;
|
||||
|
||||
@Column(name="recreatable")
|
||||
@Column(name = "recreatable")
|
||||
private boolean recreatable;
|
||||
|
||||
@Column(name="use_local_storage")
|
||||
@Column(name = "use_local_storage")
|
||||
private boolean useLocalStorage;
|
||||
|
||||
@Column(name="system_use")
|
||||
@Column(name = "system_use")
|
||||
private boolean systemUse;
|
||||
|
||||
@Column(name="customized")
|
||||
@Column(name = "customized")
|
||||
private boolean customized;
|
||||
|
||||
@Column(name="uuid")
|
||||
@Column(name = "uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name="sort_key")
|
||||
@Column(name = "sort_key")
|
||||
int sortKey;
|
||||
|
||||
@Column(name="display_offering")
|
||||
@Column(name = "display_offering")
|
||||
boolean displayOffering;
|
||||
|
||||
public DiskOfferingVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public DiskOfferingVO(Long domainId, String name, String displayText, long diskSize, String tags, boolean isCustomized) {
|
||||
public DiskOfferingVO(Long domainId, String name, String displayText, long diskSize, String tags,
|
||||
boolean isCustomized) {
|
||||
this.domainId = domainId;
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
|
|
@ -117,10 +115,11 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
this.type = Type.Disk;
|
||||
this.useLocalStorage = false;
|
||||
this.customized = isCustomized;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage, boolean systemUse, boolean customized) {
|
||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
|
||||
boolean useLocalStorage, boolean systemUse, boolean customized) {
|
||||
this.domainId = null;
|
||||
this.type = Type.Service;
|
||||
this.name = name;
|
||||
|
|
@ -130,11 +129,13 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
this.useLocalStorage = useLocalStorage;
|
||||
this.systemUse = systemUse;
|
||||
this.customized = customized;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
//domain specific offerings constructor (null domainId implies public offering)
|
||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage, boolean systemUse, boolean customized, Long domainId) {
|
||||
// domain specific offerings constructor (null domainId implies public
|
||||
// offering)
|
||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
|
||||
boolean useLocalStorage, boolean systemUse, boolean customized, Long domainId) {
|
||||
this.type = Type.Service;
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
|
|
@ -144,7 +145,7 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
this.systemUse = systemUse;
|
||||
this.customized = customized;
|
||||
this.domainId = domainId;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -154,14 +155,14 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
|
||||
@Override
|
||||
public boolean isCustomized() {
|
||||
return customized;
|
||||
}
|
||||
return customized;
|
||||
}
|
||||
|
||||
public void setCustomized(boolean customized) {
|
||||
this.customized = customized;
|
||||
}
|
||||
public void setCustomized(boolean customized) {
|
||||
this.customized = customized;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getUniqueName() {
|
||||
return uniqueName;
|
||||
}
|
||||
|
|
@ -197,7 +198,6 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getSystemUse() {
|
||||
return systemUse;
|
||||
|
|
@ -211,13 +211,14 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public void setDisplayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDiskSize(){
|
||||
return diskSize;
|
||||
public long getDiskSize() {
|
||||
return diskSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -229,10 +230,10 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
return created;
|
||||
}
|
||||
|
||||
protected void setTags(String tags) {
|
||||
this.tags = tags;
|
||||
|
|
@ -290,9 +291,9 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
setTags(buf.toString());
|
||||
}
|
||||
|
||||
public void setUseLocalStorage(boolean useLocalStorage) {
|
||||
this.useLocalStorage = useLocalStorage;
|
||||
}
|
||||
public void setUseLocalStorage(boolean useLocalStorage) {
|
||||
this.useLocalStorage = useLocalStorage;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
|
|
@ -300,25 +301,24 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void setSortKey(int key) {
|
||||
sortKey = key;
|
||||
sortKey = key;
|
||||
}
|
||||
|
||||
public int getSortKey() {
|
||||
return sortKey;
|
||||
}
|
||||
|
||||
public void setRecreatable(boolean recreatable) {
|
||||
this.recreatable = recreatable;
|
||||
return sortKey;
|
||||
}
|
||||
|
||||
public void setRecreatable(boolean recreatable) {
|
||||
this.recreatable = recreatable;
|
||||
}
|
||||
|
||||
public boolean getDisplayOffering() {
|
||||
return displayOffering;
|
||||
|
|
|
|||
|
|
@ -25,44 +25,41 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name="guest_os_category")
|
||||
@Table(name = "guest_os_category")
|
||||
public class GuestOSCategoryVO implements GuestOsCategory {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
long id;
|
||||
|
||||
@Column(name="name")
|
||||
@Column(name = "name")
|
||||
String name;
|
||||
|
||||
@Column(name="uuid")
|
||||
@Column(name = "uuid")
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,66 +25,63 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name="guest_os")
|
||||
@Table(name = "guest_os")
|
||||
public class GuestOSVO implements GuestOS {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
long id;
|
||||
|
||||
@Column(name="category_id")
|
||||
@Column(name = "category_id")
|
||||
private long categoryId;
|
||||
|
||||
@Column(name="name")
|
||||
@Column(name = "name")
|
||||
String name;
|
||||
|
||||
@Column(name="display_name")
|
||||
@Column(name = "display_name")
|
||||
String displayName;
|
||||
|
||||
@Column(name="uuid")
|
||||
@Column(name = "uuid")
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getCategoryId() {
|
||||
return categoryId;
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(long categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,19 +24,20 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="launch_permission")
|
||||
@Table(name = "launch_permission")
|
||||
public class LaunchPermissionVO implements InternalIdentity {
|
||||
@Id
|
||||
@Column(name="id")
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name="template_id")
|
||||
@Column(name = "template_id")
|
||||
private long templateId;
|
||||
|
||||
@Column(name="account_id")
|
||||
@Column(name = "account_id")
|
||||
private long accountId;
|
||||
|
||||
public LaunchPermissionVO() { }
|
||||
public LaunchPermissionVO() {
|
||||
}
|
||||
|
||||
public LaunchPermissionVO(long templateId, long accountId) {
|
||||
this.templateId = templateId;
|
||||
|
|
|
|||
|
|
@ -18,10 +18,7 @@
|
|||
*/
|
||||
package com.cloud.storage;
|
||||
|
||||
import com.cloud.agent.api.to.S3TO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
|
@ -29,7 +26,9 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.agent.api.to.S3TO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name = "s3")
|
||||
|
|
@ -76,11 +75,9 @@ public class S3VO implements S3 {
|
|||
super();
|
||||
}
|
||||
|
||||
public S3VO(final String uuid, final String accessKey,
|
||||
final String secretKey, final String endPoint,
|
||||
final String bucketName, final Boolean httpsFlag,
|
||||
final Integer connectionTimeout, final Integer maxErrorRetry,
|
||||
final Integer socketTimeout, final Date created) {
|
||||
public S3VO(final String uuid, final String accessKey, final String secretKey, final String endPoint,
|
||||
final String bucketName, final Boolean httpsFlag, final Integer connectionTimeout,
|
||||
final Integer maxErrorRetry, final Integer socketTimeout, final Date created) {
|
||||
|
||||
super();
|
||||
|
||||
|
|
@ -111,10 +108,8 @@ public class S3VO implements S3 {
|
|||
httpsFlag = this.httpsFlag == 0 ? false : true;
|
||||
}
|
||||
|
||||
return new S3TO(this.id, this.uuid, this.accessKey, this.secretKey,
|
||||
this.endPoint, this.bucketName, httpsFlag,
|
||||
this.connectionTimeout, this.maxErrorRetry, this.socketTimeout,
|
||||
this.created);
|
||||
return new S3TO(this.id, this.uuid, this.accessKey, this.secretKey, this.endPoint, this.bucketName, httpsFlag,
|
||||
this.connectionTimeout, this.maxErrorRetry, this.socketTimeout, this.created);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,53 +25,51 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import com.cloud.storage.snapshot.SnapshotPolicy;
|
||||
import com.cloud.utils.DateUtil.IntervalType;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name="snapshot_policy")
|
||||
@Table(name = "snapshot_policy")
|
||||
public class SnapshotPolicyVO implements SnapshotPolicy {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
long id;
|
||||
|
||||
@Column(name="volume_id")
|
||||
@Column(name = "volume_id")
|
||||
long volumeId;
|
||||
|
||||
@Column(name="schedule")
|
||||
@Column(name = "schedule")
|
||||
String schedule;
|
||||
|
||||
@Column(name="timezone")
|
||||
@Column(name = "timezone")
|
||||
String timezone;
|
||||
|
||||
@Column(name="interval")
|
||||
@Column(name = "interval")
|
||||
private short interval;
|
||||
|
||||
@Column(name="max_snaps")
|
||||
@Column(name = "max_snaps")
|
||||
private int maxSnaps;
|
||||
|
||||
@Column(name="active")
|
||||
@Column(name = "active")
|
||||
boolean active = false;
|
||||
|
||||
@Column(name="uuid")
|
||||
@Column(name = "uuid")
|
||||
String uuid;
|
||||
|
||||
public SnapshotPolicyVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public SnapshotPolicyVO(long volumeId, String schedule, String timezone, IntervalType intvType, int maxSnaps) {
|
||||
this.volumeId = volumeId;
|
||||
this.volumeId = volumeId;
|
||||
this.schedule = schedule;
|
||||
this.timezone = timezone;
|
||||
this.interval = (short)intvType.ordinal();
|
||||
this.interval = (short) intvType.ordinal();
|
||||
this.maxSnaps = maxSnaps;
|
||||
this.active = true;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
|
|
@ -79,10 +77,10 @@ public class SnapshotPolicyVO implements SnapshotPolicy {
|
|||
}
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public void setSchedule(String schedule) {
|
||||
public void setSchedule(String schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
|
|
@ -124,10 +122,10 @@ public class SnapshotPolicyVO implements SnapshotPolicy {
|
|||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue