Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
Deal with Storage Manager tech debt#13598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -18,7 +18,6 @@ | ||
| import java.util.Collection; | ||
| import java.util.HashMap; | ||
| import java.util.Iterator; | ||
| import java.util.Map; | ||
| @@ -31,7 +30,6 @@ | ||
| import org.apache.cloudstack.api.response.ImageStoreResponse; | ||
| import org.apache.cloudstack.api.response.ZoneResponse; | ||
| import com.cloud.exception.DiscoveryException; | ||
| import com.cloud.storage.ImageStore; | ||
| import com.cloud.user.Account; | ||
| @@ -79,11 +77,10 @@ public Long getZoneId() { | ||
| public Map<String, String> getDetails() { | ||
| Map<String, String> detailsMap = null; | ||
| if (details != null && !details.isEmpty()) { | ||
| detailsMap = new HashMap<String, String>(); | ||
| detailsMap = new HashMap<>(); | ||
| Collection<?> props = details.values(); | ||
| Iterator<?> iter = props.iterator(); | ||
| while (iter.hasNext()) { | ||
| HashMap<String, String> detail = (HashMap<String, String>)iter.next(); | ||
| for (Object prop : props) { | ||
| HashMap<String, String> detail = (HashMap<String, String>) prop; | ||
| String key = detail.get("key"); | ||
| String value = detail.get("value"); | ||
| detailsMap.put(key, value); | ||
| @@ -123,20 +120,15 @@ public long getEntityOwnerId() { | ||
| @Override | ||
| public void execute(){ | ||
| try{ | ||
| ImageStore result = _storageService.discoverImageStore(getName(), getUrl(), getProviderName(), getZoneId(), getDetails()); | ||
| ImageStoreResponse storeResponse = null; | ||
| if (result != null) { | ||
| storeResponse = _responseGenerator.createImageStoreResponse(result); | ||
| storeResponse.setResponseName(getCommandName()); | ||
| storeResponse.setObjectName("imagestore"); | ||
| setResponseObject(storeResponse); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage"); | ||
| } | ||
| } catch (DiscoveryException ex) { | ||
| logger.warn("Exception: ", ex); | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); | ||
| ImageStore result = _storageService.discoverImageStore(getName(), getUrl(), getProviderName(), getZoneId(), getDetails()); | ||
| ImageStoreResponse storeResponse; | ||
| if (result != null) { | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here | ||
| storeResponse = _responseGenerator.createImageStoreResponse(result); | ||
| storeResponse.setResponseName(getCommandName()); | ||
| storeResponse.setObjectName("imagestore"); | ||
| setResponseObject(storeResponse); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage"); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -48,15 +48,14 @@ | ||
| import org.apache.cloudstack.api.response.ImageStoreResponse; | ||
| import com.cloud.exception.ConcurrentOperationException; | ||
| import com.cloud.exception.DiscoveryException; | ||
| import com.cloud.exception.InsufficientCapacityException; | ||
| import com.cloud.exception.NetworkRuleConflictException; | ||
| import com.cloud.exception.ResourceAllocationException; | ||
| import com.cloud.exception.ResourceUnavailableException; | ||
| import com.cloud.storage.ImageStore; | ||
| @APICommand(name = "addImageStoreS3", description = "Adds S3 Image Store", responseObject = ImageStoreResponse.class, since = "4.7.0", | ||
| requestHasSensitiveInfo = true, responseHasSensitiveInfo = false) | ||
| @APICommand(name = "addImageStoreS3", description = "Adds S3 Image Store", responseObject = ImageStoreResponse.class, | ||
| since = "4.7.0", responseHasSensitiveInfo = false) | ||
Comment on lines
+57
to
+58
| ||
| public final class AddImageStoreS3CMD extends BaseCmd implements ClientOptions { | ||
| private static final String s_name = "addImageStoreS3Response"; | ||
| @@ -73,32 +72,32 @@ public final class AddImageStoreS3CMD extends BaseCmd implements ClientOptions { | ||
| @Parameter(name = S3_BUCKET_NAME, type = STRING, required = true, description = "Name of the storage bucket") | ||
| private String bucketName; | ||
| @Parameter(name = S3_SIGNER, type = STRING, required = false, description = "Signer Algorithm to use, either S3SignerType or AWSS3V4SignerType") | ||
| @Parameter(name = S3_SIGNER, type = STRING, description = "Signer Algorithm to use, either S3SignerType or AWSS3V4SignerType") | ||
| private String signer; | ||
| @Parameter(name = S3_HTTPS_FLAG, type = BOOLEAN, required = false, description = "Use HTTPS instead of HTTP") | ||
| @Parameter(name = S3_HTTPS_FLAG, type = BOOLEAN, description = "Use HTTPS instead of HTTP") | ||
| private Boolean httpsFlag; | ||
| @Parameter(name = S3_CONNECTION_TIMEOUT, type = INTEGER, required = false, description = "Connection timeout (milliseconds)") | ||
| @Parameter(name = S3_CONNECTION_TIMEOUT, type = INTEGER, description = "Connection timeout (milliseconds)") | ||
| private Integer connectionTimeout; | ||
| @Parameter(name = S3_MAX_ERROR_RETRY, type = INTEGER, required = false, description = "Maximum number of times to retry on error") | ||
| @Parameter(name = S3_MAX_ERROR_RETRY, type = INTEGER, description = "Maximum number of times to retry on error") | ||
| private Integer maxErrorRetry; | ||
| @Parameter(name = S3_SOCKET_TIMEOUT, type = INTEGER, required = false, description = "Socket timeout (milliseconds)") | ||
| @Parameter(name = S3_SOCKET_TIMEOUT, type = INTEGER, description = "Socket timeout (milliseconds)") | ||
| private Integer socketTimeout; | ||
| @Parameter(name = S3_CONNECTION_TTL, type = INTEGER, required = false, description = "Connection TTL (milliseconds)") | ||
| @Parameter(name = S3_CONNECTION_TTL, type = INTEGER, description = "Connection TTL (milliseconds)") | ||
| private Integer connectionTtl; | ||
| @Parameter(name = S3_USE_TCP_KEEPALIVE, type = BOOLEAN, required = false, description = "Whether TCP keep-alive is used") | ||
| @Parameter(name = S3_USE_TCP_KEEPALIVE, type = BOOLEAN, description = "Whether TCP keep-alive is used") | ||
| private Boolean useTCPKeepAlive; | ||
| @Override | ||
| public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, | ||
| ResourceAllocationException, NetworkRuleConflictException { | ||
| Map<String, String> dm = new HashMap(); | ||
| Map<String, String> dm = new HashMap<>(); | ||
| dm.put(ApiConstants.S3_ACCESS_KEY, getAccessKey()); | ||
| dm.put(ApiConstants.SECRET_KEY, getSecretKey()); | ||
| @@ -127,20 +126,15 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE | ||
| dm.put(ApiConstants.S3_USE_TCP_KEEPALIVE, getUseTCPKeepAlive().toString()); | ||
| } | ||
| try{ | ||
| ImageStore result = _storageService.discoverImageStore(null, null, "S3", null, dm); | ||
| ImageStoreResponse storeResponse; | ||
| if (result != null) { | ||
| storeResponse = _responseGenerator.createImageStoreResponse(result); | ||
| storeResponse.setResponseName(getCommandName()); | ||
| storeResponse.setObjectName("imagestore"); | ||
| setResponseObject(storeResponse); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3 Image Store."); | ||
| } | ||
| } catch (DiscoveryException ex) { | ||
| logger.warn("Exception: ", ex); | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); | ||
| ImageStore result = _storageService.discoverImageStore(null, null, "S3", null, dm); | ||
| ImageStoreResponse storeResponse; | ||
| if (result != null) { | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here | ||
| storeResponse = _responseGenerator.createImageStoreResponse(result); | ||
| storeResponse.setResponseName(getCommandName()); | ||
| storeResponse.setObjectName("imagestore"); | ||
| setResponseObject(storeResponse); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3 Image Store."); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DaanHoogland can we invert the logic to reduce identation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not my style, but I’ll have to revisit anyway because of conflicts :/ later..