mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	add inital swift support
Conflicts: server/src/com/cloud/resource/ResourceManagerImpl.java server/test/com/cloud/resource/MockResourceManagerImpl.java
This commit is contained in:
		
							parent
							
								
									b020bcfb49
								
							
						
					
					
						commit
						0c1ae20e77
					
				| @ -25,15 +25,18 @@ public class SwiftTO implements DataStoreTO { | |||||||
| 
 | 
 | ||||||
|     String userName; |     String userName; | ||||||
|     String key; |     String key; | ||||||
|  |     String container; | ||||||
| 
 | 
 | ||||||
|     public SwiftTO() { } |     public SwiftTO() { } | ||||||
| 
 | 
 | ||||||
|     public SwiftTO(Long id, String url, String account, String userName, String key) { |     public SwiftTO(Long id, String url, String account, String userName, String key, | ||||||
|  |                    String container) { | ||||||
|         this.id = id; |         this.id = id; | ||||||
|         this.url = url; |         this.url = url; | ||||||
|         this.account = account; |         this.account = account; | ||||||
|         this.userName = userName; |         this.userName = userName; | ||||||
|         this.key = key; |         this.key = key; | ||||||
|  |         this.container = container; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Long getId() { |     public Long getId() { | ||||||
| @ -61,6 +64,9 @@ public class SwiftTO implements DataStoreTO { | |||||||
|         return DataStoreRole.Image; |         return DataStoreRole.Image; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public String getContainer() { | ||||||
|  |         return this.container; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -27,10 +27,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.ReconnectHostCmd; | ||||||
| import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd; | 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.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 com.cloud.exception.DiscoveryException; | import com.cloud.exception.DiscoveryException; | ||||||
| import com.cloud.exception.InvalidParameterValueException; | import com.cloud.exception.InvalidParameterValueException; | ||||||
| @ -38,9 +34,6 @@ import com.cloud.exception.ResourceInUseException; | |||||||
| import com.cloud.host.Host; | import com.cloud.host.Host; | ||||||
| import com.cloud.hypervisor.Hypervisor.HypervisorType; | import com.cloud.hypervisor.Hypervisor.HypervisorType; | ||||||
| import com.cloud.org.Cluster; | import com.cloud.org.Cluster; | ||||||
| import com.cloud.storage.S3; |  | ||||||
| import com.cloud.storage.Swift; |  | ||||||
| import com.cloud.utils.Pair; |  | ||||||
| import com.cloud.utils.fsm.NoTransitionException; | import com.cloud.utils.fsm.NoTransitionException; | ||||||
| 
 | 
 | ||||||
| public interface ResourceService { | public interface ResourceService { | ||||||
| @ -97,16 +90,8 @@ public interface ResourceService { | |||||||
| 
 | 
 | ||||||
|     Cluster getCluster(Long clusterId); |     Cluster getCluster(Long clusterId); | ||||||
| 
 | 
 | ||||||
|     Swift discoverSwift(AddSwiftCmd addSwiftCmd) throws DiscoveryException; |  | ||||||
| 
 |  | ||||||
|     S3 discoverS3(AddS3Cmd cmd) throws DiscoveryException; |  | ||||||
| 
 |  | ||||||
|     List<HypervisorType> getSupportedHypervisorTypes(long zoneId, boolean forVirtualRouter, Long podId); |     List<HypervisorType> getSupportedHypervisorTypes(long zoneId, boolean forVirtualRouter, Long podId); | ||||||
| 
 | 
 | ||||||
|     Pair<List<? extends Swift>, Integer> listSwifts(ListSwiftsCmd cmd); |  | ||||||
| 
 |  | ||||||
|     List<? extends S3> listS3s(ListS3sCmd cmd); |  | ||||||
| 
 |  | ||||||
|     boolean releaseHostReservation(Long hostId); |     boolean releaseHostReservation(Long hostId); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,118 +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 org.apache.cloudstack.api.command.admin.swift; |  | ||||||
| 
 |  | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.Map; |  | ||||||
| 
 |  | ||||||
| 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.command.admin.storage.AddImageStoreCmd; |  | ||||||
| import org.apache.cloudstack.api.response.ImageStoreResponse; |  | ||||||
| import org.apache.log4j.Logger; |  | ||||||
| 
 |  | ||||||
| import com.cloud.exception.DiscoveryException; |  | ||||||
| import com.cloud.storage.ImageStore; |  | ||||||
| import com.cloud.user.Account; |  | ||||||
| 
 |  | ||||||
| @APICommand(name = "addSwift", description = "Adds Swift.", responseObject = ImageStoreResponse.class, since="3.0.0") |  | ||||||
| public class AddSwiftCmd extends BaseCmd { |  | ||||||
|     public static final Logger s_logger = Logger.getLogger(AddSwiftCmd.class.getName()); |  | ||||||
|     private static final String s_name = "addswiftresponse"; |  | ||||||
| 
 |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
|     //////////////// API parameters ///////////////////// |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
| 
 |  | ||||||
|     @Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "the URL for swift") |  | ||||||
|     private String url; |  | ||||||
| 
 |  | ||||||
|     @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the account for swift") |  | ||||||
|     private String account; |  | ||||||
| 
 |  | ||||||
|     @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, description = "the username for swift") |  | ||||||
|     private String username; |  | ||||||
| 
 |  | ||||||
|     @Parameter(name = ApiConstants.KEY, type = CommandType.STRING, description = " key for the user for swift") |  | ||||||
|     private String key; |  | ||||||
| 
 |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
|     /////////////////// Accessors /////////////////////// |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
| 
 |  | ||||||
|     public String getUrl() { |  | ||||||
|         return url; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
|     /////////////// API Implementation/////////////////// |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
| 
 |  | ||||||
|     public String getAccount() { |  | ||||||
|         return account; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public String getUsername() { |  | ||||||
|         return username; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public String getKey() { |  | ||||||
|         return key; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public String getCommandName() { |  | ||||||
|         return s_name; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public long getEntityOwnerId() { |  | ||||||
|         return Account.ACCOUNT_ID_SYSTEM; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public void execute(){ |  | ||||||
|         AddImageStoreCmd cmd = new AddImageStoreCmd(); |  | ||||||
|         cmd.setProviderName("Swift"); |  | ||||||
|         cmd.setUrl(this.getUrl()); |  | ||||||
|         Map<String, String> details = new HashMap<String, String>(); |  | ||||||
|         details.put(ApiConstants.ACCOUNT, this.getAccount()); |  | ||||||
|         details.put(ApiConstants.USERNAME, this.getUsername()); |  | ||||||
|         details.put(ApiConstants.KEY, this.getKey()); |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|         try{ |  | ||||||
|             ImageStore result = _storageService.discoverImageStore(cmd); |  | ||||||
|             ImageStoreResponse storeResponse = null; |  | ||||||
|             if (result != null ) { |  | ||||||
|                     storeResponse = _responseGenerator.createImageStoreResponse(result); |  | ||||||
|                     storeResponse.setResponseName(getCommandName()); |  | ||||||
|                     storeResponse.setObjectName("secondarystorage"); |  | ||||||
|                     this.setResponseObject(storeResponse); |  | ||||||
|             } else { |  | ||||||
|                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage"); |  | ||||||
|             } |  | ||||||
|         } catch (DiscoveryException ex) { |  | ||||||
|             s_logger.warn("Exception: ", ex); |  | ||||||
|             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,70 +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 org.apache.cloudstack.api.command.admin.swift; |  | ||||||
| 
 |  | ||||||
| import org.apache.cloudstack.api.APICommand; |  | ||||||
| import org.apache.cloudstack.api.ApiConstants; |  | ||||||
| import org.apache.cloudstack.api.BaseListCmd; |  | ||||||
| import org.apache.cloudstack.api.Parameter; |  | ||||||
| import org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd; |  | ||||||
| import org.apache.cloudstack.api.response.ImageStoreResponse; |  | ||||||
| import org.apache.cloudstack.api.response.ListResponse; |  | ||||||
| import org.apache.log4j.Logger; |  | ||||||
| 
 |  | ||||||
| import com.cloud.user.Account; |  | ||||||
| 
 |  | ||||||
| @APICommand(name = "listSwifts", description = "List Swift.", responseObject = ImageStoreResponse.class, since="3.0.0") |  | ||||||
| public class ListSwiftsCmd extends BaseListCmd { |  | ||||||
|     public static final Logger s_logger = Logger.getLogger(ListSwiftsCmd.class.getName()); |  | ||||||
|     private static final String s_name = "listswiftsresponse"; |  | ||||||
| 
 |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
|     //////////////// API parameters ///////////////////// |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
| 
 |  | ||||||
|     @Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "the id of the swift") |  | ||||||
|     private Long id; |  | ||||||
| 
 |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
|     /////////////// API Implementation/////////////////// |  | ||||||
|     ///////////////////////////////////////////////////// |  | ||||||
| 
 |  | ||||||
|     public Long getId() { |  | ||||||
|         return id; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public String getCommandName() { |  | ||||||
|         return s_name; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public long getEntityOwnerId() { |  | ||||||
|         return Account.ACCOUNT_ID_SYSTEM; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public void execute(){ |  | ||||||
| 
 |  | ||||||
|         ListImageStoresCmd cmd = new ListImageStoresCmd(); |  | ||||||
|         cmd.setProvider("Swift"); |  | ||||||
|         ListResponse<ImageStoreResponse> response = _queryService.searchForImageStores(cmd); |  | ||||||
|         response.setResponseName(getCommandName()); |  | ||||||
|         this.setResponseObject(response); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,129 +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 org.apache.cloudstack.storage.command; |  | ||||||
| 
 |  | ||||||
| import com.cloud.agent.api.Command; |  | ||||||
| import com.cloud.agent.api.storage.PasswordAuth; |  | ||||||
| import com.cloud.agent.api.storage.Proxy; |  | ||||||
| import com.cloud.agent.api.to.DataStoreTO; |  | ||||||
| import com.cloud.template.VirtualMachineTemplate; |  | ||||||
| 
 |  | ||||||
| public class DownloadSystemTemplateCommand extends Command { |  | ||||||
| 
 |  | ||||||
|     private PasswordAuth auth; |  | ||||||
|     private Proxy _proxy; |  | ||||||
|     private DataStoreTO _store; |  | ||||||
|     private Long resourceId; |  | ||||||
|     private Long accountId; |  | ||||||
|     private String url; |  | ||||||
|     private Long maxDownloadSizeInBytes; |  | ||||||
|     private String name; |  | ||||||
| 
 |  | ||||||
|     protected DownloadSystemTemplateCommand() { |  | ||||||
|         super(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, VirtualMachineTemplate template, |  | ||||||
|             Long maxDownloadSizeInBytes) { |  | ||||||
|         super(); |  | ||||||
|         this._store = store; |  | ||||||
|         this.accountId = template.getAccountId(); |  | ||||||
|         this.url = secUrl; |  | ||||||
|         this.maxDownloadSizeInBytes = maxDownloadSizeInBytes; |  | ||||||
|         this.resourceId = template.getId(); |  | ||||||
|         this.name = template.getUniqueName(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, String url, VirtualMachineTemplate template, |  | ||||||
|             String user, String passwd, Long maxDownloadSizeInBytes) { |  | ||||||
|         super(); |  | ||||||
|         this._store = store; |  | ||||||
|         this.accountId = template.getAccountId(); |  | ||||||
|         this.url = secUrl; |  | ||||||
|         this.maxDownloadSizeInBytes = maxDownloadSizeInBytes; |  | ||||||
|         this.resourceId = template.getId(); |  | ||||||
|         auth = new PasswordAuth(user, passwd); |  | ||||||
|         this.name = template.getUniqueName(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public PasswordAuth getAuth() { |  | ||||||
|         return auth; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setCreds(String userName, String passwd) { |  | ||||||
|         auth = new PasswordAuth(userName, passwd); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public Proxy getProxy() { |  | ||||||
|         return _proxy; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setProxy(Proxy proxy) { |  | ||||||
|         _proxy = proxy; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public Long getMaxDownloadSizeInBytes() { |  | ||||||
|         return maxDownloadSizeInBytes; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public DataStoreTO getDataStore() { |  | ||||||
|         return _store; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setDataStore(DataStoreTO _store) { |  | ||||||
|         this._store = _store; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public Long getResourceId() { |  | ||||||
|         return resourceId; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setResourceId(Long resourceId) { |  | ||||||
|         this.resourceId = resourceId; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public Long getAccountId() { |  | ||||||
|         return accountId; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setAccountId(Long accountId) { |  | ||||||
|         this.accountId = accountId; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public String getUrl() { |  | ||||||
|         return url; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setUrl(String url) { |  | ||||||
|         this.url = url; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public String getName() { |  | ||||||
|         return name; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setName(String name) { |  | ||||||
|         this.name = name; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public boolean executeInSequence() { |  | ||||||
|         // TODO Auto-generated method stub |  | ||||||
|         return false; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| @ -99,7 +99,7 @@ public class SwiftVO implements Swift, InternalIdentity { | |||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public SwiftTO toSwiftTO() { |     public SwiftTO toSwiftTO() { | ||||||
|         return new SwiftTO(getId(), getUrl(), getAccount(), getUserName(), getKey()); |         return null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -1,31 +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 com.cloud.agent.api.to.SwiftTO; |  | ||||||
| import com.cloud.storage.SwiftVO; |  | ||||||
| import com.cloud.utils.db.GenericDao; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  *  |  | ||||||
|  *  |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| public interface SwiftDao extends GenericDao<SwiftVO, Long> { |  | ||||||
| 
 |  | ||||||
|     SwiftTO getSwiftTO(Long swiftId); |  | ||||||
| } |  | ||||||
| @ -1,58 +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.Collections; |  | ||||||
| import java.util.List; |  | ||||||
| 
 |  | ||||||
| import javax.ejb.Local; |  | ||||||
| 
 |  | ||||||
| import org.apache.log4j.Logger; |  | ||||||
| import org.springframework.stereotype.Component; |  | ||||||
| 
 |  | ||||||
| import com.cloud.agent.api.to.SwiftTO; |  | ||||||
| import com.cloud.storage.SwiftVO; |  | ||||||
| import com.cloud.utils.db.GenericDaoBase; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  *  |  | ||||||
|  *  |  | ||||||
|  */ |  | ||||||
| @Component |  | ||||||
| @Local(value = { SwiftDao.class }) |  | ||||||
| public class SwiftDaoImpl extends GenericDaoBase<SwiftVO, Long> implements SwiftDao { |  | ||||||
|     public static final Logger s_logger = Logger.getLogger(SwiftDaoImpl.class.getName()); |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public SwiftTO getSwiftTO(Long swiftId) { |  | ||||||
|         if (swiftId != null) { |  | ||||||
|             SwiftVO swift = findById(swiftId); |  | ||||||
|             if (swift != null) { |  | ||||||
|                 return swift.toSwiftTO(); |  | ||||||
|             } |  | ||||||
|             return null; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         List<SwiftVO> swiftVOs = listAll(); |  | ||||||
|         if (swiftVOs == null || swiftVOs.size() < 1) { |  | ||||||
|             return null; |  | ||||||
|         } else { |  | ||||||
|             Collections.shuffle(swiftVOs); |  | ||||||
|             return swiftVOs.get(0).toSwiftTO(); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -36,6 +36,7 @@ | |||||||
|       <artifactId>mockito-all</artifactId> |       <artifactId>mockito-all</artifactId> | ||||||
|       <version>1.9.5</version> |       <version>1.9.5</version> | ||||||
|     </dependency> |     </dependency> | ||||||
|  | 
 | ||||||
|     <dependency> |     <dependency> | ||||||
|       <groupId>javax.inject</groupId> |       <groupId>javax.inject</groupId> | ||||||
|       <artifactId>javax.inject</artifactId> |       <artifactId>javax.inject</artifactId> | ||||||
|  | |||||||
| @ -27,7 +27,6 @@ import java.util.List; | |||||||
| 
 | 
 | ||||||
| import javax.naming.ConfigurationException; | import javax.naming.ConfigurationException; | ||||||
| 
 | 
 | ||||||
| import org.apache.cloudstack.storage.command.DownloadSystemTemplateCommand; |  | ||||||
| import org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource; | import org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource; | ||||||
| import org.apache.cloudstack.storage.template.DownloadManagerImpl; | import org.apache.cloudstack.storage.template.DownloadManagerImpl; | ||||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||||
| @ -75,61 +74,9 @@ public class MockLocalNfsSecondaryStorageResource extends NfsSecondaryStorageRes | |||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public Answer executeRequest(Command cmd) { |     public Answer executeRequest(Command cmd) { | ||||||
|         if (cmd instanceof DownloadSystemTemplateCommand) { |         // return Answer.createUnsupportedCommandAnswer(cmd); | ||||||
|             return execute((DownloadSystemTemplateCommand) cmd); |         return super.executeRequest(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); |  | ||||||
|             URL urlObj; |  | ||||||
|             try { |  | ||||||
|                 urlObj = new URL(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); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -20,8 +20,10 @@ package org.apache.cloudstack.storage.image; | |||||||
| 
 | 
 | ||||||
| import com.cloud.agent.api.Answer; | import com.cloud.agent.api.Answer; | ||||||
| import com.cloud.agent.api.storage.DownloadAnswer; | import com.cloud.agent.api.storage.DownloadAnswer; | ||||||
|  | import com.cloud.agent.api.storage.Proxy; | ||||||
| import com.cloud.agent.api.to.DataObjectType; | import com.cloud.agent.api.to.DataObjectType; | ||||||
| import com.cloud.agent.api.to.DataTO; | import com.cloud.agent.api.to.DataTO; | ||||||
|  | import com.cloud.configuration.dao.ConfigurationDao; | ||||||
| import com.cloud.storage.VMTemplateStorageResourceAssoc; | import com.cloud.storage.VMTemplateStorageResourceAssoc; | ||||||
| import com.cloud.storage.VMTemplateVO; | import com.cloud.storage.VMTemplateVO; | ||||||
| import com.cloud.storage.VolumeVO; | import com.cloud.storage.VolumeVO; | ||||||
| @ -46,12 +48,14 @@ import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; | |||||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||||
| 
 | 
 | ||||||
| import javax.inject.Inject; | import javax.inject.Inject; | ||||||
|  | import java.net.URI; | ||||||
|  | import java.net.URISyntaxException; | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
| 
 | 
 | ||||||
| public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver { | public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver { | ||||||
|     private static final Logger s_logger = Logger.getLogger(BaseImageStoreDriverImpl.class); |     private static final Logger s_logger = Logger.getLogger(BaseImageStoreDriverImpl.class); | ||||||
|     @Inject |     @Inject | ||||||
|     VMTemplateDao _templateDao; |     protected VMTemplateDao _templateDao; | ||||||
|     @Inject |     @Inject | ||||||
|     DownloadMonitor _downloadMonitor; |     DownloadMonitor _downloadMonitor; | ||||||
|     @Inject |     @Inject | ||||||
| @ -62,6 +66,22 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver { | |||||||
|     TemplateDataStoreDao _templateStoreDao; |     TemplateDataStoreDao _templateStoreDao; | ||||||
|     @Inject |     @Inject | ||||||
|     EndPointSelector _epSelector; |     EndPointSelector _epSelector; | ||||||
|  |     @Inject | ||||||
|  |     ConfigurationDao configDao; | ||||||
|  |     protected String _proxy = null; | ||||||
|  | 
 | ||||||
|  |     protected Proxy getHttpProxy() { | ||||||
|  |         if (_proxy == null) { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |         try { | ||||||
|  |             URI uri = new URI(_proxy); | ||||||
|  |             Proxy prx = new Proxy(uri); | ||||||
|  |             return prx; | ||||||
|  |         } catch (URISyntaxException e) { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public DataTO getTO(DataObject data) { |     public DataTO getTO(DataObject data) { | ||||||
| @ -77,6 +97,14 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     protected Long getMaxTemplateSizeInBytes() { | ||||||
|  |         try { | ||||||
|  |             return Long.parseLong(configDao.getValue("max.template.iso.size")) * 1024L * 1024L * 1024L; | ||||||
|  |         } catch (NumberFormatException e) { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) { |     public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) { | ||||||
|         CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data); |         CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data); | ||||||
|  | |||||||
| @ -19,13 +19,26 @@ | |||||||
| package org.apache.cloudstack.storage.datastore.driver; | package org.apache.cloudstack.storage.datastore.driver; | ||||||
| 
 | 
 | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  | import java.util.Timer; | ||||||
| import javax.inject.Inject; | import javax.inject.Inject; | ||||||
| 
 | 
 | ||||||
|  | import com.cloud.agent.api.storage.DownloadAnswer; | ||||||
|  | import com.cloud.agent.api.to.DataObjectType; | ||||||
|  | import com.cloud.storage.download.DownloadListener; | ||||||
|  | import com.cloud.storage.template.TemplateConstants; | ||||||
|  | import com.cloud.storage.upload.UploadListener; | ||||||
|  | import com.cloud.template.VirtualMachineTemplate; | ||||||
|  | import com.cloud.utils.component.ComponentContext; | ||||||
| import org.apache.cloudstack.api.ApiConstants; | import org.apache.cloudstack.api.ApiConstants; | ||||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; | import org.apache.cloudstack.engine.subsystem.api.storage.*; | ||||||
|  | import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; | ||||||
|  | import org.apache.cloudstack.framework.async.AsyncCompletionCallback; | ||||||
|  | import org.apache.cloudstack.storage.command.DownloadCommand; | ||||||
|  | import org.apache.cloudstack.storage.command.DownloadProgressCommand; | ||||||
| import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao; | import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao; | ||||||
| import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl; | import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl; | ||||||
| import org.apache.cloudstack.storage.image.store.ImageStoreImpl; | import org.apache.cloudstack.storage.image.store.ImageStoreImpl; | ||||||
|  | import org.apache.cloudstack.storage.to.TemplateObjectTO; | ||||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||||
| 
 | 
 | ||||||
| import com.cloud.agent.api.to.DataStoreTO; | import com.cloud.agent.api.to.DataStoreTO; | ||||||
| @ -38,13 +51,15 @@ public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl { | |||||||
| 
 | 
 | ||||||
|     @Inject |     @Inject | ||||||
|     ImageStoreDetailsDao _imageStoreDetailsDao; |     ImageStoreDetailsDao _imageStoreDetailsDao; | ||||||
|  |     @Inject | ||||||
|  |     EndPointSelector _epSelector; | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public DataStoreTO getStoreTO(DataStore store) { |     public DataStoreTO getStoreTO(DataStore store) { | ||||||
|         ImageStoreImpl imgStore = (ImageStoreImpl) store; |         ImageStoreImpl imgStore = (ImageStoreImpl) store; | ||||||
|         Map<String, String> details = _imageStoreDetailsDao.getDetails(imgStore.getId()); |         Map<String, String> details = _imageStoreDetailsDao.getDetails(imgStore.getId()); | ||||||
|         return new SwiftTO(imgStore.getId(), imgStore.getUri(), details.get(ApiConstants.ACCOUNT), |         return new SwiftTO(imgStore.getId(), imgStore.getUri(), details.get(ApiConstants.ACCOUNT), | ||||||
|                 details.get(ApiConstants.USERNAME), details.get(ApiConstants.KEY)); |                 details.get(ApiConstants.USERNAME), details.get(ApiConstants.KEY), details.get(ApiConstants.S3_BUCKET_NAME)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
| @ -52,4 +67,32 @@ public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl { | |||||||
|         throw new UnsupportedServiceException("Extract entity url is not yet supported for Swift image store provider"); |         throw new UnsupportedServiceException("Extract entity url is not yet supported for Swift image store provider"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     @Override | ||||||
|  |     public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) { | ||||||
|  |         Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes(); | ||||||
|  |         VirtualMachineTemplate tmpl = _templateDao.findById(data.getId()); | ||||||
|  |         DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes); | ||||||
|  |         dcmd.setProxy(getHttpProxy()); | ||||||
|  | 
 | ||||||
|  |         EndPoint ep = _epSelector.select(data); | ||||||
|  |         if (ep == null) { | ||||||
|  |             s_logger.warn("There is no secondary storage VM for downloading template to image store " + dataStore.getName()); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data); | ||||||
|  |         AsyncCallbackDispatcher<SwiftImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher | ||||||
|  |                 .create(this); | ||||||
|  |         caller.setContext(context); | ||||||
|  | 
 | ||||||
|  |         if (data.getType() == DataObjectType.TEMPLATE) { | ||||||
|  |             caller.setCallback(caller.getTarget().createTemplateAsyncCallback(null, null)); | ||||||
|  |         } else if (data.getType() == DataObjectType.VOLUME) { | ||||||
|  |             caller.setCallback(caller.getTarget().createVolumeAsyncCallback(null, null)); | ||||||
|  |         } | ||||||
|  |         ep.sendMessageAsync(dcmd, caller); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -70,7 +70,6 @@ import com.cloud.storage.VMTemplateVO; | |||||||
| import com.cloud.storage.VolumeVO; | import com.cloud.storage.VolumeVO; | ||||||
| import com.cloud.storage.dao.VMTemplatePoolDao; | import com.cloud.storage.dao.VMTemplatePoolDao; | ||||||
| import com.cloud.storage.dao.VolumeDao; | import com.cloud.storage.dao.VolumeDao; | ||||||
| import com.cloud.storage.swift.SwiftManager; |  | ||||||
| import com.cloud.uservm.UserVm; | import com.cloud.uservm.UserVm; | ||||||
| import com.cloud.utils.DateUtil; | import com.cloud.utils.DateUtil; | ||||||
| import com.cloud.utils.NumbersUtil; | import com.cloud.utils.NumbersUtil; | ||||||
| @ -119,8 +118,6 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, | |||||||
|     @Inject |     @Inject | ||||||
|     StorageManager _storageMgr; |     StorageManager _storageMgr; | ||||||
|     @Inject |     @Inject | ||||||
|     SwiftManager _swiftMgr; |  | ||||||
|     @Inject |  | ||||||
|     ConfigurationManager _configMgr; |     ConfigurationManager _configMgr; | ||||||
|     @Inject |     @Inject | ||||||
|     HypervisorCapabilitiesDao _hypervisorCapabilitiesDao; |     HypervisorCapabilitiesDao _hypervisorCapabilitiesDao; | ||||||
|  | |||||||
| @ -172,12 +172,8 @@ import com.cloud.service.ServiceOfferingVO; | |||||||
| import com.cloud.service.dao.ServiceOfferingDao; | import com.cloud.service.dao.ServiceOfferingDao; | ||||||
| import com.cloud.service.dao.ServiceOfferingDetailsDao; | import com.cloud.service.dao.ServiceOfferingDetailsDao; | ||||||
| import com.cloud.storage.DiskOfferingVO; | import com.cloud.storage.DiskOfferingVO; | ||||||
| import com.cloud.storage.SwiftVO; |  | ||||||
| import com.cloud.storage.dao.DiskOfferingDao; | import com.cloud.storage.dao.DiskOfferingDao; | ||||||
| import com.cloud.storage.dao.S3Dao; | 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.test.IPRangeConfig; | ||||||
| import com.cloud.user.Account; | import com.cloud.user.Account; | ||||||
| import com.cloud.user.AccountDetailVO; | import com.cloud.user.AccountDetailVO; | ||||||
| @ -227,8 +223,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati | |||||||
|     @Inject |     @Inject | ||||||
|     DomainDao _domainDao; |     DomainDao _domainDao; | ||||||
|     @Inject |     @Inject | ||||||
|     SwiftDao _swiftDao; |  | ||||||
|     @Inject |  | ||||||
|     S3Dao _s3Dao; |     S3Dao _s3Dao; | ||||||
|     @Inject |     @Inject | ||||||
|     ServiceOfferingDao _serviceOfferingDao; |     ServiceOfferingDao _serviceOfferingDao; | ||||||
| @ -277,10 +271,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati | |||||||
|     @Inject |     @Inject | ||||||
|     PhysicalNetworkDao _physicalNetworkDao; |     PhysicalNetworkDao _physicalNetworkDao; | ||||||
|     @Inject |     @Inject | ||||||
|     SwiftManager _swiftMgr; |  | ||||||
|     @Inject |  | ||||||
|     S3Manager _s3Mgr; |  | ||||||
|     @Inject |  | ||||||
|     PhysicalNetworkTrafficTypeDao _trafficTypeDao; |     PhysicalNetworkTrafficTypeDao _trafficTypeDao; | ||||||
|     @Inject |     @Inject | ||||||
|     NicDao _nicDao; |     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); |                 s_logger.error("Configuration variable " + name + " is expecting true or false in stead of " + value); | ||||||
|                 return "Please enter either 'true' or 'false'."; |                 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; |             return null; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -1980,9 +1952,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati | |||||||
| 
 | 
 | ||||||
|             // Create default system networks |             // Create default system networks | ||||||
|             createDefaultSystemNetworks(zone.getId()); |             createDefaultSystemNetworks(zone.getId()); | ||||||
| 
 |  | ||||||
|             _swiftMgr.propagateSwiftTmplteOnZone(zone.getId()); |  | ||||||
|             _s3Mgr.propagateTemplatesToZone(zone); |  | ||||||
|             txn.commit(); |             txn.commit(); | ||||||
|             return zone; |             return zone; | ||||||
|         } catch (Exception ex) { |         } catch (Exception ex) { | ||||||
|  | |||||||
| @ -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.ReconnectHostCmd; | ||||||
| import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd; | 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.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.region.dao.RegionDao; | ||||||
| import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; | import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; | ||||||
| import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; | 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.org.Managed; | ||||||
| import com.cloud.service.ServiceOfferingVO; | import com.cloud.service.ServiceOfferingVO; | ||||||
| import com.cloud.storage.GuestOSCategoryVO; | import com.cloud.storage.GuestOSCategoryVO; | ||||||
| import com.cloud.storage.S3; |  | ||||||
| import com.cloud.storage.S3VO; |  | ||||||
| import com.cloud.storage.StorageManager; | import com.cloud.storage.StorageManager; | ||||||
| import com.cloud.storage.StoragePool; | import com.cloud.storage.StoragePool; | ||||||
| import com.cloud.storage.StoragePoolHostVO; | import com.cloud.storage.StoragePoolHostVO; | ||||||
| import com.cloud.storage.StoragePoolStatus; | import com.cloud.storage.StoragePoolStatus; | ||||||
| import com.cloud.storage.StorageService; | import com.cloud.storage.StorageService; | ||||||
| import com.cloud.storage.Swift; |  | ||||||
| import com.cloud.storage.SwiftVO; |  | ||||||
| import com.cloud.storage.VMTemplateVO; | import com.cloud.storage.VMTemplateVO; | ||||||
| import com.cloud.storage.dao.GuestOSCategoryDao; | import com.cloud.storage.dao.GuestOSCategoryDao; | ||||||
| import com.cloud.storage.dao.StoragePoolHostDao; | import com.cloud.storage.dao.StoragePoolHostDao; | ||||||
| import com.cloud.storage.dao.VMTemplateDao; | import com.cloud.storage.dao.VMTemplateDao; | ||||||
| import com.cloud.storage.s3.S3Manager; | import com.cloud.storage.s3.S3Manager; | ||||||
| import com.cloud.storage.secondary.SecondaryStorageVmManager; | import com.cloud.storage.secondary.SecondaryStorageVmManager; | ||||||
| import com.cloud.storage.swift.SwiftManager; |  | ||||||
| import com.cloud.template.VirtualMachineTemplate; | import com.cloud.template.VirtualMachineTemplate; | ||||||
| import com.cloud.user.Account; | import com.cloud.user.Account; | ||||||
| import com.cloud.user.AccountManager; | import com.cloud.user.AccountManager; | ||||||
| @ -196,8 +187,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, | |||||||
|     @Inject |     @Inject | ||||||
|     protected HostDao _hostDao; |     protected HostDao _hostDao; | ||||||
|     @Inject |     @Inject | ||||||
|     protected SwiftManager _swiftMgr; |  | ||||||
|     @Inject |  | ||||||
|     protected S3Manager _s3Mgr; |     protected S3Manager _s3Mgr; | ||||||
|     @Inject |     @Inject | ||||||
|     protected HostDetailsDao _hostDetailsDao; |     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); |         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, |     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, |             String hypervisorType, List<String> hostTags, Map<String, String> params, boolean deferAgentCreation) throws IllegalArgumentException, | ||||||
|             DiscoveryException, InvalidParameterValueException { |             DiscoveryException, InvalidParameterValueException { | ||||||
|  | |||||||
| @ -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.ListStorageProvidersCmd; | ||||||
| import org.apache.cloudstack.api.command.admin.storage.PreparePrimaryStorageForMaintenanceCmd; | 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.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.systemvm.*; | ||||||
| import org.apache.cloudstack.api.command.admin.template.PrepareTemplateCmd; | import org.apache.cloudstack.api.command.admin.template.PrepareTemplateCmd; | ||||||
| import org.apache.cloudstack.api.command.admin.usage.AddTrafficMonitorCmd; | 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.s3.S3Manager; | ||||||
| import com.cloud.storage.secondary.SecondaryStorageVmManager; | import com.cloud.storage.secondary.SecondaryStorageVmManager; | ||||||
| import com.cloud.storage.snapshot.SnapshotManager; | import com.cloud.storage.snapshot.SnapshotManager; | ||||||
| import com.cloud.storage.swift.SwiftManager; |  | ||||||
| import com.cloud.storage.upload.UploadMonitor; | import com.cloud.storage.upload.UploadMonitor; | ||||||
| import com.cloud.tags.ResourceTagVO; | import com.cloud.tags.ResourceTagVO; | ||||||
| import com.cloud.tags.dao.ResourceTagDao; | import com.cloud.tags.dao.ResourceTagDao; | ||||||
| @ -601,8 +598,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe | |||||||
|     @Inject |     @Inject | ||||||
|     private SecondaryStorageVmManager _secStorageVmMgr; |     private SecondaryStorageVmManager _secStorageVmMgr; | ||||||
|     @Inject |     @Inject | ||||||
|     private SwiftManager _swiftMgr; |  | ||||||
|     @Inject |  | ||||||
|     private ServiceOfferingDao _offeringsDao; |     private ServiceOfferingDao _offeringsDao; | ||||||
|     @Inject |     @Inject | ||||||
|     private DiskOfferingDao _diskOfferingDao; |     private DiskOfferingDao _diskOfferingDao; | ||||||
| @ -2531,8 +2526,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe | |||||||
|         cmdList.add(FindStoragePoolsForMigrationCmd.class); |         cmdList.add(FindStoragePoolsForMigrationCmd.class); | ||||||
|         cmdList.add(PreparePrimaryStorageForMaintenanceCmd.class); |         cmdList.add(PreparePrimaryStorageForMaintenanceCmd.class); | ||||||
|         cmdList.add(UpdateStoragePoolCmd.class); |         cmdList.add(UpdateStoragePoolCmd.class); | ||||||
|         cmdList.add(AddSwiftCmd.class); |  | ||||||
|         cmdList.add(ListSwiftsCmd.class); |  | ||||||
|         cmdList.add(DestroySystemVmCmd.class); |         cmdList.add(DestroySystemVmCmd.class); | ||||||
|         cmdList.add(ListSystemVMsCmd.class); |         cmdList.add(ListSystemVMsCmd.class); | ||||||
|         cmdList.add(MigrateSystemVMCmd.class); |         cmdList.add(MigrateSystemVMCmd.class); | ||||||
|  | |||||||
| @ -99,7 +99,6 @@ import com.cloud.storage.dao.VMTemplateDao; | |||||||
| import com.cloud.storage.dao.VolumeDao; | import com.cloud.storage.dao.VolumeDao; | ||||||
| import com.cloud.storage.s3.S3Manager; | import com.cloud.storage.s3.S3Manager; | ||||||
| import com.cloud.storage.secondary.SecondaryStorageVmManager; | import com.cloud.storage.secondary.SecondaryStorageVmManager; | ||||||
| import com.cloud.storage.swift.SwiftManager; |  | ||||||
| import com.cloud.storage.template.TemplateConstants; | import com.cloud.storage.template.TemplateConstants; | ||||||
| import com.cloud.tags.ResourceTagVO; | import com.cloud.tags.ResourceTagVO; | ||||||
| import com.cloud.tags.dao.ResourceTagDao; | import com.cloud.tags.dao.ResourceTagDao; | ||||||
| @ -179,8 +178,6 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager, | |||||||
|     @Inject |     @Inject | ||||||
|     private ResourceLimitService _resourceLimitMgr; |     private ResourceLimitService _resourceLimitMgr; | ||||||
|     @Inject |     @Inject | ||||||
|     private SwiftManager _swiftMgr; |  | ||||||
|     @Inject |  | ||||||
|     private S3Manager _s3Mgr; |     private S3Manager _s3Mgr; | ||||||
|     @Inject |     @Inject | ||||||
|     private SecondaryStorageVmManager _ssvmMgr; |     private SecondaryStorageVmManager _ssvmMgr; | ||||||
|  | |||||||
| @ -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); |  | ||||||
| } |  | ||||||
| @ -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() { |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -160,8 +160,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { | |||||||
|             AsyncCallbackDispatcher<HypervisorTemplateAdapter, TemplateApiResult> caller = AsyncCallbackDispatcher.create(this); |             AsyncCallbackDispatcher<HypervisorTemplateAdapter, TemplateApiResult> caller = AsyncCallbackDispatcher.create(this); | ||||||
|             caller.setCallback(caller.getTarget().createTemplateAsyncCallBack(null, null)); |             caller.setCallback(caller.getTarget().createTemplateAsyncCallBack(null, null)); | ||||||
|             caller.setContext(context); |             caller.setContext(context); | ||||||
|             this.imageService |             this.imageService.createTemplateAsync(tmpl, imageStore, caller); | ||||||
|             .createTemplateAsync(tmpl, imageStore, caller); |  | ||||||
|         } |         } | ||||||
|         _resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template); |         _resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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.AddClusterCmd; | ||||||
| import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd; | 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.*; | ||||||
| import org.apache.cloudstack.api.command.admin.host.AddSecondaryStorageCmd; | import org.apache.cloudstack.api.command.admin.storage.*; | ||||||
| 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 com.cloud.agent.api.StartupCommand; | import com.cloud.agent.api.StartupCommand; | ||||||
| import com.cloud.agent.api.StartupRoutingCommand; | import com.cloud.agent.api.StartupRoutingCommand; | ||||||
| import com.cloud.dc.DataCenterVO; | import com.cloud.dc.DataCenterVO; | ||||||
| @ -57,8 +47,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType; | |||||||
| import com.cloud.org.Cluster; | import com.cloud.org.Cluster; | ||||||
| import com.cloud.resource.ResourceState.Event; | import com.cloud.resource.ResourceState.Event; | ||||||
| import com.cloud.service.ServiceOfferingVO; | import com.cloud.service.ServiceOfferingVO; | ||||||
| import com.cloud.storage.S3; | import com.cloud.storage.ImageStore; | ||||||
| import com.cloud.storage.Swift; |  | ||||||
| import com.cloud.template.VirtualMachineTemplate; | import com.cloud.template.VirtualMachineTemplate; | ||||||
| import com.cloud.utils.Pair; | import com.cloud.utils.Pair; | ||||||
| import com.cloud.utils.component.ManagerBase; | import com.cloud.utils.component.ManagerBase; | ||||||
| @ -179,23 +168,6 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana | |||||||
|         return null; |         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) |     /* (non-Javadoc) | ||||||
|      * @see com.cloud.resource.ResourceService#getSupportedHypervisorTypes(long, boolean, java.lang.Long) |      * @see com.cloud.resource.ResourceService#getSupportedHypervisorTypes(long, boolean, java.lang.Long) | ||||||
| @ -206,24 +178,6 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana | |||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* (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) |     /* (non-Javadoc) | ||||||
|      * @see com.cloud.resource.ResourceManager#registerResourceEvent(java.lang.Integer, com.cloud.resource.ResourceListener) |      * @see com.cloud.resource.ResourceManager#registerResourceEvent(java.lang.Integer, com.cloud.resource.ResourceListener) | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -100,11 +100,8 @@ import com.cloud.storage.dao.DiskOfferingDaoImpl; | |||||||
| import com.cloud.storage.dao.S3DaoImpl; | import com.cloud.storage.dao.S3DaoImpl; | ||||||
| import com.cloud.storage.dao.SnapshotDaoImpl; | import com.cloud.storage.dao.SnapshotDaoImpl; | ||||||
| import com.cloud.storage.dao.StoragePoolDetailsDaoImpl; | import com.cloud.storage.dao.StoragePoolDetailsDaoImpl; | ||||||
| import com.cloud.storage.dao.SwiftDaoImpl; |  | ||||||
| import com.cloud.storage.dao.VolumeDaoImpl; | import com.cloud.storage.dao.VolumeDaoImpl; | ||||||
| import com.cloud.storage.s3.S3Manager; |  | ||||||
| import com.cloud.storage.secondary.SecondaryStorageVmManager; | import com.cloud.storage.secondary.SecondaryStorageVmManager; | ||||||
| import com.cloud.storage.swift.SwiftManager; |  | ||||||
| import com.cloud.tags.dao.ResourceTagsDaoImpl; | import com.cloud.tags.dao.ResourceTagsDaoImpl; | ||||||
| import com.cloud.user.AccountDetailsDao; | import com.cloud.user.AccountDetailsDao; | ||||||
| import com.cloud.user.AccountManager; | import com.cloud.user.AccountManager; | ||||||
| @ -126,7 +123,6 @@ import org.apache.cloudstack.region.PortableIpRangeDaoImpl; | |||||||
|         VolumeDaoImpl.class, |         VolumeDaoImpl.class, | ||||||
|         HostPodDaoImpl.class, |         HostPodDaoImpl.class, | ||||||
|         DomainDaoImpl.class, |         DomainDaoImpl.class, | ||||||
|         SwiftDaoImpl.class, |  | ||||||
|         ServiceOfferingDaoImpl.class, |         ServiceOfferingDaoImpl.class, | ||||||
|         ServiceOfferingDetailsDaoImpl.class, |         ServiceOfferingDetailsDaoImpl.class, | ||||||
|         VlanDaoImpl.class, |         VlanDaoImpl.class, | ||||||
| @ -224,16 +220,6 @@ public class ChildTestConfiguration { | |||||||
|         return Mockito.mock(SecondaryStorageVmManager.class); |         return Mockito.mock(SecondaryStorageVmManager.class); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Bean |  | ||||||
|     public SwiftManager swiftMgr() { |  | ||||||
|         return Mockito.mock(SwiftManager.class); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Bean |  | ||||||
|     public S3Manager s3Mgr() { |  | ||||||
|         return Mockito.mock(S3Manager.class); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Bean |     @Bean | ||||||
|     public VpcManager vpcMgr() { |     public VpcManager vpcMgr() { | ||||||
|         return Mockito.mock(VpcManager.class); |         return Mockito.mock(VpcManager.class); | ||||||
|  | |||||||
| @ -63,6 +63,7 @@ | |||||||
|   <build> |   <build> | ||||||
|     <defaultGoal>install</defaultGoal> |     <defaultGoal>install</defaultGoal> | ||||||
|     <sourceDirectory>src</sourceDirectory> |     <sourceDirectory>src</sourceDirectory> | ||||||
|  |     <testSourceDirectory>test</testSourceDirectory> | ||||||
|     <plugins> |     <plugins> | ||||||
|       <plugin> |       <plugin> | ||||||
|         <groupId>org.codehaus.mojo</groupId> |         <groupId>org.codehaus.mojo</groupId> | ||||||
|  | |||||||
| @ -32,7 +32,6 @@ import java.util.List; | |||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
| import java.util.concurrent.Executors; | import java.util.concurrent.Executors; | ||||||
| 
 | 
 | ||||||
| import org.apache.cloudstack.storage.command.DownloadSystemTemplateCommand; |  | ||||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||||
| 
 | 
 | ||||||
| @ -77,66 +76,7 @@ public class LocalNfsSecondaryStorageResource extends NfsSecondaryStorageResourc | |||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public Answer executeRequest(Command cmd) { |     public Answer executeRequest(Command cmd) { | ||||||
|         if (cmd instanceof DownloadSystemTemplateCommand) { |          return super.executeRequest(cmd); | ||||||
|             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); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -519,6 +519,10 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     protected Answer registerTemplateOnSwift(DownloadCommand cmd) { | ||||||
|  | 
 | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|     private Answer execute(DownloadCommand cmd) { |     private Answer execute(DownloadCommand cmd) { | ||||||
|         DataStoreTO dstore = cmd.getDataStore(); |         DataStoreTO dstore = cmd.getDataStore(); | ||||||
|         if (dstore instanceof NfsTO || dstore instanceof S3TO) { |         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()); } } |          * s3Obj.get(0).getSize(), s3Obj .get(0).getETag()); } } | ||||||
|          */ |          */ | ||||||
|         else if (dstore instanceof SwiftTO) { |         else if (dstore instanceof SwiftTO) { | ||||||
|             // TODO: need to move code from |             return registerTemplateOnSwift(cmd); | ||||||
|             // 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 { |         } else { | ||||||
|             return new Answer(cmd, false, "Unsupported image data store: " + dstore); |             return new Answer(cmd, false, "Unsupported image data store: " + dstore); | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user