mirror of https://github.com/apache/cloudstack.git
Fix applicationContext.xml to properly load all new refactored image
store related classes, also add enableImageStore api.
This commit is contained in:
parent
74880fa26f
commit
9be9902ed5
|
|
@ -23,6 +23,7 @@ import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaint
|
|||
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeleteImageStoreCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.EnableImageStoreCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
|
||||
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
|
|
@ -91,4 +92,5 @@ public interface StorageService{
|
|||
|
||||
ImageStore discoverImageStore(AddImageStoreCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
|
||||
|
||||
ImageStore enableImageStore(EnableImageStoreCmd cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.storage;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.AccountResponse;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ImageStoreResponse;
|
||||
import org.apache.cloudstack.region.RegionService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.storage.ImageStore;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "enableImageStore", description="Enable an image store", responseObject=ImageStoreResponse.class)
|
||||
public class EnableImageStoreCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(EnableImageStoreCmd.class.getName());
|
||||
private static final String s_name = "enableimagestoreresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=ImageStoreResponse.class,
|
||||
description="Image Store id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="Enables specified image store.")
|
||||
private String storeName;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
ImageStore result = _storageService.enableImageStore(this);
|
||||
if (result != null){
|
||||
ImageStoreResponse response = _responseGenerator.createImageStoreResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable image store");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -224,6 +224,21 @@
|
|||
<artifactId>cloud-plugin-storage-volume-default</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-storage-image-default</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-storage-image-s3</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-storage-image-swift</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-syslog-alerts</artifactId>
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@
|
|||
<bean id="dataCenterJoinDaoImpl" class="com.cloud.api.query.dao.DataCenterJoinDaoImpl" />
|
||||
<bean id="dataCenterLinkLocalIpAddressDaoImpl" class="com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl" />
|
||||
<bean id="dataCenterVnetDaoImpl" class="com.cloud.dc.dao.DataCenterVnetDaoImpl" />
|
||||
<bean id="dataStoreProviderDaoImpl" class="org.apache.cloudstack.storage.datastore.db.DataStoreProviderDaoImpl" />
|
||||
<bean id="dataStoreProviderDaoImpl" class="org.apache.cloudstack.storage.db.DataStoreProviderDaoImpl" />
|
||||
<bean id="dcDetailsDaoImpl" class="com.cloud.dc.dao.DcDetailsDaoImpl" />
|
||||
<bean id="engineDcDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DcDetailsDaoImpl" />
|
||||
<bean id="diskOfferingJoinDaoImpl" class="com.cloud.api.query.dao.DiskOfferingJoinDaoImpl" />
|
||||
|
|
@ -223,8 +223,12 @@
|
|||
<bean id="hostTransferMapDaoImpl" class="com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl" />
|
||||
<bean id="iPAddressDaoImpl" class="com.cloud.network.dao.IPAddressDaoImpl" />
|
||||
<bean id="identityDaoImpl" class="com.cloud.uuididentity.dao.IdentityDaoImpl" />
|
||||
<bean id="imageDaoStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageDaoStoreDaoImpl" />
|
||||
<bean id="imageDataStoreProviderDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageDataStoreProviderDaoImpl" />
|
||||
<bean id="imageStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDaoImpl" />
|
||||
<bean id="imageStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDetailsDaoImpl" />
|
||||
<bean id="imageStoreJoinDaoImpl" class="com.cloud.api.query.dao.ImageStoreJoinDaoImpl" />
|
||||
<bean id="snapshotDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.SnapshotDataStoreDaoImpl" />
|
||||
<bean id="templateDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.TemplateDataStoreDaoImpl" />
|
||||
<bean id="volumeDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.VolumeDataStoreDaoImpl" />
|
||||
<bean id="inlineLoadBalancerNicMapDaoImpl" class="com.cloud.network.dao.InlineLoadBalancerNicMapDaoImpl" />
|
||||
<bean id="instanceGroupDaoImpl" class="com.cloud.vm.dao.InstanceGroupDaoImpl" />
|
||||
<bean id="instanceGroupJoinDaoImpl" class="com.cloud.api.query.dao.InstanceGroupJoinDaoImpl" />
|
||||
|
|
@ -270,7 +274,7 @@
|
|||
<bean id="portForwardingRulesDaoImpl" class="com.cloud.network.rules.dao.PortForwardingRulesDaoImpl" />
|
||||
<bean id="portProfileDaoImpl" class="com.cloud.network.dao.PortProfileDaoImpl" />
|
||||
<bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
|
||||
<bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDetailsDaoImpl" />
|
||||
<bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.volume.db.PrimaryDataStoreDetailsDaoImpl" />
|
||||
<bean id="privateIpDaoImpl" class="com.cloud.network.vpc.dao.PrivateIpDaoImpl" />
|
||||
<bean id="projectAccountDaoImpl" class="com.cloud.projects.dao.ProjectAccountDaoImpl" />
|
||||
<bean id="projectAccountJoinDaoImpl" class="com.cloud.api.query.dao.ProjectAccountJoinDaoImpl" />
|
||||
|
|
@ -713,7 +717,6 @@
|
|||
<bean id="agentMonitor" class="com.cloud.agent.manager.AgentMonitor" />
|
||||
<bean id="alertGenerator" class="com.cloud.event.AlertGenerator" />
|
||||
<bean id="ancientDataMotionStrategy" class="org.apache.cloudstack.storage.motion.AncientDataMotionStrategy" />
|
||||
<bean id="ancientImageDataStoreProvider" class="org.apache.cloudstack.storage.image.store.AncientImageDataStoreProvider" />
|
||||
<bean id="ancientSnapshotStrategy" class="org.apache.cloudstack.storage.snapshot.strategy.AncientSnapshotStrategy" />
|
||||
<bean id="apiDBUtils" class="com.cloud.api.ApiDBUtils" />
|
||||
<bean id="apiDiscoveryServiceImpl" class="org.apache.cloudstack.discovery.ApiDiscoveryServiceImpl" />
|
||||
|
|
@ -732,6 +735,7 @@
|
|||
<bean id="dataStoreManagerImpl" class="org.apache.cloudstack.storage.datastore.DataStoreManagerImpl" />
|
||||
<bean id="defaultEndPointSelector" class="org.apache.cloudstack.storage.endpoint.DefaultEndPointSelector" />
|
||||
<bean id="primaryDataStoreProviderManagerImpl" class="org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreProviderManagerImpl" />
|
||||
<bean id="imageStoreProviderManagerImpl" class="org.apache.cloudstack.storage.image.manager.ImageStoreProviderManagerImpl" />
|
||||
<bean id="eventUtils" class="com.cloud.event.EventUtils" />
|
||||
<bean id="globalLoadBalancingRulesServiceImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl" />
|
||||
<bean id="hypervsiorHostEndPointRpcServer" class="org.apache.cloudstack.storage.HypervsiorHostEndPointRpcServer" />
|
||||
|
|
@ -739,8 +743,7 @@
|
|||
<bean id="ISO" class="org.apache.cloudstack.storage.image.format.ISO" />
|
||||
<bean id="imageDataFactoryImpl" class="org.apache.cloudstack.storage.image.ImageDataFactoryImpl" />
|
||||
<bean id="imageDataManagerImpl" class="org.apache.cloudstack.storage.image.manager.ImageDataManagerImpl" />
|
||||
<bean id="imageDataStoreHelper" class="org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper" />
|
||||
<bean id="imageDataStoreManagerImpl" class="org.apache.cloudstack.storage.image.manager.ImageDataStoreManagerImpl" />
|
||||
<bean id="imageStoreHelper" class="org.apache.cloudstack.storage.image.datastore.ImageStoreHelper" />
|
||||
<bean id="imageFormatHelper" class="org.apache.cloudstack.storage.image.format.ImageFormatHelper" />
|
||||
<bean id="imageServiceImpl" class="org.apache.cloudstack.storage.image.ImageServiceImpl" />
|
||||
<bean id="iso" class="org.apache.cloudstack.engine.subsystem.api.storage.type.Iso" />
|
||||
|
|
|
|||
|
|
@ -22,4 +22,6 @@ import com.cloud.utils.db.GenericDao;
|
|||
|
||||
public interface ImageStoreDao extends GenericDao<ImageStoreVO, Long> {
|
||||
public ImageStoreVO findByName(String name);
|
||||
|
||||
public ImageStoreVO findEnabledStore();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,22 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.image.db;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.ImageStore;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.SearchCriteriaService;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
|
@ -30,11 +41,41 @@ import com.cloud.utils.db.SearchCriteria.Op;
|
|||
@Component
|
||||
public class ImageStoreDaoImpl extends GenericDaoBase<ImageStoreVO, Long> implements ImageStoreDao {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(ImageStoreDaoImpl.class);
|
||||
private SearchBuilder<ImageStoreVO> nameSearch;
|
||||
private SearchBuilder<ImageStoreVO> enableSearch;
|
||||
|
||||
|
||||
@Override
|
||||
public ImageStoreVO findByName(String name) {
|
||||
SearchCriteriaService<ImageStoreVO, ImageStoreVO> sc = SearchCriteria2.create(ImageStoreVO.class);
|
||||
sc.addAnd(sc.getEntity().getName(), Op.EQ, name);
|
||||
return sc.find();
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
|
||||
nameSearch = createSearchBuilder();
|
||||
nameSearch.and("name", nameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
nameSearch.done();
|
||||
|
||||
|
||||
enableSearch = createSearchBuilder();
|
||||
enableSearch.and("state", enableSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
enableSearch.done();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageStoreVO findByName(String name) {
|
||||
SearchCriteria<ImageStoreVO> sc = nameSearch.create();
|
||||
sc.setParameters("name", name);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageStoreVO findEnabledStore() {
|
||||
SearchCriteria<ImageStoreVO> sc = nameSearch.create();
|
||||
sc.setParameters("state", ImageStore.State.Enabled); // only one image store is enabled at one time.
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
|
|||
storeSearch.done();
|
||||
|
||||
liveStoreSearch = createSearchBuilder();
|
||||
liveStoreSearch.and("store_id", storeSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.and("destroyed", storeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.and("store_id", liveStoreSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.and("destroyed", liveStoreSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.done();
|
||||
|
||||
updateStateSearch = this.createSearchBuilder();
|
||||
|
|
@ -109,7 +109,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
|
|||
|
||||
@Override
|
||||
public List<SnapshotDataStoreVO> listLiveByStoreId(long id) {
|
||||
SearchCriteria<SnapshotDataStoreVO> sc = storeSearch.create();
|
||||
SearchCriteria<SnapshotDataStoreVO> sc = liveStoreSearch.create();
|
||||
sc.setParameters("store_id", id);
|
||||
sc.setParameters("destroyed", false);
|
||||
return listIncludingRemovedBy(sc);
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
|
|||
storeSearch.done();
|
||||
|
||||
liveStoreSearch = createSearchBuilder();
|
||||
liveStoreSearch.and("store_id", storeSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.and("destroyed", storeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.and("store_id", liveStoreSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.and("destroyed", liveStoreSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.done();
|
||||
|
||||
updateStateSearch = this.createSearchBuilder();
|
||||
|
|
@ -109,7 +109,7 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
|
|||
}
|
||||
@Override
|
||||
public List<TemplateDataStoreVO> listLiveByStoreId(long id) {
|
||||
SearchCriteria<TemplateDataStoreVO> sc = storeSearch.create();
|
||||
SearchCriteria<TemplateDataStoreVO> sc = liveStoreSearch.create();
|
||||
sc.setParameters("store_id", id);
|
||||
sc.setParameters("destroyed", false);
|
||||
return listIncludingRemovedBy(sc);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,15 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
|
|||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
|
||||
storeSearch = createSearchBuilder();
|
||||
storeSearch.and("store_id", storeSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||
storeSearch.done();
|
||||
|
||||
liveStoreSearch = createSearchBuilder();
|
||||
liveStoreSearch.and("store_id", liveStoreSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.and("destroyed", liveStoreSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
liveStoreSearch.done();
|
||||
|
||||
updateStateSearch = this.createSearchBuilder();
|
||||
updateStateSearch.and("id", updateStateSearch.entity().getId(), Op.EQ);
|
||||
updateStateSearch.and("state", updateStateSearch.entity().getState(), Op.EQ);
|
||||
|
|
@ -100,7 +109,7 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
|
|||
}
|
||||
@Override
|
||||
public List<VolumeDataStoreVO> listLiveByStoreId(long id) {
|
||||
SearchCriteria<VolumeDataStoreVO> sc = storeSearch.create();
|
||||
SearchCriteria<VolumeDataStoreVO> sc = liveStoreSearch.create();
|
||||
sc.setParameters("store_id", id);
|
||||
sc.setParameters("destroyed", false);
|
||||
return listIncludingRemovedBy(sc);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaint
|
|||
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeleteImageStoreCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.EnableImageStoreCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
|
|
@ -165,6 +166,7 @@ import com.cloud.tags.dao.ResourceTagDao;
|
|||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
|
|
@ -2011,5 +2013,40 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageStore enableImageStore(EnableImageStoreCmd cmd) {
|
||||
Long storeId = cmd.getId();
|
||||
String storeName = cmd.getStoreName();
|
||||
|
||||
ImageStore store = null;
|
||||
if ( storeId != null ){
|
||||
store = _imageStoreDao.findById(storeId);
|
||||
} else if ( storeName != null ){
|
||||
store = _imageStoreDao.findByName(storeName);
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Either image store id or name has to be specified!");
|
||||
}
|
||||
|
||||
if (store == null) {
|
||||
throw new InvalidParameterValueException("Unable to find image store by id: " + storeId + " OR by name: " + storeName);
|
||||
}
|
||||
// disable currently active store
|
||||
ImageStoreVO activeStore = _imageStoreDao.findEnabledStore();
|
||||
ImageStoreVO activeStoreForUpdate = _imageStoreDao.createForUpdate();
|
||||
activeStoreForUpdate.setState(ImageStore.State.Disabled);
|
||||
if ( !_imageStoreDao.update(activeStore.getId(), activeStoreForUpdate)){
|
||||
throw new CloudRuntimeException("Failed to disable current active image store " + activeStore.getName());
|
||||
}
|
||||
|
||||
ImageStoreVO storeForUpdate = _imageStoreDao.createForUpdate();
|
||||
storeForUpdate.setState(ImageStore.State.Enabled);
|
||||
if (_imageStoreDao.update(store.getId(), storeForUpdate)){
|
||||
return _imageStoreDao.findById(store.getId());
|
||||
}
|
||||
else{
|
||||
throw new CloudRuntimeException("Failed to enable image store by id: " + storeId + " OR by name: " + storeName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue