mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
squash changes into one giant patch
This commit is contained in:
parent
d81209210c
commit
a22403edcd
@ -18,6 +18,7 @@ package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
||||
|
||||
/**
|
||||
* This currently assumes that both primary and secondary storage are mounted on the XenServer.
|
||||
*/
|
||||
|
||||
@ -99,10 +99,7 @@ public interface StoragePool extends Identity, InternalIdentity {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getStorageProvider();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getStorageType();
|
||||
Long getStorageProviderId();
|
||||
|
||||
boolean isInMaintenance();
|
||||
}
|
||||
|
||||
@ -17,11 +17,6 @@
|
||||
package com.cloud.storage;
|
||||
|
||||
public enum StoragePoolStatus {
|
||||
Creating,
|
||||
Up,
|
||||
PrepareForMaintenance,
|
||||
ErrorInMaintenance,
|
||||
CancelMaintenance,
|
||||
Maintenance,
|
||||
Removed;
|
||||
Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance,
|
||||
ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
|
||||
}
|
||||
|
||||
@ -22,17 +22,10 @@ import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaint
|
||||
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceInUseException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
public interface StorageService{
|
||||
/**
|
||||
@ -51,37 +44,6 @@ public interface StorageService{
|
||||
StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException,
|
||||
UnknownHostException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Creates the database object for a volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
|
||||
* name)
|
||||
* @return the volume object
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
Volume allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Creates the volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
|
||||
* name)
|
||||
* @return the volume object
|
||||
*/
|
||||
Volume createVolume(CreateVolumeCmd cmd);
|
||||
|
||||
|
||||
/**
|
||||
* Resizes the volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria
|
||||
* @return the volume object
|
||||
*/
|
||||
Volume resizeVolume(ResizeVolumeCmd cmd);
|
||||
|
||||
/**
|
||||
* Delete the storage pool
|
||||
*
|
||||
@ -120,19 +82,4 @@ public interface StorageService{
|
||||
public StoragePool updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;
|
||||
|
||||
public StoragePool getStoragePool(long id);
|
||||
|
||||
Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
|
||||
|
||||
|
||||
/**
|
||||
* Uploads the volume to secondary storage
|
||||
*
|
||||
* @param UploadVolumeCmd cmd
|
||||
*
|
||||
* @return Volume object
|
||||
*/
|
||||
Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
boolean deleteVolume(long volumeId, Account caller) throws ConcurrentOperationException;
|
||||
|
||||
}
|
||||
|
||||
@ -39,9 +39,12 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
||||
Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
|
||||
Resizing("The volume is being resized"),
|
||||
Expunging("The volume is being expunging"),
|
||||
Expunged("The volume is being expunging"),
|
||||
Destroy("The volume is destroyed, and can't be recovered."),
|
||||
Destroying("The volume is destroying, and can't be recovered."),
|
||||
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage");
|
||||
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage"),
|
||||
Uploading("volume is uploading"),
|
||||
Uploaded("volume is uploaded");
|
||||
|
||||
String _description;
|
||||
|
||||
@ -70,12 +73,15 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
||||
s_fsm.addTransition(Resizing, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Resizing, Event.OperationFailed, Ready);
|
||||
s_fsm.addTransition(Allocated, Event.UploadRequested, UploadOp);
|
||||
s_fsm.addTransition(UploadOp, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
|
||||
s_fsm.addTransition(Uploaded, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
|
||||
s_fsm.addTransition(Creating, Event.CopySucceeded, Ready);
|
||||
s_fsm.addTransition(Creating, Event.CopyFailed, UploadOp);// Copying volume from sec to primary failed.
|
||||
s_fsm.addTransition(Creating, Event.CopyFailed, Uploaded);// Copying volume from sec to primary failed.
|
||||
s_fsm.addTransition(UploadOp, Event.DestroyRequested, Destroy);
|
||||
s_fsm.addTransition(Ready, Event.DestroyRequested, Destroy);
|
||||
s_fsm.addTransition(Destroy, Event.ExpungingRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.ExpungingRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.OperationSucceeded, Expunged);
|
||||
s_fsm.addTransition(Expunging, Event.OperationFailed, Expunging);
|
||||
s_fsm.addTransition(Ready, Event.SnapshotRequested, Snapshotting);
|
||||
s_fsm.addTransition(Snapshotting, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Snapshotting, Event.OperationFailed, Ready);
|
||||
@ -83,6 +89,9 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
||||
s_fsm.addTransition(Migrating, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Migrating, Event.OperationFailed, Ready);
|
||||
s_fsm.addTransition(Destroy, Event.OperationSucceeded, Destroy);
|
||||
s_fsm.addTransition(UploadOp, Event.OperationSucceeded, Uploaded);
|
||||
s_fsm.addTransition(UploadOp, Event.OperationFailed, Allocated);
|
||||
s_fsm.addTransition(Uploaded, Event.DestroyRequested, Destroy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +119,7 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
||||
/**
|
||||
* @return total size of the partition
|
||||
*/
|
||||
long getSize();
|
||||
Long getSize();
|
||||
|
||||
/**
|
||||
* @return the vm instance id
|
||||
|
||||
80
api/src/com/cloud/storage/VolumeApiService.java
Normal file
80
api/src/com/cloud/storage/VolumeApiService.java
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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 com.cloud.storage;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
public interface VolumeApiService {
|
||||
/**
|
||||
* Creates the database object for a volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
|
||||
* name)
|
||||
* @return the volume object
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
Volume allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Creates the volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
|
||||
* name)
|
||||
* @return the volume object
|
||||
*/
|
||||
Volume createVolume(CreateVolumeCmd cmd);
|
||||
|
||||
|
||||
/**
|
||||
* Resizes the volume based on the given criteria
|
||||
*
|
||||
* @param cmd
|
||||
* the API command wrapping the criteria
|
||||
* @return the volume object
|
||||
*/
|
||||
Volume resizeVolume(ResizeVolumeCmd cmd);
|
||||
|
||||
Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Uploads the volume to secondary storage
|
||||
*
|
||||
* @param UploadVolumeCmd cmd
|
||||
*
|
||||
* @return Volume object
|
||||
*/
|
||||
Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
boolean deleteVolume(long volumeId, Account caller) throws ConcurrentOperationException;
|
||||
|
||||
Volume attachVolumeToVM(AttachVolumeCmd command);
|
||||
|
||||
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
|
||||
}
|
||||
@ -25,6 +25,7 @@ import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
|
||||
import org.apache.cloudstack.api.command.user.iso.ExtractIsoCmd;
|
||||
import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
|
||||
@ -32,6 +33,8 @@ import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public interface TemplateService {
|
||||
|
||||
@ -87,4 +90,11 @@ public interface TemplateService {
|
||||
List<String> listTemplatePermissions(BaseListTemplateOrIsoPermissionsCmd cmd);
|
||||
|
||||
boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissionsCmd cmd);
|
||||
|
||||
VirtualMachineTemplate createPrivateTemplateRecord(CreateTemplateCmd cmd,
|
||||
Account templateOwner) throws ResourceAllocationException;
|
||||
|
||||
VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command)
|
||||
throws CloudRuntimeException;
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import javax.naming.InsufficientResourcesException;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
|
||||
@ -103,24 +102,6 @@ public interface UserVmService {
|
||||
*/
|
||||
UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Attaches the specified volume to the specified VM
|
||||
*
|
||||
* @param cmd
|
||||
* - the command specifying volumeId and vmId
|
||||
* @return the Volume object if attach worked successfully.
|
||||
*/
|
||||
Volume attachVolumeToVM(AttachVolumeCmd cmd);
|
||||
|
||||
/**
|
||||
* Detaches the specified volume from the VM it is currently attached to.
|
||||
*
|
||||
* @param cmd
|
||||
* - the command specifying volumeId
|
||||
* @return the Volume object if detach worked successfully.
|
||||
*/
|
||||
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
|
||||
|
||||
UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException,
|
||||
ResourceAllocationException;
|
||||
|
||||
@ -151,28 +132,6 @@ public interface UserVmService {
|
||||
|
||||
UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Create a template database record in preparation for creating a private template.
|
||||
*
|
||||
* @param cmd
|
||||
* the command object that defines the name, display text, snapshot/volume, bits, public/private, etc.
|
||||
* for the
|
||||
* private template
|
||||
* @param templateOwner
|
||||
* TODO
|
||||
* @return the vm template object if successful, null otherwise
|
||||
* @throws ResourceAllocationException
|
||||
*/
|
||||
VirtualMachineTemplate createPrivateTemplateRecord(CreateTemplateCmd cmd, Account templateOwner) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Creates a private template from a snapshot of a VM
|
||||
*
|
||||
* @param cmd
|
||||
* - the command specifying snapshotId, name, description
|
||||
* @return a template if successfully created, null otherwise
|
||||
*/
|
||||
VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd cmd);
|
||||
|
||||
/**
|
||||
* Creates a Basic Zone User VM in the database and returns the VM to the caller.
|
||||
|
||||
@ -444,6 +444,7 @@ public class ApiConstants {
|
||||
public static final String VM_SNAPSHOT_ID = "vmsnapshotid";
|
||||
public static final String VM_SNAPSHOT_DISK_IDS = "vmsnapshotdiskids";
|
||||
public static final String VM_SNAPSHOT_MEMORY = "snapshotmemory";
|
||||
public static final String IMAGE_STORE_UUID = "imagestoreuuid";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
||||
@ -62,6 +62,7 @@ import com.cloud.resource.ResourceService;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.server.TaggedResourceService;
|
||||
import com.cloud.storage.StorageService;
|
||||
import com.cloud.storage.VolumeApiService;
|
||||
import com.cloud.storage.snapshot.SnapshotService;
|
||||
import com.cloud.template.TemplateService;
|
||||
import com.cloud.user.Account;
|
||||
@ -69,7 +70,6 @@ import com.cloud.user.AccountService;
|
||||
import com.cloud.user.DomainService;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.BareMetalVmService;
|
||||
import com.cloud.vm.UserVmService;
|
||||
import com.cloud.vm.snapshot.VMSnapshotService;
|
||||
|
||||
@ -102,6 +102,7 @@ public abstract class BaseCmd {
|
||||
@Inject public UserVmService _userVmService;
|
||||
@Inject public ManagementService _mgr;
|
||||
@Inject public StorageService _storageService;
|
||||
@Inject public VolumeApiService _volumeService;
|
||||
@Inject public ResourceService _resourceService;
|
||||
@Inject public NetworkService _networkService;
|
||||
@Inject public TemplateService _templateService;
|
||||
|
||||
@ -36,6 +36,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@APICommand(name = "createStoragePool", description="Creates a storage pool.", responseObject=StoragePoolResponse.class)
|
||||
public class CreateStoragePoolCmd extends BaseCmd {
|
||||
@ -70,6 +71,14 @@ public class CreateStoragePoolCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
|
||||
required=true, description="the Zone ID for the storage pool")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.PROVIDER, type=CommandType.UUID,
|
||||
required=false, description="the storage provider uuid")
|
||||
private String storageProviderUuid;
|
||||
|
||||
@Parameter(name=ApiConstants.SCOPE, type=CommandType.STRING,
|
||||
required=false, description="the scope of the storage: cluster or zone")
|
||||
private String scope;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -102,6 +111,14 @@ public class CreateStoragePoolCmd extends BaseCmd {
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getStorageProviderUuid() {
|
||||
return this.storageProviderUuid;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
||||
@ -88,6 +88,10 @@ public class RegisterIsoCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
|
||||
description="Register iso for the project")
|
||||
private Long projectId;
|
||||
|
||||
@Parameter(name=ApiConstants.IMAGE_STORE_UUID, type=CommandType.UUID,
|
||||
description="Image store uuid")
|
||||
private String imageStoreUuid;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -140,6 +144,10 @@ public class RegisterIsoCmd extends BaseCmd {
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getImageStoreUuid() {
|
||||
return this.imageStoreUuid;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
||||
@ -240,7 +240,7 @@ import com.cloud.user.UserContext;
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VirtualMachineTemplate template = null;
|
||||
template = _userVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
|
||||
template = this._templateService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
|
||||
if (template != null) {
|
||||
this.setEntityId(template.getId());
|
||||
this.setEntityUuid(template.getUuid());
|
||||
@ -255,7 +255,7 @@ import com.cloud.user.UserContext;
|
||||
public void execute() {
|
||||
UserContext.current().setEventDetails("Template Id: "+getEntityId()+((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId()));
|
||||
VirtualMachineTemplate template = null;
|
||||
template = _userVmService.createPrivateTemplate(this);
|
||||
template = this._templateService.createPrivateTemplate(this);
|
||||
|
||||
if (template != null){
|
||||
List<TemplateResponse> templateResponses;
|
||||
|
||||
@ -110,7 +110,11 @@ public class RegisterTemplateCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
|
||||
description="Register template for the project")
|
||||
private Long projectId;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.IMAGE_STORE_UUID, type=CommandType.UUID,
|
||||
description="Image store uuid")
|
||||
private String imageStoreUuid;
|
||||
|
||||
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")
|
||||
protected Map details;
|
||||
|
||||
@ -189,6 +193,10 @@ public class RegisterTemplateCmd extends BaseCmd {
|
||||
public String getTemplateTag() {
|
||||
return templateTag;
|
||||
}
|
||||
|
||||
public String getImageStoreUuid() {
|
||||
return this.imageStoreUuid;
|
||||
}
|
||||
|
||||
public Map getDetails() {
|
||||
if (details == null || details.isEmpty()) {
|
||||
|
||||
@ -119,7 +119,7 @@ public class AttachVolumeCmd extends BaseAsyncCmd {
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
|
||||
Volume result = _userVmService.attachVolumeToVM(this);
|
||||
Volume result = _volumeService.attachVolumeToVM(this);
|
||||
if (result != null) {
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
@ -153,7 +153,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException{
|
||||
|
||||
Volume volume = _storageService.allocVolume(this);
|
||||
Volume volume = this._volumeService.allocVolume(this);
|
||||
if (volume != null) {
|
||||
this.setEntityId(volume.getId());
|
||||
this.setEntityUuid(volume.getUuid());
|
||||
@ -165,7 +165,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Volume Id: "+getEntityId()+((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()));
|
||||
Volume volume = _storageService.createVolume(this);
|
||||
Volume volume = _volumeService.createVolume(this);
|
||||
if (volume != null) {
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
|
||||
//FIXME - have to be moved to ApiResponseHelper
|
||||
|
||||
@ -80,7 +80,7 @@ public class DeleteVolumeCmd extends BaseCmd {
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException {
|
||||
UserContext.current().setEventDetails("Volume Id: "+getId());
|
||||
boolean result = _storageService.deleteVolume(id, UserContext.current().getCaller());
|
||||
boolean result = this._volumeService.deleteVolume(id, UserContext.current().getCaller());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
||||
@ -130,7 +130,7 @@ public class DetachVolumeCmd extends BaseAsyncCmd {
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
|
||||
Volume result = _userVmService.detachVolumeFromVM(this);
|
||||
Volume result = _volumeService.detachVolumeFromVM(this);
|
||||
if (result != null){
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
|
||||
response.setResponseName("volume");
|
||||
|
||||
@ -92,7 +92,7 @@ public class MigrateVolumeCmd extends BaseAsyncCmd {
|
||||
public void execute(){
|
||||
Volume result;
|
||||
try {
|
||||
result = _storageService.migrateVolume(getVolumeId(), getStoragePoolId());
|
||||
result = _volumeService.migrateVolume(getVolumeId(), getStoragePoolId());
|
||||
if (result != null) {
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
@ -133,7 +133,7 @@ public class ResizeVolumeCmd extends BaseAsyncCmd {
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
|
||||
Volume volume = _storageService.resizeVolume(this);
|
||||
Volume volume = _volumeService.resizeVolume(this);
|
||||
if (volume != null) {
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
|
||||
//FIXME - have to be moved to ApiResponseHelper
|
||||
|
||||
@ -67,6 +67,10 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
|
||||
|
||||
@Parameter(name=ApiConstants.CHECKSUM, type=CommandType.STRING, description="the MD5 checksum value of this volume")
|
||||
private String checksum;
|
||||
|
||||
@Parameter(name=ApiConstants.IMAGE_STORE_UUID, type=CommandType.UUID,
|
||||
description="Image store uuid")
|
||||
private String imageStoreUuid;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -99,6 +103,10 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getImageStoreUuid() {
|
||||
return this.imageStoreUuid;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
@ -110,7 +118,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
|
||||
ConcurrentOperationException, ResourceAllocationException,
|
||||
NetworkRuleConflictException {
|
||||
|
||||
Volume volume = _storageService.uploadVolume(this);
|
||||
Volume volume = _volumeService.uploadVolume(this);
|
||||
if (volume != null){
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
@ -133,15 +133,15 @@ public class BackupSnapshotCommandTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageProvider() {
|
||||
public Long getStorageProviderId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageType() {
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -115,16 +115,16 @@ public class SnapshotCommandTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageProvider() {
|
||||
public Long getStorageProviderId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
};
|
||||
@Override
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
SnapshotCommand ssc = new SnapshotCommand(pool,
|
||||
|
||||
@ -134,15 +134,15 @@ public class ResizeVolumeCommandTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageProvider() {
|
||||
public Long getStorageProviderId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageType() {
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -282,7 +282,8 @@
|
||||
</copy>
|
||||
<copy
|
||||
todir="${basedir}/target/generated-webapp/WEB-INF/classes/scripts">
|
||||
<fileset dir="${basedir}/../scripts" />
|
||||
<fileset dir="${basedir}/../scripts">
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy
|
||||
todir="${basedir}/target/generated-webapp/WEB-INF/classes/vms">
|
||||
|
||||
@ -31,7 +31,11 @@
|
||||
<artifactId>cloud-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
|
||||
@ -19,6 +19,8 @@ package com.cloud.storage;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
|
||||
|
||||
@ -1,346 +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 com.cloud.storage;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.TableGenerator;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@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)
|
||||
@Column(name="id", updatable=false, nullable = false)
|
||||
private long id;
|
||||
|
||||
@Column(name="name", updatable=false, nullable=false, length=255)
|
||||
private String name = null;
|
||||
|
||||
@Column(name="uuid", length=255)
|
||||
private String uuid = null;
|
||||
|
||||
@Column(name="pool_type", updatable=false, nullable=false, length=32)
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private StoragePoolType poolType;
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
Date created;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
@Column(name="update_time", updatable=true)
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
private Date updateTime;
|
||||
|
||||
@Column(name="data_center_id", updatable=true, nullable=false)
|
||||
private long dataCenterId;
|
||||
|
||||
@Column(name="pod_id", updatable=true)
|
||||
private Long podId;
|
||||
|
||||
@Column(name="available_bytes", updatable=true, nullable=true)
|
||||
private long availableBytes;
|
||||
|
||||
@Column(name="capacity_bytes", updatable=true, nullable=true)
|
||||
private long capacityBytes;
|
||||
|
||||
@Column(name="status", updatable=true, nullable=false)
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private StoragePoolStatus status;
|
||||
|
||||
// TODO, disable persisency of storageProvider and storageType, javelin new code not
|
||||
// sync with the schema!
|
||||
|
||||
// @Column(name="storage_provider", updatable=true, nullable=false)
|
||||
@Transient private String storageProvider;
|
||||
|
||||
// Column(name="storage_type", nullable=false)
|
||||
@Transient private String storageType;
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoragePoolStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public StoragePoolVO() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoragePoolType getPoolType() {
|
||||
return poolType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAvailableBytes() {
|
||||
return availableBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageProvider() {
|
||||
return storageProvider;
|
||||
}
|
||||
|
||||
public void setStorageProvider(String provider) {
|
||||
storageProvider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
public void setStorageType(String type) {
|
||||
storageType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapacityBytes() {
|
||||
return capacityBytes;
|
||||
}
|
||||
|
||||
public void setAvailableBytes(long available) {
|
||||
availableBytes = available;
|
||||
}
|
||||
|
||||
public void setCapacityBytes(long capacity) {
|
||||
capacityBytes = capacity;
|
||||
}
|
||||
|
||||
@Column(name="host_address")
|
||||
private String hostAddress;
|
||||
|
||||
@Column(name="path")
|
||||
private String path;
|
||||
|
||||
@Column(name="port")
|
||||
private int port;
|
||||
|
||||
@Column(name="user_info")
|
||||
private String userInfo;
|
||||
|
||||
@Column(name="cluster_id")
|
||||
private Long clusterId;
|
||||
|
||||
|
||||
@Override
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHostAddress() {
|
||||
return hostAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
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;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.availableBytes = availableBytes;
|
||||
this.capacityBytes = capacityBytes;
|
||||
this.hostAddress = hostAddress;
|
||||
this.path = hostPath;
|
||||
this.port = port;
|
||||
this.podId = podId;
|
||||
this.setStatus(StoragePoolStatus.Creating);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public StoragePoolVO(StoragePoolType type, String hostAddress, int port, String path) {
|
||||
this.poolType = type;
|
||||
this.hostAddress = hostAddress;
|
||||
this.port = port;
|
||||
this.path = path;
|
||||
this.setStatus(StoragePoolStatus.Creating);
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public StoragePoolVO(StoragePoolType type, String hostAddress, int port, String path, String userInfo) {
|
||||
this.poolType = type;
|
||||
this.hostAddress = hostAddress;
|
||||
this.port = port;
|
||||
this.path = path;
|
||||
this.userInfo = userInfo;
|
||||
this.setStatus(StoragePoolStatus.Creating);
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public void setStatus(StoragePoolStatus status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setDataCenterId(long dcId) {
|
||||
this.dataCenterId = dcId;
|
||||
}
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void setUserInfo(String userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShared() {
|
||||
return poolType.isShared();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return !poolType.isShared();
|
||||
}
|
||||
|
||||
@Transient
|
||||
public String toUri() {
|
||||
/*
|
||||
URI uri = new URI();
|
||||
try {
|
||||
if (type == StoragePoolType.Filesystem) {
|
||||
uri.setScheme("file");
|
||||
} else if (type == StoragePoolType.NetworkFilesystem) {
|
||||
uri.setScheme("nfs");
|
||||
} else if (type == StoragePoolType.IscsiLUN) {
|
||||
}
|
||||
} catch (MalformedURIException e) {
|
||||
throw new VmopsRuntimeException("Unable to form the uri " + id);
|
||||
}
|
||||
return uri.toString();
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isInMaintenance() {
|
||||
return status == StoragePoolStatus.PrepareForMaintenance || status == StoragePoolStatus.Maintenance || status == StoragePoolStatus.ErrorInMaintenance || removed != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof StoragePoolVO) || obj == null) {
|
||||
return false;
|
||||
}
|
||||
StoragePoolVO that = (StoragePoolVO)obj;
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new Long(id).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("Pool[").append(id).append("|").append(poolType).append("]").toString();
|
||||
}
|
||||
}
|
||||
@ -29,8 +29,10 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
/**
|
||||
* Join table for storage hosts and templates
|
||||
@ -38,7 +40,7 @@ import org.apache.cloudstack.api.InternalIdentity;
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="template_host_ref")
|
||||
public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc {
|
||||
public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc, DataObjectInStore {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@ -90,6 +92,18 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc {
|
||||
@Column(name="destroyed")
|
||||
boolean destroyed = false;
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
protected long updatedCount;
|
||||
|
||||
@Column(name = "updated")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
Date updated;
|
||||
|
||||
@Column(name = "state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
ObjectInDataStoreStateMachine.State state;
|
||||
|
||||
|
||||
@Override
|
||||
public String getInstallPath() {
|
||||
return installPath;
|
||||
@ -162,6 +176,7 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc {
|
||||
super();
|
||||
this.hostId = hostId;
|
||||
this.templateId = templateId;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
}
|
||||
|
||||
public VMTemplateHostVO(long hostId, long templateId, Date lastUpdated,
|
||||
@ -282,4 +297,26 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc {
|
||||
return new StringBuilder("TmplHost[").append(id).append("-").append(templateId).append("-").append(hostId).append(installPath).append("]").toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectInDataStoreStateMachine.State getState() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public long getUpdatedCount() {
|
||||
return this.updatedCount;
|
||||
}
|
||||
|
||||
public void incrUpdatedCount() {
|
||||
this.updatedCount++;
|
||||
}
|
||||
|
||||
public void decrUpdatedCount() {
|
||||
this.updatedCount--;
|
||||
}
|
||||
|
||||
public Date getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,8 +29,11 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
/**
|
||||
* Join table for storage pools and templates
|
||||
@ -38,7 +41,7 @@ import org.apache.cloudstack.api.InternalIdentity;
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="template_spool_ref")
|
||||
public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc {
|
||||
public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc, DataObjectInStore {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
long id;
|
||||
@ -69,7 +72,18 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc {
|
||||
@Column (name="template_size") long templateSize;
|
||||
|
||||
@Column (name="marked_for_gc") boolean markedForGC;
|
||||
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
protected long updatedCount;
|
||||
|
||||
@Column(name = "updated")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
Date updated;
|
||||
|
||||
@Column(name = "state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
ObjectInDataStoreStateMachine.State state;
|
||||
|
||||
@Override
|
||||
public String getInstallPath() {
|
||||
return installPath;
|
||||
@ -148,6 +162,7 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc {
|
||||
this.poolId = poolId;
|
||||
this.templateId = templateId;
|
||||
this.downloadState = Status.NOT_DOWNLOADED;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
this.markedForGC = false;
|
||||
}
|
||||
|
||||
@ -235,4 +250,26 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc {
|
||||
return new StringBuilder("TmplPool[").append(id).append("-").append(templateId).append("-").append("poolId").append("-").append(installPath).append("]").toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public long getUpdatedCount() {
|
||||
return this.updatedCount;
|
||||
}
|
||||
|
||||
public void incrUpdatedCount() {
|
||||
this.updatedCount++;
|
||||
}
|
||||
|
||||
public void decrUpdatedCount() {
|
||||
this.updatedCount--;
|
||||
}
|
||||
|
||||
public Date getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -31,17 +31,18 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
@Entity
|
||||
@Table(name="vm_template")
|
||||
public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
public class VMTemplateVO implements VirtualMachineTemplate, StateObject<TemplateState> {
|
||||
@Id
|
||||
@TableGenerator(name="vm_template_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="vm_template_seq", allocationSize=1)
|
||||
@Column(name="id", nullable = false)
|
||||
@ -127,6 +128,22 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
|
||||
@Column(name="enable_sshkey")
|
||||
private boolean enableSshKey;
|
||||
|
||||
@Column(name = "image_data_store_id")
|
||||
private long imageDataStoreId;
|
||||
|
||||
@Column(name = "size")
|
||||
private Long size;
|
||||
|
||||
@Column(name = "state")
|
||||
private TemplateState state;
|
||||
|
||||
@Column(name="update_count", updatable = true)
|
||||
protected long updatedCount;
|
||||
|
||||
@Column(name = "updated")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
Date updated;
|
||||
|
||||
@Transient
|
||||
Map details;
|
||||
@ -140,8 +157,9 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
this.uniqueName = uniqueName;
|
||||
}
|
||||
|
||||
protected VMTemplateVO() {
|
||||
public VMTemplateVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = TemplateState.Allocated;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,12 +168,14 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType, Map details) {
|
||||
this(id, generateUniqueName(id, accountId, name), name, format, isPublic, featured, isExtractable, type, url, null, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = TemplateState.Allocated;
|
||||
}
|
||||
|
||||
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType, String templateTag, Map details, boolean sshKeyEnabled) {
|
||||
this(id, name, format, isPublic, featured, isExtractable, type, url, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
||||
this.templateTag = templateTag;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = TemplateState.Allocated;
|
||||
this.enableSshKey = sshKeyEnabled;
|
||||
}
|
||||
|
||||
@ -179,6 +199,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
this.bootable = bootable;
|
||||
this.hypervisorType = hyperType;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = TemplateState.Allocated;
|
||||
}
|
||||
|
||||
// Has an extra attribute - isExtractable
|
||||
@ -468,5 +489,46 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
public void setEnableSshKey(boolean enable) {
|
||||
enableSshKey = enable;
|
||||
}
|
||||
|
||||
public Long getImageDataStoreId() {
|
||||
return this.imageDataStoreId;
|
||||
}
|
||||
|
||||
public void setImageDataStoreId(long dataStoreId) {
|
||||
this.imageDataStoreId = dataStoreId;
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public TemplateState getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public long getUpdatedCount() {
|
||||
return this.updatedCount;
|
||||
}
|
||||
|
||||
public void incrUpdatedCount() {
|
||||
this.updatedCount++;
|
||||
}
|
||||
|
||||
public void decrUpdatedCount() {
|
||||
this.updatedCount--;
|
||||
}
|
||||
|
||||
public Date getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(Date updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -29,11 +29,13 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
//import com.cloud.storage.VMVolumeStorageResourceAssoc.Status;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
/**
|
||||
* Join table for storage hosts and volumes
|
||||
@ -41,7 +43,7 @@ import org.apache.cloudstack.api.InternalIdentity;
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="volume_host_ref")
|
||||
public class VolumeHostVO implements InternalIdentity {
|
||||
public class VolumeHostVO implements InternalIdentity, DataObjectInStore {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@ -99,6 +101,16 @@ public class VolumeHostVO implements InternalIdentity {
|
||||
@Column(name="destroyed")
|
||||
boolean destroyed = false;
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
protected long updatedCount;
|
||||
|
||||
@Column(name = "updated")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
Date updated;
|
||||
|
||||
@Column(name = "state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
ObjectInDataStoreStateMachine.State state;
|
||||
|
||||
public String getInstallPath() {
|
||||
return installPath;
|
||||
@ -187,6 +199,7 @@ public class VolumeHostVO implements InternalIdentity {
|
||||
super();
|
||||
this.hostId = hostId;
|
||||
this.volumeId = volumeId;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
}
|
||||
|
||||
public VolumeHostVO(long hostId, long volumeId, long zoneId, Date lastUpdated,
|
||||
@ -308,5 +321,27 @@ public class VolumeHostVO implements InternalIdentity {
|
||||
public String toString() {
|
||||
return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(hostId).append(installPath).append("]").toString();
|
||||
}
|
||||
|
||||
public long getUpdatedCount() {
|
||||
return this.updatedCount;
|
||||
}
|
||||
|
||||
public void incrUpdatedCount() {
|
||||
this.updatedCount++;
|
||||
}
|
||||
|
||||
public void decrUpdatedCount() {
|
||||
this.updatedCount--;
|
||||
}
|
||||
|
||||
public Date getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectInDataStoreStateMachine.State getState() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.state;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -32,11 +32,9 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name = "volumes")
|
||||
@ -69,7 +67,7 @@ public class VolumeVO implements Volume {
|
||||
Long deviceId = null;
|
||||
|
||||
@Column(name = "size")
|
||||
long size;
|
||||
Long size;
|
||||
|
||||
@Column(name = "folder")
|
||||
String folder;
|
||||
@ -257,11 +255,11 @@ public class VolumeVO implements Volume {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<artifactId>cloud-framework-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@ -28,4 +28,5 @@ public interface DataObject {
|
||||
public DataObjectType getType();
|
||||
public DiskFormat getFormat();
|
||||
public String getUuid();
|
||||
public void processEvent(ObjectInDataStoreStateMachine.Event event);
|
||||
}
|
||||
|
||||
@ -16,30 +16,11 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.volume;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
|
||||
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.Volume.Event;
|
||||
import com.cloud.storage.Volume.State;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
|
||||
public interface VolumeManager {
|
||||
VolumeVO allocateDuplicateVolume(VolumeVO oldVol);
|
||||
|
||||
VolumeVO processEvent(Volume vol, Volume.Event event) throws NoTransitionException;
|
||||
|
||||
VolumeProfile getProfile(long volumeId);
|
||||
|
||||
VolumeVO getVolume(long volumeId);
|
||||
|
||||
VolumeVO updateVolume(VolumeVO volume);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
StateMachine2<State, Event, VolumeVO> getStateMachine();
|
||||
public interface DataObjectInStore extends StateObject<ObjectInDataStoreStateMachine.State> {
|
||||
public String getInstallPath();
|
||||
}
|
||||
@ -20,6 +20,9 @@ public interface DataStore {
|
||||
DataStoreDriver getDriver();
|
||||
DataStoreRole getRole();
|
||||
long getId();
|
||||
String getUuid();
|
||||
String getUri();
|
||||
Scope getScope();
|
||||
DataObject create(DataObject obj);
|
||||
boolean delete(DataObject obj);
|
||||
}
|
||||
|
||||
@ -20,23 +20,23 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
|
||||
|
||||
public interface DataStoreLifeCycle {
|
||||
public DataStore initialize(Map<String, String> dsInfos);
|
||||
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();
|
||||
|
||||
public boolean unmanaged();
|
||||
|
||||
public boolean maintain();
|
||||
|
||||
public boolean cancelMaintain();
|
||||
|
||||
public boolean deleteDataStore();
|
||||
public boolean maintain(long storeId);
|
||||
|
||||
public boolean cancelMaintain(long storeId);
|
||||
|
||||
public boolean deleteDataStore(long storeId);
|
||||
}
|
||||
|
||||
@ -16,14 +16,16 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.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> getImageStores(Scope scope);
|
||||
public DataStore registerDataStore(Map<String, String> params, String providerUuid);
|
||||
}
|
||||
@ -16,12 +16,10 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.datastore.provider;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
|
||||
|
||||
public interface DataStoreProvider {
|
||||
public DataStoreLifeCycle getLifeCycle();
|
||||
@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.datastore.provider;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -26,5 +26,6 @@ public interface DataStoreProviderManager extends Manager {
|
||||
public DataStoreProvider getDataStoreProviderByUuid(String uuid);
|
||||
public DataStoreProvider getDataStoreProviderById(long id);
|
||||
public DataStoreProvider getDataStoreProvider(String name);
|
||||
public DataStoreProvider getDefaultPrimaryDataStoreProvider();
|
||||
public List<DataStoreProvider> getDataStoreProviders();
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public enum DataStoreStatus {
|
||||
Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
|
||||
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.engine.subsystem.api.storage;
|
||||
|
||||
public interface HypervisorHostListener {
|
||||
boolean hostConnect(long hostId, long poolId);
|
||||
boolean hostDisconnected(long hostId, long poolId);
|
||||
}
|
||||
@ -16,10 +16,11 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.image;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
|
||||
public interface ImageDataFactory {
|
||||
TemplateInfo getTemplate(long templateId, DataStore store);
|
||||
TemplateInfo getTemplate(DataObject obj, DataStore store);
|
||||
TemplateInfo getTemplate(long templateId);
|
||||
}
|
||||
@ -16,13 +16,14 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.image;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallFuture;
|
||||
|
||||
public interface ImageService {
|
||||
AsyncCallFuture<CommandResult> createTemplateAsync(TemplateInfo template, DataStore store);
|
||||
AsyncCallFuture<CommandResult> createTemplateFromSnapshotAsync(SnapshotInfo snapshot, TemplateInfo template, DataStore store);
|
||||
AsyncCallFuture<CommandResult> createTemplateFromVolumeAsync(VolumeInfo volume, TemplateInfo template, DataStore store);
|
||||
AsyncCallFuture<CommandResult> deleteTemplateAsync(TemplateInfo template);
|
||||
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.volume;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
@ -49,6 +49,7 @@ public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataS
|
||||
OperationSuccessed,
|
||||
OperationFailed,
|
||||
CopyingRequested,
|
||||
ExpungeRequested
|
||||
|
||||
}
|
||||
}
|
||||
@ -19,21 +19,19 @@
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
public interface PrimaryDataStoreInfo {
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
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 long getCapacity();
|
||||
public long getAvailableCapacity();
|
||||
|
||||
public long getId();
|
||||
public String getUuid();
|
||||
public DataCenterResourceEntity.State getManagedState();
|
||||
public String getName();
|
||||
public String getType();
|
||||
|
||||
public StoragePoolType getPoolType();
|
||||
public PrimaryDataStoreLifeCycle getLifeCycle();
|
||||
}
|
||||
|
||||
@ -16,10 +16,11 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.snapshot;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
|
||||
public interface SnapshotDataFactory {
|
||||
public SnapshotInfo getSnapshot(long snapshotId, DataStore store);
|
||||
public SnapshotInfo getSnapshot(DataObject obj, DataStore store);
|
||||
public SnapshotInfo getSnapshot(long snapshotId);
|
||||
}
|
||||
@ -14,10 +14,8 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.storage.snapshot;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
|
||||
public interface SnapshotInfo extends DataObject {
|
||||
public SnapshotInfo getParent();
|
||||
@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.image;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public enum TemplateEvent {
|
||||
CreateRequested,
|
||||
@ -16,12 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.image;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public interface TemplateInfo extends DataObject {
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.image;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public enum TemplateState {
|
||||
Allocated,
|
||||
@ -16,11 +16,11 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
|
||||
public interface VolumeDataFactory {
|
||||
VolumeInfo getVolume(long volumeId, DataStore store);
|
||||
VolumeInfo getVolume(DataObject volume, DataStore store);
|
||||
VolumeInfo getVolume(long volumeId);
|
||||
}
|
||||
@ -18,6 +18,10 @@
|
||||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public interface VolumeInfo extends DataObject {
|
||||
import com.cloud.storage.Volume;
|
||||
|
||||
public interface VolumeInfo extends DataObject, Volume {
|
||||
public boolean isAttachedVM();
|
||||
public void addPayload(Object data);
|
||||
public Object getpayload();
|
||||
}
|
||||
|
||||
@ -16,17 +16,13 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.storage.volume;
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallFuture;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
|
||||
|
||||
public interface VolumeService {
|
||||
|
||||
@ -40,10 +36,6 @@ public interface VolumeService {
|
||||
return this.volume;
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId);
|
||||
|
||||
/**
|
||||
* Creates the volume based on the given criteria
|
||||
@ -52,7 +44,7 @@ public interface VolumeService {
|
||||
*
|
||||
* @return the volume object
|
||||
*/
|
||||
AsyncCallFuture<VolumeApiResult> createVolumeAsync(VolumeInfo volume, long dataStoreId);
|
||||
AsyncCallFuture<VolumeApiResult> createVolumeAsync(VolumeInfo volume, DataStore store);
|
||||
|
||||
/**
|
||||
* Delete volume
|
||||
@ -61,7 +53,7 @@ public interface VolumeService {
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
AsyncCallFuture<VolumeApiResult> deleteVolumeAsync(VolumeInfo volume);
|
||||
AsyncCallFuture<VolumeApiResult> expungeVolumeAsync(VolumeInfo volume);
|
||||
|
||||
/**
|
||||
*
|
||||
@ -71,21 +63,16 @@ public interface VolumeService {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
boolean createVolumeFromSnapshot(long volumeId, long snapshotId);
|
||||
AsyncCallFuture<VolumeApiResult> createVolumeFromSnapshot(VolumeInfo volume, DataStore store, SnapshotInfo snapshot);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
String grantAccess(VolumeInfo volume, EndPoint endpointId);
|
||||
|
||||
TemplateOnPrimaryDataStoreInfo grantAccess(TemplateOnPrimaryDataStoreInfo template, EndPoint endPoint);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
boolean rokeAccess(long volumeId, long endpointId);
|
||||
|
||||
VolumeEntity getVolumeEntity(long volumeId);
|
||||
|
||||
AsyncCallFuture<VolumeApiResult> createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, TemplateInfo template);
|
||||
AsyncCallFuture<VolumeApiResult> copyVolume(VolumeInfo srcVolume, DataStore destStore);
|
||||
|
||||
boolean destroyVolume(long volumeId) throws ConcurrentOperationException;
|
||||
|
||||
AsyncCallFuture<VolumeApiResult> registerVolume(VolumeInfo volume, DataStore store);
|
||||
|
||||
}
|
||||
@ -21,23 +21,23 @@ package org.apache.cloudstack.storage.datastore.db;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.DataStoreStatus;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreStatus;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface PrimaryDataStoreDao extends GenericDao<PrimaryDataStoreVO, Long> {
|
||||
public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
|
||||
|
||||
/**
|
||||
* @param datacenterId
|
||||
* -- the id of the datacenter (availability zone)
|
||||
*/
|
||||
List<PrimaryDataStoreVO> listByDataCenterId(long datacenterId);
|
||||
List<StoragePoolVO> listByDataCenterId(long datacenterId);
|
||||
|
||||
/**
|
||||
* @param datacenterId
|
||||
* -- the id of the datacenter (availability zone)
|
||||
*/
|
||||
List<PrimaryDataStoreVO> listBy(long datacenterId, long podId, Long clusterId);
|
||||
List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId);
|
||||
|
||||
/**
|
||||
* Set capacity of storage pool in bytes
|
||||
@ -59,7 +59,7 @@ public interface PrimaryDataStoreDao extends GenericDao<PrimaryDataStoreVO, Long
|
||||
*/
|
||||
void updateAvailable(long id, long available);
|
||||
|
||||
PrimaryDataStoreVO persist(PrimaryDataStoreVO pool, Map<String, String> details);
|
||||
StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details);
|
||||
|
||||
/**
|
||||
* Find pool by name.
|
||||
@ -68,7 +68,7 @@ public interface PrimaryDataStoreDao extends GenericDao<PrimaryDataStoreVO, Long
|
||||
* name of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
List<PrimaryDataStoreVO> findPoolByName(String name);
|
||||
List<StoragePoolVO> findPoolByName(String name);
|
||||
|
||||
/**
|
||||
* Find pools by the pod that matches the details.
|
||||
@ -79,9 +79,9 @@ public interface PrimaryDataStoreDao extends GenericDao<PrimaryDataStoreVO, Long
|
||||
* details to match. All must match for the pool to be returned.
|
||||
* @return List of StoragePoolVO
|
||||
*/
|
||||
List<PrimaryDataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details);
|
||||
List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details);
|
||||
|
||||
List<PrimaryDataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared);
|
||||
List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared);
|
||||
|
||||
/**
|
||||
* Find pool by UUID.
|
||||
@ -90,13 +90,13 @@ public interface PrimaryDataStoreDao extends GenericDao<PrimaryDataStoreVO, Long
|
||||
* uuid of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
PrimaryDataStoreVO findPoolByUUID(String uuid);
|
||||
StoragePoolVO findPoolByUUID(String uuid);
|
||||
|
||||
List<PrimaryDataStoreVO> listByStorageHost(String hostFqdnOrIp);
|
||||
List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp);
|
||||
|
||||
PrimaryDataStoreVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
|
||||
StoragePoolVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
|
||||
|
||||
List<PrimaryDataStoreVO> listPoolByHostPath(String host, String path);
|
||||
List<StoragePoolVO> listPoolByHostPath(String host, String path);
|
||||
|
||||
void updateDetails(long poolId, Map<String, String> details);
|
||||
|
||||
@ -104,13 +104,13 @@ public interface PrimaryDataStoreDao extends GenericDao<PrimaryDataStoreVO, Long
|
||||
|
||||
List<String> searchForStoragePoolDetails(long poolId, String value);
|
||||
|
||||
List<PrimaryDataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid);
|
||||
List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid);
|
||||
|
||||
List<PrimaryDataStoreVO> listByStatus(DataStoreStatus status);
|
||||
List<StoragePoolVO> listByStatus(DataStoreStatus status);
|
||||
|
||||
long countPoolsByStatus(DataStoreStatus... statuses);
|
||||
|
||||
List<PrimaryDataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status);
|
||||
List<StoragePoolVO> listByStatusInZone(long dcId, DataStoreStatus status);
|
||||
|
||||
List<PrimaryDataStoreVO> listPoolsByCluster(long clusterId);
|
||||
List<StoragePoolVO> listPoolsByCluster(long clusterId);
|
||||
}
|
||||
@ -29,7 +29,7 @@ import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.DataStoreStatus;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.DB;
|
||||
@ -43,12 +43,12 @@ import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO, Long> implements PrimaryDataStoreDao {
|
||||
protected final SearchBuilder<PrimaryDataStoreVO> AllFieldSearch;
|
||||
protected final SearchBuilder<PrimaryDataStoreVO> DcPodSearch;
|
||||
protected final SearchBuilder<PrimaryDataStoreVO> DcPodAnyClusterSearch;
|
||||
protected final SearchBuilder<PrimaryDataStoreVO> DeleteLvmSearch;
|
||||
protected final GenericSearchBuilder<PrimaryDataStoreVO, Long> StatusCountSearch;
|
||||
public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements PrimaryDataStoreDao {
|
||||
protected final SearchBuilder<StoragePoolVO> AllFieldSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DcPodSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
|
||||
protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
|
||||
|
||||
@Inject protected PrimaryDataStoreDetailsDao _detailsDao;
|
||||
|
||||
@ -99,73 +99,73 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO,
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> findPoolByName(String name) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
public List<StoragePoolVO> findPoolByName(String name) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("name", name);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryDataStoreVO findPoolByUUID(String uuid) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
public StoragePoolVO findPoolByUUID(String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> listByDataCenterId(long datacenterId) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
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) {
|
||||
PrimaryDataStoreVO pool = createForUpdate(id);
|
||||
StoragePoolVO pool = createForUpdate(id);
|
||||
pool.setAvailableBytes(available);
|
||||
update(id, pool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCapacity(long id, long capacity) {
|
||||
PrimaryDataStoreVO pool = createForUpdate(id);
|
||||
StoragePoolVO pool = createForUpdate(id);
|
||||
pool.setCapacityBytes(capacity);
|
||||
update(id, pool);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> listByStorageHost(String hostFqdnOrIp) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
public List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", hostFqdnOrIp);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> listByStatus(DataStoreStatus status) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
public List<StoragePoolVO> listByStatus(DataStoreStatus status) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("status", status);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
public List<StoragePoolVO> listByStatusInZone(long dcId, DataStoreStatus status) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("status", status);
|
||||
sc.setParameters("datacenterId", dcId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryDataStoreVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
public StoragePoolVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", host);
|
||||
sc.setParameters("path", path);
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
@ -176,16 +176,16 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO,
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> listBy(long datacenterId, long podId, Long clusterId) {
|
||||
public List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId) {
|
||||
if (clusterId != null) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = DcPodSearch.create();
|
||||
SearchCriteria<StoragePoolVO> sc = DcPodSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
sc.setParameters("podId", podId);
|
||||
|
||||
sc.setParameters("cluster", clusterId);
|
||||
return listBy(sc);
|
||||
} else {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = DcPodAnyClusterSearch.create();
|
||||
SearchCriteria<StoragePoolVO> sc = DcPodAnyClusterSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
sc.setParameters("podId", podId);
|
||||
return listBy(sc);
|
||||
@ -193,16 +193,16 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO,
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> listPoolByHostPath(String host, String path) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
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 PrimaryDataStoreVO listById(Integer id) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
public StoragePoolVO listById(Integer id) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("id", id);
|
||||
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
@ -210,7 +210,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO,
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public PrimaryDataStoreVO persist(PrimaryDataStoreVO pool, Map<String, String> details) {
|
||||
public StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
pool = super.persist(pool);
|
||||
@ -226,7 +226,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO,
|
||||
|
||||
@DB
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details) {
|
||||
public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details) {
|
||||
StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
|
||||
if (clusterId != null) {
|
||||
sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND (");
|
||||
@ -248,7 +248,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO,
|
||||
}
|
||||
pstmt.setInt(i++, details.size());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
List<PrimaryDataStoreVO> pools = new ArrayList<PrimaryDataStoreVO>();
|
||||
List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
|
||||
while (rs.next()) {
|
||||
pools.add(toEntityBean(rs, false));
|
||||
}
|
||||
@ -267,8 +267,8 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO,
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared) {
|
||||
List<PrimaryDataStoreVO> storagePools = null;
|
||||
public List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared) {
|
||||
List<StoragePoolVO> storagePools = null;
|
||||
if (tags == null || tags.length == 0) {
|
||||
storagePools = listBy(dcId, podId, clusterId);
|
||||
} else {
|
||||
@ -279,8 +279,8 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO,
|
||||
if (shared == null) {
|
||||
return storagePools;
|
||||
} else {
|
||||
List<PrimaryDataStoreVO> filteredStoragePools = new ArrayList<PrimaryDataStoreVO>(storagePools);
|
||||
for (PrimaryDataStoreVO pool : storagePools) {
|
||||
List<StoragePoolVO> filteredStoragePools = new ArrayList<StoragePoolVO>(storagePools);
|
||||
for (StoragePoolVO pool : storagePools) {
|
||||
/*
|
||||
* if (shared != pool.isShared()) {
|
||||
* filteredStoragePools.remove(pool); }
|
||||
@ -351,8 +351,8 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO,
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryDataStoreVO> listPoolsByCluster(long clusterId) {
|
||||
SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
|
||||
public List<StoragePoolVO> listPoolsByCluster(long clusterId) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("clusterId", clusterId);
|
||||
|
||||
return listBy(sc);
|
||||
@ -18,7 +18,6 @@ package org.apache.cloudstack.storage.datastore.db;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.storage.StoragePoolDetailVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface PrimaryDataStoreDetailsDao extends GenericDao<PrimaryDataStoreDetailVO, Long> {
|
||||
@ -1,24 +1,23 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// 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.datastore.db;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@ -30,15 +29,15 @@ import javax.persistence.TableGenerator;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
|
||||
import org.apache.cloudstack.storage.datastore.DataStoreStatus;
|
||||
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name = "storage_pool")
|
||||
public class PrimaryDataStoreVO implements Identity {
|
||||
@Table(name="storage_pool")
|
||||
public class StoragePoolVO {
|
||||
@Id
|
||||
@TableGenerator(name = "storage_pool_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "storage_pool_seq", allocationSize = 1)
|
||||
@Column(name = "id", updatable = false, nullable = false)
|
||||
@ -51,7 +50,8 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
private String uuid = null;
|
||||
|
||||
@Column(name = "pool_type", updatable = false, nullable = false, length = 32)
|
||||
private String poolType;
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private StoragePoolType poolType;
|
||||
|
||||
@Column(name = GenericDao.CREATED_COLUMN)
|
||||
Date created;
|
||||
@ -77,7 +77,7 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
|
||||
@Column(name = "status", updatable = true, nullable = false)
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private DataStoreStatus status;
|
||||
private StoragePoolStatus status;
|
||||
|
||||
@Column(name = "storage_provider_id", updatable = true, nullable = false)
|
||||
private Long storageProviderId;
|
||||
@ -105,28 +105,57 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
return id;
|
||||
}
|
||||
|
||||
public DataStoreStatus getStatus() {
|
||||
public StoragePoolStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public PrimaryDataStoreVO() {
|
||||
this.status = DataStoreStatus.Initial;
|
||||
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;
|
||||
this.id = poolId;
|
||||
this.uuid = uuid;
|
||||
this.poolType = type;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.availableBytes = availableBytes;
|
||||
this.capacityBytes = capacityBytes;
|
||||
this.hostAddress = hostAddress;
|
||||
this.path = hostPath;
|
||||
this.port = port;
|
||||
this.podId = podId;
|
||||
this.setStatus(StoragePoolStatus.Initial);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public StoragePoolVO(StoragePoolType type, String hostAddress, int port, String path) {
|
||||
this.poolType = type;
|
||||
this.hostAddress = hostAddress;
|
||||
this.port = port;
|
||||
this.path = path;
|
||||
this.setStatus(StoragePoolStatus.Initial);
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getPoolType() {
|
||||
public StoragePoolType getPoolType() {
|
||||
return poolType;
|
||||
}
|
||||
|
||||
public void setPoolType(String protocol) {
|
||||
public void setPoolType(StoragePoolType protocol) {
|
||||
this.poolType = protocol;
|
||||
}
|
||||
|
||||
@ -194,7 +223,7 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setStatus(DataStoreStatus status) {
|
||||
public void setStatus(StoragePoolStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@ -248,10 +277,10 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PrimaryDataStoreVO) || obj == null) {
|
||||
if (!(obj instanceof StoragePoolVO) || obj == null) {
|
||||
return false;
|
||||
}
|
||||
PrimaryDataStoreVO that = (PrimaryDataStoreVO) obj;
|
||||
StoragePoolVO that = (StoragePoolVO) obj;
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@ -264,4 +293,12 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -20,7 +20,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -28,6 +27,7 @@ import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDao;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
@ -45,22 +45,18 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VirtualMachineProfileImpl;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@ -104,6 +100,8 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
||||
|
||||
@Inject
|
||||
protected StoragePoolDao _storagePoolDao;
|
||||
@Inject
|
||||
DataStoreManager dataStoreMgr;
|
||||
|
||||
@Override
|
||||
public VMEntityVO loadVirtualMachine(String vmId) {
|
||||
@ -134,7 +132,8 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
||||
List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vm.getId());
|
||||
if(!vols.isEmpty()){
|
||||
VolumeVO vol = vols.get(0);
|
||||
StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId());
|
||||
StoragePool pool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
|
||||
|
||||
if (!pool.isInMaintenance()) {
|
||||
long rootVolDcId = pool.getDataCenterId();
|
||||
Long rootVolPodId = pool.getPodId();
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.cloudstack.storage.backup;
|
||||
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
|
||||
public interface BackupService {
|
||||
public boolean backupSnapshot(SnapshotInfo snapshot, long backupStoreId);
|
||||
|
||||
@ -20,38 +20,74 @@ package org.apache.cloudstack.storage.image;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.storage.datastore.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataVO;
|
||||
import org.apache.cloudstack.storage.image.store.TemplateObject;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||
|
||||
@Component
|
||||
public class ImageDataFactoryImpl implements ImageDataFactory {
|
||||
private static final Logger s_logger = Logger
|
||||
.getLogger(ImageDataFactoryImpl.class);
|
||||
@Inject
|
||||
ImageDataDao imageDataDao;
|
||||
VMTemplateDao imageDataDao;
|
||||
@Inject
|
||||
ObjectInDataStoreManager objMap;
|
||||
@Inject
|
||||
DataStoreManager storeMgr;
|
||||
@Inject
|
||||
VMTemplatePoolDao templatePoolDao;
|
||||
@Override
|
||||
public TemplateInfo getTemplate(long templateId, DataStore store) {
|
||||
ImageDataVO templ = imageDataDao.findById(templateId);
|
||||
VMTemplateVO templ = imageDataDao.findById(templateId);
|
||||
if (store == null) {
|
||||
TemplateObject tmpl = TemplateObject.getTemplate(templ, null);
|
||||
return tmpl;
|
||||
}
|
||||
ObjectInDataStoreVO obj = objMap.findObject(templateId, DataObjectType.TEMPLATE, store.getId(), store.getRole());
|
||||
if (obj == null) {
|
||||
TemplateObject tmpl = TemplateObject.getTemplate(templ, null);
|
||||
return tmpl;
|
||||
boolean found = false;
|
||||
if (store.getRole() == DataStoreRole.Primary) {
|
||||
VMTemplateStoragePoolVO templatePoolVO = templatePoolDao.findByPoolTemplate(store.getId(), templateId);
|
||||
if (templatePoolVO != null) {
|
||||
found = true;
|
||||
}
|
||||
} else {
|
||||
DataObjectInStore obj = objMap.findObject(templ.getUuid(), DataObjectType.TEMPLATE, store.getUuid(), store.getRole());
|
||||
if (obj != null) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
s_logger.debug("template " + templateId + " is not in store:" + store.getId() + ", type:" + store.getRole());
|
||||
}
|
||||
|
||||
TemplateObject tmpl = TemplateObject.getTemplate(templ, store);
|
||||
return tmpl;
|
||||
}
|
||||
@Override
|
||||
public TemplateInfo getTemplate(long templateId) {
|
||||
VMTemplateVO templ = imageDataDao.findById(templateId);
|
||||
if (templ.getImageDataStoreId() == null) {
|
||||
return this.getTemplate(templateId, null);
|
||||
}
|
||||
DataStore store = this.storeMgr.getDataStore(templ.getImageDataStoreId(), DataStoreRole.Image);
|
||||
return this.getTemplate(templateId, store);
|
||||
}
|
||||
@Override
|
||||
public TemplateInfo getTemplate(DataObject obj, DataStore store) {
|
||||
return this.getTemplate(obj.getId(), store);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,15 +22,21 @@ import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ImageService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallFuture;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||
import org.apache.cloudstack.storage.datastore.DataObjectManager;
|
||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.store.TemplateObject;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -41,21 +47,25 @@ public class ImageServiceImpl implements ImageService {
|
||||
private static final Logger s_logger = Logger.getLogger(ImageServiceImpl.class);
|
||||
@Inject
|
||||
ObjectInDataStoreManager objectInDataStoreMgr;
|
||||
@Inject
|
||||
DataObjectManager dataObjectMgr;
|
||||
|
||||
class CreateTemplateContext<T> extends AsyncRpcConext<T> {
|
||||
final TemplateInfo srcTemplate;
|
||||
final TemplateInfo templateOnStore;
|
||||
final DataStore store;
|
||||
final AsyncCallFuture<CommandResult> future;
|
||||
final ObjectInDataStoreVO obj;
|
||||
final DataObject templateOnStore;
|
||||
|
||||
public CreateTemplateContext(AsyncCompletionCallback<T> callback, TemplateInfo srcTemplate,
|
||||
TemplateInfo templateOnStore,
|
||||
AsyncCallFuture<CommandResult> future,
|
||||
ObjectInDataStoreVO obj) {
|
||||
DataStore store,
|
||||
DataObject templateOnStore
|
||||
) {
|
||||
super(callback);
|
||||
this.srcTemplate = srcTemplate;
|
||||
this.templateOnStore = templateOnStore;
|
||||
this.future = future;
|
||||
this.obj = obj;
|
||||
this.store = store;
|
||||
this.templateOnStore = templateOnStore;
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,31 +84,15 @@ public class ImageServiceImpl implements ImageService {
|
||||
return future;
|
||||
}
|
||||
|
||||
ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(template.getId(), template.getType(), store.getId(), store.getRole());
|
||||
TemplateInfo templateOnStore = null;
|
||||
if (obj == null) {
|
||||
templateOnStore = (TemplateInfo)objectInDataStoreMgr.create(template, store);
|
||||
obj = objectInDataStoreMgr.findObject(template.getId(), template.getType(), store.getId(), store.getRole());
|
||||
} else {
|
||||
CommandResult result = new CommandResult();
|
||||
result.setResult("duplicate template on the storage");
|
||||
future.complete(result);
|
||||
return future;
|
||||
}
|
||||
DataObject templateOnStore = store.create(template);
|
||||
templateOnStore.processEvent(ObjectInDataStoreStateMachine.Event.CreateOnlyRequested);
|
||||
|
||||
try {
|
||||
objectInDataStoreMgr.update(obj, Event.CreateOnlyRequested);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("failed to transit", e);
|
||||
CommandResult result = new CommandResult();
|
||||
result.setResult(e.toString());
|
||||
future.complete(result);
|
||||
return future;
|
||||
}
|
||||
CreateTemplateContext<CommandResult> context = new CreateTemplateContext<CommandResult>(null,
|
||||
template, templateOnStore,
|
||||
template,
|
||||
future,
|
||||
obj);
|
||||
store,
|
||||
templateOnStore
|
||||
);
|
||||
AsyncCallbackDispatcher<ImageServiceImpl, CreateCmdResult> caller = AsyncCallbackDispatcher.create(this);
|
||||
caller.setCallback(caller.getTarget().createTemplateCallback(null, null))
|
||||
.setContext(context);
|
||||
@ -108,42 +102,25 @@ public class ImageServiceImpl implements ImageService {
|
||||
|
||||
protected Void createTemplateCallback(AsyncCallbackDispatcher<ImageServiceImpl, CreateCmdResult> callback,
|
||||
CreateTemplateContext<CreateCmdResult> context) {
|
||||
|
||||
TemplateInfo templateOnStore = context.templateOnStore;
|
||||
TemplateObject template = (TemplateObject)context.srcTemplate;
|
||||
AsyncCallFuture<CommandResult> future = context.future;
|
||||
CommandResult result = new CommandResult();
|
||||
|
||||
DataObject templateOnStore = context.templateOnStore;
|
||||
CreateCmdResult callbackResult = callback.getResult();
|
||||
if (callbackResult.isFailed()) {
|
||||
try {
|
||||
objectInDataStoreMgr.update(templateOnStore, Event.OperationFailed);
|
||||
templateOnStore.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||
template.stateTransit(TemplateEvent.OperationFailed);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("failed to transit state", e);
|
||||
s_logger.debug("Failed to update template state", e);
|
||||
}
|
||||
result.setResult(callbackResult.getResult());
|
||||
future.complete(result);
|
||||
return null;
|
||||
}
|
||||
ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(templateOnStore.getId(), templateOnStore.getType(), templateOnStore.getDataStore().getId(), templateOnStore.getDataStore().getRole());
|
||||
obj.setInstallPath(callbackResult.getPath());
|
||||
|
||||
if (callbackResult.getSize() != null) {
|
||||
obj.setSize(callbackResult.getSize());
|
||||
}
|
||||
|
||||
try {
|
||||
objectInDataStoreMgr.update(obj, Event.OperationSuccessed);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Failed to transit state", e);
|
||||
result.setResult(e.toString());
|
||||
future.complete(result);
|
||||
return null;
|
||||
}
|
||||
|
||||
template.setImageStoreId(templateOnStore.getDataStore().getId());
|
||||
template.setSize(callbackResult.getSize());
|
||||
try {
|
||||
templateOnStore.processEvent(ObjectInDataStoreStateMachine.Event.OperationSuccessed);
|
||||
template.stateTransit(TemplateEvent.OperationSucceeded);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Failed to transit state", e);
|
||||
@ -162,4 +139,18 @@ public class ImageServiceImpl implements ImageService {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncCallFuture<CommandResult> createTemplateFromSnapshotAsync(
|
||||
SnapshotInfo snapshot, TemplateInfo template, DataStore store) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncCallFuture<CommandResult> createTemplateFromVolumeAsync(
|
||||
VolumeInfo volume, TemplateInfo template, DataStore store) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.cloudstack.storage.image.downloader;
|
||||
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
|
||||
public interface ImageDownloader {
|
||||
public void downloadImage(TemplateInfo template);
|
||||
|
||||
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* 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.image.driver;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||
import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.storage.DeleteVolumeCommand;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.storage.RegisterVolumePayload;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VMTemplateZoneVO;
|
||||
import com.cloud.storage.VolumeHostVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.dao.VolumeHostDao;
|
||||
import com.cloud.storage.download.DownloadMonitor;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class AncientImageDataStoreDriverImpl implements ImageDataStoreDriver {
|
||||
private static final Logger s_logger = Logger
|
||||
.getLogger(AncientImageDataStoreDriverImpl.class);
|
||||
@Inject
|
||||
VMTemplateZoneDao templateZoneDao;
|
||||
@Inject
|
||||
VMTemplateDao templateDao;
|
||||
@Inject DownloadMonitor _downloadMonitor;
|
||||
@Inject
|
||||
VMTemplateHostDao _vmTemplateHostDao;
|
||||
@Inject VolumeDao volumeDao;
|
||||
@Inject VolumeHostDao volumeHostDao;
|
||||
@Inject HostDao hostDao;
|
||||
@Inject AgentManager agentMgr;
|
||||
@Override
|
||||
public String grantAccess(DataObject data, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAccess(DataObject data, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<DataObject> listObjects(DataStore store) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
class CreateContext<T> extends AsyncRpcConext<T> {
|
||||
final DataObject data;
|
||||
public CreateContext(AsyncCompletionCallback<T> callback, DataObject data) {
|
||||
super(callback);
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createAsync(DataObject data,
|
||||
AsyncCompletionCallback<CreateCmdResult> callback) {
|
||||
if (data.getType() == DataObjectType.TEMPLATE) {
|
||||
List<VMTemplateZoneVO> templateZones = this.templateZoneDao.listByTemplateId(data.getId());
|
||||
for (VMTemplateZoneVO templateZone : templateZones) {
|
||||
VMTemplateVO template = this.templateDao.findById(data.getId());
|
||||
_downloadMonitor.downloadTemplateToStorage(template, templateZone.getZoneId());
|
||||
}
|
||||
} else if (data.getType() == DataObjectType.VOLUME) {
|
||||
VolumeVO vol = this.volumeDao.findById(data.getId());
|
||||
VolumeInfo volInfo = (VolumeInfo)data;
|
||||
RegisterVolumePayload payload = (RegisterVolumePayload)volInfo.getpayload();
|
||||
_downloadMonitor.downloadVolumeToStorage(vol, vol.getDataCenterId(), payload.getUrl(),
|
||||
payload.getChecksum(), ImageFormat.valueOf(payload.getFormat().toUpperCase()));
|
||||
}
|
||||
|
||||
CreateCmdResult result = new CreateCmdResult(null, null);
|
||||
callback.complete(result);
|
||||
}
|
||||
|
||||
private void deleteVolume(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
|
||||
// TODO Auto-generated method stub
|
||||
VolumeVO vol = volumeDao.findById(data.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Expunging " + vol);
|
||||
}
|
||||
|
||||
// Find out if the volume is present on secondary storage
|
||||
VolumeHostVO volumeHost = volumeHostDao.findByVolumeId(vol.getId());
|
||||
if (volumeHost != null) {
|
||||
if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
||||
HostVO ssHost = hostDao.findById(volumeHost.getHostId());
|
||||
DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(
|
||||
ssHost.getStorageUrl(), volumeHost.getInstallPath());
|
||||
Answer answer = agentMgr.sendToSecStorage(ssHost, dtCommand);
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.debug("Failed to delete "
|
||||
+ volumeHost
|
||||
+ " due to "
|
||||
+ ((answer == null) ? "answer is null" : answer
|
||||
.getDetails()));
|
||||
return;
|
||||
}
|
||||
} else if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS) {
|
||||
s_logger.debug("Volume: " + vol.getName()
|
||||
+ " is currently being uploaded; cant' delete it.");
|
||||
throw new CloudRuntimeException(
|
||||
"Please specify a volume that is not currently being uploaded.");
|
||||
}
|
||||
volumeHostDao.remove(volumeHost.getId());
|
||||
volumeDao.remove(vol.getId());
|
||||
CommandResult result = new CommandResult();
|
||||
callback.complete(result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteTemplate(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAsync(DataObject data,
|
||||
AsyncCompletionCallback<CommandResult> callback) {
|
||||
if (data.getType() == DataObjectType.VOLUME) {
|
||||
deleteVolume(data, callback);
|
||||
} else if (data.getType() == DataObjectType.TEMPLATE) {
|
||||
deleteTemplate(data, callback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyAsync(DataObject srcdata, DataObject destData,
|
||||
AsyncCompletionCallback<CopyCommandResult> callback) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCopy(DataObject srcData, DataObject destData) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -34,15 +34,15 @@ import org.apache.cloudstack.storage.command.CreateObjectAnswer;
|
||||
import org.apache.cloudstack.storage.command.CreateObjectCommand;
|
||||
import org.apache.cloudstack.storage.endpoint.EndPointSelector;
|
||||
import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataVO;
|
||||
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
|
||||
//http-read-only based image store
|
||||
public class DefaultImageDataStoreDriverImpl implements ImageDataStoreDriver {
|
||||
@Inject
|
||||
EndPointSelector selector;
|
||||
@Inject
|
||||
ImageDataDao imageDataDao;
|
||||
VMTemplateDao imageDataDao;
|
||||
public DefaultImageDataStoreDriverImpl() {
|
||||
}
|
||||
|
||||
|
||||
@ -18,13 +18,13 @@
|
||||
*/
|
||||
package org.apache.cloudstack.storage.image.manager;
|
||||
|
||||
import org.apache.cloudstack.storage.image.TemplateEvent;
|
||||
import org.apache.cloudstack.storage.image.TemplateState;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataVO;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
||||
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
|
||||
public interface ImageDataManager {
|
||||
StateMachine2<TemplateState, TemplateEvent, ImageDataVO> getStateMachine();
|
||||
StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> getStateMachine();
|
||||
|
||||
}
|
||||
|
||||
@ -18,17 +18,17 @@
|
||||
*/
|
||||
package org.apache.cloudstack.storage.image.manager;
|
||||
|
||||
import org.apache.cloudstack.storage.image.TemplateEvent;
|
||||
import org.apache.cloudstack.storage.image.TemplateState;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataVO;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
|
||||
@Component
|
||||
public class ImageDataManagerImpl implements ImageDataManager {
|
||||
private final StateMachine2<TemplateState, TemplateEvent, ImageDataVO>
|
||||
stateMachine = new StateMachine2<TemplateState, TemplateEvent, ImageDataVO>();
|
||||
private final StateMachine2<TemplateState, TemplateEvent, VMTemplateVO>
|
||||
stateMachine = new StateMachine2<TemplateState, TemplateEvent, VMTemplateVO>();
|
||||
|
||||
public ImageDataManagerImpl() {
|
||||
stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.CreateRequested, TemplateState.Creating);
|
||||
@ -44,7 +44,7 @@ public class ImageDataManagerImpl implements ImageDataManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StateMachine2<TemplateState, TemplateEvent, ImageDataVO> getStateMachine() {
|
||||
public StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> getStateMachine() {
|
||||
return stateMachine;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,38 +18,48 @@
|
||||
*/
|
||||
package org.apache.cloudstack.storage.image.manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
|
||||
import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
|
||||
import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.store.HttpDataStoreImpl;
|
||||
import org.apache.cloudstack.storage.image.store.DefaultImageDataStoreImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
|
||||
@Component
|
||||
public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
|
||||
@Inject
|
||||
ImageDataStoreDao dataStoreDao;
|
||||
@Inject
|
||||
ImageDataDao imageDataDao;
|
||||
VMTemplateDao imageDataDao;
|
||||
@Inject
|
||||
DataStoreProviderManager providerManager;
|
||||
Map<String, ImageDataStoreDriver> driverMaps = new HashMap<String, ImageDataStoreDriver>();
|
||||
Map<String, ImageDataStoreDriver> driverMaps;
|
||||
|
||||
@PostConstruct
|
||||
public void config() {
|
||||
driverMaps = new HashMap<String, ImageDataStoreDriver>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageDataStore getImageDataStore(long dataStoreId) {
|
||||
ImageDataStoreVO dataStore = dataStoreDao.findById(dataStoreId);
|
||||
long providerId = dataStore.getProvider();
|
||||
ImageDataStoreProvider provider = (ImageDataStoreProvider)providerManager.getDataStoreProviderById(providerId);
|
||||
ImageDataStore imgStore = HttpDataStoreImpl.getDataStore(dataStore,
|
||||
ImageDataStore imgStore = DefaultImageDataStoreImpl.getDataStore(dataStore,
|
||||
driverMaps.get(provider.getUuid()), provider
|
||||
);
|
||||
// TODO Auto-generated method stub
|
||||
@ -65,4 +75,20 @@ public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageDataStore getImageDataStore(String uuid) {
|
||||
ImageDataStoreVO dataStore = dataStoreDao.findByUuid(uuid);
|
||||
return getImageDataStore(dataStore.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStore> getList() {
|
||||
List<ImageDataStoreVO> stores = dataStoreDao.listAll();
|
||||
List<DataStore> imageStores = new ArrayList<DataStore>();
|
||||
for (ImageDataStoreVO store : stores) {
|
||||
imageStores.add(getImageDataStore(store.getId()));
|
||||
}
|
||||
return imageStores;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.image.store;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
|
||||
import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
|
||||
import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
|
||||
import org.apache.cloudstack.storage.image.driver.AncientImageDataStoreDriverImpl;
|
||||
import org.apache.cloudstack.storage.image.store.lifecycle.DefaultImageDataStoreLifeCycle;
|
||||
import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
|
||||
@Component
|
||||
public class AncientImageDataStoreProvider implements ImageDataStoreProvider {
|
||||
|
||||
private final String name = "ancient image data store";
|
||||
protected ImageDataStoreLifeCycle lifeCycle;
|
||||
protected ImageDataStoreDriver driver;
|
||||
@Inject
|
||||
ImageDataStoreManager storeMgr;
|
||||
@Inject
|
||||
ImageDataStoreHelper helper;
|
||||
long id;
|
||||
String uuid;
|
||||
@Override
|
||||
public DataStoreLifeCycle getLifeCycle() {
|
||||
return lifeCycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(Map<String, Object> params) {
|
||||
lifeCycle = ComponentContext.inject(DefaultImageDataStoreLifeCycle.class);
|
||||
driver = ComponentContext.inject(AncientImageDataStoreDriverImpl.class);
|
||||
uuid = (String)params.get("uuid");
|
||||
id = (Long)params.get("id");
|
||||
storeMgr.registerDriver(uuid, driver);
|
||||
|
||||
Map<String, Object> infos = new HashMap<String, Object>();
|
||||
String dataStoreName = UUID.nameUUIDFromBytes(this.name.getBytes()).toString();
|
||||
infos.put("name", dataStoreName);
|
||||
infos.put("uuid", dataStoreName);
|
||||
infos.put("protocol", "http");
|
||||
infos.put("scope", ScopeType.GLOBAL);
|
||||
infos.put("provider", this.getId());
|
||||
DataStoreLifeCycle lifeCycle = this.getLifeCycle();
|
||||
lifeCycle.initialize(infos);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -26,24 +26,24 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||
import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
|
||||
import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.storage.encoding.EncodingType;
|
||||
|
||||
|
||||
public class HttpDataStoreImpl implements ImageDataStore {
|
||||
public class DefaultImageDataStoreImpl implements ImageDataStore {
|
||||
@Inject
|
||||
ImageDataDao imageDao;
|
||||
VMTemplateDao imageDao;
|
||||
@Inject
|
||||
private ObjectInDataStoreManager objectInStoreMgr;
|
||||
protected ImageDataStoreDriver driver;
|
||||
@ -51,7 +51,7 @@ public class HttpDataStoreImpl implements ImageDataStore {
|
||||
protected ImageDataStoreProvider provider;
|
||||
boolean needDownloadToCacheStorage = false;
|
||||
|
||||
protected HttpDataStoreImpl() {
|
||||
protected DefaultImageDataStoreImpl() {
|
||||
|
||||
}
|
||||
|
||||
@ -62,9 +62,9 @@ public class HttpDataStoreImpl implements ImageDataStore {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public static HttpDataStoreImpl getDataStore(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver imageDataStoreDriver,
|
||||
public static ImageDataStore getDataStore(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver imageDataStoreDriver,
|
||||
ImageDataStoreProvider provider) {
|
||||
HttpDataStoreImpl instance = (HttpDataStoreImpl)ComponentContext.inject(HttpDataStoreImpl.class);
|
||||
DefaultImageDataStoreImpl instance = (DefaultImageDataStoreImpl)ComponentContext.inject(DefaultImageDataStoreImpl.class);
|
||||
instance.configure(dataStoreVO, imageDataStoreDriver, provider);
|
||||
return instance;
|
||||
}
|
||||
@ -81,24 +81,17 @@ public class HttpDataStoreImpl implements ImageDataStore {
|
||||
return this.driver;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public DataStoreRole getRole() {
|
||||
// TODO Auto-generated method stub
|
||||
return DataStoreRole.Image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.imageDataStoreVO.getId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getUri() {
|
||||
return this.imageDataStoreVO.getProtocol() + "://" + "?" + EncodingType.ROLE + "=" + this.getRole();
|
||||
@ -106,39 +99,47 @@ public class HttpDataStoreImpl implements ImageDataStore {
|
||||
|
||||
@Override
|
||||
public Scope getScope() {
|
||||
// TODO Auto-generated method stub
|
||||
return new ZoneScope(imageDataStoreVO.getDcId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public TemplateInfo getTemplate(long templateId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public VolumeInfo getVolume(long volumeId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SnapshotInfo getSnapshot(long snapshotId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean exists(DataObject object) {
|
||||
return (objectInStoreMgr.findObject(object.getId(), object.getType(),
|
||||
this.getId(), this.getRole()) != null) ? true : false;
|
||||
return (objectInStoreMgr.findObject(object,
|
||||
this) != null) ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.imageDataStoreVO.getUuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObject create(DataObject obj) {
|
||||
DataObject object = objectInStoreMgr.create(obj, this);
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(DataObject obj) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -29,11 +29,9 @@ import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
|
||||
import org.apache.cloudstack.storage.image.driver.DefaultImageDataStoreDriverImpl;
|
||||
import org.apache.cloudstack.storage.image.store.lifecycle.DefaultImageDataStoreLifeCycle;
|
||||
import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
|
||||
@Component
|
||||
public class DefaultImageDataStoreProvider implements ImageDataStoreProvider {
|
||||
private final String name = "default image data store";
|
||||
protected ImageDataStoreLifeCycle lifeCycle;
|
||||
|
||||
@ -20,44 +20,48 @@ package org.apache.cloudstack.storage.image.store;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
|
||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.TemplateEvent;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataVO;
|
||||
import org.apache.cloudstack.storage.image.manager.ImageDataManager;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.utils.storage.encoding.EncodingType;
|
||||
|
||||
public class TemplateObject implements TemplateInfo {
|
||||
private static final Logger s_logger = Logger
|
||||
.getLogger(TemplateObject.class);
|
||||
private ImageDataVO imageVO;
|
||||
private VMTemplateVO imageVO;
|
||||
private DataStore dataStore;
|
||||
@Inject
|
||||
ImageDataManager imageMgr;
|
||||
@Inject
|
||||
ImageDataDao imageDao;
|
||||
VMTemplateDao imageDao;
|
||||
@Inject
|
||||
ObjectInDataStoreManager ojbectInStoreMgr;
|
||||
@Inject VMTemplatePoolDao templatePoolDao;
|
||||
|
||||
protected TemplateObject() {
|
||||
}
|
||||
|
||||
protected void configure(ImageDataVO template, DataStore dataStore) {
|
||||
protected void configure(VMTemplateVO template, DataStore dataStore) {
|
||||
this.imageVO = template;
|
||||
this.dataStore = dataStore;
|
||||
}
|
||||
|
||||
public static TemplateObject getTemplate(ImageDataVO vo, DataStore store) {
|
||||
public static TemplateObject getTemplate(VMTemplateVO vo, DataStore store) {
|
||||
TemplateObject to = ComponentContext.inject(TemplateObject.class);
|
||||
to.configure(vo, store);
|
||||
return to;
|
||||
@ -66,12 +70,12 @@ public class TemplateObject implements TemplateInfo {
|
||||
public void setImageStoreId(long id) {
|
||||
this.imageVO.setImageDataStoreId(id);
|
||||
}
|
||||
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.imageVO.setSize(size);
|
||||
}
|
||||
|
||||
public ImageDataVO getImage() {
|
||||
public VMTemplateVO getImage() {
|
||||
return this.imageVO;
|
||||
}
|
||||
|
||||
@ -87,23 +91,20 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return this.imageVO.getUuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUri() {
|
||||
ImageDataVO image = imageDao.findById(this.imageVO.getId());
|
||||
VMTemplateVO image = imageDao.findById(this.imageVO.getId());
|
||||
if (this.dataStore == null) {
|
||||
return image.getUrl();
|
||||
} else {
|
||||
ObjectInDataStoreVO obj = ojbectInStoreMgr.findObject(
|
||||
this.imageVO.getId(), DataObjectType.TEMPLATE,
|
||||
this.dataStore.getId(), this.dataStore.getRole());
|
||||
DataObjectInStore obj = ojbectInStoreMgr.findObject(this, this.dataStore);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (obj.getState() == ObjectInDataStoreStateMachine.State.Ready
|
||||
|| obj.getState() == ObjectInDataStoreStateMachine.State.Copying) {
|
||||
|
||||
|
||||
builder.append(this.dataStore.getUri());
|
||||
builder.append("&" + EncodingType.OBJTYPE + "=" + DataObjectType.TEMPLATE);
|
||||
builder.append("&" + EncodingType.PATH + "=" + obj.getInstallPath());
|
||||
@ -124,10 +125,33 @@ public class TemplateObject implements TemplateInfo {
|
||||
if (this.dataStore == null) {
|
||||
return this.imageVO.getSize();
|
||||
}
|
||||
ObjectInDataStoreVO obj = ojbectInStoreMgr.findObject(
|
||||
this.imageVO.getId(), DataObjectType.TEMPLATE,
|
||||
this.dataStore.getId(), this.dataStore.getRole());
|
||||
return obj.getSize();
|
||||
|
||||
/*
|
||||
|
||||
// If the template that was passed into this allocator is not installed in the storage pool,
|
||||
// add 3 * (template size on secondary storage) to the running total
|
||||
VMTemplateHostVO templateHostVO = _storageMgr.findVmTemplateHost(templateForVmCreation.getId(), null);
|
||||
|
||||
if (templateHostVO == null) {
|
||||
VMTemplateSwiftVO templateSwiftVO = _swiftMgr.findByTmpltId(templateForVmCreation.getId());
|
||||
if (templateSwiftVO != null) {
|
||||
long templateSize = templateSwiftVO.getPhysicalSize();
|
||||
if (templateSize == 0) {
|
||||
templateSize = templateSwiftVO.getSize();
|
||||
}
|
||||
totalAllocatedSize += (templateSize + _extraBytesPerVolume);
|
||||
}
|
||||
} else {
|
||||
long templateSize = templateHostVO.getPhysicalSize();
|
||||
if ( templateSize == 0 ){
|
||||
templateSize = templateHostVO.getSize();
|
||||
}
|
||||
totalAllocatedSize += (templateSize + _extraBytesPerVolume);
|
||||
}
|
||||
|
||||
*/
|
||||
VMTemplateVO image = imageDao.findById(this.imageVO.getId());
|
||||
return image.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,7 +161,7 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public DiskFormat getFormat() {
|
||||
return DiskFormat.getFormat(this.imageVO.getFormat());
|
||||
return DiskFormat.valueOf(this.imageVO.getFormat().toString());
|
||||
}
|
||||
|
||||
public boolean stateTransit(TemplateEvent e) throws NoTransitionException {
|
||||
@ -146,4 +170,14 @@ public class TemplateObject implements TemplateInfo {
|
||||
this.imageVO = imageDao.findById(this.imageVO.getId());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processEvent(Event event) {
|
||||
try {
|
||||
ojbectInStoreMgr.update(this, event);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("failed to update state", e);
|
||||
throw new CloudRuntimeException("Failed to update state" + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,12 +22,15 @@ import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
|
||||
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
|
||||
public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
|
||||
@Inject
|
||||
protected ImageDataStoreDao imageStoreDao;
|
||||
@ -40,7 +43,7 @@ public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
|
||||
|
||||
|
||||
@Override
|
||||
public DataStore initialize(Map<String, String> dsInfos) {
|
||||
public DataStore initialize(Map<String, Object> dsInfos) {
|
||||
ImageDataStoreVO ids = imageStoreHelper.createImageDataStore(dsInfos);
|
||||
return imageStoreMgr.getImageDataStore(ids.getId());
|
||||
}
|
||||
@ -53,6 +56,14 @@ public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean attachHost(DataStore store, HostScope scope,
|
||||
StoragePoolInfo existingInfo) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean attachZone(DataStore dataStore, ZoneScope scope) {
|
||||
// TODO Auto-generated method stub
|
||||
@ -75,23 +86,27 @@ public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean maintain() {
|
||||
public boolean maintain(long storeId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean cancelMaintain() {
|
||||
public boolean cancelMaintain(long storeId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean deleteDataStore() {
|
||||
public boolean deleteDataStore(long storeId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import javax.inject.Inject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
@ -32,12 +31,11 @@ import org.apache.cloudstack.storage.command.CopyCmd;
|
||||
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
|
||||
import org.apache.cloudstack.storage.endpoint.EndPointSelector;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
||||
//At least one of datastore is coming from image store or image cache store
|
||||
@Component
|
||||
|
||||
public class DefaultImageMotionStrategy implements ImageMotionStrategy {
|
||||
@Inject
|
||||
EndPointSelector selector;
|
||||
@ -86,14 +84,15 @@ public class DefaultImageMotionStrategy implements ImageMotionStrategy {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(DataObject srcData, DataObject destData) {
|
||||
/*
|
||||
DataStore destStore = destData.getDataStore();
|
||||
DataStore srcStore = srcData.getDataStore();
|
||||
if (destStore.getRole() == DataStoreRole.Image || destStore.getRole() == DataStoreRole.ImageCache
|
||||
|| srcStore.getRole() == DataStoreRole.Image
|
||||
|| srcStore.getRole() == DataStoreRole.ImageCache) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -23,18 +23,12 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ImageService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.ImageService;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||
import org.apache.cloudstack.storage.volume.VolumeService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
public class ImageMotionServiceImpl implements ImageMotionService {
|
||||
@Inject
|
||||
List<ImageMotionStrategy> motionStrategies;
|
||||
|
||||
@ -16,14 +16,25 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.storage.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.cloudstack.acl.APIChecker;
|
||||
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||
import org.apache.cloudstack.storage.HostEndpointRpcServer;
|
||||
import org.apache.cloudstack.storage.endpoint.EndPointSelector;
|
||||
import org.apache.cloudstack.storage.test.ChildTestConfiguration.Library;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.cluster.ClusteredAgentRebalanceService;
|
||||
import com.cloud.cluster.agentlb.dao.HostTransferMapDao;
|
||||
import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
|
||||
@ -50,11 +61,35 @@ import com.cloud.host.dao.HostTagsDaoImpl;
|
||||
import com.cloud.server.auth.UserAuthenticator;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.storage.dao.StoragePoolHostDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateDetailsDao;
|
||||
import com.cloud.storage.dao.VMTemplateDetailsDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateHostDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplatePoolDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDaoImpl;
|
||||
|
||||
import com.cloud.storage.dao.VolumeDaoImpl;
|
||||
import com.cloud.storage.dao.VolumeHostDaoImpl;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||
import com.cloud.utils.component.SpringComponentScanUtils;
|
||||
import com.cloud.vm.dao.NicDaoImpl;
|
||||
import com.cloud.vm.dao.VMInstanceDaoImpl;
|
||||
@Configuration
|
||||
@ComponentScan(basePackageClasses={
|
||||
NicDaoImpl.class,
|
||||
VMInstanceDaoImpl.class,
|
||||
VMTemplateHostDaoImpl.class,
|
||||
VolumeHostDaoImpl.class,
|
||||
VolumeDaoImpl.class,
|
||||
VMTemplatePoolDaoImpl.class,
|
||||
ResourceTagsDaoImpl.class,
|
||||
VMTemplateDaoImpl.class,
|
||||
MockStorageMotionStrategy.class
|
||||
},
|
||||
includeFilters={@Filter(value=Library.class, type=FilterType.CUSTOM)},
|
||||
useDefaultFilters=false
|
||||
)
|
||||
public class ChildTestConfiguration extends TestConfiguration {
|
||||
|
||||
@Override
|
||||
@ -148,6 +183,27 @@ public class ChildTestConfiguration extends TestConfiguration {
|
||||
public APIChecker apiChecker() {
|
||||
return Mockito.mock(APIChecker.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SnapshotManager snapshotMgr() {
|
||||
return Mockito.mock(SnapshotManager.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AlertManager alertMgr() {
|
||||
return Mockito.mock(AlertManager.class);
|
||||
}
|
||||
|
||||
public static class Library implements TypeFilter {
|
||||
|
||||
@Override
|
||||
public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
|
||||
mdr.getClassMetadata().getClassName();
|
||||
ComponentScan cs = ChildTestConfiguration.class.getAnnotation(ComponentScan.class);
|
||||
return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
|
||||
}
|
||||
|
||||
}
|
||||
/* @Override
|
||||
@Bean
|
||||
public PrimaryDataStoreDao primaryDataStoreDao() {
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.motion.DataMotionStrategy;
|
||||
|
||||
public class MockStorageMotionStrategy implements DataMotionStrategy {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(DataObject srcData, DataObject destData) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void copyAsync(DataObject srcData, DataObject destData,
|
||||
AsyncCompletionCallback<CopyCommandResult> callback) {
|
||||
CopyCommandResult result = new CopyCommandResult("something");
|
||||
callback.complete(result);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -28,33 +28,30 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ImageService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallFuture;
|
||||
import org.apache.cloudstack.storage.HypervisorHostEndPoint;
|
||||
import org.apache.cloudstack.storage.datastore.VolumeDataFactory;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.provider.DataStoreProvider;
|
||||
import org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManager;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.storage.endpoint.EndPointSelector;
|
||||
import org.apache.cloudstack.storage.image.ImageDataFactory;
|
||||
import org.apache.cloudstack.storage.image.ImageService;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataVO;
|
||||
import org.apache.cloudstack.storage.volume.VolumeService;
|
||||
import org.apache.cloudstack.storage.volume.VolumeService.VolumeApiResult;
|
||||
import org.apache.cloudstack.storage.volume.db.VolumeDao2;
|
||||
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
||||
import org.mockito.Mockito;
|
||||
@ -78,7 +75,11 @@ import com.cloud.org.Cluster.ClusterType;
|
||||
import com.cloud.org.Managed.ManagedState;
|
||||
import com.cloud.resource.ResourceState;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
|
||||
@ContextConfiguration(locations={"classpath:/storageContext.xml"})
|
||||
public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
@ -89,7 +90,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
@Inject
|
||||
VolumeService volumeService;
|
||||
@Inject
|
||||
ImageDataDao imageDataDao;
|
||||
VMTemplateDao imageDataDao;
|
||||
@Inject
|
||||
VolumeDao2 volumeDao;
|
||||
@Inject
|
||||
@ -121,12 +122,13 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
|
||||
@Test(priority = -1)
|
||||
public void setUp() {
|
||||
try {
|
||||
ComponentContext.initComponentsLifeCycle();
|
||||
/* try {
|
||||
dataStoreProviderMgr.configure(null, new HashMap<String, Object>());
|
||||
} catch (ConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
host = hostDao.findByGuid(this.getHostGuid());
|
||||
if (host != null) {
|
||||
dcId = host.getDataCenterId();
|
||||
@ -205,18 +207,17 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
Mockito.when(selector.select(Mockito.any(DataObject.class), Mockito.any(DataObject.class))).thenReturn(eps.get(0));
|
||||
}
|
||||
|
||||
private ImageDataVO createImageData() {
|
||||
ImageDataVO image = new ImageDataVO();
|
||||
private VMTemplateVO createImageData() {
|
||||
VMTemplateVO image = new VMTemplateVO();
|
||||
image.setTemplateType(TemplateType.USER);
|
||||
image.setUrl(this.getTemplateUrl());
|
||||
image.setUniqueName(UUID.randomUUID().toString());
|
||||
image.setName(UUID.randomUUID().toString());
|
||||
image.setPublicTemplate(true);
|
||||
image.setFeatured(true);
|
||||
image.setRequireHvm(true);
|
||||
image.setRequiresHvm(true);
|
||||
image.setBits(64);
|
||||
image.setFormat(Storage.ImageFormat.VHD.toString());
|
||||
image.setAccountId(1);
|
||||
image.setFormat(Storage.ImageFormat.VHD);
|
||||
image.setEnablePassword(true);
|
||||
image.setEnableSshKey(true);
|
||||
image.setGuestOSId(1);
|
||||
@ -234,13 +235,13 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
private TemplateInfo createTemplate() {
|
||||
try {
|
||||
DataStore store = createImageStore();
|
||||
ImageDataVO image = createImageData();
|
||||
VMTemplateVO image = createImageData();
|
||||
TemplateInfo template = imageDataFactory.getTemplate(image.getId(), store);
|
||||
AsyncCallFuture<CommandResult> future = imageService.createTemplateAsync(template, store);
|
||||
future.get();
|
||||
template = imageDataFactory.getTemplate(image.getId(), store);
|
||||
/*imageProviderMgr.configure("image Provider", new HashMap<String, Object>());
|
||||
ImageDataVO image = createImageData();
|
||||
VMTemplateVO image = createImageData();
|
||||
ImageDataStoreProvider defaultProvider = imageProviderMgr.getProvider("DefaultProvider");
|
||||
ImageDataStoreLifeCycle lifeCycle = defaultProvider.getLifeCycle();
|
||||
ImageDataStore store = lifeCycle.registerDataStore("defaultHttpStore", new HashMap<String, String>());
|
||||
@ -262,7 +263,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
@Test
|
||||
public void testCreatePrimaryStorage() {
|
||||
DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
URI uri = null;
|
||||
try {
|
||||
uri = new URI(this.getPrimaryStorageUrl());
|
||||
@ -273,7 +274,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
params.put("url", this.getPrimaryStorageUrl());
|
||||
params.put("server", uri.getHost());
|
||||
params.put("path", uri.getPath());
|
||||
params.put("protocol", uri.getScheme());
|
||||
params.put("protocol", StoragePoolType.NetworkFilesystem);
|
||||
params.put("dcId", dcId.toString());
|
||||
params.put("clusterId", clusterId.toString());
|
||||
params.put("name", this.primaryName);
|
||||
@ -290,7 +291,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
|
||||
private DataStore createImageStore() {
|
||||
DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default image data store");
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
String name = UUID.randomUUID().toString();
|
||||
params.put("name", name);
|
||||
params.put("uuid", name);
|
||||
@ -310,12 +311,12 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
public DataStore createPrimaryDataStore() {
|
||||
try {
|
||||
DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
URI uri = new URI(this.getPrimaryStorageUrl());
|
||||
params.put("url", this.getPrimaryStorageUrl());
|
||||
params.put("server", uri.getHost());
|
||||
params.put("path", uri.getPath());
|
||||
params.put("protocol", uri.getScheme());
|
||||
params.put("protocol", Storage.StoragePoolType.NetworkFilesystem);
|
||||
params.put("dcId", dcId.toString());
|
||||
params.put("clusterId", clusterId.toString());
|
||||
params.put("name", this.primaryName);
|
||||
@ -390,7 +391,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
DataStore primaryStore = this.primaryStore;
|
||||
VolumeVO volume = createVolume(null, primaryStore.getId());
|
||||
VolumeInfo vol = volumeFactory.getVolume(volume.getId(), primaryStore);
|
||||
AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore.getId());
|
||||
AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore);
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException e) {
|
||||
@ -407,7 +408,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
DataStore primaryStore = this.primaryStore;
|
||||
VolumeVO volume = createVolume(null, primaryStore.getId());
|
||||
VolumeInfo vol = volumeFactory.getVolume(volume.getId(), primaryStore);
|
||||
AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore.getId());
|
||||
AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore);
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException e) {
|
||||
@ -420,7 +421,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
|
||||
//delete the volume
|
||||
vol = volumeFactory.getVolume(volume.getId(), primaryStore);
|
||||
future = volumeService.deleteVolumeAsync(vol);
|
||||
future = volumeService.expungeVolumeAsync(vol);
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException e) {
|
||||
@ -434,9 +435,9 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
||||
|
||||
//@Test(priority=3)
|
||||
public void tearDown() {
|
||||
List<PrimaryDataStoreVO> ds = primaryStoreDao.findPoolByName(this.primaryName);
|
||||
List<StoragePoolVO> ds = primaryStoreDao.findPoolByName(this.primaryName);
|
||||
for (int i = 0; i < ds.size(); i++) {
|
||||
PrimaryDataStoreVO store = ds.get(i);
|
||||
StoragePoolVO store = ds.get(i);
|
||||
store.setUuid(null);
|
||||
primaryStoreDao.remove(ds.get(i).getId());
|
||||
primaryStoreDao.expunge(ds.get(i).getId());
|
||||
|
||||
201
engine/storage/integration-test/test/resource/component.xml
Normal file
201
engine/storage/integration-test/test/resource/component.xml
Normal file
@ -0,0 +1,201 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||
http://www.springframework.org/schema/aop
|
||||
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
|
||||
<!--
|
||||
Compose a CloudStack deployment with selected components here
|
||||
-->
|
||||
<bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker" />
|
||||
|
||||
<bean id="management-server" class ="com.cloud.server.ManagementServerExtImpl" />
|
||||
<bean id="configuration-server" class="com.cloud.server.ConfigurationServerImpl" />
|
||||
|
||||
<bean id="clusterManagerImpl" class="com.cloud.cluster.ClusterManagerImpl" />
|
||||
<bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" />
|
||||
<bean id="highAvailabilityManagerExtImpl" class="com.cloud.ha.HighAvailabilityManagerExtImpl" />
|
||||
<bean id="bareMetalVmManagerImpl" class="com.cloud.baremetal.BareMetalVmManagerImpl" />
|
||||
<bean id="consoleProxyManagerImpl" class="com.cloud.consoleproxy.ConsoleProxyManagerImpl" />
|
||||
<bean id="securityGroupManagerImpl2" class="com.cloud.network.security.SecurityGroupManagerImpl2" />
|
||||
<bean id="premiumSecondaryStorageManagerImpl" class="com.cloud.secstorage.PremiumSecondaryStorageManagerImpl" />
|
||||
<bean id="randomlyIncreasingVMInstanceDaoImpl" class="com.cloud.vm.dao.RandomlyIncreasingVMInstanceDaoImpl" />
|
||||
|
||||
|
||||
<!--
|
||||
Adapters
|
||||
-->
|
||||
<bean id="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.FirstFitRoutingAllocator">
|
||||
<property name="name" value="FirstFitRouting"/>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
Storage pool allocators
|
||||
-->
|
||||
<bean id="LocalStoragePoolAllocator" class="com.cloud.storage.allocator.LocalStoragePoolAllocator">
|
||||
<property name="name" value="LocalStorage"/>
|
||||
</bean>
|
||||
<bean id="FirstFitStoragePoolAllocator" class="com.cloud.storage.allocator.FirstFitStoragePoolAllocator">
|
||||
<property name="name" value="Storage"/>
|
||||
</bean>
|
||||
|
||||
<bean id="UserConcentratedAllocator" class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator">
|
||||
<property name="name" value="User First"/>
|
||||
</bean>
|
||||
|
||||
<bean id="ConsoleProxyAllocator" class="com.cloud.consoleproxy.ConsoleProxyBalanceAllocator">
|
||||
<property name="name" value="Balance"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="ExteralIpAddressAllocator" class="com.cloud.network.ExteralIpAddressAllocator">
|
||||
<property name="name" value="Basic"/>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
Investigators
|
||||
-->
|
||||
<bean id="CheckOnAgentInvestigator" class="com.cloud.ha.CheckOnAgentInvestigator">
|
||||
<property name="name" value="SimpleInvestigator"/>
|
||||
</bean>
|
||||
|
||||
<bean id="XenServerInvestigator" class="com.cloud.ha.XenServerInvestigator">
|
||||
<property name="name" value="XenServerInvestigator"/>
|
||||
</bean>
|
||||
|
||||
<bean id="UserVmDomRInvestigator" class="com.cloud.ha.UserVmDomRInvestigator">
|
||||
<property name="name" value="PingInvestigator"/>
|
||||
</bean>
|
||||
|
||||
<bean id="ManagementIPSystemVMInvestigator" class="com.cloud.ha.ManagementIPSystemVMInvestigator">
|
||||
<property name="name" value="ManagementIPSysVMInvestigator"/>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
Fencers
|
||||
-->
|
||||
<bean id="XenServerFencer" class="com.cloud.ha.XenServerFencer">
|
||||
<property name="name" value="XenServerFenceBuilder"/>
|
||||
</bean>
|
||||
<bean id="KVMFencer" class="com.cloud.ha.KVMFencer">
|
||||
<property name="name" value="KVMFenceBuilder"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="XcpServerDiscoverer" class="com.cloud.hypervisor.xen.discoverer.XcpServerDiscoverer">
|
||||
<property name="name" value="XCP Agent"/>
|
||||
</bean>
|
||||
|
||||
<bean id="SecondaryStorageDiscoverer" class="com.cloud.storage.secondary.SecondaryStorageDiscoverer">
|
||||
<property name="name" value="SecondaryStorage"/>
|
||||
</bean>
|
||||
|
||||
<bean id="KvmServerDiscoverer" class="com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer">
|
||||
<property name="name" value="KVM Agent"/>
|
||||
</bean>
|
||||
|
||||
<bean id="BareMetalDiscoverer" class="com.cloud.baremetal.BareMetalDiscoverer">
|
||||
<property name="name" value="Bare Metal Agent"/>
|
||||
</bean>
|
||||
|
||||
<bean id="HypervServerDiscoverer" class="com.cloud.hypervisor.hyperv.HypervServerDiscoverer">
|
||||
<property name="name" value="SCVMMServer"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="FirstFitPlanner" class="com.cloud.deploy.FirstFitPlanner">
|
||||
<property name="name" value="First Fit"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="BareMetalPlanner" class="com.cloud.deploy.BareMetalPlanner">
|
||||
<property name="name" value="BareMetal Fit"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<!--
|
||||
Network Gurus
|
||||
-->
|
||||
<bean id="StorageNetworkGuru" class="com.cloud.network.guru.StorageNetworkGuru">
|
||||
<property name="name" value="StorageNetworkGuru"/>
|
||||
</bean>
|
||||
<bean id="ExternalGuestNetworkGuru" class="com.cloud.network.guru.ExternalGuestNetworkGuru">
|
||||
<property name="name" value="ExternalGuestNetworkGuru"/>
|
||||
</bean>
|
||||
<bean id="PublicNetworkGuru" class="com.cloud.network.guru.PublicNetworkGuru">
|
||||
<property name="name" value="PublicNetworkGuru"/>
|
||||
</bean>
|
||||
<bean id="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru">
|
||||
<property name="name" value="PodBasedNetworkGuru"/>
|
||||
</bean>
|
||||
<bean id="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru">
|
||||
<property name="name" value="ControlNetworkGuru"/>
|
||||
</bean>
|
||||
<bean id="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru">
|
||||
<property name="name" value="DirectNetworkGuru"/>
|
||||
</bean>
|
||||
<bean id="DirectPodBasedNetworkGuru" class="com.cloud.network.guru.DirectPodBasedNetworkGuru">
|
||||
<property name="name" value="DirectPodBasedNetworkGuru"/>
|
||||
</bean>
|
||||
<bean id="OvsGuestNetworkGuru" class="com.cloud.network.guru.OvsGuestNetworkGuru">
|
||||
<property name="name" value="OvsGuestNetworkGuru"/>
|
||||
</bean>
|
||||
<bean id="PrivateNetworkGuru" class="com.cloud.network.guru.PrivateNetworkGuru">
|
||||
<property name="name" value="PrivateNetworkGuru"/>
|
||||
</bean>
|
||||
<bean id="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement">
|
||||
<property name="name" value="VpcVirtualRouter"/>
|
||||
</bean>
|
||||
<!--
|
||||
Hypervisor Gurus
|
||||
-->
|
||||
<bean id="XenServerGuru" class="com.cloud.hypervisor.XenServerGuru">
|
||||
<property name="name" value="XenServerGuru"/>
|
||||
</bean>
|
||||
|
||||
<bean id="KVMGuru" class="com.cloud.hypervisor.KVMGuru">
|
||||
<property name="name" value="KVMGuru"/>
|
||||
</bean>
|
||||
|
||||
<bean id="BareMetalGuru" class="com.cloud.baremetal.BareMetalGuru">
|
||||
<property name="name" value="BareMetalGuru"/>
|
||||
</bean>
|
||||
|
||||
<bean id="HypervGuru" class="com.cloud.hypervisor.guru.HypervGuru">
|
||||
<property name="name" value="HypervGuru"/>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
DAO with customized configuration
|
||||
-->
|
||||
<bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl">
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -45,6 +45,7 @@
|
||||
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
|
||||
<bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
|
||||
|
||||
<bean id="componentContext" class="com.cloud.utils.component.ComponentContext"/>
|
||||
|
||||
<bean class="org.apache.cloudstack.storage.test.ChildTestConfiguration" />
|
||||
|
||||
|
||||
@ -20,11 +20,14 @@ package org.apache.cloudstack.storage.snapshot;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.storage.datastore.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.snapshot.db.SnapshotDao2;
|
||||
import org.apache.cloudstack.storage.snapshot.db.SnapshotVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -40,8 +43,21 @@ public class SnapshotDataFactoryImpl implements SnapshotDataFactory {
|
||||
@Override
|
||||
public SnapshotInfo getSnapshot(long snapshotId, DataStore store) {
|
||||
SnapshotVO snapshot = snapshotDao.findById(snapshotId);
|
||||
ObjectInDataStoreVO obj = objMap.findObject(snapshotId, DataObjectType.SNAPSHOT, store.getId(), store.getRole());
|
||||
DataObjectInStore obj = objMap.findObject(snapshot.getUuid(), DataObjectType.SNAPSHOT, store.getUuid(), store.getRole());
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
SnapshotObject so = new SnapshotObject(snapshot, store);
|
||||
return so;
|
||||
}
|
||||
@Override
|
||||
public SnapshotInfo getSnapshot(long snapshotId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public SnapshotInfo getSnapshot(DataObject obj, DataStore store) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,8 @@ package org.apache.cloudstack.storage.snapshot;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
|
||||
import org.apache.cloudstack.storage.snapshot.db.SnapshotVO;
|
||||
@ -97,4 +99,10 @@ public class SnapshotObject implements SnapshotInfo {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processEvent(Event event) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
package org.apache.cloudstack.storage.snapshot;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.storage.snapshot.strategy;
|
||||
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotStrategy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.storage.snapshot.strategy;
|
||||
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotStrategy;
|
||||
|
||||
public class StorageBasedSnapshot implements SnapshotStrategy {
|
||||
|
||||
@ -24,14 +24,14 @@ import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.motion.DataMotionService;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -52,7 +52,7 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
protected DataObject waitingForCreated(DataObject dataObj,
|
||||
DataStore dataStore) {
|
||||
long retries = this.waitingRetries;
|
||||
ObjectInDataStoreVO obj = null;
|
||||
DataObjectInStore obj = null;
|
||||
do {
|
||||
try {
|
||||
Thread.sleep(waitingTime);
|
||||
@ -61,8 +61,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
throw new CloudRuntimeException("sleep interrupted", e);
|
||||
}
|
||||
|
||||
obj = objectInDataStoreMgr.findObject(dataObj.getId(),
|
||||
dataObj.getType(), dataStore.getId(), dataStore.getRole());
|
||||
obj = objectInDataStoreMgr.findObject(dataObj,
|
||||
dataStore);
|
||||
if (obj == null) {
|
||||
s_logger.debug("can't find object in db, maybe it's cleaned up already, exit waiting");
|
||||
break;
|
||||
@ -92,11 +92,10 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createAsync(DataObject data, DataStore store,
|
||||
public void createAsync(DataObject data, DataStore store,
|
||||
AsyncCompletionCallback<CreateCmdResult> callback, boolean noCopy) {
|
||||
ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
|
||||
data.getId(), data.getType(), store.getId(),
|
||||
store.getRole());
|
||||
DataObjectInStore obj = objectInDataStoreMgr.findObject(
|
||||
data, store);
|
||||
DataObject objInStore = null;
|
||||
boolean freshNewTemplate = false;
|
||||
if (obj == null) {
|
||||
@ -105,8 +104,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
data, store);
|
||||
freshNewTemplate = true;
|
||||
} catch (Throwable e) {
|
||||
obj = objectInDataStoreMgr.findObject(data.getId(),
|
||||
data.getType(), store.getId(), store.getRole());
|
||||
obj = objectInDataStoreMgr.findObject(data,
|
||||
store);
|
||||
if (obj == null) {
|
||||
CreateCmdResult result = new CreateCmdResult(
|
||||
null, null);
|
||||
@ -184,20 +183,12 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
|
||||
objInStrore.getId(), objInStrore
|
||||
.getType(), objInStrore.getDataStore()
|
||||
.getId(), objInStrore.getDataStore()
|
||||
.getRole());
|
||||
|
||||
obj.setInstallPath(result.getPath());
|
||||
obj.setSize(result.getSize());
|
||||
try {
|
||||
objectInDataStoreMgr.update(obj,
|
||||
objectInDataStoreMgr.update(objInStrore,
|
||||
ObjectInDataStoreStateMachine.Event.OperationSuccessed);
|
||||
} catch (NoTransitionException e) {
|
||||
try {
|
||||
objectInDataStoreMgr.update(obj,
|
||||
objectInDataStoreMgr.update(objInStrore,
|
||||
ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||
} catch (NoTransitionException e1) {
|
||||
s_logger.debug("failed to change state", e1);
|
||||
@ -259,14 +250,10 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
CopyContext<CreateCmdResult> context) {
|
||||
CopyCommandResult result = callback.getResult();
|
||||
DataObject destObj = context.destObj;
|
||||
ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
|
||||
destObj.getId(), destObj
|
||||
.getType(), destObj.getDataStore()
|
||||
.getId(), destObj.getDataStore()
|
||||
.getRole());
|
||||
|
||||
if (result.isFailed()) {
|
||||
try {
|
||||
objectInDataStoreMgr.update(obj, Event.OperationFailed);
|
||||
objectInDataStoreMgr.update(destObj, Event.OperationFailed);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Failed to update copying state", e);
|
||||
}
|
||||
@ -276,10 +263,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
context.getParentCallback().complete(res);
|
||||
}
|
||||
|
||||
obj.setInstallPath(result.getPath());
|
||||
|
||||
try {
|
||||
objectInDataStoreMgr.update(obj,
|
||||
objectInDataStoreMgr.update(destObj,
|
||||
ObjectInDataStoreStateMachine.Event.OperationSuccessed);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Failed to update copying state: ", e);
|
||||
@ -311,11 +296,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
@Override
|
||||
public void deleteAsync(DataObject data,
|
||||
AsyncCompletionCallback<CommandResult> callback) {
|
||||
ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
|
||||
data.getId(), data.getType(), data.getDataStore().getId(),
|
||||
data.getDataStore().getRole());
|
||||
try {
|
||||
objectInDataStoreMgr.update(obj, Event.DestroyRequested);
|
||||
objectInDataStoreMgr.update(data, Event.DestroyRequested);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("destroy failed", e);
|
||||
CreateCmdResult res = new CreateCmdResult(
|
||||
@ -338,23 +320,18 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
protected Void deleteAsynCallback(AsyncCallbackDispatcher<DataObjectManagerImpl, CommandResult> callback,
|
||||
DeleteContext<CommandResult> context) {
|
||||
DataObject destObj = context.obj;
|
||||
ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
|
||||
destObj.getId(), destObj
|
||||
.getType(), destObj.getDataStore()
|
||||
.getId(), destObj.getDataStore()
|
||||
.getRole());
|
||||
|
||||
|
||||
CommandResult res = callback.getResult();
|
||||
if (res.isFailed()) {
|
||||
try {
|
||||
objectInDataStoreMgr.update(obj, Event.OperationFailed);
|
||||
objectInDataStoreMgr.update(destObj, Event.OperationFailed);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("delete failed", e);
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
objectInDataStoreMgr.update(obj, Event.OperationSuccessed);
|
||||
objectInDataStoreMgr.update(destObj, Event.OperationSuccessed);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("delete failed", e);
|
||||
}
|
||||
@ -366,9 +343,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
|
||||
@Override
|
||||
public DataObject createInternalStateOnly(DataObject data, DataStore store) {
|
||||
ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
|
||||
data.getId(), data.getType(), store.getId(),
|
||||
store.getRole());
|
||||
DataObjectInStore obj = objectInDataStoreMgr.findObject(
|
||||
data, store);
|
||||
DataObject objInStore = null;
|
||||
if (obj == null) {
|
||||
objInStore = objectInDataStoreMgr.create(
|
||||
@ -391,12 +367,6 @@ public class DataObjectManagerImpl implements DataObjectManager {
|
||||
|
||||
@Override
|
||||
public void update(DataObject data, String path, Long size) {
|
||||
ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
|
||||
data.getId(), data.getType(), data.getDataStore().getId(),
|
||||
data.getDataStore().getRole());
|
||||
|
||||
obj.setInstallPath(path);
|
||||
obj.setSize(size);
|
||||
objectInDataStoreMgr.update(obj);
|
||||
throw new CloudRuntimeException("not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,12 +18,15 @@
|
||||
*/
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -50,5 +53,22 @@ public class DataStoreManagerImpl implements DataStoreManager {
|
||||
String providerUuid) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public DataStore getDataStore(String uuid, DataStoreRole role) {
|
||||
if (role == DataStoreRole.Primary) {
|
||||
return primaryStorMgr.getPrimaryDataStore(uuid);
|
||||
} else if (role == DataStoreRole.Image) {
|
||||
return imageDataStoreMgr.getImageDataStore(uuid);
|
||||
}
|
||||
throw new CloudRuntimeException("un recognized type" + role);
|
||||
}
|
||||
@Override
|
||||
public List<DataStore> getImageStores(Scope scope) {
|
||||
return imageDataStoreMgr.getList();
|
||||
}
|
||||
@Override
|
||||
public DataStore getPrimaryDataStore(long storeId) {
|
||||
return primaryStorMgr.getPrimaryDataStore(storeId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,26 +17,20 @@
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
|
||||
public interface ObjectInDataStoreManager {
|
||||
public DataObject create(DataObject template, DataStore dataStore);
|
||||
public VolumeInfo create(VolumeInfo volume, DataStore dataStore);
|
||||
public SnapshotInfo create(SnapshotInfo snapshot, DataStore dataStore);
|
||||
public ObjectInDataStoreVO findObject(long objectId, DataObjectType type,
|
||||
long dataStoreId, DataStoreRole role);
|
||||
public DataObject get(DataObject dataObj, DataStore store);
|
||||
public boolean update(DataObject vo, Event event) throws NoTransitionException;
|
||||
boolean update(ObjectInDataStoreVO obj, Event event)
|
||||
throws NoTransitionException;
|
||||
|
||||
boolean update(ObjectInDataStoreVO obj);
|
||||
DataObjectInStore findObject(String uuid, DataObjectType type,
|
||||
String dataStoreUuid, DataStoreRole role);
|
||||
DataObjectInStore findObject(DataObject obj, DataStore store);
|
||||
DataStore findStore(String objUuid, DataObjectType type, DataStoreRole role);
|
||||
}
|
||||
|
||||
@ -19,19 +19,25 @@ package org.apache.cloudstack.storage.datastore;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreDao;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.ImageDataFactory;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.State;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||
import com.cloud.storage.dao.VolumeHostDao;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.SearchCriteriaService;
|
||||
@ -41,16 +47,28 @@ import com.cloud.utils.fsm.StateMachine2;
|
||||
|
||||
@Component
|
||||
public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
||||
private static final Logger s_logger = Logger
|
||||
.getLogger(ObjectInDataStoreManagerImpl.class);
|
||||
@Inject
|
||||
ImageDataFactory imageFactory;
|
||||
@Inject
|
||||
DataStoreManager storeMgr;
|
||||
@Inject
|
||||
VolumeDataFactory volumeFactory;
|
||||
@Inject
|
||||
ObjectInDataStoreDao objectDataStoreDao;
|
||||
protected StateMachine2<State, Event, ObjectInDataStoreVO> stateMachines;
|
||||
@Inject
|
||||
VolumeHostDao volumeHostDao;
|
||||
@Inject
|
||||
VMTemplateHostDao templateHostDao;
|
||||
@Inject
|
||||
VMTemplatePoolDao templatePoolDao;
|
||||
@Inject
|
||||
SnapshotDataFactory snapshotFactory;
|
||||
protected StateMachine2<State, Event, DataObjectInStore> stateMachines;
|
||||
|
||||
public ObjectInDataStoreManagerImpl() {
|
||||
stateMachines = new StateMachine2<State, Event, ObjectInDataStoreVO>();
|
||||
stateMachines = new StateMachine2<State, Event, DataObjectInStore>();
|
||||
stateMachines.addTransition(State.Allocated, Event.CreateRequested,
|
||||
State.Creating);
|
||||
stateMachines.addTransition(State.Creating, Event.OperationSuccessed,
|
||||
@ -76,101 +94,122 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
||||
stateMachines.addTransition(State.Allocated, Event.CreateOnlyRequested,
|
||||
State.Creating2);
|
||||
stateMachines.addTransition(State.Creating2, Event.OperationFailed,
|
||||
State.Failed);
|
||||
State.Allocated);
|
||||
stateMachines.addTransition(State.Creating2, Event.OperationSuccessed,
|
||||
State.Ready);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObject create(DataObject obj, DataStore dataStore) {
|
||||
|
||||
ObjectInDataStoreVO vo = new ObjectInDataStoreVO();
|
||||
vo.setDataStoreId(dataStore.getId());
|
||||
vo.setDataStoreRole(dataStore.getRole());
|
||||
vo.setObjectId(obj.getId());
|
||||
vo.setSize(obj.getSize());
|
||||
|
||||
vo.setObjectType(obj.getType());
|
||||
vo = objectDataStoreDao.persist(vo);
|
||||
if (obj.getType() == DataObjectType.TEMPLATE && dataStore.getRole() == DataStoreRole.Primary) {
|
||||
VMTemplateStoragePoolVO vo = new VMTemplateStoragePoolVO(dataStore.getId(), obj.getId());
|
||||
vo = templatePoolDao.persist(vo);
|
||||
} else {
|
||||
ObjectInDataStoreVO vo = new ObjectInDataStoreVO();
|
||||
vo.setDataStoreRole(dataStore.getRole());
|
||||
vo.setDataStoreUuid(dataStore.getUuid());
|
||||
vo.setObjectType(obj.getType());
|
||||
vo.setObjectUuid(obj.getUuid());
|
||||
vo = objectDataStoreDao.persist(vo);
|
||||
}
|
||||
|
||||
if (obj.getType() == DataObjectType.TEMPLATE) {
|
||||
return imageFactory.getTemplate(obj.getId(), dataStore);
|
||||
return imageFactory.getTemplate(obj, dataStore);
|
||||
} else if (obj.getType() == DataObjectType.VOLUME) {
|
||||
return volumeFactory.getVolume(obj.getId(), dataStore);
|
||||
return volumeFactory.getVolume(obj, dataStore);
|
||||
} else if (obj.getType() == DataObjectType.SNAPSHOT) {
|
||||
return snapshotFactory.getSnapshot(obj, dataStore);
|
||||
}
|
||||
throw new CloudRuntimeException("unknown type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeInfo create(VolumeInfo volume, DataStore dataStore) {
|
||||
ObjectInDataStoreVO vo = new ObjectInDataStoreVO();
|
||||
vo.setDataStoreId(dataStore.getId());
|
||||
vo.setDataStoreRole(dataStore.getRole());
|
||||
vo.setObjectId(volume.getId());
|
||||
vo.setObjectType(volume.getType());
|
||||
vo = objectDataStoreDao.persist(vo);
|
||||
|
||||
return volumeFactory.getVolume(volume.getId(), dataStore);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SnapshotInfo create(SnapshotInfo snapshot, DataStore dataStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectInDataStoreVO findObject(long objectId, DataObjectType type,
|
||||
long dataStoreId, DataStoreRole role) {
|
||||
SearchCriteriaService<ObjectInDataStoreVO, ObjectInDataStoreVO> sc = SearchCriteria2
|
||||
.create(ObjectInDataStoreVO.class);
|
||||
sc.addAnd(sc.getEntity().getObjectId(), Op.EQ, objectId);
|
||||
sc.addAnd(sc.getEntity().getDataStoreId(), Op.EQ, dataStoreId);
|
||||
sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, type);
|
||||
sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, role);
|
||||
sc.addAnd(sc.getEntity().getState(), Op.NIN,
|
||||
ObjectInDataStoreStateMachine.State.Destroyed,
|
||||
ObjectInDataStoreStateMachine.State.Failed);
|
||||
ObjectInDataStoreVO objectStoreVO = sc.find();
|
||||
return objectStoreVO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean update(DataObject data, Event event)
|
||||
throws NoTransitionException {
|
||||
ObjectInDataStoreVO obj = this.findObject(data.getId(), data.getType(),
|
||||
data.getDataStore().getId(), data.getDataStore().getRole());
|
||||
DataObjectInStore obj = this.findObject(data, data.getDataStore());
|
||||
if (obj == null) {
|
||||
throw new CloudRuntimeException(
|
||||
"can't find mapping in ObjectInDataStore table for: "
|
||||
+ data);
|
||||
}
|
||||
return this.stateMachines.transitTo(obj, event, null,
|
||||
objectDataStoreDao);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(ObjectInDataStoreVO obj, Event event)
|
||||
throws NoTransitionException {
|
||||
return this.stateMachines.transitTo(obj, event, null,
|
||||
objectDataStoreDao);
|
||||
|
||||
|
||||
if (data.getType() == DataObjectType.TEMPLATE && data.getDataStore().getRole() == DataStoreRole.Primary) {
|
||||
try {
|
||||
this.stateMachines.transitTo(obj, event, null,
|
||||
templatePoolDao);
|
||||
} catch (NoTransitionException e) {
|
||||
if (event == Event.CreateOnlyRequested || event == Event.OperationSuccessed) {
|
||||
s_logger.debug("allow muliple create requests");
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.stateMachines.transitTo(obj, event, null, objectDataStoreDao);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObject get(DataObject dataObj, DataStore store) {
|
||||
if (dataObj.getType() == DataObjectType.TEMPLATE) {
|
||||
return imageFactory.getTemplate(dataObj.getId(), store);
|
||||
return imageFactory.getTemplate(dataObj, store);
|
||||
} else if (dataObj.getType() == DataObjectType.VOLUME) {
|
||||
return volumeFactory.getVolume(dataObj.getId(), store);
|
||||
return volumeFactory.getVolume(dataObj, store);
|
||||
}
|
||||
throw new CloudRuntimeException("unknown type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(ObjectInDataStoreVO obj) {
|
||||
return objectDataStoreDao.update(obj.getId(), obj);
|
||||
public DataObjectInStore findObject(DataObject obj, DataStore store) {
|
||||
DataObjectInStore vo = null;
|
||||
SearchCriteriaService<ObjectInDataStoreVO, ObjectInDataStoreVO> sc = SearchCriteria2.create(ObjectInDataStoreVO.class);
|
||||
|
||||
if (store.getRole() == DataStoreRole.Image) {
|
||||
sc.addAnd(sc.getEntity().getDataStoreUuid(), Op.EQ, store.getUuid());
|
||||
sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, store.getRole());
|
||||
sc.addAnd(sc.getEntity().getObjectUuid(), Op.EQ, obj.getUuid());
|
||||
sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, obj.getType());
|
||||
vo = sc.find();
|
||||
} else if (obj.getType() == DataObjectType.TEMPLATE && store.getRole() == DataStoreRole.Primary) {
|
||||
vo = templatePoolDao.findByPoolTemplate(store.getId(), obj.getId());
|
||||
} else {
|
||||
s_logger.debug("unknown type: " + obj.getType() + " " + store.getRole());
|
||||
throw new CloudRuntimeException("unknown type");
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataObjectInStore findObject(String uuid, DataObjectType type,
|
||||
String dataStoreUuid, DataStoreRole role) {
|
||||
DataObjectInStore vo = null;
|
||||
SearchCriteriaService<ObjectInDataStoreVO, ObjectInDataStoreVO> sc = SearchCriteria2.create(ObjectInDataStoreVO.class);
|
||||
|
||||
if (role == DataStoreRole.Image) {
|
||||
sc.addAnd(sc.getEntity().getDataStoreUuid(), Op.EQ, dataStoreUuid);
|
||||
sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, role);
|
||||
sc.addAnd(sc.getEntity().getObjectUuid(), Op.EQ, uuid);
|
||||
sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, type);
|
||||
vo = sc.find();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStore findStore(String objUuid, DataObjectType type, DataStoreRole role) {
|
||||
DataStore store = null;
|
||||
if (role == DataStoreRole.Image) {
|
||||
SearchCriteriaService<ObjectInDataStoreVO, ObjectInDataStoreVO> sc = SearchCriteria2.create(ObjectInDataStoreVO.class);
|
||||
sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, role);
|
||||
sc.addAnd(sc.getEntity().getObjectUuid(), Op.EQ, objUuid);
|
||||
sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, type);
|
||||
ObjectInDataStoreVO vo = sc.find();
|
||||
if (vo != null) {
|
||||
store = this.storeMgr.getDataStore(vo.getDataStoreUuid(), vo.getDataStoreRole());
|
||||
}
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,31 +20,19 @@ package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||
|
||||
public interface PrimaryDataStore extends DataStore, PrimaryDataStoreInfo {
|
||||
VolumeInfo getVolume(long id);
|
||||
|
||||
List<VolumeInfo> getVolumes();
|
||||
|
||||
/* void deleteVolumeAsync(VolumeInfo volume, AsyncCompletionCallback<CommandResult> callback);
|
||||
|
||||
void createVolumeAsync(VolumeInfo vo, VolumeDiskType diskType, AsyncCompletionCallback<CommandResult> callback);
|
||||
|
||||
void createVoluemFromBaseImageAsync(VolumeInfo volume, TemplateInfo templateStore, AsyncCompletionCallback<CommandResult> callback);
|
||||
*/
|
||||
|
||||
boolean exists(DataObject data);
|
||||
|
||||
TemplateInfo getTemplate(long templateId);
|
||||
@ -53,13 +41,4 @@ public interface PrimaryDataStore extends DataStore, PrimaryDataStoreInfo {
|
||||
|
||||
|
||||
DiskFormat getDefaultDiskType();
|
||||
|
||||
/* void takeSnapshot(SnapshotInfo snapshot,
|
||||
AsyncCompletionCallback<CommandResult> callback);
|
||||
|
||||
void revertSnapshot(SnapshotInfo snapshot,
|
||||
AsyncCompletionCallback<CommandResult> callback);
|
||||
|
||||
void deleteSnapshot(SnapshotInfo snapshot,
|
||||
AsyncCompletionCallback<CommandResult> callback);*/
|
||||
}
|
||||
|
||||
@ -26,8 +26,8 @@ import java.util.Map;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
|
||||
public class PrimaryDataStoreEntityImpl implements StorageEntity {
|
||||
private PrimaryDataStoreInfo dataStore;
|
||||
@ -132,7 +132,8 @@ public class PrimaryDataStoreEntityImpl implements StorageEntity {
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return this.dataStore.getManagedState();
|
||||
//return this.dataStore.getManagedState();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -229,13 +230,7 @@ public class PrimaryDataStoreEntityImpl implements StorageEntity {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageProvider() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStorageType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
@ -247,4 +242,16 @@ public class PrimaryDataStoreEntityImpl implements StorageEntity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getStorageProviderId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInMaintenance() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,11 +18,14 @@
|
||||
*/
|
||||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
|
||||
import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
|
||||
|
||||
|
||||
public interface PrimaryDataStoreProviderManager {
|
||||
public PrimaryDataStore getPrimaryDataStore(long dataStoreId);
|
||||
public PrimaryDataStore getPrimaryDataStore(String uuid);
|
||||
|
||||
boolean registerDriver(String uuid, PrimaryDataStoreDriver driver);
|
||||
boolean registerHostListener(String uuid, HypervisorHostListener listener);
|
||||
}
|
||||
|
||||
@ -26,14 +26,19 @@ import java.util.UUID;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
|
||||
import org.apache.cloudstack.storage.datastore.db.DataStoreProviderDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.DataStoreProviderVO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
|
||||
@Component
|
||||
public class DataStoreProviderManagerImpl extends ManagerBase implements DataStoreProviderManager {
|
||||
private static final Logger s_logger = Logger
|
||||
.getLogger(DataStoreProviderManagerImpl.class);
|
||||
@Inject
|
||||
List<DataStoreProvider> providers;
|
||||
@Inject
|
||||
@ -59,8 +64,8 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
|
||||
/*
|
||||
Map<String, Object> copyParams = new HashMap<String, Object>(params);
|
||||
|
||||
//TODO: hold global lock
|
||||
List<DataStoreProviderVO> providerVos = providerDao.listAll();
|
||||
for (DataStoreProvider provider : providers) {
|
||||
@ -83,12 +88,20 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
|
||||
} else {
|
||||
uuid = providerVO.getUuid();
|
||||
}
|
||||
params.put("uuid", uuid);
|
||||
params.put("id", providerVO.getId());
|
||||
provider.configure(params);
|
||||
copyParams.put("uuid", uuid);
|
||||
copyParams.put("id", providerVO.getId());
|
||||
providerMap.put(uuid, provider);
|
||||
try {
|
||||
boolean registrationResult = provider.configure(copyParams);
|
||||
if (!registrationResult) {
|
||||
providerMap.remove(uuid);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
s_logger.debug("configure provider failed", e);
|
||||
providerMap.remove(uuid);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -97,4 +110,9 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
|
||||
DataStoreProviderVO provider = providerDao.findById(id);
|
||||
return providerMap.get(provider.getUuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStoreProvider getDefaultPrimaryDataStoreProvider() {
|
||||
return this.getDataStoreProvider("ancient primary data store provider");
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.apache.cloudstack.storage.datastore.provider;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
|
||||
|
||||
public interface ImageDataStoreProvider extends DataStoreProvider {
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user