cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [8/8] create template/primary data store is done
Date Wed, 21 Nov 2012 03:01:20 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java
index 241bc3b..e6508e6 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java
@@ -19,29 +19,67 @@
 package org.apache.cloudstack.storage.volume;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
+import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.db.VolumeVO;
+import org.springframework.stereotype.Component;
 
-import com.cloud.storage.VolumeVO;
 import com.cloud.storage.Volume;
-import com.cloud.storage.dao.VolumeDao;
+import com.cloud.storage.Volume.Event;
+import com.cloud.storage.Volume.State;
 import com.cloud.utils.component.Inject;
 import com.cloud.utils.fsm.NoTransitionException;
 import com.cloud.utils.fsm.StateMachine2;
 
+@Component
 public class VolumeManagerImpl implements VolumeManager {
-    private StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
     @Inject
     protected VolumeDao _volumeDao;
+    private final static StateMachine2<State, Event, VolumeVO> s_fsm = new StateMachine2<State,
Event, VolumeVO>();
+    public VolumeManagerImpl() {
+        initStateMachine();
+    }
 
     public VolumeVO allocateDuplicateVolume(VolumeVO oldVol) {
+        /*
         VolumeVO newVol = new VolumeVO(oldVol.getVolumeType(), oldVol.getName(), oldVol.getDataCenterId(),
oldVol.getDomainId(), oldVol.getAccountId(), oldVol.getDiskOfferingId(), oldVol.getSize());
         newVol.setTemplateId(oldVol.getTemplateId());
         newVol.setDeviceId(oldVol.getDeviceId());
         newVol.setInstanceId(oldVol.getInstanceId());
         newVol.setRecreatable(oldVol.isRecreatable());
         newVol.setReservationId(oldVol.getReservationId());
+        */
         return null;
         // return _volumeDao.persist(newVol);
     }
+    
+    private void initStateMachine() {
+            s_fsm.addTransition(Volume.State.Allocated, Event.CreateRequested, Volume.State.Creating);
+            s_fsm.addTransition(Volume.State.Allocated, Event.DestroyRequested, Volume.State.Destroy);
+            s_fsm.addTransition(Volume.State.Creating, Event.OperationRetry, Volume.State.Creating);
+            s_fsm.addTransition(Volume.State.Creating, Event.OperationFailed, Volume.State.Allocated);
+            s_fsm.addTransition(Volume.State.Creating, Event.OperationSucceeded, Volume.State.Ready);
+            s_fsm.addTransition(Volume.State.Creating, Event.DestroyRequested, Volume.State.Destroy);
+            s_fsm.addTransition(Volume.State.Creating, Event.CreateRequested, Volume.State.Creating);
           
+            s_fsm.addTransition(Volume.State.Allocated, Event.UploadRequested, Volume.State.UploadOp);
+            s_fsm.addTransition(Volume.State.UploadOp, Event.CopyRequested, Volume.State.Creating);//
CopyRequested for volume from sec to primary storage            
+            s_fsm.addTransition(Volume.State.Creating, Event.CopySucceeded, Volume.State.Ready);
+            s_fsm.addTransition(Volume.State.Creating, Event.CopyFailed, Volume.State.UploadOp);//
Copying volume from sec to primary failed.  
+            s_fsm.addTransition(Volume.State.UploadOp, Event.DestroyRequested, Volume.State.Destroy);
+            s_fsm.addTransition(Volume.State.Ready, Event.DestroyRequested, Volume.State.Destroy);
+            s_fsm.addTransition(Volume.State.Destroy, Event.ExpungingRequested, Volume.State.Expunging);
+            s_fsm.addTransition(Volume.State.Ready, Event.SnapshotRequested, Volume.State.Snapshotting);
+            s_fsm.addTransition(Volume.State.Snapshotting, Event.OperationSucceeded, Volume.State.Ready);
+            s_fsm.addTransition(Volume.State.Snapshotting, Event.OperationFailed, Volume.State.Ready);
+            s_fsm.addTransition(Volume.State.Ready, Event.MigrationRequested, Volume.State.Migrating);
+            s_fsm.addTransition(Volume.State.Migrating, Event.OperationSucceeded, Volume.State.Ready);
+            s_fsm.addTransition(Volume.State.Migrating, Event.OperationFailed, Volume.State.Ready);
+            s_fsm.addTransition(Volume.State.Destroy, Event.OperationSucceeded, Volume.State.Destroy);
+    }
+    
+    @Override
+    public StateMachine2<State, Event, VolumeVO> getStateMachine() {
+        return s_fsm;
+    }
 
     public VolumeVO processEvent(Volume vol, Volume.Event event) throws NoTransitionException
{
         // _volStateMachine.transitTo(vol, event, null, _volumeDao);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeObject.java b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeObject.java
index f57fb75..f0eb1b5 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeObject.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeObject.java
@@ -18,6 +18,7 @@ import org.apache.log4j.Logger;
 
 import com.cloud.storage.Volume;
 import com.cloud.storage.Volume.State;
+import com.cloud.utils.component.ComponentInject;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.fsm.NoTransitionException;
 import com.cloud.utils.fsm.StateMachine2;
@@ -25,7 +26,7 @@ import com.cloud.utils.fsm.StateMachine2;
 public class VolumeObject implements VolumeInfo {
     private static final Logger s_logger = Logger.getLogger(VolumeObject.class);
     protected VolumeVO volumeVO;
-    private StateMachine2<Volume.State, VolumeEvent, VolumeVO> _volStateMachine;
+    private StateMachine2<Volume.State, Volume.Event, VolumeVO> _volStateMachine;
     protected PrimaryDataStore dataStore;
     @Inject
     VolumeDiskTypeHelper diskTypeHelper;
@@ -33,11 +34,18 @@ public class VolumeObject implements VolumeInfo {
     VolumeTypeHelper volumeTypeHelper;
     @Inject
     VolumeDao volumeDao;
-
-    public VolumeObject(PrimaryDataStore dataStore, VolumeVO volumeVO) {
+    @Inject
+    VolumeManager volumeMgr;
+    private VolumeObject(PrimaryDataStore dataStore, VolumeVO volumeVO) {
         this.volumeVO = volumeVO;
         this.dataStore = dataStore;
     }
+    
+    public static VolumeObject getVolumeObject(PrimaryDataStore dataStore, VolumeVO volumeVO)
{
+        VolumeObject vo = new VolumeObject(dataStore, volumeVO);
+        vo = ComponentInject.inject(vo);
+        return vo;
+    }
 
     public String getUuid() {
         return volumeVO.getUuid();
@@ -91,8 +99,9 @@ public class VolumeObject implements VolumeInfo {
         volumeVO.setDiskType(type.toString());
     }
 
-    public boolean stateTransit(VolumeEvent event) {
+    public boolean stateTransit(Volume.Event event) {
         boolean result = false;
+        _volStateMachine = volumeMgr.getStateMachine();
         try {
             result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao);
         } catch (NoTransitionException e) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index f994847..0e6ed9f 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -68,14 +68,14 @@ public class VolumeServiceImpl implements VolumeService {
         }
 
         VolumeObject vo = (VolumeObject) volume;
-        vo.stateTransit(VolumeEvent.CreateRequested);
+        vo.stateTransit(Volume.Event.CreateRequested);
 
         try {
             VolumeInfo vi = dataStore.createVolume(vo, diskType);
-            vo.stateTransit(VolumeEvent.OperationSucceeded);
+            vo.stateTransit(Volume.Event.OperationSucceeded);
             return vi;
         } catch (Exception e) {
-            vo.stateTransit(VolumeEvent.OperationFailed);
+            vo.stateTransit(Volume.Event.OperationFailed);
             throw new CloudRuntimeException(e.toString());
         }
     }
@@ -107,7 +107,7 @@ public class VolumeServiceImpl implements VolumeService {
     @Override
     public VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long
templateId) {
         VolumeVO vo = volDao.allocVolume(size, type, volName, templateId);
-        return new VolumeEntityImpl(new VolumeObject(null, vo));
+        return new VolumeEntityImpl(VolumeObject.getVolumeObject(null, vo), this);
     }
 
     @Override
@@ -118,10 +118,10 @@ public class VolumeServiceImpl implements VolumeService {
         }
 
         if (vo.getPoolId() == null) {
-            return new VolumeEntityImpl(new VolumeObject(null, vo));
+            return new VolumeEntityImpl(VolumeObject.getVolumeObject(null, vo), this);
         } else {
             PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(vo.getPoolId());
-            return new VolumeEntityImpl(dataStore.getVolume(volumeId));
+            return new VolumeEntityImpl(dataStore.getVolume(volumeId), this);
         }
     }
 
@@ -164,16 +164,16 @@ public class VolumeServiceImpl implements VolumeService {
 
         VolumeObject vo = (VolumeObject) volume;
         try {
-            vo.stateTransit(VolumeEvent.CreateRequested);
+            vo.stateTransit(Volume.Event.CreateRequested);
         } catch (Exception e) {
             throw new CloudRuntimeException(e.toString());
         }
 
         try {
             volume = pd.createVoluemFromBaseImage(volume, templateOnPrimaryStore);
-            vo.stateTransit(VolumeEvent.OperationSucceeded);
+            vo.stateTransit(Volume.Event.OperationSucceeded);
         } catch (Exception e) {
-            vo.stateTransit(VolumeEvent.OperationFailed);
+            vo.stateTransit(Volume.Event.OperationFailed);
             throw new CloudRuntimeException(e.toString());
         }
         return volume;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao.java
index 85124ec..ccc1901 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao.java
@@ -28,7 +28,7 @@ import com.cloud.utils.Pair;
 import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.fsm.StateDao;
 
-public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.State,
VolumeEvent, VolumeVO> {
+public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.State,
Volume.Event, VolumeVO> {
 
     List<VolumeVO> findDetachedByAccount(long accountId);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDaoImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDaoImpl.java
index 59211a8..980e4f8 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDaoImpl.java
@@ -335,7 +335,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long>
implements Vol
     }
 
     @Override
-    public boolean updateState(Volume.State currentState, VolumeEvent event, Volume.State
nextState, VolumeVO vo, Object data) {
+    public boolean updateState(Volume.State currentState, Volume.Event event, Volume.State
nextState, VolumeVO vo, Object data) {
 
         Long oldUpdated = vo.getUpdatedCount();
         Date oldUpdatedTime = vo.getUpdated();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
index 04104f6..32e6e3b 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
@@ -141,16 +141,14 @@ public class VolumeVO implements Identity, StateObject<Volume.State>
{
     @Column(name = "uuid")
     String uuid;
 
-    @Column(name = "reservation")
-    String reservationId;
-
     // Real Constructor
     public VolumeVO(long size, String type, String name, Long templateId) {
-        this.volumeType = type.toString();
+        this.volumeType = type;
         this.size = size;
         this.name = name;
         this.templateId = templateId;
         this.uuid = UUID.randomUUID().toString();
+        this.state = Volume.State.Allocated;
     }
 
     // Copy Constructor
@@ -398,14 +396,6 @@ public class VolumeVO implements Identity, StateObject<Volume.State>
{
         }
     }
 
-    public String getReservationId() {
-        return this.reservationId;
-    }
-
-    public void setReservationId(String reserv) {
-        this.reservationId = reserv;
-    }
-
     @Override
     public String getUuid() {
         return this.uuid;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/engine/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
b/engine/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
index d096cd5..2c83210 100644
--- a/engine/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
+++ b/engine/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
@@ -23,26 +23,43 @@ import static org.junit.Assert.*;
 import java.awt.List;
 import java.util.HashMap;
 import java.util.LinkedList;
+import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
+import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.QCOW2;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VHD;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VMDK;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTypeHelper;
+import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
 import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper;
 import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
+import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
 import org.apache.cloudstack.storage.datastore.provider.DefaultPrimaryDatastoreProviderImpl;
+import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
+import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
+import org.apache.cloudstack.storage.image.ImageService;
+import org.apache.cloudstack.storage.image.db.ImageDataDao;
+import org.apache.cloudstack.storage.image.db.ImageDataVO;
 import org.apache.cloudstack.storage.image.format.ISO;
 import org.apache.cloudstack.storage.image.format.ImageFormat;
 import org.apache.cloudstack.storage.image.format.ImageFormatHelper;
 import org.apache.cloudstack.storage.image.format.OVA;
 import org.apache.cloudstack.storage.image.format.Unknown;
+import org.apache.cloudstack.storage.image.provider.ImageDataStoreProvider;
 import org.apache.cloudstack.storage.image.provider.ImageDataStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+import org.apache.cloudstack.storage.volume.VolumeService;
+import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.db.VolumeVO;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -54,31 +71,110 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.mockito.Mockito.*;
 
 
+import com.cloud.storage.Storage.TemplateType;
 import com.cloud.utils.component.ComponentInject;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Transaction;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations="classpath:/resource/storageContext.xml")
 public class volumeServiceTest {
     @Inject
     ImageDataStoreProviderManager imageProviderMgr;
+    @Inject
+    ImageService imageService;
+    @Inject
+    VolumeService volumeService;
+    @Inject
+    ImageDataDao imageDataDao;
+    @Inject
+    VolumeDao volumeDao;
+    @Inject
+    PrimaryDataStoreProviderManager primaryDataStoreProviderMgr;
 	@Before
 	public void setUp() {
 		
 	}
 	
-	@Test
-	public void test() {
+	private ImageDataVO createImageData() {
+	    ImageDataVO image = new ImageDataVO();
+        image.setTemplateType(TemplateType.USER);
+        image.setUrl("http://testurl/test.vhd");
+        image.setUniqueName(UUID.randomUUID().toString());
+        image.setName(UUID.randomUUID().toString());
+        image.setPublicTemplate(true);
+        image.setFeatured(true);
+        image.setRequireHvm(true);
+        image.setBits(64);
+        image.setFormat(new VHD().toString());
+        image.setAccountId(1);
+        image.setEnablePassword(true);
+        image.setEnableSshKey(true);
+        image.setGuestOSId(1);
+        image.setBootable(true);
+        image.setPrepopulate(true);
+        image.setCrossZones(true);
+        image.setExtractable(true);
+        image = imageDataDao.persist(image);
+        return image;
+	}
+	
+	private TemplateEntity createTemplate() {
 	    try {
-	        
             imageProviderMgr.configure("image Provider", new HashMap<String, Object>());
-            
+            ImageDataVO image = createImageData();
+            ImageDataStoreProvider defaultProvider = imageProviderMgr.getProvider("DefaultProvider");
+            ImageDataStore store = defaultProvider.registerDataStore("defaultHttpStore",
new HashMap<String, String>());
+            imageService.registerTemplate(image.getId(), store.getImageDataStoreId());
+            TemplateEntity te = imageService.getTemplateEntity(image.getId());
+            return te;
+        } catch (ConfigurationException e) {
+            return null;
+        }
+	}
+	
+	@Test
+	public void createTemplateTest() {
+	    createTemplate();
+	}
+	
+	private PrimaryDataStoreInfo createPrimaryDataStore() {
+	    try {
+            primaryDataStoreProviderMgr.configure("primary data store mgr", new HashMap<String,
Object>());
+            PrimaryDataStoreProvider provider = primaryDataStoreProviderMgr.getDataStoreProvider("default
primary data store provider");
+            PrimaryDataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
+            Map<String, String> params = new HashMap<String, String>();
+            params.put("url", "nfs://test/test");
+            params.put("dcId", "1");
+            params.put("name", "my primary data store");
+            PrimaryDataStoreInfo primaryDataStoreInfo = lifeCycle.registerDataStore(params);
+            return primaryDataStoreInfo;
         } catch (ConfigurationException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            return null;
         }
 	}
 	
+	@Test
+	public void createPrimaryDataStoreTest() {
+	    createPrimaryDataStore();
+	}
+	
+	private VolumeVO createVolume(long templateId) {
+	    VolumeVO volume = new VolumeVO(1000, new RootDisk().toString(), UUID.randomUUID().toString(),
templateId);
+	    volume = volumeDao.persist(volume);
+	    return volume;
+	    
+	}
+	
+	@Test
+	public void createVolumeFromTemplate() {
+	    TemplateEntity te = createTemplate();
+	    PrimaryDataStoreInfo dataStoreInfo = createPrimaryDataStore();
+	    VolumeVO volume = createVolume(te.getId());
+	    VolumeEntity ve = volumeService.getVolumeEntity(volume.getId());
+	    ve.createVolumeFromTemplate(dataStoreInfo.getId(), new VHD(), te);
+	}
+	
 	//@Test
 	public void test1() {
 		System.out.println(VolumeTypeHelper.getType("Root"));
@@ -105,7 +201,7 @@ public class volumeServiceTest {
 	//@Test
 	public void testStaticBean() {
 		DefaultPrimaryDatastoreProviderImpl provider = ComponentInject.inject(DefaultPrimaryDatastoreProviderImpl.class);
-		assertNotNull(provider.dataStoreDao);
+		//assertNotNull(provider.dataStoreDao);
 		
 		DefaultPrimaryDataStoreImpl dpdsi = new DefaultPrimaryDataStoreImpl(null, null, null);
 		ComponentInject.inject(dpdsi);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/engine/storage/test/resource/storageContext.xml
----------------------------------------------------------------------
diff --git a/engine/storage/test/resource/storageContext.xml b/engine/storage/test/resource/storageContext.xml
index 0dab1f5..dbc997f 100644
--- a/engine/storage/test/resource/storageContext.xml
+++ b/engine/storage/test/resource/storageContext.xml
@@ -12,6 +12,7 @@
                                           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
   <context:annotation-config />
   <context:component-scan base-package="org.apache.cloudstack.storage" />
+  <context:component-scan base-package="org.apache.cloudstack.engine.subsystem.api.storage"
/>
   <context:component-scan base-package="com.cloud.utils.db" />
   <context:component-scan base-package="com.cloud.utils.component" />
   
@@ -28,36 +29,7 @@
     
 
   </aop:config>
-  <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
-    <property name="entityManagerFactory" ref="entityManagerFactory" />
-  </bean>
-
-  <bean id="dataSource"
-    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
-    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
-    <property name="url" value="jdbc:mysql://localhost:3306/cloud" />
-    <property name="username" value="root" />
-    <property name="password" value="" />
-  </bean>
-
-  <bean id="openJpaVendorAdapter"
-    class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
-    <property name="showSql" value="true" />
-    <property name="databasePlatform"
-      value="org.apache.openjpa.jdbc.sql.MySQLDictionary" />
-  </bean>
-
-  <bean id="entityManagerFactory"
-    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
-    <property name="dataSource" ref="dataSource" />
-    <property name="jpaVendorAdapter" ref="openJpaVendorAdapter" />
-    <property name="packagesToScan" value="org.apache.cloudstack.storage" />
-  </bean>
-
-  <bean id="sharedEntityManager"
-    class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
-    <property name="entityManagerFactory" ref="entityManagerFactory" />
-  </bean>
+ 
 
   <bean id="someDependencyMock" class="org.apache.cloudstack.storage.test.StorageFactoryBean">
     <constructor-arg name="classToBeMocked"

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/server/src/com/cloud/upgrade/DatabaseCreator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/DatabaseCreator.java b/server/src/com/cloud/upgrade/DatabaseCreator.java
index f6a5017..079e1e9 100755
--- a/server/src/com/cloud/upgrade/DatabaseCreator.java
+++ b/server/src/com/cloud/upgrade/DatabaseCreator.java
@@ -106,8 +106,8 @@ public class DatabaseCreator {
                     System.exit(1);
                 }
 
-                SystemIntegrityChecker checker = (SystemIntegrityChecker)ComponentLocator.inject(clazz);
-                checker.check();
+                //SystemIntegrityChecker checker = (SystemIntegrityChecker)ComponentLocator.inject(clazz);
+                //checker.check();
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/setup/db/4.1-new-db-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/4.1-new-db-schema.sql b/setup/db/4.1-new-db-schema.sql
new file mode 100644
index 0000000..7be4b09
--- /dev/null
+++ b/setup/db/4.1-new-db-schema.sql
@@ -0,0 +1,41 @@
+-- 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.
+
+alter table vm_template add image_data_store_id bigint unsigned;
+alter table storage_pool add storage_provider_id bigint unsigned; 
+alter table storage_pool modify id bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL;
+alter table volumes add disk_type varchar(255);
+alter table volumes drop foreign key `fk_volumes__account_id`;
+CREATE TABLE `cloud`.`primary_data_store_provider` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `name` varchar(255) NOT NULL COMMENT 'name of primary data store provider',
+  PRIMARY KEY(`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`image_data_store_provider` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `name` varchar(255) NOT NULL COMMENT 'name of data store provider',
+  PRIMARY KEY(`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`image_data_store` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `name` varchar(255) NOT NULL COMMENT 'name of data store',
+  `image_provider_id` bigint unsigned NOT NULL COMMENT 'id of image_data_store_provider',
+  PRIMARY KEY(`id`),
+  CONSTRAINT `fk_tags__image_data_store_provider_id` FOREIGN KEY(`image_provider_id`) REFERENCES
`image_data_store_provider`(`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/550f4fbc/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index aa5867f..3d66f75 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -1500,7 +1500,6 @@ CREATE TABLE  `cloud`.`storage_pool` (
   `created` datetime COMMENT 'date the pool created',
   `removed` datetime COMMENT 'date removed if not null',
   `update_time` DATETIME,
-  `storage_provider` varchar(255) NOT NULL,
   `status` varchar(32),
   PRIMARY KEY  (`id`),
   CONSTRAINT `fk_storage_pool__pod_id` FOREIGN KEY `fk_storage_pool__pod_id` (`pod_id`) REFERENCES
`host_pod_ref` (`id`) ON DELETE CASCADE,
@@ -2372,5 +2371,19 @@ CREATE TABLE `cloud`.`nicira_nvp_nic_map` (
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+CREATE TABLE `cloud`.`image_data_store` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `name` varchar(255) NOT NULL COMMENT 'name of data store',
+  `image_provider_id` bigint unsigned NOT NULL COMMENT 'id of image_data_store_provider',
+  PRIMARY KEY(`id`),
+  CONSTRAINT `fk_tags__image_data_store_provider_id` FOREIGN KEY(`image_provider_id`) REFERENCES
`image_data_store_provider`(`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`image_data_store_provider` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `name` varchar(255) NOT NULL COMMENT 'name of data store provider',
+  PRIMARY KEY(`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
 SET foreign_key_checks = 1;
 


Mime
View raw message