cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [1/4] add inital swift support
Date Sat, 13 Jul 2013 09:15:16 GMT
Updated Branches:
  refs/heads/master b020bcfb4 -> 8f4575e87


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java
index 101902c..d54624d 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -70,7 +70,6 @@ import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.VMTemplatePoolDao;
 import com.cloud.storage.dao.VolumeDao;
-import com.cloud.storage.swift.SwiftManager;
 import com.cloud.uservm.UserVm;
 import com.cloud.utils.DateUtil;
 import com.cloud.utils.NumbersUtil;
@@ -119,8 +118,6 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
     @Inject
     StorageManager _storageMgr;
     @Inject
-    SwiftManager _swiftMgr;
-    @Inject
     ConfigurationManager _configMgr;
     @Inject
     HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 8d8b126..c3209a9 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -172,12 +172,8 @@ import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.service.dao.ServiceOfferingDetailsDao;
 import com.cloud.storage.DiskOfferingVO;
-import com.cloud.storage.SwiftVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.S3Dao;
-import com.cloud.storage.dao.SwiftDao;
-import com.cloud.storage.s3.S3Manager;
-import com.cloud.storage.swift.SwiftManager;
 import com.cloud.test.IPRangeConfig;
 import com.cloud.user.Account;
 import com.cloud.user.AccountDetailVO;
@@ -227,8 +223,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     @Inject
     DomainDao _domainDao;
     @Inject
-    SwiftDao _swiftDao;
-    @Inject
     S3Dao _s3Dao;
     @Inject
     ServiceOfferingDao _serviceOfferingDao;
@@ -277,10 +271,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
     @Inject
     PhysicalNetworkDao _physicalNetworkDao;
     @Inject
-    SwiftManager _swiftMgr;
-    @Inject
-    S3Manager _s3Mgr;
-    @Inject
     PhysicalNetworkTrafficTypeDao _trafficTypeDao;
     @Inject
     NicDao _nicDao;
@@ -720,24 +710,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
                 s_logger.error("Configuration variable " + name + " is expecting true or
false in stead of " + value);
                 return "Please enter either 'true' or 'false'.";
             }
-            if (Config.SwiftEnable.key().equals(name)) {
-                List<DataStore> stores = this._dataStoreMgr.listImageStores();
-                if (stores != null && stores.size() > 0) {
-                    return " can not change " + Config.SwiftEnable.key() + " after you have
added secondary storage";
-                }
-                SwiftVO swift = _swiftDao.findById(1L);
-                if (swift != null) {
-                    return " can not change " + Config.SwiftEnable.key() + " after you have
added Swift";
-                }
-                if (this._s3Mgr.isS3Enabled()) {
-                    return String.format("Swift is not supported when S3 is enabled.");
-                }
-            }
-            if (Config.S3Enable.key().equals(name)) {
-                if (this._swiftMgr.isSwiftEnabled()) {
-                    return String.format("S3-backed Secondary Storage is not supported when
Swift is enabled.");
-                }
-            }
             return null;
         }
 
@@ -1980,9 +1952,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
 
             // Create default system networks
             createDefaultSystemNetworks(zone.getId());
-
-            _swiftMgr.propagateSwiftTmplteOnZone(zone.getId());
-            _s3Mgr.propagateTemplatesToZone(zone);
             txn.commit();
             return zone;
         } catch (Exception ex) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index b009e63..df40066 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -43,10 +43,6 @@ import org.apache.cloudstack.api.command.admin.host.PrepareForMaintenanceCmd;
 import org.apache.cloudstack.api.command.admin.host.ReconnectHostCmd;
 import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd;
 import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
-import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
-import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
-import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
-import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
 import org.apache.cloudstack.region.dao.RegionDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
@@ -123,22 +119,17 @@ import com.cloud.org.Grouping.AllocationState;
 import com.cloud.org.Managed;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.storage.GuestOSCategoryVO;
-import com.cloud.storage.S3;
-import com.cloud.storage.S3VO;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.StoragePoolHostVO;
 import com.cloud.storage.StoragePoolStatus;
 import com.cloud.storage.StorageService;
-import com.cloud.storage.Swift;
-import com.cloud.storage.SwiftVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.dao.GuestOSCategoryDao;
 import com.cloud.storage.dao.StoragePoolHostDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.s3.S3Manager;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
