mirror of https://github.com/apache/cloudstack.git
merge from latest pull
This commit is contained in:
commit
395de6f2b3
|
|
@ -13,7 +13,6 @@
|
|||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<context:annotation-config />
|
||||
|
||||
<context:component-scan base-package="org.apache.cloudstack, com.cloud" />
|
||||
|
||||
<!--
|
||||
|
|
@ -58,6 +57,4 @@
|
|||
|
||||
<bean id="eventBus" class = "org.apache.cloudstack.framework.eventbus.EventBusBase" />
|
||||
|
||||
<bean id="userVmManager" class ="com.cloud.vm.UserVmManagerImpl" />
|
||||
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class TemplateObject implements TemplateInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ImageDataStoreInfo getImageDataStore() {
|
||||
public ImageDataStoreInfo getDataStore() {
|
||||
return this.dataStore;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,12 +18,14 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.image.driver;
|
||||
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.image.TemplateObject;
|
||||
|
||||
public interface ImageDataStoreDriver {
|
||||
boolean registerTemplate(TemplateInfo template);
|
||||
|
||||
String grantAccess(long templateId, long endPointId);
|
||||
String grantAccess(TemplateObject template, EndPoint endPointId);
|
||||
|
||||
boolean revokeAccess(long templateId, long endPointId);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.image.driver;
|
||||
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.image.TemplateObject;
|
||||
|
||||
public class ImageDataStoreDriverImpl implements ImageDataStoreDriver {
|
||||
|
||||
|
|
@ -32,9 +34,8 @@ public class ImageDataStoreDriverImpl implements ImageDataStoreDriver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String grantAccess(long templateId, long endPointId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public String grantAccess(TemplateObject template, EndPoint endPointId) {
|
||||
return template.getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -18,15 +18,11 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.image.store;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.DataStore;
|
||||
import org.apache.cloudstack.storage.image.TemplateObject;
|
||||
|
||||
public interface ImageDataStore extends ImageDataStoreInfo {
|
||||
TemplateObject registerTemplate(long templateId);
|
||||
|
||||
String grantAccess(long templateId, long endPointId);
|
||||
|
||||
boolean revokeAccess(long templateId, long endPointId);
|
||||
|
||||
boolean deleteTemplate(long templateId);
|
||||
|
||||
boolean needDownloadToCacheStorage();
|
||||
|
|
|
|||
|
|
@ -20,11 +20,15 @@ package org.apache.cloudstack.storage.image.store;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.image.TemplateObject;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.db.ImageDataVO;
|
||||
import org.apache.cloudstack.storage.image.driver.ImageDataStoreDriver;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
|
||||
public class ImageDataStoreImpl implements ImageDataStore {
|
||||
@Inject
|
||||
|
|
@ -47,18 +51,6 @@ public class ImageDataStoreImpl implements ImageDataStore {
|
|||
* } else { return null; } }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String grantAccess(long templateId, long endPointId) {
|
||||
ImageDataVO idv = imageDao.findById(templateId);
|
||||
return idv.getUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAccess(long templateId, long endPointId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteTemplate(long templateId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
@ -103,4 +95,49 @@ public class ImageDataStoreImpl implements ImageDataStore {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String grantAccess(VolumeInfo volume, EndPoint ep) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAccess(VolumeInfo volume, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String grantAccess(TemplateInfo template, EndPoint ep) {
|
||||
return this.driver.grantAccess((TemplateObject)template, ep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAccess(TemplateInfo template, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String grantAccess(SnapshotInfo snapshot, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAccess(SnapshotInfo snapshot, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRole() {
|
||||
return "imageStore";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,10 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
|||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorageCmd;
|
||||
import org.apache.cloudstack.storage.command.CopyCmd;
|
||||
import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorageAnswer;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -36,24 +37,12 @@ import com.cloud.agent.api.Answer;
|
|||
public class DefaultImageMotionStrategy implements ImageMotionStrategy {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TemplateOnPrimaryDataStoreInfo templateStore) {
|
||||
public boolean canHandle(TemplateInfo templateStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EndPoint getEndPoint(TemplateOnPrimaryDataStoreInfo templateStore) {
|
||||
PrimaryDataStore pdi = templateStore.getPrimaryDataStore();
|
||||
return pdi.getEndPoints().get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore, EndPoint ep) {
|
||||
ImageOnPrimayDataStoreTO imageTo = new ImageOnPrimayDataStoreTO(templateStore);
|
||||
CopyTemplateToPrimaryStorageCmd copyCommand = new CopyTemplateToPrimaryStorageCmd(imageTo);
|
||||
ep.sendMessage(copyCommand);
|
||||
return true;
|
||||
}
|
||||
|
||||
private class CreateTemplateContext<T> extends AsyncRpcConext<T> {
|
||||
private final TemplateOnPrimaryDataStoreInfo template;
|
||||
|
|
@ -69,10 +58,10 @@ public class DefaultImageMotionStrategy implements ImageMotionStrategy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void copyTemplateAsync(TemplateOnPrimaryDataStoreInfo templateStore, EndPoint ep, AsyncCompletionCallback<CommandResult> callback) {
|
||||
ImageOnPrimayDataStoreTO imageTo = new ImageOnPrimayDataStoreTO(templateStore);
|
||||
CopyTemplateToPrimaryStorageCmd copyCommand = new CopyTemplateToPrimaryStorageCmd(imageTo);
|
||||
CreateTemplateContext<CommandResult> context = new CreateTemplateContext<CommandResult>(callback, templateStore);
|
||||
public void copyTemplateAsync(String destUri, String srcUri, EndPoint ep, AsyncCompletionCallback<CommandResult> callback) {
|
||||
|
||||
CopyCmd copyCommand = new CopyCmd(destUri, srcUri);
|
||||
CreateTemplateContext<CommandResult> context = new CreateTemplateContext<CommandResult>(callback, null);
|
||||
AsyncCallbackDispatcher<DefaultImageMotionStrategy, Answer> caller = AsyncCallbackDispatcher.create(this);
|
||||
caller.setCallback(caller.getTarget().copyTemplateCallBack(null, null))
|
||||
.setContext(context);
|
||||
|
|
@ -98,4 +87,10 @@ public class DefaultImageMotionStrategy implements ImageMotionStrategy {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EndPoint getEndPoint(TemplateInfo destTemplate,
|
||||
TemplateInfo srcTemplate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import javax.inject.Inject;
|
|||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
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;
|
||||
|
|
@ -48,11 +49,13 @@ public class ImageMotionServiceImpl implements ImageMotionService {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore) {
|
||||
public void copyTemplateAsync(TemplateInfo destTemplate, TemplateInfo srcTemplate, AsyncCompletionCallback<CommandResult> callback) {
|
||||
ImageMotionStrategy ims = null;
|
||||
for (ImageMotionStrategy strategy : motionStrategies) {
|
||||
if (strategy.canHandle(templateStore)) {
|
||||
if (strategy.canHandle(srcTemplate)) {
|
||||
ims = strategy;
|
||||
break;
|
||||
}
|
||||
|
|
@ -62,34 +65,11 @@ public class ImageMotionServiceImpl implements ImageMotionService {
|
|||
throw new CloudRuntimeException("Can't find proper image motion strategy");
|
||||
}
|
||||
|
||||
EndPoint ep = ims.getEndPoint(templateStore);
|
||||
|
||||
volumeService.grantAccess(templateStore, ep);
|
||||
TemplateInfo template = templateStore.getTemplate();
|
||||
imageService.grantTemplateAccess(template, ep);
|
||||
return ims.copyTemplate(templateStore, ep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTemplateAsync(TemplateOnPrimaryDataStoreInfo templateStore, AsyncCompletionCallback<CommandResult> callback) {
|
||||
ImageMotionStrategy ims = null;
|
||||
for (ImageMotionStrategy strategy : motionStrategies) {
|
||||
if (strategy.canHandle(templateStore)) {
|
||||
ims = strategy;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ims == null) {
|
||||
throw new CloudRuntimeException("Can't find proper image motion strategy");
|
||||
}
|
||||
|
||||
EndPoint ep = ims.getEndPoint(templateStore);
|
||||
volumeService.grantAccess(templateStore, ep);
|
||||
TemplateInfo template = templateStore.getTemplate();
|
||||
imageService.grantTemplateAccess(template, ep);
|
||||
EndPoint ep = ims.getEndPoint(destTemplate, srcTemplate);
|
||||
String srcUri = srcTemplate.getDataStore().grantAccess(srcTemplate, ep);
|
||||
String destUri = destTemplate.getDataStore().grantAccess(destTemplate, ep);
|
||||
|
||||
ims.copyTemplateAsync(templateStore, ep, callback);
|
||||
ims.copyTemplateAsync(destUri, srcUri, ep, callback);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,13 +22,11 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
|||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.cloudstack.storage.datastore.DataStore;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
|
||||
public interface ImageMotionStrategy {
|
||||
public boolean canHandle(TemplateOnPrimaryDataStoreInfo templateStore);
|
||||
|
||||
public EndPoint getEndPoint(TemplateOnPrimaryDataStoreInfo templateStore);
|
||||
|
||||
public boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore, EndPoint ep);
|
||||
|
||||
public void copyTemplateAsync(TemplateOnPrimaryDataStoreInfo templateStore, EndPoint ep, AsyncCompletionCallback<CommandResult> callback);
|
||||
public boolean canHandle(TemplateInfo templateStore);
|
||||
public EndPoint getEndPoint(TemplateInfo destTemplate, TemplateInfo srcTemplate);
|
||||
public void copyTemplateAsync(String destUri, String sourceUri, EndPoint ep, AsyncCompletionCallback<CommandResult> callback);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@ import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
|
|||
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class CopyTemplateToPrimaryStorageCmd extends Command implements StorageSubSystemCommand {
|
||||
public class CopyCmd extends Command implements StorageSubSystemCommand {
|
||||
|
||||
private ImageOnPrimayDataStoreTO imageTO;
|
||||
|
||||
protected CopyTemplateToPrimaryStorageCmd() {
|
||||
protected CopyCmd() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CopyTemplateToPrimaryStorageCmd(ImageOnPrimayDataStoreTO image) {
|
||||
public CopyCmd(String destUri, String srcUri) {
|
||||
super();
|
||||
this.imageTO = image;
|
||||
// this.imageTO = image;
|
||||
}
|
||||
|
||||
public ImageOnPrimayDataStoreTO getImage() {
|
||||
|
|
@ -27,9 +27,9 @@ public class CreateVolumeFromBaseImageCommand extends Command implements Storage
|
|||
private final VolumeTO volume;
|
||||
private final ImageOnPrimayDataStoreTO image;
|
||||
|
||||
public CreateVolumeFromBaseImageCommand(VolumeTO volume, ImageOnPrimayDataStoreTO image) {
|
||||
public CreateVolumeFromBaseImageCommand(VolumeTO volume, String image) {
|
||||
this.volume = volume;
|
||||
this.image = image;
|
||||
this.image = null;
|
||||
}
|
||||
|
||||
public VolumeTO getVolume() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
|
||||
public interface DataStore {
|
||||
String grantAccess(VolumeInfo volume, EndPoint ep);
|
||||
boolean revokeAccess(VolumeInfo volume, EndPoint ep);
|
||||
String grantAccess(TemplateInfo template, EndPoint ep);
|
||||
boolean revokeAccess(TemplateInfo template, EndPoint ep);
|
||||
String grantAccess(SnapshotInfo snapshot, EndPoint ep);
|
||||
boolean revokeAccess(SnapshotInfo snapshot, EndPoint ep);
|
||||
String getRole();
|
||||
long getId();
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
|
||||
|
||||
public interface ObjectInDataStoreManager {
|
||||
public TemplateInfo create(TemplateInfo template, DataStore dataStore);
|
||||
public ObjectInDataStoreVO create(VolumeInfo volume, DataStore dataStore);
|
||||
public ObjectInDataStoreVO create(SnapshotInfo snapshot, DataStore dataStore);
|
||||
public TemplateInfo findTemplate(TemplateInfo template, DataStore dataStore);
|
||||
public VolumeInfo findVolume(VolumeInfo volume, DataStore dataStore);
|
||||
public SnapshotInfo findSnapshot(SnapshotInfo snapshot, DataStore dataStore);
|
||||
public boolean update(TemplateInfo vo, ObjectInDataStoreStateMachine.Event event);
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreDao;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
||||
@Component
|
||||
public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
||||
@Inject
|
||||
ObjectInDataStoreDao objectDataStoreDao;
|
||||
@Override
|
||||
public TemplateInfo create(TemplateInfo template, DataStore dataStore) {
|
||||
ObjectInDataStoreVO vo = new ObjectInDataStoreVO();
|
||||
vo.setDataStoreId(dataStore.getId());
|
||||
vo.setDataStoreType(dataStore.getRole());
|
||||
vo.setObjectId(template.getId());
|
||||
vo.setObjectType("template");
|
||||
vo = objectDataStoreDao.persist(vo);
|
||||
TemplateInDataStore tmpl = new TemplateInDataStore(template, dataStore, vo);
|
||||
return tmpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectInDataStoreVO create(VolumeInfo volume, DataStore dataStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectInDataStoreVO create(SnapshotInfo snapshot, DataStore dataStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateInfo findTemplate(TemplateInfo template, DataStore dataStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeInfo findVolume(VolumeInfo volume, DataStore dataStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SnapshotInfo findSnapshot(SnapshotInfo snapshot, DataStore dataStore) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TemplateInfo vo, Event event) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
|||
import org.apache.cloudstack.storage.to.VolumeTO;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||
|
||||
public interface PrimaryDataStore extends PrimaryDataStoreInfo {
|
||||
public interface PrimaryDataStore extends DataStore, PrimaryDataStoreInfo {
|
||||
VolumeInfo getVolume(long id);
|
||||
|
||||
List<VolumeInfo> getVolumes();
|
||||
|
|
@ -42,7 +42,7 @@ public interface PrimaryDataStore extends PrimaryDataStoreInfo {
|
|||
|
||||
VolumeInfo createVoluemFromBaseImage(VolumeInfo volume, TemplateOnPrimaryDataStoreInfo templateStore);
|
||||
|
||||
void createVoluemFromBaseImageAsync(VolumeInfo volume, TemplateOnPrimaryDataStoreInfo templateStore, AsyncCompletionCallback<CommandResult> callback);
|
||||
void createVoluemFromBaseImageAsync(VolumeInfo volume, TemplateInfo templateStore, AsyncCompletionCallback<CommandResult> callback);
|
||||
|
||||
List<EndPoint> getEndPoints();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package org.apache.cloudstack.storage.datastore;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
|
||||
|
||||
public class TemplateInDataStore implements TemplateInfo {
|
||||
public TemplateInDataStore(TemplateInfo template, DataStore dataStore, ObjectInDataStoreVO obj) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public ImageDataStoreInfo getDataStore() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeDiskType getDiskType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package org.apache.cloudstack.storage.db;
|
||||
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.fsm.StateDao;
|
||||
|
||||
public interface ObjectInDataStoreDao extends GenericDao<ObjectInDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, ObjectInDataStoreVO> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package org.apache.cloudstack.storage.db;
|
||||
|
||||
|
||||
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.State;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
||||
|
||||
public class ObjectInDataStoreDaoImpl extends GenericDaoBase<ObjectInDataStoreVO, Long> implements ObjectInDataStoreDao {
|
||||
|
||||
@Override
|
||||
public boolean updateState(State currentState, Event event,
|
||||
State nextState, ObjectInDataStoreVO vo, Object data) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package org.apache.cloudstack.storage.db;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
||||
@Entity
|
||||
@Table(name = "object_datastore_ref")
|
||||
public class ObjectInDataStoreVO {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
long id;
|
||||
|
||||
@Column(name = "datastore_id")
|
||||
private long dataStoreId;
|
||||
|
||||
@Column(name = "datastore_type")
|
||||
private String dataStoreType;
|
||||
|
||||
@Column(name = "ojbect_id")
|
||||
long objectId;
|
||||
|
||||
@Column(name = "object_type")
|
||||
String objectType;
|
||||
|
||||
@Column(name = GenericDaoBase.CREATED_COLUMN)
|
||||
Date created = null;
|
||||
|
||||
@Column(name = "last_updated")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
Date lastUpdated = null;
|
||||
|
||||
@Column(name = "download_pct")
|
||||
int downloadPercent;
|
||||
|
||||
@Column(name = "download_state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
Status downloadState;
|
||||
|
||||
@Column(name = "local_path")
|
||||
String localDownloadPath;
|
||||
|
||||
@Column(name = "error_str")
|
||||
String errorString;
|
||||
|
||||
@Column(name = "job_id")
|
||||
String jobId;
|
||||
|
||||
@Column(name = "install_path")
|
||||
String installPath;
|
||||
|
||||
@Column(name = "size")
|
||||
long size;
|
||||
|
||||
@Column(name = "state")
|
||||
String state;
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
protected long updatedCount;
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public long getDataStoreId() {
|
||||
return this.dataStoreId;
|
||||
}
|
||||
|
||||
public void setDataStoreId(long id) {
|
||||
this.dataStoreId = id;
|
||||
}
|
||||
|
||||
public String getDataStoreType() {
|
||||
return this.dataStoreType;
|
||||
}
|
||||
|
||||
public void setDataStoreType(String type) {
|
||||
this.dataStoreType = type;
|
||||
}
|
||||
|
||||
public long getObjectId() {
|
||||
return this.objectId;
|
||||
}
|
||||
|
||||
public void setObjectId(long id) {
|
||||
this.objectId = id;
|
||||
}
|
||||
|
||||
public String getObjectType() {
|
||||
return this.objectType;
|
||||
}
|
||||
|
||||
public void setObjectType(String type) {
|
||||
this.objectType = type;
|
||||
}
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ public class TemplateEntityImpl implements TemplateEntity {
|
|||
}
|
||||
|
||||
public ImageDataStoreInfo getImageDataStore() {
|
||||
return templateInfo.getImageDataStore();
|
||||
return (ImageDataStoreInfo)templateInfo.getDataStore();
|
||||
}
|
||||
|
||||
public long getImageDataStoreId() {
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTyp
|
|||
import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
|
||||
|
||||
public interface TemplateInfo {
|
||||
ImageDataStoreInfo getImageDataStore();
|
||||
|
||||
ImageDataStoreInfo getDataStore();
|
||||
|
||||
long getId();
|
||||
|
||||
VolumeDiskType getDiskType();
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ package org.apache.cloudstack.storage.image.motion;
|
|||
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||
|
||||
public interface ImageMotionService {
|
||||
boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore);
|
||||
|
||||
void copyTemplateAsync(TemplateOnPrimaryDataStoreInfo templateStore, AsyncCompletionCallback<CommandResult> callback);
|
||||
void copyTemplateAsync(TemplateInfo destTemplate, TemplateInfo srcTemplate, AsyncCompletionCallback<CommandResult> callback);
|
||||
boolean copyIso(String isoUri, String destIsoUri);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.image.store;
|
||||
|
||||
public interface ImageDataStoreInfo {
|
||||
import org.apache.cloudstack.storage.datastore.DataStore;
|
||||
|
||||
public interface ImageDataStoreInfo extends DataStore {
|
||||
public long getImageDataStoreId();
|
||||
public String getType();
|
||||
public String getUri();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.apache.cloudstack.storage.to;
|
|||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
|
||||
|
||||
public class TemplateTO {
|
||||
private final String path;
|
||||
|
|
@ -13,7 +14,7 @@ public class TemplateTO {
|
|||
this.path = template.getPath();
|
||||
this.uuid = template.getUuid();
|
||||
this.diskType = template.getDiskType();
|
||||
this.imageDataStore = new ImageDataStoreTO(template.getImageDataStore());
|
||||
this.imageDataStore = new ImageDataStoreTO((ImageDataStoreInfo)template.getDataStore());
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.cloudstack.storage.volume;
|
|||
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
public interface TemplateOnPrimaryDataStoreStateMachine extends StateObject<TemplateOnPrimaryDataStoreStateMachine.State> {
|
||||
public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataStoreStateMachine.State> {
|
||||
enum State {
|
||||
Allocated("The initial state"),
|
||||
Creating("The template is being downloading to data store"),
|
||||
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.volume.db;
|
||||
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.fsm.StateDao;
|
||||
|
||||
public interface TemplatePrimaryDataStoreDao extends GenericDao<TemplatePrimaryDataStoreVO, Long>, StateDao<TemplateOnPrimaryDataStoreStateMachine.State, TemplateOnPrimaryDataStoreStateMachine.Event, TemplatePrimaryDataStoreVO> {
|
||||
public interface TemplatePrimaryDataStoreDao extends GenericDao<TemplatePrimaryDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, TemplatePrimaryDataStoreVO> {
|
||||
public TemplatePrimaryDataStoreVO findByTemplateIdAndPoolId(long templateId, long poolId);
|
||||
public TemplatePrimaryDataStoreVO findByTemplateIdAndPoolIdAndReady(long templateId, long poolId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cloudstack.storage.volume.db;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine.State;
|
||||
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;
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ public class TemplatePrimaryDataStoreDaoImpl extends GenericDaoBase<TemplatePrim
|
|||
SearchCriteriaService<TemplatePrimaryDataStoreVO, TemplatePrimaryDataStoreVO> sc = SearchCriteria2.create(TemplatePrimaryDataStoreVO.class);
|
||||
sc.addAnd(sc.getEntity().getTemplateId(), Op.EQ, templateId);
|
||||
sc.addAnd(sc.getEntity().getPoolId(), Op.EQ, poolId);
|
||||
sc.addAnd(sc.getEntity().getState(), Op.EQ, TemplateOnPrimaryDataStoreStateMachine.State.Ready);
|
||||
sc.addAnd(sc.getEntity().getState(), Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
|
||||
return sc.find();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ import javax.persistence.Temporal;
|
|||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
@Entity
|
||||
@Table(name = "template_spool_ref")
|
||||
public class TemplatePrimaryDataStoreVO implements StateObject<TemplateOnPrimaryDataStoreStateMachine.State> {
|
||||
public class TemplatePrimaryDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State> {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
long id;
|
||||
|
|
@ -83,7 +83,7 @@ public class TemplatePrimaryDataStoreVO implements StateObject<TemplateOnPrimary
|
|||
|
||||
@Column(name = "state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
TemplateOnPrimaryDataStoreStateMachine.State state;
|
||||
ObjectInDataStoreStateMachine.State state;
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
protected long updatedCount;
|
||||
|
|
@ -165,7 +165,7 @@ public class TemplatePrimaryDataStoreVO implements StateObject<TemplateOnPrimary
|
|||
this.poolId = poolId;
|
||||
this.templateId = templateId;
|
||||
this.downloadState = Status.NOT_DOWNLOADED;
|
||||
this.state = TemplateOnPrimaryDataStoreStateMachine.State.Allocated;
|
||||
this.state = ObjectInDataStoreStateMachine.State.Allocated;
|
||||
this.markedForGC = false;
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +246,7 @@ public class TemplatePrimaryDataStoreVO implements StateObject<TemplateOnPrimary
|
|||
}
|
||||
|
||||
@Override
|
||||
public TemplateOnPrimaryDataStoreStateMachine.State getState() {
|
||||
public ObjectInDataStoreStateMachine.State getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
|||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
||||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeTO;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||
|
|
@ -219,11 +220,11 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void createVoluemFromBaseImageAsync(VolumeInfo volume, TemplateOnPrimaryDataStoreInfo templateStore, AsyncCompletionCallback<CommandResult> callback) {
|
||||
public void createVoluemFromBaseImageAsync(VolumeInfo volume, TemplateInfo templateStore, AsyncCompletionCallback<CommandResult> callback) {
|
||||
VolumeObject vo = (VolumeObject) volume;
|
||||
vo.setVolumeDiskType(templateStore.getTemplate().getDiskType());
|
||||
|
||||
this.driver.createVolumeFromBaseImageAsync(vo, templateStore, callback);
|
||||
vo.setVolumeDiskType(templateStore.getDiskType());
|
||||
String templateUri = templateStore.getDataStore().grantAccess(templateStore, this.getEndPoints().get(0));
|
||||
this.driver.createVolumeFromBaseImageAsync(vo, templateUri, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -262,5 +263,45 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
|
|||
return this.provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String grantAccess(VolumeInfo volume, EndPoint ep) {
|
||||
return this.driver.grantAccess((VolumeObject)volume, ep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAccess(VolumeInfo volume, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String grantAccess(TemplateInfo template, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAccess(TemplateInfo template, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String grantAccess(SnapshotInfo snapshot, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeAccess(SnapshotInfo snapshot, EndPoint ep) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRole() {
|
||||
// TODO Auto-generated method stub
|
||||
return "volumeStore";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,11 +134,10 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
|
|||
|
||||
}
|
||||
@Override
|
||||
public void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateOnPrimaryDataStoreInfo template, AsyncCompletionCallback<CommandResult> callback) {
|
||||
public void createVolumeFromBaseImageAsync(VolumeObject volume, String template, AsyncCompletionCallback<CommandResult> callback) {
|
||||
VolumeTO vol = this.dataStore.getVolumeTO(volume);
|
||||
ImageOnPrimayDataStoreTO image = new ImageOnPrimayDataStoreTO(template);
|
||||
CreateVolumeFromBaseImageCommand cmd = new CreateVolumeFromBaseImageCommand(vol, image);
|
||||
List<EndPoint> endPoints = template.getPrimaryDataStore().getEndPoints();
|
||||
CreateVolumeFromBaseImageCommand cmd = new CreateVolumeFromBaseImageCommand(vol, template);
|
||||
List<EndPoint> endPoints = this.dataStore.getEndPoints();
|
||||
EndPoint ep = endPoints.get(0);
|
||||
|
||||
CreateVolumeFromBaseImageContext<CommandResult> context = new CreateVolumeFromBaseImageContext<CommandResult>(callback, volume);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import org.apache.cloudstack.storage.volume.VolumeObject;
|
|||
public interface PrimaryDataStoreDriver {
|
||||
void createVolumeAsync(VolumeObject vol, AsyncCompletionCallback<CommandResult> callback);
|
||||
|
||||
void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateOnPrimaryDataStoreInfo template, AsyncCompletionCallback<CommandResult> callback);
|
||||
void createVolumeFromBaseImageAsync(VolumeObject volume, String template, AsyncCompletionCallback<CommandResult> callback);
|
||||
|
||||
void deleteVolumeAsync(VolumeObject vo, AsyncCompletionCallback<CommandResult> callback);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ package org.apache.cloudstack.storage.volume;
|
|||
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine.State;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.State;
|
||||
import org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreVO;
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ public class TemplateOnPrimaryDataStoreObject implements TemplateOnPrimaryDataSt
|
|||
vo = templateStoreDao.findById(vo.getId());
|
||||
}
|
||||
|
||||
public void stateTransit(TemplateOnPrimaryDataStoreStateMachine.Event event) {
|
||||
public void stateTransit(ObjectInDataStoreStateMachine.Event event) {
|
||||
try {
|
||||
this.stateMachine.transitTo(vo, event, null, templateStoreDao);
|
||||
vo = templateStoreDao.findById(vo.getId());
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ package org.apache.cloudstack.storage.volume;
|
|||
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine.State;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.State;
|
||||
import org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreVO;
|
||||
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import javax.inject.Inject;
|
|||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreStateMachine.State;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.State;
|
||||
import org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -45,14 +45,14 @@ public class TemplatePrimaryDataStoreManagerImpl implements TemplatePrimaryDataS
|
|||
protected StateMachine2<State, Event, TemplatePrimaryDataStoreVO> stateMachines;
|
||||
public TemplatePrimaryDataStoreManagerImpl() {
|
||||
stateMachines = new StateMachine2<State, Event, TemplatePrimaryDataStoreVO>();
|
||||
stateMachines.addTransition(TemplateOnPrimaryDataStoreStateMachine.State.Allocated, Event.CreateRequested, TemplateOnPrimaryDataStoreStateMachine.State.Creating);
|
||||
stateMachines.addTransition(TemplateOnPrimaryDataStoreStateMachine.State.Creating, Event.OperationSuccessed, TemplateOnPrimaryDataStoreStateMachine.State.Ready);
|
||||
stateMachines.addTransition(TemplateOnPrimaryDataStoreStateMachine.State.Creating, Event.OperationFailed, TemplateOnPrimaryDataStoreStateMachine.State.Failed);
|
||||
stateMachines.addTransition(TemplateOnPrimaryDataStoreStateMachine.State.Failed, Event.CreateRequested, TemplateOnPrimaryDataStoreStateMachine.State.Creating);
|
||||
stateMachines.addTransition(TemplateOnPrimaryDataStoreStateMachine.State.Ready, Event.DestroyRequested, TemplateOnPrimaryDataStoreStateMachine.State.Destroying);
|
||||
stateMachines.addTransition(TemplateOnPrimaryDataStoreStateMachine.State.Destroying, Event.OperationSuccessed, TemplateOnPrimaryDataStoreStateMachine.State.Destroyed);
|
||||
stateMachines.addTransition(TemplateOnPrimaryDataStoreStateMachine.State.Destroying, Event.OperationFailed, TemplateOnPrimaryDataStoreStateMachine.State.Destroying);
|
||||
stateMachines.addTransition(TemplateOnPrimaryDataStoreStateMachine.State.Destroying, Event.DestroyRequested, TemplateOnPrimaryDataStoreStateMachine.State.Destroying);
|
||||
stateMachines.addTransition(ObjectInDataStoreStateMachine.State.Allocated, Event.CreateRequested, ObjectInDataStoreStateMachine.State.Creating);
|
||||
stateMachines.addTransition(ObjectInDataStoreStateMachine.State.Creating, Event.OperationSuccessed, ObjectInDataStoreStateMachine.State.Ready);
|
||||
stateMachines.addTransition(ObjectInDataStoreStateMachine.State.Creating, Event.OperationFailed, ObjectInDataStoreStateMachine.State.Failed);
|
||||
stateMachines.addTransition(ObjectInDataStoreStateMachine.State.Failed, Event.CreateRequested, ObjectInDataStoreStateMachine.State.Creating);
|
||||
stateMachines.addTransition(ObjectInDataStoreStateMachine.State.Ready, Event.DestroyRequested, ObjectInDataStoreStateMachine.State.Destroying);
|
||||
stateMachines.addTransition(ObjectInDataStoreStateMachine.State.Destroying, Event.OperationSuccessed, ObjectInDataStoreStateMachine.State.Destroyed);
|
||||
stateMachines.addTransition(ObjectInDataStoreStateMachine.State.Destroying, Event.OperationFailed, ObjectInDataStoreStateMachine.State.Destroying);
|
||||
stateMachines.addTransition(ObjectInDataStoreStateMachine.State.Destroying, Event.DestroyRequested, ObjectInDataStoreStateMachine.State.Destroying);
|
||||
}
|
||||
|
||||
private TemplatePrimaryDataStoreVO waitingForTemplateDownload(TemplateInfo template, PrimaryDataStoreInfo dataStore) {
|
||||
|
|
@ -98,7 +98,7 @@ public class TemplatePrimaryDataStoreManagerImpl implements TemplatePrimaryDataS
|
|||
}
|
||||
|
||||
//If it's not a fresh template downloading, waiting for other people downloading finished.
|
||||
if (!freshNewTemplate && templateStoreVO.getState() != TemplateOnPrimaryDataStoreStateMachine.State.Ready) {
|
||||
if (!freshNewTemplate && templateStoreVO.getState() != ObjectInDataStoreStateMachine.State.Ready) {
|
||||
templateStoreVO = waitingForTemplateDownload(template, dataStore);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,10 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
|||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||
import org.apache.cloudstack.storage.EndPoint;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||
import org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreManager;
|
||||
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
|
||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||
import org.apache.cloudstack.storage.image.motion.ImageMotionService;
|
||||
import org.apache.cloudstack.storage.volume.VolumeService.VolumeApiResult;
|
||||
|
|
@ -54,7 +56,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
@Inject
|
||||
PrimaryDataStoreManager dataStoreMgr;
|
||||
@Inject
|
||||
TemplatePrimaryDataStoreManager templatePrimaryStoreMgr;
|
||||
ObjectInDataStoreManager objectInDataStoreMgr;
|
||||
@Inject
|
||||
ImageMotionService imageMotion;
|
||||
|
||||
|
|
@ -238,9 +240,9 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
private class CreateBaseImageContext<T> extends AsyncRpcConext<T> {
|
||||
private final VolumeInfo volume;
|
||||
private final PrimaryDataStore dataStore;
|
||||
private final TemplateOnPrimaryDataStoreObject template;
|
||||
private final TemplateInfo template;
|
||||
private final AsyncCallFuture<VolumeApiResult> future;
|
||||
public CreateBaseImageContext(AsyncCompletionCallback<T> callback, VolumeInfo volume, PrimaryDataStore datastore, TemplateOnPrimaryDataStoreObject template,
|
||||
public CreateBaseImageContext(AsyncCompletionCallback<T> callback, VolumeInfo volume, PrimaryDataStore datastore, TemplateInfo template,
|
||||
AsyncCallFuture<VolumeApiResult> future) {
|
||||
super(callback);
|
||||
this.volume = volume;
|
||||
|
|
@ -257,7 +259,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
return this.dataStore;
|
||||
}
|
||||
|
||||
public TemplateOnPrimaryDataStoreObject getTemplate() {
|
||||
public TemplateInfo getTemplate() {
|
||||
return this.template;
|
||||
}
|
||||
|
||||
|
|
@ -268,15 +270,15 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
}
|
||||
@DB
|
||||
protected void createBaseImageAsync(VolumeInfo volume, PrimaryDataStore dataStore, TemplateInfo template, AsyncCallFuture<VolumeApiResult> future) {
|
||||
TemplateOnPrimaryDataStoreObject templateOnPrimaryStoreObj = (TemplateOnPrimaryDataStoreObject) templatePrimaryStoreMgr.createTemplateOnPrimaryDataStore(template, dataStore);
|
||||
templateOnPrimaryStoreObj.stateTransit(TemplateOnPrimaryDataStoreStateMachine.Event.CreateRequested);
|
||||
TemplateInfo templateOnPrimaryStoreObj = objectInDataStoreMgr.create(template, dataStore);
|
||||
/*templateOnPrimaryStoreObj.stateTransit(ObjectInDataStoreStateMachine.Event.CreateRequested);
|
||||
templateOnPrimaryStoreObj.updateStatus(Status.CREATING);
|
||||
try {
|
||||
dataStore.installTemplate(templateOnPrimaryStoreObj);
|
||||
templateOnPrimaryStoreObj.updateStatus(Status.CREATED);
|
||||
} catch (Exception e) {
|
||||
templateOnPrimaryStoreObj.updateStatus(Status.ABANDONED);
|
||||
templateOnPrimaryStoreObj.stateTransit(TemplateOnPrimaryDataStoreStateMachine.Event.OperationFailed);
|
||||
templateOnPrimaryStoreObj.stateTransit(ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||
VolumeApiResult result = new VolumeApiResult(volume);
|
||||
result.setResult(e.toString());
|
||||
future.complete(result);
|
||||
|
|
@ -284,29 +286,30 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
}
|
||||
|
||||
templateOnPrimaryStoreObj.updateStatus(Status.DOWNLOAD_IN_PROGRESS);
|
||||
|
||||
*/
|
||||
CreateBaseImageContext<VolumeApiResult> context = new CreateBaseImageContext<VolumeApiResult>(null, volume, dataStore, templateOnPrimaryStoreObj, future);
|
||||
AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this);
|
||||
caller.setCallback(caller.getTarget().createBaseImageCallback(null, null))
|
||||
.setContext(context);
|
||||
|
||||
objectInDataStoreMgr.update(templateOnPrimaryStoreObj, ObjectInDataStoreStateMachine.Event.CreateRequested);
|
||||
|
||||
imageMotion.copyTemplateAsync(templateOnPrimaryStoreObj, caller);
|
||||
imageMotion.copyTemplateAsync(templateOnPrimaryStoreObj, template, caller);
|
||||
}
|
||||
|
||||
@DB
|
||||
protected Void createBaseImageCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> callback, CreateBaseImageContext<VolumeApiResult> context) {
|
||||
CommandResult result = callback.getResult();
|
||||
TemplateOnPrimaryDataStoreObject templateOnPrimaryStoreObj = context.getTemplate();
|
||||
TemplateInfo templateOnPrimaryStoreObj = context.getTemplate();
|
||||
if (result.isSuccess()) {
|
||||
templateOnPrimaryStoreObj.stateTransit(TemplateOnPrimaryDataStoreStateMachine.Event.OperationSuccessed);
|
||||
objectInDataStoreMgr.update(templateOnPrimaryStoreObj, ObjectInDataStoreStateMachine.Event.OperationSuccessed);
|
||||
} else {
|
||||
templateOnPrimaryStoreObj.stateTransit(TemplateOnPrimaryDataStoreStateMachine.Event.OperationFailed);
|
||||
objectInDataStoreMgr.update(templateOnPrimaryStoreObj, ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||
}
|
||||
|
||||
AsyncCallFuture<VolumeApiResult> future = context.getFuture();
|
||||
VolumeInfo volume = context.getVolume();
|
||||
PrimaryDataStore pd = context.getDataStore();
|
||||
|
||||
createVolumeFromBaseImageAsync(volume, templateOnPrimaryStoreObj, pd, future);
|
||||
return null;
|
||||
}
|
||||
|
|
@ -330,7 +333,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
}
|
||||
|
||||
@DB
|
||||
protected void createVolumeFromBaseImageAsync(VolumeInfo volume, TemplateOnPrimaryDataStoreInfo templateOnPrimaryStore, PrimaryDataStore pd, AsyncCallFuture<VolumeApiResult> future) {
|
||||
protected void createVolumeFromBaseImageAsync(VolumeInfo volume, TemplateInfo templateOnPrimaryStore, PrimaryDataStore pd, AsyncCallFuture<VolumeApiResult> future) {
|
||||
VolumeObject vo = (VolumeObject) volume;
|
||||
try {
|
||||
vo.stateTransit(Volume.Event.CreateRequested);
|
||||
|
|
@ -379,7 +382,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
return future;
|
||||
}
|
||||
|
||||
createVolumeFromBaseImageAsync(volume, templateOnPrimaryStore, pd, future);
|
||||
createVolumeFromBaseImageAsync(volume, template, pd, future);
|
||||
return future;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import java.util.UUID;
|
|||
|
||||
import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreAnswer;
|
||||
import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
|
||||
import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorageCmd;
|
||||
import org.apache.cloudstack.storage.command.CopyCmd;
|
||||
import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorageAnswer;
|
||||
import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd;
|
||||
import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
|
||||
|
|
@ -88,8 +88,8 @@ public class XenServerStorageResource {
|
|||
}
|
||||
|
||||
public Answer handleStorageCommands(StorageSubSystemCommand command) {
|
||||
if (command instanceof CopyTemplateToPrimaryStorageCmd) {
|
||||
return this.execute((CopyTemplateToPrimaryStorageCmd)command);
|
||||
if (command instanceof CopyCmd) {
|
||||
return this.execute((CopyCmd)command);
|
||||
} else if (command instanceof AttachPrimaryDataStoreCmd) {
|
||||
return this.execute((AttachPrimaryDataStoreCmd)command);
|
||||
} else if (command instanceof CreatePrimaryDataStoreCmd) {
|
||||
|
|
@ -472,7 +472,7 @@ public class XenServerStorageResource {
|
|||
|
||||
}
|
||||
|
||||
protected Answer directDownloadHttpTemplate(CopyTemplateToPrimaryStorageCmd cmd, TemplateTO template, PrimaryDataStoreTO primarDataStore) {
|
||||
protected Answer directDownloadHttpTemplate(CopyCmd cmd, TemplateTO template, PrimaryDataStoreTO primarDataStore) {
|
||||
String primaryStoreUuid = primarDataStore.getUuid();
|
||||
Connection conn = hypervisorResource.getConnection();
|
||||
SR poolsr = null;
|
||||
|
|
@ -570,7 +570,7 @@ public class XenServerStorageResource {
|
|||
}
|
||||
}
|
||||
|
||||
protected Answer execute(CopyTemplateToPrimaryStorageCmd cmd) {
|
||||
protected Answer execute(CopyCmd cmd) {
|
||||
ImageOnPrimayDataStoreTO imageTO = cmd.getImage();
|
||||
TemplateTO template = imageTO.getTemplate();
|
||||
if (template.getPath().startsWith("http")) {
|
||||
|
|
|
|||
|
|
@ -18,12 +18,15 @@ package com.cloud.network.dao;
|
|||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.NiciraNvpRouterMappingVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Component
|
||||
@Local(value=NiciraNvpRouterMappingDao.class)
|
||||
public class NiciraNvpRouterMappingDaoImpl extends GenericDaoBase<NiciraNvpRouterMappingVO, Long> implements NiciraNvpRouterMappingDao {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.CreateLogicalSwitchAnswer;
|
||||
|
|
@ -66,6 +67,7 @@ import com.cloud.vm.ReservationContext;
|
|||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Component
|
||||
@Local(value=NetworkGuru.class)
|
||||
public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(NiciraNvpGuestNetworkGuru.class);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import com.cloud.user.User;
|
|||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
|
||||
@Component
|
||||
@Local(value = SecurityChecker.class)
|
||||
public class DomainChecker extends AdapterBase implements SecurityChecker {
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,14 @@ import com.cloud.api.query.vo.UserAccountJoinVO;
|
|||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import org.apache.cloudstack.api.response.AccountResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={AccountJoinDao.class})
|
||||
public class AccountJoinDaoImpl extends GenericDaoBase<AccountJoinVO, Long> implements AccountJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(AccountJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ import com.cloud.api.query.vo.AsyncJobJoinVO;
|
|||
import com.cloud.async.AsyncJob;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
import org.apache.cloudstack.api.response.AsyncJobResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={AsyncJobJoinDao.class})
|
||||
public class AsyncJobJoinDaoImpl extends GenericDaoBase<AsyncJobJoinVO, Long> implements AsyncJobJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(AsyncJobJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
|||
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.NicResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -37,7 +39,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
|||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={DomainRouterJoinDao.class})
|
||||
public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO, Long> implements DomainRouterJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(DomainRouterJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -36,13 +36,15 @@ import com.cloud.host.HostStats;
|
|||
|
||||
import org.apache.cloudstack.api.ApiConstants.HostDetails;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.StorageStats;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={HostJoinDao.class})
|
||||
public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements HostJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(HostJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.cloud.api.ApiResponseHelper;
|
|||
import com.cloud.api.query.vo.InstanceGroupJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
|
@ -33,6 +34,7 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
import com.cloud.vm.InstanceGroup;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={InstanceGroupJoinDao.class})
|
||||
public class InstanceGroupJoinDaoImpl extends GenericDaoBase<InstanceGroupJoinVO, Long> implements InstanceGroupJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(InstanceGroupJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||
import com.cloud.projects.ProjectAccount;
|
||||
|
|
@ -30,6 +31,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
|||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Component
|
||||
@Local(value={ProjectAccountJoinDao.class})
|
||||
public class ProjectAccountJoinDaoImpl extends GenericDaoBase<ProjectAccountJoinVO, Long> implements ProjectAccountJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(ProjectAccountJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import javax.ejb.Local;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
|
|
@ -30,6 +31,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
|||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Component
|
||||
@Local(value={ProjectInvitationJoinDao.class})
|
||||
public class ProjectInvitationJoinDaoImpl extends GenericDaoBase<ProjectInvitationJoinVO, Long> implements ProjectInvitationJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(ProjectInvitationJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -29,12 +29,15 @@ import com.cloud.api.query.vo.ResourceTagJoinVO;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Component
|
||||
@Local(value={ProjectJoinDao.class})
|
||||
public class ProjectJoinDaoImpl extends GenericDaoBase<ProjectJoinVO, Long> implements ProjectJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(ProjectJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -28,13 +28,15 @@ import com.cloud.api.query.vo.ResourceTagJoinVO;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={ResourceTagJoinDao.class})
|
||||
public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Long> implements ResourceTagJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(ResourceTagJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
|||
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.security.SecurityGroup;
|
||||
import com.cloud.network.security.SecurityRule.SecurityRuleType;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -39,6 +41,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
|||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Component
|
||||
@Local(value={SecurityGroupJoinDao.class})
|
||||
public class SecurityGroupJoinDaoImpl extends GenericDaoBase<SecurityGroupJoinVO, Long> implements SecurityGroupJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(SecurityGroupJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.cloud.api.ApiDBUtils;
|
|||
import com.cloud.api.query.vo.StoragePoolJoinVO;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.StorageStats;
|
||||
|
|
@ -35,6 +36,7 @@ import com.cloud.utils.db.SearchBuilder;
|
|||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={StoragePoolJoinDao.class})
|
||||
public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Long> implements StoragePoolJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(StoragePoolJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.cloud.api.query.vo.UserAccountJoinVO;
|
|||
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
|
|
@ -39,6 +40,7 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
import com.cloud.vm.InstanceGroup;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={UserAccountJoinDao.class})
|
||||
public class UserAccountJoinDaoImpl extends GenericDaoBase<UserAccountJoinVO, Long> implements UserAccountJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UserAccountJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -36,9 +36,10 @@ import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
|||
import org.apache.cloudstack.api.response.NicResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
|
@ -46,6 +47,7 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
import com.cloud.vm.VmStats;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={UserVmJoinDao.class})
|
||||
public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implements UserVmJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UserVmJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import com.cloud.api.query.vo.VolumeJoinVO;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
|
||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.storage.Storage;
|
||||
|
|
@ -44,6 +45,7 @@ import com.cloud.utils.db.SearchBuilder;
|
|||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={VolumeJoinDao.class})
|
||||
public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implements VolumeJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(VolumeJoinDaoImpl.class);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import com.cloud.utils.db.DB;
|
|||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={SyncQueueManager.class})
|
||||
public class SyncQueueManagerImpl implements SyncQueueManager {
|
||||
public static final Logger s_logger = Logger.getLogger(SyncQueueManagerImpl.class.getName());
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.usage.dao.UsageJobDao;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Component
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package com.cloud.ha;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -66,8 +65,6 @@ import com.cloud.storage.dao.GuestOSCategoryDao;
|
|||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementors
|
|||
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
|
|
@ -58,6 +57,8 @@ import com.cloud.alert.AlertManager;
|
|||
import com.cloud.api.ApiDBUtils;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ import org.apache.cloudstack.api.command.user.autoscale.ListAutoScaleVmGroupsCmd
|
|||
import org.apache.cloudstack.api.command.user.autoscale.ListConditionsCmd;
|
||||
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScalePolicyCmd;
|
||||
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScaleVmProfileCmd;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
|
|
@ -93,6 +95,7 @@ import com.cloud.utils.net.NetUtils;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@Component
|
||||
@Local(value = { AutoScaleService.class, AutoScaleManager.class })
|
||||
public class AutoScaleManagerImpl<Type> implements AutoScaleManager, AutoScaleService, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(AutoScaleManagerImpl.class);
|
||||
|
|
|
|||
|
|
@ -19,11 +19,14 @@ package com.cloud.network.as.dao;
|
|||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.as.AutoScalePolicyConditionMapVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={AutoScalePolicyConditionMapDao.class})
|
||||
public class AutoScalePolicyConditionMapDaoImpl extends GenericDaoBase<AutoScalePolicyConditionMapVO, Long> implements AutoScalePolicyConditionMapDao {
|
||||
|
||||
|
|
|
|||
|
|
@ -17,11 +17,14 @@
|
|||
package com.cloud.network.as.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.as.AutoScalePolicyVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value = { AutoScalePolicyDao.class })
|
||||
public class AutoScalePolicyDaoImpl extends GenericDaoBase<AutoScalePolicyVO, Long> implements AutoScalePolicyDao {
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,16 @@ package com.cloud.network.as.dao;
|
|||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.as.AutoScaleVmGroupVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value = { AutoScaleVmGroupDao.class })
|
||||
public class AutoScaleVmGroupDaoImpl extends GenericDaoBase<AutoScaleVmGroupVO, Long> implements AutoScaleVmGroupDao {
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,16 @@ package com.cloud.network.as.dao;
|
|||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.as.AutoScaleVmGroupPolicyMapVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value={AutoScaleVmGroupPolicyMapDao.class})
|
||||
public class AutoScaleVmGroupPolicyMapDaoImpl extends GenericDaoBase<AutoScaleVmGroupPolicyMapVO, Long> implements AutoScaleVmGroupPolicyMapDao {
|
||||
|
||||
|
|
|
|||
|
|
@ -17,11 +17,14 @@
|
|||
package com.cloud.network.as.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.as.AutoScaleVmProfileVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value = { AutoScaleVmProfileDao.class })
|
||||
public class AutoScaleVmProfileDaoImpl extends GenericDaoBase<AutoScaleVmProfileVO, Long> implements AutoScaleVmProfileDao {
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,15 @@ package com.cloud.network.as.dao;
|
|||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.as.ConditionVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Component
|
||||
@Local(value = ConditionDao.class)
|
||||
public class ConditionDaoImpl extends GenericDaoBase<ConditionVO, Long> implements ConditionDao {
|
||||
final SearchBuilder<ConditionVO> AllFieldsSearch;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import java.util.List;
|
|||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.as.CounterVO;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
|
@ -28,6 +30,7 @@ import com.cloud.utils.db.SearchBuilder;
|
|||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Component
|
||||
@Local(value = CounterDao.class)
|
||||
public class CounterDaoImpl extends GenericDaoBase<CounterVO, Long> implements CounterDao {
|
||||
final SearchBuilder<CounterVO> AllFieldsSearch;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import java.util.Random;
|
|||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
|
|
@ -78,12 +79,12 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
|||
GenericSearchBuilder<NetworkVO, Long> VpcNetworksCount;
|
||||
SearchBuilder<NetworkVO> OfferingAccountNetworkSearch;
|
||||
|
||||
ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
|
||||
NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class);
|
||||
NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class);
|
||||
NetworkOpDaoImpl _opDao = ComponentLocator.inject(NetworkOpDaoImpl.class);
|
||||
NetworkServiceMapDaoImpl _ntwkSvcMap = ComponentLocator.inject(NetworkServiceMapDaoImpl.class);
|
||||
NetworkOfferingDaoImpl _ntwkOffDao = ComponentLocator.inject(NetworkOfferingDaoImpl.class);
|
||||
@Inject ResourceTagsDaoImpl _tagsDao;
|
||||
@Inject NetworkAccountDaoImpl _accountsDao;
|
||||
@Inject NetworkDomainDaoImpl _domainsDao;
|
||||
@Inject NetworkOpDaoImpl _opDao;
|
||||
@Inject NetworkServiceMapDaoImpl _ntwkSvcMap;
|
||||
@Inject NetworkOfferingDaoImpl _ntwkOffDao;
|
||||
|
||||
|
||||
TableGenerator _tgMacAddress;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,6 @@ import java.util.TimeZone;
|
|||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.api.commands.GenerateUsageRecordsCmd;
|
||||
import com.cloud.api.commands.GetUsageRecordsCmd;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
|
|
@ -36,6 +33,8 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.projects.Project;
|
||||
import org.apache.cloudstack.api.response.UsageTypeResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.usage.UsageJobVO;
|
||||
import com.cloud.usage.UsageTypes;
|
||||
import com.cloud.usage.UsageVO;
|
||||
|
|
@ -50,7 +49,6 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Component
|
||||
@Primary
|
||||
public class ManagementServerExtImpl extends ManagementServerImpl implements ManagementServerExt {
|
||||
@Inject private AccountDao _accountDao;
|
||||
@Inject private DomainDao _domainDao;
|
||||
|
|
|
|||
|
|
@ -266,7 +266,6 @@ import com.cloud.vm.dao.VMInstanceDao;
|
|||
import edu.emory.mathcs.backport.java.util.Arrays;
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
|
||||
@Component
|
||||
public class ManagementServerImpl implements ManagementServer {
|
||||
public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName());
|
||||
|
||||
|
|
@ -382,8 +381,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
S3Manager _s3Mgr;
|
||||
|
||||
@Inject
|
||||
ComponentContext _placeholder;
|
||||
|
||||
ComponentContext _placeholder; // create a dependency to ComponentContext so that it can be loaded beforehead
|
||||
|
||||
private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
|
||||
private KeystoreManager _ksMgr;
|
||||
|
||||
|
|
@ -463,20 +462,15 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
private void startManagers() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map<String, Manager> managers = ComponentContext.getApplicationContext().getBeansOfType(
|
||||
Manager.class);
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
for (Manager manager : managers.values()) {
|
||||
s_logger.info("Start manager: " + ComponentContext.getTargetClass(manager).getName() + "...");
|
||||
try {
|
||||
if (!ComponentContext.isPrimary(manager, Manager.class)) {
|
||||
s_logger.error("Skip manager:" + ComponentContext.getTargetClass(manager).getName() + " as there are multiple matches");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!manager.configure(manager.getClass().getSimpleName(), params)) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map<String, Manager> managers = ComponentContext.getApplicationContext().getBeansOfType(
|
||||
Manager.class);
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
for(Manager manager : managers.values()) {
|
||||
s_logger.info("Start manager: " + ComponentContext.getTargetClass(manager).getName() + "...");
|
||||
try {
|
||||
if(!manager.configure(manager.getClass().getSimpleName(), params)) {
|
||||
throw new CloudRuntimeException("Failed to start manager: " + ComponentContext.getTargetClass(manager).getName());
|
||||
}
|
||||
|
||||
|
|
@ -495,17 +489,18 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
private void startAdapters() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map<String, Adapter> adapters = ComponentContext.getApplicationContext().getBeansOfType(
|
||||
Adapter.class);
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
for (Adapter adapter : adapters.values()) {
|
||||
try {
|
||||
if (!ComponentContext.isPrimary(adapter, Adapter.class))
|
||||
continue;
|
||||
|
||||
if (!adapter.configure(adapter.getClass().getSimpleName(), params)) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map<String, Adapter> adapters = ComponentContext.getApplicationContext().getBeansOfType(
|
||||
Adapter.class);
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
for(Adapter adapter : adapters.values()) {
|
||||
try {
|
||||
// we also skip Adapter class that is both a manager class and a adapter class
|
||||
if(Manager.class.isAssignableFrom(ComponentContext.getTargetClass(adapter)))
|
||||
continue;
|
||||
|
||||
if(!adapter.configure(adapter.getClass().getSimpleName(), params)) {
|
||||
throw new CloudRuntimeException("Failed to start adapter: " + ComponentContext.getTargetClass(adapter).getName());
|
||||
}
|
||||
if (!adapter.start()) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ import com.cloud.utils.db.GenericDaoBase;
|
|||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Local(S3Dao.class)
|
||||
public class S3DaoImpl extends GenericDaoBase<S3VO, Long> implements S3Dao {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,12 @@ import com.cloud.utils.db.SearchBuilder;
|
|||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Local(VMTemplateS3Dao.class)
|
||||
public class VMTemplateS3DaoImpl extends GenericDaoBase<VMTemplateS3VO, Long>
|
||||
implements VMTemplateS3Dao {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ import com.cloud.agent.api.DownloadTemplateFromS3ToSecondaryStorageCommand;
|
|||
import com.cloud.agent.api.UploadTemplateToS3FromSecondaryStorageCommand;
|
||||
import com.cloud.agent.api.to.S3TO;
|
||||
import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
|
|
@ -80,6 +82,7 @@ import com.cloud.utils.db.Filter;
|
|||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
@Local(value = { S3Manager.class })
|
||||
public class S3ManagerImpl implements S3Manager {
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import java.net.URISyntaxException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -31,6 +30,7 @@ import javax.inject.Inject;
|
|||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
|
|
@ -112,8 +112,6 @@ import com.cloud.user.UserContext;
|
|||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
|
|
@ -222,7 +220,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
UserVmDetailsDao _vmDetailsDao;
|
||||
@Inject
|
||||
protected ResourceManager _resourceMgr;
|
||||
@Inject
|
||||
//@Inject // TODO this is a very strange usage, a singleton class need to inject itself?
|
||||
protected SecondaryStorageVmManager _ssvmMgr;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
|
|
@ -250,6 +248,10 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
|
||||
private final GlobalLock _allocLock = GlobalLock.getInternLock(getAllocLockName());
|
||||
|
||||
public SecondaryStorageManagerImpl() {
|
||||
_ssvmMgr = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecondaryStorageVmVO startSecStorageVm(long secStorageVmId) {
|
||||
try {
|
||||
|
|
@ -893,9 +895,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
return true;
|
||||
}
|
||||
|
||||
protected SecondaryStorageManagerImpl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long convertToId(String vmName) {
|
||||
if (!VirtualMachineName.isValidSystemVmName(vmName, _instance, "s")) {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
|
|||
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
|
@ -236,6 +237,7 @@ import com.cloud.vm.dao.UserVmDao;
|
|||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Component
|
||||
@Local(value = { UserVmManager.class, UserVmService.class })
|
||||
public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager {
|
||||
private static final Logger s_logger = Logger
|
||||
|
|
|
|||
|
|
@ -67,16 +67,22 @@ public class ComponentContext implements ApplicationContextAware {
|
|||
Map<String, T> matchedTypes = getComponentsOfType(beanType);
|
||||
if(matchedTypes.size() > 0) {
|
||||
for(Map.Entry<String, T> entry : matchedTypes.entrySet()) {
|
||||
Primary primary = getTargetClass(entry).getAnnotation(Primary.class);
|
||||
Primary primary = getTargetClass(entry.getValue()).getAnnotation(Primary.class);
|
||||
if(primary != null)
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
s_logger.warn("Unable to uniquely locate bean type " + beanType.getName());
|
||||
if(matchedTypes.size() > 1) {
|
||||
s_logger.warn("Unable to uniquely locate bean type " + beanType.getName());
|
||||
for(Map.Entry<String, T> entry : matchedTypes.entrySet()) {
|
||||
s_logger.warn("Candidate " + getTargetClass(entry.getValue()).getName());
|
||||
}
|
||||
}
|
||||
|
||||
return (T)matchedTypes.values().toArray()[0];
|
||||
}
|
||||
}
|
||||
throw new NoSuchBeanDefinitionException("Unable to resolve bean type " + beanType.getName());
|
||||
throw new NoSuchBeanDefinitionException(beanType.getName());
|
||||
}
|
||||
|
||||
public static <T> Map<String, T> getComponentsOfType(Class<T> beanType) {
|
||||
|
|
@ -84,13 +90,13 @@ public class ComponentContext implements ApplicationContextAware {
|
|||
}
|
||||
|
||||
public static <T> boolean isPrimary(Object instance, Class<T> beanType) {
|
||||
|
||||
// we assume single line of interface inheritance of beanType
|
||||
Class<?> componentType = beanType;
|
||||
Class<?> targetClass = getTargetClass(instance);
|
||||
|
||||
Class<?> interfaces[] = targetClass.getInterfaces();
|
||||
for(Class<?> intf : interfaces) {
|
||||
if(beanType.isAssignableFrom(intf)) {
|
||||
if(beanType.isAssignableFrom(intf) && intf != beanType) {
|
||||
componentType = intf;
|
||||
break;
|
||||
}
|
||||
|
|
@ -99,9 +105,15 @@ public class ComponentContext implements ApplicationContextAware {
|
|||
Map<String, T> matchedTypes = (Map<String, T>)ComponentContext.getComponentsOfType(componentType);
|
||||
if(matchedTypes.size() > 1) {
|
||||
Primary primary = targetClass.getAnnotation(Primary.class);
|
||||
if(primary != null)
|
||||
if(primary != null) {
|
||||
s_logger.info(targetClass.getName() + " is the primary component of " + componentType.getName());
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
s_logger.warn(targetClass.getName() + " is not the primary component of " + componentType.getName() + ", there are other candidates");
|
||||
for(T candidate : matchedTypes.values()) {
|
||||
s_logger.warn("Candidate " + getTargetClass(candidate).getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue