cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [52/57] [abbrv] Renamed internal classes to use "imageStorexxx" instead of previous "imageDataStorexxx". Add new addImageStoreCmd to use 3 image store provider plugins.
Date Sat, 06 Apr 2013 00:35:25 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/server/src/com/cloud/storage/dao/ImageDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/ImageDataStoreDaoImpl.java b/server/src/com/cloud/storage/dao/ImageDataStoreDaoImpl.java
deleted file mode 100644
index 1b3fa46..0000000
--- a/server/src/com/cloud/storage/dao/ImageDataStoreDaoImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage.dao;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-
-import org.apache.cloudstack.storage.datastore.db.ImageDataStoreDetailVO;
-import org.apache.cloudstack.storage.datastore.db.ImageDataStoreDetailsDao;
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.Transaction;
-
-@Component
-@Local(value=ImageDataStoreDetailsDao.class)
-public class ImageDataStoreDaoImpl extends GenericDaoBase<ImageDataStoreDetailVO, Long>
implements ImageDataStoreDetailsDao {
-
-    protected final SearchBuilder<ImageDataStoreDetailVO> storeSearch;
-
-    protected ImageDataStoreDaoImpl() {
-        super();
-        storeSearch = createSearchBuilder();
-        storeSearch.and("store", storeSearch.entity().getStoreId(), SearchCriteria.Op.EQ);
-        storeSearch.done();
-    }
-
-    @Override
-    public void update(long storeId, Map<String, String> details) {
-        Transaction txn = Transaction.currentTxn();
-        SearchCriteria<ImageDataStoreDetailVO> sc = storeSearch.create();
-        sc.setParameters("store", storeId);
-
-        txn.start();
-        expunge(sc);
-        for (Map.Entry<String, String> entry : details.entrySet()) {
-            ImageDataStoreDetailVO detail = new ImageDataStoreDetailVO(storeId, entry.getKey(),
entry.getValue());
-            persist(detail);
-        }
-        txn.commit();
-    }
-
-    @Override
-    public Map<String, String> getDetails(long storeId) {
-    	SearchCriteria<ImageDataStoreDetailVO> sc = storeSearch.create();
-    	sc.setParameters("store", storeId);
-
-    	List<ImageDataStoreDetailVO> details = listBy(sc);
-    	Map<String, String> detailsMap = new HashMap<String, String>();
-    	for (ImageDataStoreDetailVO detail : details) {
-    		detailsMap.put(detail.getName(), detail.getValue());
-    	}
-
-    	return detailsMap;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/server/src/com/cloud/storage/s3/S3Manager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/s3/S3Manager.java b/server/src/com/cloud/storage/s3/S3Manager.java
index 0f74e43..14da1da 100644
--- a/server/src/com/cloud/storage/s3/S3Manager.java
+++ b/server/src/com/cloud/storage/s3/S3Manager.java
@@ -19,6 +19,7 @@
 package com.cloud.storage.s3;
 
 import java.util.List;
+import java.util.Map;
 
 import com.cloud.agent.api.to.S3TO;
 import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
@@ -40,6 +41,8 @@ public interface S3Manager extends Manager {
 
     S3 addS3(AddS3Cmd addS3Cmd) throws DiscoveryException;
 
+    void verifyS3Fields(Map<String, String> params) throws DiscoveryException;
+
     Long chooseZoneForTemplateExtract(VMTemplateVO template);
 
     boolean isS3Enabled();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/server/src/com/cloud/storage/s3/S3ManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/s3/S3ManagerImpl.java b/server/src/com/cloud/storage/s3/S3ManagerImpl.java
index 61e5573..06106db 100644
--- a/server/src/com/cloud/storage/s3/S3ManagerImpl.java
+++ b/server/src/com/cloud/storage/s3/S3ManagerImpl.java
@@ -46,6 +46,7 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
 import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
 import org.apache.log4j.Logger;
@@ -89,12 +90,13 @@ public class S3ManagerImpl extends ManagerBase implements S3Manager {
 
     private static final Logger LOGGER = Logger.getLogger(S3ManagerImpl.class);
 
-    @Inject 
+    @Inject
     private AgentManager agentManager;
 
     @Inject
     private S3Dao s3Dao;
 
+
     @Inject
     private VMTemplateZoneDao vmTemplateZoneDao;
 
@@ -121,7 +123,7 @@ public class S3ManagerImpl extends ManagerBase implements S3Manager {
 
     public S3ManagerImpl() {
     }
-    
+
     private void verifyConnection(final S3TO s3) throws DiscoveryException {
 
         if (!canConnect(s3)) {
@@ -247,6 +249,26 @@ public class S3ManagerImpl extends ManagerBase implements S3Manager {
 
     }
 
+
+    @Override
+    public void verifyS3Fields(Map<String, String> params) throws DiscoveryException
{
+        final S3VO s3VO = new S3VO(UUID.randomUUID().toString(),
+                params.get(ApiConstants.S3_ACCESS_KEY),
+                params.get(ApiConstants.S3_SECRET_KEY),
+                params.get(ApiConstants.S3_END_POINT),
+                params.get(ApiConstants.S3_BUCKET_NAME),
+                Boolean.valueOf(params.get(ApiConstants.S3_HTTPS_FLAG)),
+                Integer.valueOf(params.get(ApiConstants.S3_CONNECTION_TIMEOUT)),
+                Integer.valueOf(params.get(ApiConstants.S3_MAX_ERROR_RETRY)),
+                Integer.valueOf(params.get(ApiConstants.S3_SOCKET_TIMEOUT)), now());
+
+        this.validateFields(s3VO);
+
+        final S3TO s3 = s3VO.toS3TO();
+        this.verifyConnection(s3);
+        this.verifyBuckets(s3);
+    }
+
     @Override
     public boolean isS3Enabled() {
         return Boolean

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/server/test/com/cloud/resource/MockResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/resource/MockResourceManagerImpl.java b/server/test/com/cloud/resource/MockResourceManagerImpl.java
index df62d2e..da4d3fb 100644
--- a/server/test/com/cloud/resource/MockResourceManagerImpl.java
+++ b/server/test/com/cloud/resource/MockResourceManagerImpl.java
@@ -49,7 +49,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.org.Cluster;
 import com.cloud.resource.ResourceState.Event;
 import com.cloud.service.ServiceOfferingVO;
-import com.cloud.storage.ObjectStore;
+import com.cloud.storage.ImageStore;
 import com.cloud.storage.S3;
 import com.cloud.storage.Swift;
 import com.cloud.template.VirtualMachineTemplate;
@@ -610,7 +610,7 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana
 	}
 
     @Override
-    public ObjectStore discoverObjectStore(AddSecondaryStorageCmd cmd) throws IllegalArgumentException,
DiscoveryException,
+    public ImageStore discoverImageStore(AddImageStoreCmd cmd) throws IllegalArgumentException,
DiscoveryException,
             InvalidParameterValueException {
         // TODO Auto-generated method stub
         return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index ed95461..38bad7a 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -68,54 +68,53 @@ CREATE TABLE  `cloud`.`object_datastore_ref` (
 --  PRIMARY KEY(`id`)
 -- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
-CREATE TABLE `cloud`.`image_data_store` (
+CREATE TABLE `cloud`.`image_store` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
   `name` varchar(255) NOT NULL COMMENT 'name of data store',
-  `image_provider_name` varchar(255) NOT NULL COMMENT 'id of image_data_store_provider',
+  `image_provider_name` varchar(255) NOT NULL COMMENT 'id of image_store_provider',
   `protocol` varchar(255) NOT NULL COMMENT 'protocol of data store',
   `url` varchar(255) COMMENT 'url for image data store',
   `data_center_id` bigint unsigned  COMMENT 'datacenter id of data store',
-  `region_id` bigint unsigned  COMMENT 'region id of data store',
   `scope` varchar(255) COMMENT 'scope of data store',
   `uuid` varchar(255) COMMENT 'uuid of data store',
+  `state` varchar(30) COMMENT 'state of data store',
+  `created` datetime COMMENT 'date the image store first signed on',
+  `removed` datetime COMMENT 'date removed if not null',  
   PRIMARY KEY(`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
-CREATE TABLE `cloud`.`image_data_store_details` (
+CREATE TABLE `cloud`.`image_store_details` (
   `id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id',
   `store_id` bigint unsigned NOT NULL COMMENT 'store the detail is related to',
   `name` varchar(255) NOT NULL COMMENT 'name of the detail',
   `value` varchar(255) NOT NULL COMMENT 'value of the detail',
   PRIMARY KEY (`id`),
-  CONSTRAINT `fk_image_data_store_details__store_id` FOREIGN KEY `fk_image_data_store__store_id`(`store_id`)
REFERENCES `image_data_store`(`id`) ON DELETE CASCADE,
-  INDEX `i_image_data_store__name__value`(`name`(128), `value`(128))
+  CONSTRAINT `fk_image_store_details__store_id` FOREIGN KEY `fk_image_store__store_id`(`store_id`)
REFERENCES `image_store`(`id`) ON DELETE CASCADE,
+  INDEX `i_image_store__name__value`(`name`(128), `value`(128))
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
-DROP VIEW IF EXISTS `cloud`.`image_data_store_view`;
-CREATE VIEW `cloud`.`image_data_store_view` AS
+DROP VIEW IF EXISTS `cloud`.`image_store_view`;
+CREATE VIEW `cloud`.`image_store_view` AS
     select 
-        image_data_store.id,
-        image_data_store.uuid,
-        image_data_store.name,
-        image_data_store.provider_name,
-        image_data_store.protocol,
-        image_data_store.url,
-        image_data_store.scope,
+        image_store.id,
+        image_store.uuid,
+        image_store.name,
+        image_store.image_provider_name,
+        image_store.protocol,
+        image_store.url,
+        image_store.scope,
+        image_store.state,
         data_center.id data_center_id,
         data_center.uuid data_center_uuid,
         data_center.name data_center_name,
-        region.id region_id,
-        region.name region_name,
-        image_data_store_details.name detail_name,
-        image_data_store_details.value detail_value
+        image_store_details.name detail_name,
+        image_store_details.value detail_value
     from
-        `cloud`.`image_data_store`
+        `cloud`.`image_store`
             left join
-        `cloud`.`data_center` ON image_data_store.data_center_id = data_center.id
+        `cloud`.`data_center` ON image_store.data_center_id = data_center.id
             left join
-        `cloud`.`region` ON image_data_store.region_id = region.id
-            left join
-        `cloud`.`image_data_store_details` ON image_data_store_details.store_id = image_data_store.id;
+        `cloud`.`image_store_details` ON image_store_details.store_id = image_store.id;
             
             
 CREATE TABLE  `cloud`.`template_store_ref` (


Mime
View raw message