-import com.cloud.storage.swift.SwiftManager;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
@@ -196,8 +187,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
     @Inject
     protected HostDao _hostDao;
     @Inject
-    protected SwiftManager _swiftMgr;
-    @Inject
     protected S3Manager _s3Mgr;
     @Inject
     protected HostDetailsDao _hostDetailsDao;
@@ -623,28 +612,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
         return discoverHostsFull(dcId, null, null, null, url, null, null, "SecondaryStorage",
null, null, false);
     }
 
-    @Override
-    public Swift discoverSwift(AddSwiftCmd cmd) throws DiscoveryException {
-        return _swiftMgr.addSwift(cmd);
-    }
-
-    @Override
-    public Pair<List<? extends Swift>, Integer> listSwifts(ListSwiftsCmd cmd)
{
-        Pair<List<SwiftVO>, Integer> swifts = _swiftMgr.listSwifts(cmd);
-        return new Pair<List<? extends Swift>, Integer>(swifts.first(), swifts.second());
-    }
-
-    @Override
-    public S3 discoverS3(final AddS3Cmd cmd) throws DiscoveryException {
-        return _s3Mgr.addS3(cmd);
-    }
-
-    @Override
-    public List<S3VO> listS3s(final ListS3sCmd cmd) {
-        return _s3Mgr.listS3s(cmd);
-    }
-
-
     private List<HostVO> discoverHostsFull(Long dcId, Long podId, Long clusterId, String
clusterName, String url, String username, String password,
             String hypervisorType, List<String> hostTags, Map<String, String>
params, boolean deferAgentCreation) throws IllegalArgumentException,
             DiscoveryException, InvalidParameterValueException {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 58e4b44..cdffb16 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -154,8 +154,6 @@ import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
 import org.apache.cloudstack.api.command.admin.storage.ListStorageProvidersCmd;
 import org.apache.cloudstack.api.command.admin.storage.PreparePrimaryStorageForMaintenanceCmd;
 import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
-import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
-import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
 import org.apache.cloudstack.api.command.admin.systemvm.*;
 import org.apache.cloudstack.api.command.admin.template.PrepareTemplateCmd;
 import org.apache.cloudstack.api.command.admin.usage.AddTrafficMonitorCmd;
@@ -503,7 +501,6 @@ import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.s3.S3Manager;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
 import com.cloud.storage.snapshot.SnapshotManager;
-import com.cloud.storage.swift.SwiftManager;
 import com.cloud.storage.upload.UploadMonitor;
 import com.cloud.tags.ResourceTagVO;
 import com.cloud.tags.dao.ResourceTagDao;
@@ -601,8 +598,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     @Inject
     private SecondaryStorageVmManager _secStorageVmMgr;
     @Inject
-    private SwiftManager _swiftMgr;
-    @Inject
     private ServiceOfferingDao _offeringsDao;
     @Inject
     private DiskOfferingDao _diskOfferingDao;
@@ -2531,8 +2526,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         cmdList.add(FindStoragePoolsForMigrationCmd.class);
         cmdList.add(PreparePrimaryStorageForMaintenanceCmd.class);
         cmdList.add(UpdateStoragePoolCmd.class);
-        cmdList.add(AddSwiftCmd.class);
-        cmdList.add(ListSwiftsCmd.class);
         cmdList.add(DestroySystemVmCmd.class);
         cmdList.add(ListSystemVMsCmd.class);
         cmdList.add(MigrateSystemVMCmd.class);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index ebe06e7..a67316f 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -99,7 +99,6 @@ import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.s3.S3Manager;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
-import com.cloud.storage.swift.SwiftManager;
 import com.cloud.storage.template.TemplateConstants;
 import com.cloud.tags.ResourceTagVO;
 import com.cloud.tags.dao.ResourceTagDao;
@@ -179,8 +178,6 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
     @Inject
     private ResourceLimitService _resourceLimitMgr;
     @Inject
-    private SwiftManager _swiftMgr;
-    @Inject
     private S3Manager _s3Mgr;
     @Inject
     private SecondaryStorageVmManager _ssvmMgr;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/server/src/com/cloud/storage/swift/SwiftManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/swift/SwiftManager.java b/server/src/com/cloud/storage/swift/SwiftManager.java
deleted file mode 100644
index 2abdac7..0000000
--- a/server/src/com/cloud/storage/swift/SwiftManager.java
+++ /dev/null
@@ -1,57 +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.swift;
-
-import java.util.List;
-
-import com.cloud.agent.api.to.SwiftTO;
-import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
-import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
-import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
-import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.storage.Swift;
-import com.cloud.storage.SwiftVO;
-import com.cloud.storage.VMTemplateSwiftVO;
-import com.cloud.utils.Pair;
-import com.cloud.utils.component.Manager;
-public interface SwiftManager extends Manager {
-
-    SwiftTO getSwiftTO(Long swiftId);
-
-    SwiftTO getSwiftTO();
-
-    Swift addSwift(AddSwiftCmd cmd) throws DiscoveryException;
-
-    boolean isSwiftEnabled();
-
-    public boolean isTemplateInstalled(Long templateId);
-
-    void deleteIso(DeleteIsoCmd cmd);
-
-    void deleteTemplate(DeleteTemplateCmd cmd);
-
-    void propagateTemplateOnAllZones(Long tmpltId);
-
-    void propagateSwiftTmplteOnZone(Long zoneId);
-
-    Long chooseZoneForTmpltExtract(Long tmpltId);
-
-    Pair<List<SwiftVO>, Integer> listSwifts(ListSwiftsCmd cmd);
-
-    VMTemplateSwiftVO findByTmpltId(Long tmpltId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/swift/SwiftManagerImpl.java b/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
deleted file mode 100644
index 3149f5a..0000000
--- a/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
+++ /dev/null
@@ -1,298 +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.swift;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
-import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
-import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.to.SwiftTO;
-import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
-import org.apache.cloudstack.storage.command.DeleteCommand;
-import org.apache.cloudstack.storage.to.TemplateObjectTO;
-
-import com.cloud.configuration.Config;
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
-import com.cloud.storage.SwiftVO;
-import com.cloud.storage.VMTemplateHostVO;
-import com.cloud.storage.VMTemplateSwiftVO;
-import com.cloud.storage.VMTemplateZoneVO;
-import com.cloud.storage.dao.SwiftDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
-import com.cloud.storage.dao.VMTemplateSwiftDao;
-import com.cloud.storage.dao.VMTemplateZoneDao;
-import com.cloud.utils.Pair;
-import com.cloud.utils.component.ManagerBase;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.SearchCriteria2;
-import com.cloud.utils.db.SearchCriteriaService;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Component
-@Local(value = { SwiftManager.class })
-public class SwiftManagerImpl extends ManagerBase implements SwiftManager {
-    private static final Logger s_logger = Logger.getLogger(SwiftManagerImpl.class);
-
-    @Inject
-    private SwiftDao _swiftDao;
-    @Inject
-    VMTemplateSwiftDao _vmTmpltSwiftlDao;
-    @Inject
-    private ConfigurationDao _configDao;
-    @Inject
-    private AgentManager _agentMgr;
-    @Inject
-    private DataCenterDao _dcDao;
-    @Inject
-    private VMTemplateZoneDao _vmTmpltZoneDao;
-    @Inject
-    private VMTemplateHostDao _vmTmpltHostDao;
-    @Inject
-    private HostDao _hostDao;
-
-    @Override
-    public SwiftTO getSwiftTO(Long swiftId) {
-        return _swiftDao.getSwiftTO(swiftId);
-    }
-
-    @Override
-    public SwiftTO getSwiftTO() {
-        return _swiftDao.getSwiftTO(null);
-    }
-
-    @Override
-    public boolean isSwiftEnabled() {
-        Boolean swiftEnable = Boolean.valueOf(_configDao.getValue(Config.SwiftEnable.key()));
-        if (swiftEnable) {
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public boolean isTemplateInstalled(Long templateId) {
-
-        SearchCriteriaService<VMTemplateSwiftVO, VMTemplateSwiftVO> sc = SearchCriteria2.create(VMTemplateSwiftVO.class);
-        sc.addAnd(sc.getEntity().getTemplateId(), Op.EQ, templateId);
-        return !sc.list().isEmpty();
-    }
-
-    @Override
-    public SwiftVO addSwift(AddSwiftCmd cmd) throws DiscoveryException {
-        if (!isSwiftEnabled()) {
-            throw new DiscoveryException("Swift is not enabled");
-        }
-        SwiftVO swift = new SwiftVO(cmd.getUrl(), cmd.getAccount(), cmd.getUsername(), cmd.getKey());
-        swift = _swiftDao.persist(swift);
-        return swift;
-    }
-
-    @Override
-    public boolean start() {
-        if (s_logger.isInfoEnabled()) {
-            s_logger.info("Start Swift Manager");
-        }
-
-        return true;
-    }
-
-    @Override
-    public void deleteIso(DeleteIsoCmd cmd) {
-        String msg;
-        SwiftTO swift = getSwiftTO();
-        if (swift == null) {
-            msg = "There is no Swift in this setup";
-            s_logger.warn(msg);
-            throw new CloudRuntimeException(msg);
-        }
-        VMTemplateSwiftVO tmpltSwiftRef = _vmTmpltSwiftlDao.findBySwiftTemplate(swift.getId(),
cmd.getId());
-        if ( tmpltSwiftRef == null ) {
-           msg = "Delete ISO failed due to  cannot find ISO " + cmd.getId() + " in Swift
";
-           s_logger.warn(msg);
-           throw new CloudRuntimeException(msg);
-        }
-        TemplateObjectTO tmplTO = new TemplateObjectTO();
-        tmplTO.setDataStore(swift);
-        tmplTO.setId(cmd.getId());
-        Answer answer = _agentMgr.sendToSSVM(null, new DeleteCommand(tmplTO));
-        if (answer == null || !answer.getResult()) {
-            msg = "Failed to delete " + tmpltSwiftRef + " due to " + ((answer == null) ?
"answer is null" : answer.getDetails());
-            s_logger.warn(msg);
-            throw new CloudRuntimeException(msg);
-        } else {
-            _vmTmpltSwiftlDao.remove(tmpltSwiftRef.getId());
-            s_logger.debug("Deleted template " + cmd.getId() + " in Swift");
-        }
-    }
-
-    @Override
-    public void deleteTemplate(DeleteTemplateCmd cmd) {
-        String msg;
-        SwiftTO swift = getSwiftTO();
-        if (swift == null) {
-            msg = "There is no Swift in this setup";
-            s_logger.warn(msg);
-            throw new CloudRuntimeException(msg);
-        }
-        VMTemplateSwiftVO tmpltSwiftRef = _vmTmpltSwiftlDao.findBySwiftTemplate(swift.getId(),
cmd.getId());
-        if (tmpltSwiftRef == null) {
-            msg = "Delete Template failed due to cannot find Template" + cmd.getId() + "
in Swift ";
-            s_logger.warn(msg);
-            throw new CloudRuntimeException(msg);
-        }
-        TemplateObjectTO tmplTO = new TemplateObjectTO();
-        tmplTO.setId(cmd.getId());
-        Answer answer = _agentMgr.sendToSSVM(null, new DeleteCommand(tmplTO));
-        if (answer == null || !answer.getResult()) {
-            msg = "Failed to delete " + tmpltSwiftRef + " due to " + ((answer == null) ?
"answer is null" : answer.getDetails());
-            s_logger.warn(msg);
-            throw new CloudRuntimeException(msg);
-        } else {
-            _vmTmpltSwiftlDao.remove(tmpltSwiftRef.getId());
-            s_logger.debug("Deleted template " + cmd.getId() + " in Swift");
-        }
-    }
-
-    @Override
-    public void propagateTemplateOnAllZones(Long tmpltId) {
-        String msg;
-        SwiftTO swift = getSwiftTO();
-        if (swift == null) {
-            msg = "There is no Swift in this setup";
-            s_logger.trace(msg);
-            return;
-        }
-        VMTemplateSwiftVO tmpltSwiftRef = _vmTmpltSwiftlDao.findOneByTemplateId(tmpltId);
-        if (tmpltSwiftRef != null) {
-            List<DataCenterVO> dcs = _dcDao.listAll();
-            for (DataCenterVO dc : dcs) {
-                VMTemplateZoneVO tmpltZoneVO = new VMTemplateZoneVO(dc.getId(), tmpltId,
new Date());
-                try {
-                    _vmTmpltZoneDao.persist(tmpltZoneVO);
-                } catch (Exception e) {
-                }
-            }
-        }
-    }
-
-    @Override
-    public void propagateSwiftTmplteOnZone(Long zoneId) {
-        String msg;
-        SwiftTO swift = getSwiftTO();
-        if (swift == null) {
-            msg = "There is no Swift in this setup";
-            s_logger.trace(msg);
-            return;
-        }
-        List<Long> tmpltIds = new ArrayList<Long>();
-        List<VMTemplateSwiftVO> tmpltSwiftRefs = _vmTmpltSwiftlDao.listAll();
-        if (tmpltSwiftRefs == null) {
-            return;
-        }
-        for (VMTemplateSwiftVO tmpltSwiftRef : tmpltSwiftRefs) {
-            Long tmpltId = tmpltSwiftRef.getTemplateId();
-            if (!tmpltIds.contains(tmpltId)) {
-                tmpltIds.add(tmpltId);
-                VMTemplateZoneVO tmpltZoneVO = new VMTemplateZoneVO(zoneId, tmpltId, new
Date());
-                try {
-                    _vmTmpltZoneDao.persist(tmpltZoneVO);
-                } catch (Exception e) {
-                }
-            }
-        }
-    }
-
-    @Override
-    public Long chooseZoneForTmpltExtract(Long tmpltId) {
-        SwiftTO swift = getSwiftTO();
-        if (swift == null) {
-            return null;
-        }
-
-        List<VMTemplateHostVO> tmpltHosts = _vmTmpltHostDao.listByOnlyTemplateId(tmpltId);
-        if (tmpltHosts != null) {
-            Collections.shuffle(tmpltHosts);
-            for (VMTemplateHostVO tHost : tmpltHosts) {
-                HostVO host = _hostDao.findById(tHost.getHostId());
-                if (host != null) {
-                    return host.getDataCenterId();
-                }
-                throw new CloudRuntimeException("can not find secondary storage host");
-            }
-        }
-        List<DataCenterVO> dcs = _dcDao.listAll();
-        Collections.shuffle(dcs);
-        return dcs.get(0).getId();
-    }
-
-    @Override
-    public Pair<List<SwiftVO>, Integer> listSwifts(ListSwiftsCmd cmd) {
-        Filter searchFilter = new Filter(SwiftVO.class, "id", Boolean.TRUE, cmd.getStartIndex(),
cmd.getPageSizeVal());
-        SearchCriteria<SwiftVO> sc = _swiftDao.createSearchCriteria();
-        if (cmd.getId() != null) {
-            sc.addAnd("id", SearchCriteria.Op.EQ, cmd.getId());
-        }
-        return _swiftDao.searchAndCount(sc, searchFilter);
-
-    }
-
-    @Override
-    public VMTemplateSwiftVO findByTmpltId(Long tmpltId) {
-        return _vmTmpltSwiftlDao.findOneByTemplateId(tmpltId);
-    }
-
-    @Override
-    public boolean stop() {
-        if (s_logger.isInfoEnabled()) {
-            s_logger.info("Stop Swift Manager");
-        }
-        return true;
-    }
-
-    @Override
-    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
-        if (s_logger.isInfoEnabled()) {
-            s_logger.info("Start configuring Swift Manager : " + name);
-        }
-
-        return true;
-    }
-
-    protected SwiftManagerImpl() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/server/src/com/cloud/template/HypervisorTemplateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
index 06bc094..6531838 100755
--- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java
+++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
@@ -160,8 +160,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
             AsyncCallbackDispatcher<HypervisorTemplateAdapter, TemplateApiResult> caller
= AsyncCallbackDispatcher.create(this);
             caller.setCallback(caller.getTarget().createTemplateAsyncCallBack(null, null));
             caller.setContext(context);
-            this.imageService
-            .createTemplateAsync(tmpl, imageStore, caller);
+            this.imageService.createTemplateAsync(tmpl, imageStore, caller);
         }
         _resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/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 18cff80..2c66134 100644
--- a/server/test/com/cloud/resource/MockResourceManagerImpl.java
+++ b/server/test/com/cloud/resource/MockResourceManagerImpl.java
@@ -26,18 +26,8 @@ import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
 import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
-import org.apache.cloudstack.api.command.admin.host.AddHostCmd;
-import org.apache.cloudstack.api.command.admin.host.AddSecondaryStorageCmd;
-import org.apache.cloudstack.api.command.admin.host.CancelMaintenanceCmd;
-import org.apache.cloudstack.api.command.admin.host.PrepareForMaintenanceCmd;
-import org.apache.cloudstack.api.command.admin.host.ReconnectHostCmd;
-import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd;
-import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
-import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
-import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
-import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
-import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
-
+import org.apache.cloudstack.api.command.admin.host.*;
+import org.apache.cloudstack.api.command.admin.storage.*;
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
 import com.cloud.dc.DataCenterVO;
@@ -57,8 +47,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.S3;
-import com.cloud.storage.Swift;
+import com.cloud.storage.ImageStore;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.ManagerBase;
@@ -179,23 +168,6 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see com.cloud.resource.ResourceService#discoverSwift(com.cloud.api.commands.AddSwiftCmd)
-     */
-    @Override
-    public Swift discoverSwift(AddSwiftCmd addSwiftCmd) throws DiscoveryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see com.cloud.resource.ResourceService#discoverS3(com.cloud.api.commands.AddS3Cmd)
-     */
-    @Override
-    public S3 discoverS3(AddS3Cmd cmd) throws DiscoveryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
 
     /* (non-Javadoc)
      * @see com.cloud.resource.ResourceService#getSupportedHypervisorTypes(long, boolean,
java.lang.Long)
@@ -207,24 +179,6 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana
     }
 
     /* (non-Javadoc)
-     * @see com.cloud.resource.ResourceService#listSwifts(com.cloud.api.commands.ListSwiftsCmd)
-     */
-    @Override
-    public Pair<List<? extends Swift>, Integer> listSwifts(ListSwiftsCmd cmd)
{
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see com.cloud.resource.ResourceService#listS3s(com.cloud.api.commands.ListS3sCmd)
-     */
-    @Override
-    public List<? extends S3> listS3s(ListS3sCmd cmd) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
      * @see com.cloud.resource.ResourceManager#registerResourceEvent(java.lang.Integer, com.cloud.resource.ResourceListener)
      */
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java
b/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java
index 6398e20..27faa4d 100644
--- a/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java
+++ b/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java
@@ -100,11 +100,8 @@ import com.cloud.storage.dao.DiskOfferingDaoImpl;
 import com.cloud.storage.dao.S3DaoImpl;
 import com.cloud.storage.dao.SnapshotDaoImpl;
 import com.cloud.storage.dao.StoragePoolDetailsDaoImpl;
-import com.cloud.storage.dao.SwiftDaoImpl;
 import com.cloud.storage.dao.VolumeDaoImpl;
-import com.cloud.storage.s3.S3Manager;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
-import com.cloud.storage.swift.SwiftManager;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 import com.cloud.user.AccountDetailsDao;
 import com.cloud.user.AccountManager;
@@ -126,7 +123,6 @@ import org.apache.cloudstack.region.PortableIpRangeDaoImpl;
         VolumeDaoImpl.class,
         HostPodDaoImpl.class,
         DomainDaoImpl.class,
-        SwiftDaoImpl.class,
         ServiceOfferingDaoImpl.class,
         ServiceOfferingDetailsDaoImpl.class,
         VlanDaoImpl.class,
@@ -225,16 +221,6 @@ public class ChildTestConfiguration {
     }
 
     @Bean
-    public SwiftManager swiftMgr() {
-        return Mockito.mock(SwiftManager.class);
-    }
-
-    @Bean
-    public S3Manager s3Mgr() {
-        return Mockito.mock(S3Manager.class);
-    }
-
-    @Bean
     public VpcManager vpcMgr() {
         return Mockito.mock(VpcManager.class);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/services/secondary-storage/pom.xml
----------------------------------------------------------------------
diff --git a/services/secondary-storage/pom.xml b/services/secondary-storage/pom.xml
index eb6c0ee..124fa5e 100644
--- a/services/secondary-storage/pom.xml
+++ b/services/secondary-storage/pom.xml
@@ -63,6 +63,7 @@
   <build>
     <defaultGoal>install</defaultGoal>
     <sourceDirectory>src</sourceDirectory>
+    <testSourceDirectory>test</testSourceDirectory>
     <plugins>
       <plugin>
         <groupId>org.codehaus.mojo</groupId>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
index 02ff8bc..1a6dcf8 100644
--- a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
+++ b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
@@ -32,7 +32,6 @@ import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.Executors;
 
-import org.apache.cloudstack.storage.command.DownloadSystemTemplateCommand;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -77,66 +76,7 @@ public class LocalNfsSecondaryStorageResource extends NfsSecondaryStorageResourc
 
     @Override
     public Answer executeRequest(Command cmd) {
-        if (cmd instanceof DownloadSystemTemplateCommand) {
-            return execute((DownloadSystemTemplateCommand) cmd);
-        } else {
-            // return Answer.createUnsupportedCommandAnswer(cmd);
-            return super.executeRequest(cmd);
-        }
-    }
-
-    private Answer execute(DownloadSystemTemplateCommand cmd) {
-        DataStoreTO dstore = cmd.getDataStore();
-        if (dstore instanceof S3TO) {
-            // TODO: how to handle download progress for S3
-            S3TO s3 = (S3TO) cmd.getDataStore();
-            String url = cmd.getUrl();
-            String user = null;
-            String password = null;
-            if (cmd.getAuth() != null) {
-                user = cmd.getAuth().getUserName();
-                password = new String(cmd.getAuth().getPassword());
-            }
-            // get input stream from the given url
-            InputStream in = UriUtils.getInputStreamFromUrl(url, user, password);
-            URI uri;
-            URL urlObj;
-            try {
-                uri = new URI(url);
-                urlObj = new URL(url);
-            } catch (URISyntaxException e) {
-                throw new CloudRuntimeException("URI is incorrect: " + url);
-            } catch (MalformedURLException e) {
-                throw new CloudRuntimeException("URL is incorrect: " + url);
-            }
-
-            final String bucket = s3.getBucketName();
-            // convention is no / in the end for install path based on S3Utils
-            // implementation.
-            String path = determineS3TemplateDirectory(cmd.getAccountId(), cmd.getResourceId(),
cmd.getName());
-            // template key is
-            // TEMPLATE_ROOT_DIR/account_id/template_id/template_name
-            String key = join(asList(path, urlObj.getFile()), S3Utils.SEPARATOR);
-            S3Utils.putObject(s3, in, bucket, key);
-            List<S3ObjectSummary> s3Obj = S3Utils.getDirectory(s3, bucket, path);
-            if (s3Obj == null || s3Obj.size() == 0) {
-                return new Answer(cmd, false, "Failed to download to S3 bucket: " + bucket
+ " with key: " + key);
-            } else {
-                return new DownloadAnswer(null, 100, null, Status.DOWNLOADED, path, path,
s3Obj.get(0).getSize(), s3Obj.get(0).getSize(), s3Obj
-                        .get(0).getETag());
-            }
-        } else if (dstore instanceof NfsTO) {
-            return new Answer(cmd, false, "Nfs needs to be pre-installed with system vm templates");
-        } else if (dstore instanceof SwiftTO) {
-            // TODO: need to move code from
-            // execute(uploadTemplateToSwiftFromSecondaryStorageCommand) here,
-            // but we need to handle
-            // source is url, most likely we need to modify our existing
-            // swiftUpload python script.
-            return new Answer(cmd, false, "Swift is not currently support DownloadCommand");
-        } else {
-            return new Answer(cmd, false, "Unsupported image data store: " + dstore);
-        }
+         return super.executeRequest(cmd);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c1ae20e/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index 17ec0bb..cefc08a 100755
--- a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -519,6 +519,10 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements
S
         }
     }
 
+    protected Answer registerTemplateOnSwift(DownloadCommand cmd) {
+
+        return null;
+    }
     private Answer execute(DownloadCommand cmd) {
         DataStoreTO dstore = cmd.getDataStore();
         if (dstore instanceof NfsTO || dstore instanceof S3TO) {
@@ -560,12 +564,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements
S
          * s3Obj.get(0).getSize(), s3Obj .get(0).getETag()); } }
          */
         else if (dstore instanceof SwiftTO) {
-            // TODO: need to move code from
-            // execute(uploadTemplateToSwiftFromSecondaryStorageCommand) here,
-            // but we need to handle
-            // source is url, most likely we need to modify our existing
-            // swiftUpload python script.
-            return new Answer(cmd, false, "Swift is not currently support DownloadCommand");
+            return registerTemplateOnSwift(cmd);
         } else {
             return new Answer(cmd, false, "Unsupported image data store: " + dstore);
         }


Mime
View raw message