| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| command.setAccessDetail(NetworkElementCommand.ROUTER_IP, routerControlHelper.getRouterControlIp(router.getId())); | ||
| command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); | ||
|
|
||
| // String routerAccessIP = command.getRouterAccessIp(); |
There was a problem hiding this comment.
please remove commented code
Sorry, something went wrong.
| @@ -0,0 +1,43 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
double comment ;)
Sorry, something went wrong.
| @@ -0,0 +1,29 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
nested comment
Sorry, something went wrong.
| @@ -0,0 +1,114 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
nested comment
Sorry, something went wrong.
| @@ -0,0 +1,53 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
nest
Sorry, something went wrong.
| @@ -0,0 +1,30 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
nest
Sorry, something went wrong.
| @@ -0,0 +1,115 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
nest
Sorry, something went wrong.
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| $1 $2 -c 5 |
There was a problem hiding this comment.
so is this inteded for more than just 'ping'? passing $1 seems like it is intended but it is senseless given the script name 'ping_remotely.sh'
Sorry, something went wrong.
| if (origAnswer instanceof ExecuteDiagnosisAnswer) { | ||
| answer = (ExecuteDiagnosisAnswer) origAnswer; | ||
| } else { | ||
| s_logger.warn("Unable to update router " + router.getHostName() + "status"); |
There was a problem hiding this comment.
c&p? I would expect amessage about remote execution
Sorry, something went wrong.
There was a problem hiding this comment.
as a user of this feature, ... ;)
Sorry, something went wrong.
| //////////////// API parameters ///////////////////// | ||
| ///////////////////////////////////////////////////// | ||
| @Parameter(name = ApiConstants.ID, | ||
| description = "The ID of the System VM instance", |
There was a problem hiding this comment.
"... to diagnose" ?
Sorry, something went wrong.
There was a problem hiding this comment.
Addressed
Sorry, something went wrong.
| private Long id; | ||
|
|
||
| @Parameter(name = ApiConstants.IP_ADDRESS, | ||
| description = "Destination IP address to ping", |
There was a problem hiding this comment.
"Destination address IP to test conection to"
Sorry, something went wrong.
There was a problem hiding this comment.
Addressed
Sorry, something went wrong.
| description = "The type of command to be executed inside the System VM instance, e.g. ping, tracert or arping", | ||
| required = true, | ||
| type = CommandType.STRING) | ||
| private String type; |
There was a problem hiding this comment.
how are these validated?
Sorry, something went wrong.
There was a problem hiding this comment.
Using Preconditions with an enum that throws an IllegalArgument exception.
Sorry, something went wrong.
| private String type; | ||
|
|
||
| @Parameter(name = ApiConstants.PARAMS, | ||
| description = "Additional command line options", |
There was a problem hiding this comment.
a little word on how these are processed/used?
Sorry, something went wrong.
There was a problem hiding this comment.
The aim of this was to allow a user to specify optional arguments like they normally would when using the command from the terminal.
If a user passes an Illegal argument for a specific command type, then script execution will fail and stderr will be propagated back as API response
Sorry, something went wrong.
| authorized = RoleType.Admin) | ||
| public class RemoteDiagnosticsCmd extends BaseCmd { | ||
|
|
||
| public static final String APINAME = "remoteDiganosis"; |
There was a problem hiding this comment.
remoteDiagnosis is a better name IMNSHO, but it must coincide with the actual API name
Sorry, something went wrong.
There was a problem hiding this comment.
Changed name to executeDiagnostics following ACS API naming conventions.
Sorry, something went wrong.
| @Override | ||
| public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, | ||
| ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { | ||
| Preconditions.checkState(RemoteDiagnosticsService.DiagnosisType.contains(getType()), "%s is " + |
There was a problem hiding this comment.
as an enum this is not very flexible. consider making it a registry?
Sorry, something went wrong.
There was a problem hiding this comment.
Under consideration.
Sorry, something went wrong.
| @Param(description = "Script execution result") | ||
| private String details; | ||
|
|
||
| @SerializedName(ApiConstants.RESULT) |
There was a problem hiding this comment.
I thought we had discussed return value/exit code instead of success status?
Sorry, something went wrong.
There was a problem hiding this comment.
I have included the exit code to be returned by the python script.
Sorry, something went wrong.
| private Boolean success; | ||
|
|
||
| @SerializedName("command") | ||
| @Param(description = "Command passed to script") |
There was a problem hiding this comment.
this description doesn't tell me what I expect to read here. Is it the exact RemoteDiagnosticsCmd.type? or the cmd line as eventually executed remotely, including the standard and extra parameters, or even path?
Sorry, something went wrong.
There was a problem hiding this comment.
I put this the for debug purposes, I will remove it in the final product. But this is the command line is eventually executed remotely.
E.g. command = ping 8.8.8.8 -c 5
Sorry, something went wrong.
There was a problem hiding this comment.
ok, that might be usefull for an administrator in more elaborate cases as well
Sorry, something went wrong.
There was a problem hiding this comment.
Removed this field in the API response.
Sorry, something went wrong.
| @EntityReference(value = VirtualMachine.class) | ||
| public class RemoteDiagnosticsResponse extends BaseResponse { | ||
| @SerializedName(ApiConstants.DETAILS) | ||
| @Param(description = "Script execution result") |
There was a problem hiding this comment.
this is stdout on remote, right?
Sorry, something went wrong.
There was a problem hiding this comment.
Correct. It represents both stdout and stderr.
Sorry, something went wrong.
There was a problem hiding this comment.
neat code
Sorry, something went wrong.
| @@ -0,0 +1,136 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
still nested comment
Sorry, something went wrong.
There was a problem hiding this comment.
Addressed.
Sorry, something went wrong.
| @@ -0,0 +1,66 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
nested comment
Sorry, something went wrong.
There was a problem hiding this comment.
Addressed
Sorry, something went wrong.
| @@ -0,0 +1,45 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
nested comment
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| public interface RemoteDiagnosticsService { | ||
| RemoteDiagnosticsResponse executeDiagnosisToolInSystemVm(RemoteDiagnosticsCmd cmd) throws AgentUnavailableException, InvalidParameterValueException; | ||
|
|
||
| enum DiagnosisType { |
There was a problem hiding this comment.
I would like to see this as a registry, for instance by means of a comma separated configuration value
Sorry, something went wrong.
There was a problem hiding this comment.
Under consideration
Sorry, something went wrong.
|
|
||
| public static boolean contains(String cmd){ | ||
| try{ | ||
| valueOf(cmd); |
There was a problem hiding this comment.
might we go for ignore case?
Sorry, something went wrong.
There was a problem hiding this comment.
Refactored enum
Sorry, something went wrong.
|
|
||
| public static final String VR_CFG = "vr_cfg.sh"; | ||
|
|
||
| // New script for use by remoteDiagnosis API |
There was a problem hiding this comment.
Are these both to be used? or is this part of a transition?
Sorry, something went wrong.
There was a problem hiding this comment.
Part of transition, final product will make use of a python based script
Sorry, something went wrong.
|
|
||
| import com.cloud.agent.api.Answer; | ||
|
|
||
| public class ExecuteDiagnosisAnswer extends Answer { |
There was a problem hiding this comment.
so this one stuck to the more beautiful name.
Sorry, something went wrong.
There was a problem hiding this comment.
Renamed.
Sorry, something went wrong.
| @@ -0,0 +1,121 @@ | |||
| /* | |||
| * // Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
nested comment
Sorry, something went wrong.
There was a problem hiding this comment.
Addressed
Sorry, something went wrong.
|
|
||
| private static String setupRemoteCommand(String diagnosisType, String destinationIpAddress, String optionalArguments){ | ||
| if (optionalArguments != null){ | ||
| return String.format("%s %s", diagnosisType, destinationIpAddress+" "+optionalArguments); |
There was a problem hiding this comment.
so the optional arguments are always last. for some commands that will exclude options. thought the trend is to allow for any argument on any place in teh command line. This is possible place for augmentation.
Sorry, something went wrong.
There was a problem hiding this comment.
I am working on refactoring this entire method during migration to python based script. I aim at parsing all arguments passed for each command type.
Sorry, something went wrong.
| if (optionalArguments != null){ | ||
| return String.format("%s %s", diagnosisType, destinationIpAddress+" "+optionalArguments); | ||
| } | ||
| return String.format("%s %s", diagnosisType, destinationIpAddress); |
There was a problem hiding this comment.
second occurence of the same string, extract to a constant? for instance named COMMAND_LINE_TEMPLATE.
Sorry, something went wrong.
There was a problem hiding this comment.
Done.
Sorry, something went wrong.
There was a problem hiding this comment.
Please address outstanding issues, let's syncup to discuss some of the items.
Sorry, something went wrong.
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = RemoteDiagnosticsCmd.APINAME, | ||
| since = "4.11", |
There was a problem hiding this comment.
Change since to 4.12.0.0.
Sorry, something went wrong.
There was a problem hiding this comment.
Addressed
Sorry, something went wrong.
| authorized = {RoleType.Admin}) | ||
| public class RemoteDiagnosticsCmd extends BaseCmd { | ||
| private static final Logger s_logger = Logger.getLogger(RemoteDiagnosticsCmd.class); | ||
| public static final String APINAME = "remoteDiganostics"; |
There was a problem hiding this comment.
Fix typo in APINAME to remoteDiagnostics, or consider above ^^
Sorry, something went wrong.
There was a problem hiding this comment.
Amended API command name to executeDiagnostics following CS naming convention.
Sorry, something went wrong.
| ///////////////////////////////////////////////////// | ||
| //////////////// API parameters ///////////////////// | ||
| ///////////////////////////////////////////////////// | ||
| @Parameter(name = ApiConstants.ID, type = CommandType.UUID, required = true, entityType = RemoteDiagnosticsResponse.class, |
There was a problem hiding this comment.
The use of RemoteDiagnosticsResponse could be misleading, let's discuss this issue over syncup.
Sorry, something went wrong.
There was a problem hiding this comment.
This could be UserVmResponse (sort of a hack, as the annotation leads to all the user/system vms), or perhaps SystemVmResponse. You'll need to check if this works.
Sorry, something went wrong.
There was a problem hiding this comment.
UserVmResponse shows guest VM instances only. SystemVmResponse or DomainRouterResponse do not show anything, will revisit and investigate further.
Sorry, something went wrong.
| private Long id; | ||
|
|
||
| @Parameter(name = ApiConstants.IP_ADDRESS, type = CommandType.STRING, required = true, | ||
| description = "Destination IP address to test connection to") |
There was a problem hiding this comment.
Change description to say - IP/address i.e. the address could be an IP or (domain) address.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| private String address; | ||
|
|
||
| @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, required = true, | ||
| description = "The type of diagnostics command to be executed on the System VM instance, e.g. ping, tracert or arping") |
There was a problem hiding this comment.
In the description, instead of giving example, state the current list of comma-separated enums that can be used.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
|
|
||
| from nose.plugins.attrib import attr | ||
|
|
||
| class TestRemoteDiagnosticsInSystemVMs(cloudstackTestCase): |
There was a problem hiding this comment.
I'll review this next time in detail after rest of the code reviews have been addressed.
Sorry, something went wrong.
There was a problem hiding this comment.
Ready for review
Sorry, something went wrong.
| domainid=cls.account.domainid, | ||
| serviceofferingid=cls.service_offering.id | ||
| ) | ||
| cls.cleanup = [ |
There was a problem hiding this comment.
You also want to cleanup the vm that was created.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| def setUp(self): | ||
| self.apiclient = self.testClient.getApiClient() | ||
| self.hypervisor = self.testClient.getHypervisorInfo() | ||
| return |
There was a problem hiding this comment.
No need to return after end of the method. Remove it from here and rest of the methods.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| self.hypervisor = self.testClient.getHypervisorInfo() | ||
| return | ||
|
|
||
| def tearDown(self): |
There was a problem hiding this comment.
You probably want to remove self.cleanup. Also add newline after pass. Run your python file via pep8 or pylint etc.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| 'cloudian': 'Cloudian', | ||
| 'Sioc' : 'Sioc' | ||
| 'Sioc' : 'Sioc', | ||
| 'remoteDiganostics': 'Virtual Machine' |
There was a problem hiding this comment.
Rename as 'Diagnostics': 'Diagnostics'. When you build cloudstack, go to tools/apidocs/target and open the generated html to see how APIs are grouped in sections.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| } | ||
|
|
||
| @Override | ||
| public String getConfigComponentName() { |
There was a problem hiding this comment.
Remove this as well.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| // under the License. | ||
| // | ||
|
|
||
|
|
There was a problem hiding this comment.
Remove extra new line.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| Mockito.when(vmInstanceDao.findByIdTypes(remoteDiagnosticsCmd.getId(), VirtualMachine.Type.ConsoleProxy, | ||
| VirtualMachine.Type.DomainRouter, VirtualMachine.Type.SecondaryStorageVm)).thenReturn(null); | ||
| diagnosticsService.executeDiagnosticsToolInSystemVm(remoteDiagnosticsCmd); | ||
| } |
There was a problem hiding this comment.
Mock and check the answer
Sorry, something went wrong.
| return cmd | ||
|
|
||
| else: | ||
| return cmd + " -c 4" |
There was a problem hiding this comment.
Default options for each type/command.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| @@ -0,0 +1,173 @@ | |||
| # Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
Simplify/Rename the file to test_diagnostics.py
Sorry, something went wrong.
There was a problem hiding this comment.
Renamed file.
Sorry, something went wrong.
There was a problem hiding this comment.
biggest comment is the that logging of exceptions is usually done on catching and not before throwing. lot's of comments, nothing lethal, though
Sorry, something went wrong.
| public DiagnosticsType getType() { | ||
| DiagnosticsType diagnosticsType = DiagnosticsType.getCommand(type); | ||
| if (diagnosticsType == null) { | ||
| LOGGER.warn("An Invalid diagnostics command type passed: " + type); |
There was a problem hiding this comment.
I don't think you need to log this here as you are throwing it and it will be caught and logged elsewhere
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| public String getOptionalArguments() { | ||
| final String EMPTY_STRING = ""; | ||
|
|
||
| if (optionalArguments == null || optionalArguments.isEmpty()) { |
There was a problem hiding this comment.
I do this a lot as well, but it's better to use CollectionUtils.isEmpty()
Sorry, something went wrong.
There was a problem hiding this comment.
There is not much difference in terms of performance, but adopted since it provides cleaner code
Sorry, something went wrong.
| final Pattern pattern = Pattern.compile(regex); | ||
| final boolean hasInvalidChar = pattern.matcher(optionalArguments).find(); | ||
| if (!hasInvalidChar) { | ||
| LOGGER.error("An Invalid character has been passed as an optional parameter"); |
There was a problem hiding this comment.
again, you don't need to log what you throw. In this case I would include the offensive parameter for convenience of the operator.
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved
Sorry, something went wrong.
| response.setStdout(answerMap.get("STDOUT")); | ||
| response.setStderr(answerMap.get("STDERR")); | ||
| response.setExitCode(answerMap.get("EXITCODE")); | ||
| response.setResult(answerMap.get("SUCCESS")); |
There was a problem hiding this comment.
as discussed: considder not returning success but only exitcode.
Sorry, something went wrong.
There was a problem hiding this comment.
Removed success return
Sorry, something went wrong.
| response.setStderr(answerMap.get("STDERR")); | ||
| response.setExitCode(answerMap.get("EXITCODE")); | ||
| response.setResult(answerMap.get("SUCCESS")); | ||
| response.setObjectName("diagnostics"); |
There was a problem hiding this comment.
should the name contain some noun or verb indicating that it contains the resiult of a test/diagnostic command-run?
Sorry, something went wrong.
There was a problem hiding this comment.
maybe involve Paul in that discussion
Sorry, something went wrong.
There was a problem hiding this comment.
Changed it to diagnostics results
Sorry, something went wrong.
| import com.cloud.utils.db.TransactionLegacy; | ||
| import com.cloud.utils.exception.CloudRuntimeException; | ||
| import com.cloud.vm.VirtualMachine.PowerState; | ||
| import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; |
There was a problem hiding this comment.
if only the order of imports has changed you better revert this
Sorry, something went wrong.
There was a problem hiding this comment.
Done
Sorry, something went wrong.
| import com.cloud.utils.component.Manager; | ||
| import com.cloud.vm.VirtualMachine.PowerState; | ||
|
|
||
| import java.util.HashMap; |
There was a problem hiding this comment.
if only the order of imports has changed you better revert this
Sorry, something went wrong.
There was a problem hiding this comment.
Done
Sorry, something went wrong.
| final VMInstanceVO vmInstance = instanceDao.findByIdTypes(vmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.DomainRouter, VirtualMachine.Type.SecondaryStorageVm); | ||
|
|
||
| if (vmInstance == null) { | ||
| LOGGER.error("Invalid system vm id provided " + vmId); |
There was a problem hiding this comment.
both logging and throwing is not needed, also you would use a single string object to use for both ;)
Sorry, something went wrong.
| final Long hostId = vmInstance.getHostId(); | ||
|
|
||
| if (hostId == null) { | ||
| LOGGER.warn("Unable to find host for virtual machine instance: " + vmInstance.getInstanceName()); |
There was a problem hiding this comment.
if you throw an exception it is at least an error, not a warning.
you can reuse one string for both
is it really needed to bot log and throw?
Sorry, something went wrong.
| throw new CloudRuntimeException("Failed to execute diagnostics command: " + answer.getDetails()); | ||
| } | ||
| } catch (OperationTimedoutException e) { | ||
| LOGGER.warn("Timed Out", e); |
There was a problem hiding this comment.
a warning should be an error that can be handled. throwing and warning seem kind of contradictory
Sorry, something went wrong.
| final DiagnosticsCommand command = new DiagnosticsCommand(cmdType, cmdAddress, optionalArguments); | ||
| command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, vmInstance.getInstanceName()); | ||
| command.setAccessDetail(NetworkElementCommand.ROUTER_IP, routerControlHelper.getRouterControlIp(vmInstance.getId())); | ||
| //command.setAccessDetail(NetworkElementCommand.ROUTER_IP, routerControlHelper.getRouterControlIp(vmInstance.getId())); |
There was a problem hiding this comment.
remove comment in code please, git can get it back for you!
Sorry, something went wrong.
| final DataCenterVO dcVo = dataCenterDao.findById(vmInstanceVO.getDataCenterId()); | ||
| String controlIP = null; | ||
|
|
||
| // if(vmInstanceVO.getHypervisorType() == Hypervisor.HypervisorType.VMware && dcVo.getNetworkType() == DataCenter.NetworkType.Basic ){ |
There was a problem hiding this comment.
please remove this comment. it has no value
Sorry, something went wrong.
| final DiagnosticsCommand command = new DiagnosticsCommand(cmdType, cmdAddress, optionalArguments, vmManager.getExecuteInSequence(vmInstance.getHypervisorType())); | ||
|
|
||
| if (vmInstance.getType() == VirtualMachine.Type.DomainRouter) { | ||
| command.setAccessDetail(NetworkElementCommand.ROUTER_IP, routerControlHelper.getRouterControlIp(vmInstance.getId())); |
There was a problem hiding this comment.
Remove the if-else block and replace by something like this:
networkManager.getSystemVMAccessDetails(vm). To use network manager, try something like:
@Inject
private NetworkOrchestrationService networkManager;
Sorry, something went wrong.
There was a problem hiding this comment.
Resolved, solution implemented and tested on VMware, KVM and Xenserver
Sorry, something went wrong.
| command.setAccessDetail(NetworkElementCommand.ROUTER_IP, nicVO.getIPv4Address()); | ||
| } | ||
| command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, vmInstance.getInstanceName()); | ||
| // if (vmInstance.getType() == VirtualMachine.Type.DomainRouter) { |
There was a problem hiding this comment.
After testing, the commented code can be removed.
Sorry, something went wrong.
There was a problem hiding this comment.
Changes requested.
Sorry, something went wrong.
| 'cloudian': 'Cloudian', | ||
| 'Sioc' : 'Sioc' | ||
| 'Sioc' : 'Sioc', | ||
| 'Diagnostics': 'Diagnostics' |
There was a problem hiding this comment.
You can put the API under Misc, unless you think more APIs are going to join this section in apidocs.
Sorry, something went wrong.
There was a problem hiding this comment.
I anticipate the retrieveDiagnostics API to grouped together with the Remote Diagnostics within the same section viz. Diagnostics in the apidocs.
Sorry, something went wrong.
| ) | ||
|
|
||
| # Validate Traceroute command execution with a non-existent/pingable IP address | ||
| cmd.ipaddress = '999.9999.9999.9999.9999' |
There was a problem hiding this comment.
try to pass a valid but unreachable IPv4 ip see https://stackoverflow.com/questions/10456044/what-is-a-good-invalid-ip-address-to-use-for-unit-tests
Make changes to other related invalid ips you've used. Ideally, each + and - test should be a separate test case.
Sorry, something went wrong.
There was a problem hiding this comment.
Changes made, using IP address 192.0.2.2 for the - test case. Also separated the + and - test cases for the ping command.
Sorry, something went wrong.
| return_code = 127 | ||
|
|
||
| finally: | ||
| print('%s}' % stdout.strip()) |
There was a problem hiding this comment.
Improve prefix/container for stdout and stderr with something like STDOUT{%value here}, STDERR{%value here}. Don't assume that closing brace } may not be part of stdout or stderr.
Sorry, something went wrong.
There was a problem hiding this comment.
Change, using && for parsing
Sorry, something went wrong.
There was a problem hiding this comment.
This leads to this: exitcode = EXITCODE: {0}
Will parse the details as {} without the preceding STDERR/STDOUT/EXITCODE.
The key values are already provided by/in the API response class.
Sorry, something went wrong.
| @InjectMocks | ||
| private DiagnosticsServiceImpl diagnosticsService = new DiagnosticsServiceImpl(); | ||
|
|
||
|
|
There was a problem hiding this comment.
Remove extra newline.
Sorry, something went wrong.
There was a problem hiding this comment.
Done
Sorry, something went wrong.
|
|
||
| @Before | ||
| public void setUp() throws Exception { | ||
|
|
There was a problem hiding this comment.
Remove setUp if you're not doing anything.
Sorry, something went wrong.
|
|
||
| @EntityReference(value = VirtualMachine.class) | ||
| public class ExecuteDiagnosticsResponse extends BaseResponse { | ||
| @SerializedName("STDOUT") |
There was a problem hiding this comment.
lowercase the api response keys to stdout, stderr, exitcode.
Sorry, something went wrong.
There was a problem hiding this comment.
Use api constant class for them, perhaps use the same keys in the class where the details map is created.
Sorry, something went wrong.
There was a problem hiding this comment.
Done
Sorry, something went wrong.
| try { | ||
| final Map<String, String> answerMap = diagnosticsService.runDiagnosticsCommand(this); | ||
| if (answerMap != null || !answerMap.isEmpty()) { | ||
| response.setStdout(answerMap.get("STDOUT")); |
There was a problem hiding this comment.
Change the .get() to get based on a known constant than a hardcoded string like STDOUT, STDERR and EXITCODE.
Sorry, something went wrong.
There was a problem hiding this comment.
Done
Sorry, something went wrong.
| final String EMPTY_STRING = ""; | ||
|
|
||
| if (optionalArguments == null || optionalArguments.isEmpty()) { | ||
| return EMPTY_STRING; |
There was a problem hiding this comment.
Return "" is fine, than declare a variable and return that.
Sorry, something went wrong.
There was a problem hiding this comment.
Done
Sorry, something went wrong.
| final String regex = "^[\\w\\-\\s]+$"; | ||
| final Pattern pattern = Pattern.compile(regex); | ||
| final boolean hasInvalidChar = pattern.matcher(optionalArguments).find(); | ||
| if (!hasInvalidChar) { |
There was a problem hiding this comment.
Write +/- unit tests for this validation method.
Sorry, something went wrong.
There was a problem hiding this comment.
Done
Sorry, something went wrong.
| since = "4.12.0.0") | ||
| public class ExecuteDiagnosticsCmd extends BaseCmd { | ||
| private static final Logger LOGGER = Logger.getLogger(ExecuteDiagnosticsCmd.class); | ||
| public static final String APINAME = "executeDiagnostics"; |
There was a problem hiding this comment.
Can you consider renaming this to runDiagnostics. Ignore if already discussed with Paul and others.
Sorry, something went wrong.
There was a problem hiding this comment.
At this point, might be a bit late. It would require redoing and testing a lot of things i.e unit/marvin test cases etc.
Sorry, something went wrong.
There was a problem hiding this comment.
Please address outstanding issues, then close this PR and send this to apache/cloudstack as a community PR.
Sorry, something went wrong.
There was a problem hiding this comment.
I have resolved all the comments
Sorry, something went wrong.
* NSX integration - skeletal code * Fix module not loading on startup * add upgrade path and daos \n add nsx controller command * add support for adding and listing nsx provider to a zone * add license * add default VPC offering and update upgrade path * add global setting to enable nsx plugin * add delete nsx controller operation * add nsxresource * add NSX resource , api client, create tier1 gw * update db * update response and add license * Add support to create and delete nsx tier-1 gateway * add license * cleanup and add skeletal code for network creation * add create/delete segment and UI integration * add license * address code smells - part 1 * fix test / build failure * NSX integration - skeletal code * Fix module not loading on startup * add upgrade path and daos \n add nsx controller command * add support for adding and listing nsx provider to a zone * add license * add default VPC offering and update upgrade path * add global setting to enable nsx plugin * add delete nsx controller operation * add nsxresource * add NSX resource , api client, create tier1 gw * update db * update response and add license * Add support to create and delete nsx tier-1 gateway * add license * cleanup and add skeletal code for network creation * add create/delete segment and UI integration * add license * address code smells - part 1 * fix test / build failure * add ui changes + update nsx_provider table transport zones + use NSX broadcast domain for add nics to router * ui: fix password field, and backend changes * add route advertisement * update offering * update offering * add sleep before deletion of vpc / tier g/w for ports to be removed * move creation of segments to design phase * change provider to VPC router for Dhcp & dns service in an nsx offering * Add public nic for NSX * reserve first IP (after g/w) of subnet for router nic - NSX * revert reserving 1st IP in vpc segments * [NSX] Create a DHCP relay and add it to a VPC tier segment (#107) * Create DHCP relay command and execute request * In progress integrate with networking * Create DHCP relay config on the network VR allocation * Revert domain router dao changes * Create DHCP relay con VR nic plug to NSX network * Link DHCP relay config to segment after creation * [NSX] Cleanup DHCP Relay config on segment deletion (#108) * Cleanup DHCP Relay config on segment deletion * update segment & relay name generators and call delete dhcprelay after deletion of segment * address comment * [NSX] Fix DHCP relay config deletion was missing zone name (apache#8068) * [NSX] Refactor API wrapper operations (apache#8059) * [NSX] Refactor API wrapper operations * Big refactor * Address review comment * change network cidr to cidr to prevent NPE * add domain and zone names to the various networks - vpc & tier --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> * Nsx unit tests (apache#8090) * Add tests * add test for NsxGuestNetworkGuru * add unit tests for NsxResource * add unti tests for NsxElement * cleanup * [NSX] Refactor API wrapper operations * update tests * update tests - add nsxProviderServiceImpl test * add unit test - NsxServiceImpl * add license * Big refactor * Address review comment * change network cidr to cidr to prevent NPE * add domain and zone names to the various networks - vpc & tier * fix tests --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * modify NSX resource naming convention (apache#8095) * modify NSX resource naming convention * remove unused imports * add a setup phase between desgin and implementation of a network for intermediary steps * add method to all classes * NSX: Refactor Network & VPC offering (apache#8110) * [NSX] Refactor API wrapper operations * Network offering changes for NSX * fix services and provider combination * address comments: rename param * update nsx_mode parameter --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * fix test * [NSX] Allow NSX isolated networks (apache#8132) * Add network offerings for NSX on isolated networks * Fix offerings creation * In progress NSX isolated network * Fixes * Fix NIC allocation to router * NSX: Add Step for Adding Public traffic network for NSX During zone creation (apache#8126) * NSX: Add Step for Adding Public traffic network for NSX * address comments and cleanup * address comment * remove indent * NSX: Create and Delete static NAT & Port forward rules (apache#8131) * NSX: Create and delete NSX Static Nat rules * fix issues with static nat * add static nat * Support to add and delete Port forward rules * add license * fix adding multiple pf rules * cleanup * fix lint check * fix smoke tests * fix smoke tests * Nsx add lb rule (apache#8161) * NSX: Create and delete NSX Static Nat rules * fix issues with static nat * add static nat * Support to add and delete Port forward rules * add license * fix adding multiple pf rules * cleanup * NSX: Add support to create and delete Load balancer rules * fix deletion of lb rules * add header file and update protocol detail * build failure fix * [NSX] Add SNAT support (apache#8100) * In progress add source NAT * Fix after merge * Fix tests * Fix NPE on isolated network deletion * Reserve source NAT IP when its not passed for NSX VPC * Create source NAT rule on VR NIC allocation * Fix update VPC and remove VPC to update and remove SNAT rule * Fix packaging * Address review comment * Fix build * fix build - unused import * Add defensive checks * Add missing design to NSX public guru --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> * NSX: Fix VR public NIC allocation (apache#8166) * NSX: fix LB member addition and deletion and add defensive checks (apache#8167) * Fix public NIC NPE on broadcast URI * NSX: Router Public nic to get IP from systemVM Ip range (apache#8172) * NSX: Router Public nic to get IP from systemVM Ip range * Fix VR IP address and setSourceNatIp command * NSX: hide systemVM reserved IP range SourceNAT * fix test --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * fix test failure * test failure fix * [NSX] Fix update source NAT IP (apache#8176) * [NSX] Fix update source NAT IP * Fix startup * Fix API result * NSX - add LB route Advertizement (apache#8192) * [NSX] Add ACL types support (apache#8224) * NSX: Create segment group on segment creation * Add unit tests * Remove group for segment before removing segment * Create Distributed Firewall rules * Remove distributed firewall policy on segment deletion * Fix policy rule ID and add more unit tests * Fix DROP action rules and transform tests * Add new ACL rules * Fixes * associate security policies with groups and not to DFW and add deletion of rules * Fix name convention --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> * NSX: Fix creation of VPCs (apache#8320) * Fix ACL rules creation (apache#8323) * [NSX] Fix database views (apache#8325) * NSX: Add CKS Support & Firewall rules for Isolated Networks (apache#8189) * NSX: Add ALL LB IP to the list of route advertisements in tier1 * NSX: Support Source NAT on NSX Isolated networks * NSX: Cks Support * NSX: Create segment group on segment creation * Add unit tests * Remove group for segment before removing segment * Create Distributed Firewall rules * Remove distributed firewall policy on segment deletion * Fix policy rule ID and add more unit tests * Add support for routed NSX Isolated networks \n and non RFC 1918 compliant IPs * Add support for routed NSX Isolated networks \n and non RFC 1918 compliant IPs * Add Firewall rules * build failure - fix unit test * fix npes * Add support to delete firewall rules * update nsx cks offering * add license * update order of ports in PF & FW rules * fix filter for getting transport zones * CKS support changed - MTU updated, etc * add LB for CKS on VPC * address comments * adapt upstream cks logic for vpc * rever mtu hack * update UI changes as per upstream fix * change display test for CKS n/w offerings for isolated and VPC tiers * add extra line for linter * address comment * revert list change --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * fix ui build failure * [NSX] Address SonarCloud Bugs (apache#8341) * [NSX] Address SonarCloud Bugs * Fix NSX API connection issues * NSX: Add unit tests to increase coverage (apache#8355) * NSX: Add unit tests * cleanup unused imports * add more unit tests * add tests for publicnsxnetworkguru * add license * fix build failures * address sonar comment * fix security hotspots * NSX: Add more unit tests (apache#8381) * NSX : Unit tests * remove unused imports * remove unused import causing build failure * fix build failures due to unused imports * fix build failure * fix test assertion * remove unused imports * remove unused import * Nsx UI zone bug (apache#8398) * NSX: Attempt to fix NSX Zone creation bug for public networks * fix zone wizard public traffic issue * add proper filtering of offerings based on VPC nsx mode * clean up console logs * NSX: Fix code smells and reported bugs (apache#8409) * NSX: Fix code smells and reported bugs * fox override issue * remove unused imports * fix test * refactor code to reduce complexity * add lisence * cleanup * fix build failure * fix build failure * address comments * test - add config to ignore certain files from test coverage * test exclusion of classes from test cov * rever pom changes * [NSX] Add more unit tests (apache#8431) * [NSX] Add more unit tests * More tests * Fix build errors * NSX: Prevent creation of L2 and Shared networks for NSX (apache#8463) * NSX: Prevent creation of L2 and Shared networks for NSX * add checks to backend to prevent creation of l2 and shared networks in nsx zones and filter only nsx offerings when creating isolated networks * cleanup * NSX: Fix code smells (apache#8436) * NSX: Fix code smells * Add changes to service creation logic * CKS: Add action to during firewall rule creation (apache#8498) * NSX,UI: Deduplicate network list when creating kubernetes clusters (apache#8513) * NSX: Make LB service selectable in network offering (apache#8512) * NSX: Make LB service selectable in network offering * fix label * address comments * address comments * NSX: Add appropriate error message when icmp type is set to -1 for NSX (apache#8504) * NSX: Add appropriate error message when icmp type is set to -1 for NSX * address comments * update text * fix test * fix test - build failure * fix test - build failure * NSX: Cleanup NSX resources during k8s cluster cleanup (apache#8528) * fix test failure * NSX: Improve segment deletion process (apache#8538) * NSX: Add passive monitor for NSX LB to test whether a server is available (apache#8533) * NSX: Add passive monitor for NSX LB to test whether a server is available * Add active monitors too * fix build failure * NSX: Add check for ICMP code / type for NSX zones (apache#8542) * NSX: Fix Routed Mode for Isolated and VPC networks (apache#8534) * NSX: Fix Routed Mode for Isolated and VPC networks * NSX: Fix Routed mode - add checks for ports added for FW rules * clean up code * fix build failure * NSX: Add retry logic with sleep to delete segments (apache#8554) * NSX: Add retry logic with sleep to delete segments * add logs * NSX: Fix custom ACL check (#2) * NSX: Fix custom ACL check * NSX: Fix custom ACL check * Nsx vpc routed mode (#5) * NSX: Fix VPC routed mode * NSX: VPC route mode * remove unnecessary changes * Nsx: Support internal LB (#4) * NSX: Support internal LB service in NSX * add lb removal logic * Fix UI issue hiding internal LB tab * Refactor method name --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * NSX: Improve NSX resource cleanup process (#3) * Fix unit test * NSX: Add SourceNAT service to the default Routed offering for VPC (#13) * Fix VPC restart with cleanup (#12) * NSX: Fix ACL rule removal on replacement and fix rule order (#11) * NSX: fix smoke test failure for ACLs (#9) * Fix unit tests * Fix NSX plugin pom XML * NSX: Add support to re-order ACL rules (NSX FW rules) (#14) * [WIP] NSX: Add support to re-order ACL rules (NSX FW rules) * fix reordering of acl rules on all networks that it is associated to * clean up and attempt test fix * Fix tests * Remove unused import * tweak reorder logic --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Fix zone creation issue for internal load balancer * Fix * Fix unit test * fix logger * fix logger * fix logger * NSX: Fix VPC form to ignore source NAT IP when creating VPCs and fix label * Move SQL changes to the newest schema file * NSX: Last Fixes * Fix build --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com>
| Back | FazBrowse Home | New Git URL |
Description
This a new feature for CloudStack to provide functionality for the admin user to execute network-utility commands (ping, traceroute, arping) directly on the system VMs. The initial scope is for a Root Admin using this tools with VR, SSVM and the CPVM.
FS: https://cwiki.apache.org/confluence/display/CLOUDSTACK/CloudStack+Remote+Diagnostics+API
Types of changes
Checklist:
Testing