forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 7
[WIP] Additional VM config (for review) #17
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
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9fb36e7
db: Update Apache DBCP version (#2718)
nvazquez 2936cb3
Fix typo in VirtualMachineManagerImpl.java (#2738)
GabrielBrascher 4a5fab0
packaging: Catch error in packaging script and fail the build (#2649)
khos2ow 07042a6
travis: Enhance Travis to do packaging jobs on different stage (#2640)
khos2ow 40af32b
diagnostics: new diagnostics admin API for system VMs (#2721)
d0c6cac
[CLOUDSTACK-9261] Upgrate jQuery-UI to 1.11 (JQuery UI 1.8.4 prone to…
rafaelweingartner 73608de
Support multiple volume access groups per compute cluster
99bc0e6
Merge pull request #2503 from mike-tutkowski/multi-sf-vags
38d0274
check volumes for state when retrieving pool for configDrive creation…
DaanHoogland 94dedd6
Refactor userVmDetailsDao field and remove unusued fields (#2750)
70bd177
Fix concurrency problem when moving ACL rules with drag&drop (#2703)
rafaelweingartner a6e0204
fix provisionCertificate api returns NPE when 'reconnect' parameter i…
1ccb32f
security_group: Use execute() function instead of non-existing bash()…
wido 781d6bc
register template kvm context ui fix (#2757)
ernjvr c3ff356
Merge release branch 4.11 to master
a21ebb1
api: remove empty response parameters (#2751)
marcaurele 756a7e8
Fix limitation on tag matching in 'migrateVolume' with disk offering …
rafaelweingartner d044870
Add extra parameter to accept additional configuration during VM depl…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
api/src/main/java/org/apache/cloudstack/api/command/admin/diagnostics/RunDiagnosticsCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| // 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.diagnostics; | ||
|
|
||
| import com.cloud.exception.InsufficientCapacityException; | ||
| import com.cloud.exception.ResourceUnavailableException; | ||
| import com.cloud.user.Account; | ||
| import com.cloud.vm.VirtualMachine; | ||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiArgValidator; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.ApiErrorCode; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.response.RunDiagnosticsResponse; | ||
| import org.apache.cloudstack.api.response.SystemVmResponse; | ||
| import org.apache.cloudstack.context.CallContext; | ||
| import org.apache.cloudstack.diagnostics.DiagnosticsService; | ||
| import org.apache.cloudstack.diagnostics.DiagnosticsType; | ||
| import org.apache.commons.collections.CollectionUtils; | ||
| import org.apache.log4j.Logger; | ||
|
|
||
| import javax.inject.Inject; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
|
|
||
| @APICommand(name = RunDiagnosticsCmd.APINAME, responseObject = RunDiagnosticsResponse.class, entityType = {VirtualMachine.class}, | ||
| responseHasSensitiveInfo = false, | ||
| requestHasSensitiveInfo = false, | ||
| description = "Execute network-utility command (ping/arping/tracert) on system VMs remotely", | ||
| authorized = {RoleType.Admin}, | ||
| since = "4.12.0.0") | ||
| public class RunDiagnosticsCmd extends BaseCmd { | ||
| private static final Logger LOGGER = Logger.getLogger(RunDiagnosticsCmd.class); | ||
| public static final String APINAME = "runDiagnostics"; | ||
|
|
||
| @Inject | ||
| private DiagnosticsService diagnosticsService; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| //////////////// API parameters ///////////////////// | ||
| ///////////////////////////////////////////////////// | ||
| @Parameter(name = ApiConstants.TARGET_ID, type = CommandType.UUID, required = true, entityType = SystemVmResponse.class, | ||
| validations = {ApiArgValidator.PositiveNumber}, | ||
| description = "The ID of the system VM instance to diagnose") | ||
| private Long id; | ||
|
|
||
| @Parameter(name = ApiConstants.IP_ADDRESS, type = CommandType.STRING, required = true, | ||
| validations = {ApiArgValidator.NotNullOrEmpty}, | ||
| description = "The IP/Domain address to test connection to") | ||
| private String address; | ||
|
|
||
| @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, required = true, | ||
| validations = {ApiArgValidator.NotNullOrEmpty}, | ||
| description = "The system VM diagnostics type valid options are: ping, traceroute, arping") | ||
| private String type; | ||
|
|
||
| @Parameter(name = ApiConstants.PARAMS, type = CommandType.STRING, | ||
| authorized = {RoleType.Admin}, | ||
| description = "Additional command line options that apply for each command") | ||
| private String optionalArguments; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////////// Accessors /////////////////////// | ||
| ///////////////////////////////////////////////////// | ||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public String getAddress() { | ||
| return address; | ||
| } | ||
|
|
||
| public DiagnosticsType getType() { | ||
| DiagnosticsType diagnosticsType = DiagnosticsType.getCommand(type); | ||
| if (diagnosticsType == null) { | ||
| throw new IllegalArgumentException(type + " Is not a valid diagnostics command type. "); | ||
| } | ||
| return diagnosticsType; | ||
| } | ||
|
|
||
| public String getOptionalArguments() { | ||
| return optionalArguments; | ||
| } | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////////// Implementation ////////////////// | ||
| ///////////////////////////////////////////////////// | ||
| @Override | ||
| public String getCommandName() { | ||
| return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; | ||
| } | ||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| Account account = CallContext.current().getCallingAccount(); | ||
| if (account != null) { | ||
| return account.getId(); | ||
| } | ||
| return Account.ACCOUNT_ID_SYSTEM; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException { | ||
| RunDiagnosticsResponse response = new RunDiagnosticsResponse(); | ||
| try { | ||
| final Map<String, String> answerMap = diagnosticsService.runDiagnosticsCommand(this); | ||
| if (CollectionUtils.isNotEmpty(Collections.singleton(answerMap))) { | ||
| response.setStdout(answerMap.get(ApiConstants.STDOUT)); | ||
| response.setStderr(answerMap.get(ApiConstants.STDERR)); | ||
| response.setExitCode(answerMap.get(ApiConstants.EXITCODE)); | ||
| response.setObjectName("diagnostics"); | ||
| response.setResponseName(getCommandName()); | ||
| this.setResponseObject(response); | ||
| } | ||
| } catch (final ServerApiException e) { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
do we need this boolean if there is a string (that could be null)?
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.
Thanks for spotting that, it seems redundant since I do not use it anywhere just yet and maybe should be removed during code refactoring. This is basically an initial implementation to test the MVP.