Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api/src/main/java/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public class EventTypes {
public static final String EVENT_ROUTER_REBOOT = "ROUTER.REBOOT";
public static final String EVENT_ROUTER_HA = "ROUTER.HA";
public static final String EVENT_ROUTER_UPGRADE = "ROUTER.UPGRADE";
public static final String EVENT_ROUTER_DIAGNOSTICS = "ROUTER.DIAGNOSTICS";

// Console proxy
public static final String EVENT_PROXY_CREATE = "PROXY.CREATE";
Expand All @@ -113,6 +114,7 @@ public class EventTypes {
public static final String EVENT_PROXY_STOP = "PROXY.STOP";
public static final String EVENT_PROXY_REBOOT = "PROXY.REBOOT";
public static final String EVENT_PROXY_HA = "PROXY.HA";
public static final String EVENT_PROXY_DIAGNOSTICS = "PROXY.DIAGNOSTICS";

// VNC Console Events
public static final String EVENT_VNC_CONNECT = "VNC.CONNECT";
Expand Down Expand Up @@ -266,6 +268,7 @@ public class EventTypes {
public static final String EVENT_SSVM_STOP = "SSVM.STOP";
public static final String EVENT_SSVM_REBOOT = "SSVM.REBOOT";
public static final String EVENT_SSVM_HA = "SSVM.HA";
public static final String EVENT_SSVM_DIAGNOSTICS = "SSVM.DIAGNOSTICS";

// Service Offerings
public static final String EVENT_SERVICE_OFFERING_CREATE = "SERVICE.OFFERING.CREATE";
Expand Down Expand Up @@ -584,6 +587,9 @@ public class EventTypes {
public static final String EVENT_TEMPLATE_DIRECT_DOWNLOAD_FAILURE = "TEMPLATE.DIRECT.DOWNLOAD.FAILURE";
public static final String EVENT_ISO_DIRECT_DOWNLOAD_FAILURE = "ISO.DIRECT.DOWNLOAD.FAILURE";

// Diagnostics Events
public static final String EVENT_SYSTEM_VM_DIAGNOSTICS = "SYSTEM.VM.DIAGNOSTICS";

static {

// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
Expand Down Expand Up @@ -612,6 +618,7 @@ public class EventTypes {
entityEventDetails.put(EVENT_ROUTER_REBOOT, VirtualRouter.class);
entityEventDetails.put(EVENT_ROUTER_HA, VirtualRouter.class);
entityEventDetails.put(EVENT_ROUTER_UPGRADE, VirtualRouter.class);
entityEventDetails.put(EVENT_ROUTER_DIAGNOSTICS, VirtualRouter.class);

entityEventDetails.put(EVENT_PROXY_CREATE, VirtualMachine.class);
entityEventDetails.put(EVENT_PROXY_DESTROY, VirtualMachine.class);
Expand All @@ -620,6 +627,7 @@ public class EventTypes {
entityEventDetails.put(EVENT_PROXY_REBOOT, VirtualMachine.class);
entityEventDetails.put(EVENT_ROUTER_HA, VirtualMachine.class);
entityEventDetails.put(EVENT_PROXY_HA, VirtualMachine.class);
entityEventDetails.put(EVENT_PROXY_DIAGNOSTICS, VirtualMachine.class);

entityEventDetails.put(EVENT_VNC_CONNECT, "VNC");
entityEventDetails.put(EVENT_VNC_DISCONNECT, "VNC");
Expand Down Expand Up @@ -740,6 +748,7 @@ public class EventTypes {
entityEventDetails.put(EVENT_SSVM_STOP, VirtualMachine.class);
entityEventDetails.put(EVENT_SSVM_REBOOT, VirtualMachine.class);
entityEventDetails.put(EVENT_SSVM_HA, VirtualMachine.class);
entityEventDetails.put(EVENT_SSVM_DIAGNOSTICS, VirtualMachine.class);

// Service Offerings
entityEventDetails.put(EVENT_SERVICE_OFFERING_CREATE, ServiceOffering.class);
Expand Down Expand Up @@ -977,6 +986,7 @@ public class EventTypes {

entityEventDetails.put(EVENT_TEMPLATE_DIRECT_DOWNLOAD_FAILURE, VirtualMachineTemplate.class);
entityEventDetails.put(EVENT_ISO_DIRECT_DOWNLOAD_FAILURE, "Iso");
entityEventDetails.put(EVENT_SYSTEM_VM_DIAGNOSTICS, VirtualMachine.class);
}

public static String getEntityForEvent(String eventName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@
// 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 java.util.Collections;
import java.util.Map;

import javax.inject.Inject;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.acl.SecurityChecker;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
Expand All @@ -36,17 +41,19 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;

import javax.inject.Inject;
import java.util.Collections;
import java.util.Map;
import com.cloud.event.EventTypes;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.vm.VirtualMachine;

@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 {
public class RunDiagnosticsCmd extends BaseAsyncCmd {
private static final Logger LOGGER = Logger.getLogger(RunDiagnosticsCmd.class);
public static final String APINAME = "runDiagnostics";

Expand All @@ -56,6 +63,7 @@ public class RunDiagnosticsCmd extends BaseCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@ACL(accessType = SecurityChecker.AccessType.OperateEntry)
@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")
Expand Down Expand Up @@ -116,6 +124,34 @@ public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}

@Override
public String getEventType() {
VirtualMachine.Type vmType = _entityMgr.findById(VirtualMachine.class, getId()).getType();
String eventType = "";
switch (vmType) {
case ConsoleProxy:
eventType = EventTypes.EVENT_PROXY_DIAGNOSTICS;
break;
case SecondaryStorageVm:
eventType = EventTypes.EVENT_SSVM_DIAGNOSTICS;
break;
case DomainRouter:
eventType = EventTypes.EVENT_ROUTER_DIAGNOSTICS;
break;
}
return eventType;
}

@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.SystemVm;
}

@Override
public String getEventDescription() {
return "Executing diagnostics on system vm: " + this._uuidMgr.getUuid(VirtualMachine.class, getId());
}

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException {
RunDiagnosticsResponse response = new RunDiagnosticsResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@
// under the License.
package org.apache.cloudstack.diagnostics;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import javax.inject.Inject;

import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.routing.NetworkElementCommand;
import com.cloud.event.ActionEvent;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.utils.component.ManagerBase;
Expand All @@ -34,12 +43,6 @@
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.log4j.Logger;

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

public class DiagnosticsServiceImpl extends ManagerBase implements PluggableService, DiagnosticsService {
private static final Logger LOGGER = Logger.getLogger(DiagnosticsServiceImpl.class);

Expand All @@ -53,6 +56,7 @@ public class DiagnosticsServiceImpl extends ManagerBase implements PluggableServ
private NetworkOrchestrationService networkManager;

@Override
@ActionEvent(eventType = EventTypes.EVENT_SYSTEM_VM_DIAGNOSTICS, eventDescription = "running diagnostics on system vm", async = true)
public Map<String, String> runDiagnosticsCommand(final RunDiagnosticsCmd cmd) {
final Long vmId = cmd.getId();
final String cmdType = cmd.getType().getValue();
Expand Down
8 changes: 8 additions & 0 deletions ui/css/cloudstack3.css
Original file line number Diff line number Diff line change
Expand Up @@ -12862,6 +12862,14 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it
background-position: -168px -613px;
}

.diagnostics .icon {
background-position: -165px -122px;
}

.diagnostics:hover .icon {
background-position: -165px -704px;
}

.enableOutOfBandManagement .icon {
background-position: -138px -65px;
}
Expand Down
7 changes: 7 additions & 0 deletions ui/l10n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ var dictionary = {
"label.action.restore.instance.processing":"Restoring Instance....",
"label.action.revert.snapshot":"Revert to Snapshot",
"label.action.revert.snapshot.processing":"Reverting to Snapshot...",
"label.action.run.diagnostics":"Run Diagnostics",
"label.action.secure.host":"Provision Host Security Keys",
"label.action.start.instance":"Start Instance",
"label.action.start.instance.processing":"Starting Instance....",
Expand Down Expand Up @@ -1484,6 +1485,9 @@ var dictionary = {
"label.rule.number":"Rule Number",
"label.rule.number.short": "#Rule",
"label.rules":"Rules",
"label.run.diagnostics.type":"Type",
"label.run.diagnostics.destination":"Destination",
"label.run.diagnostics.extra":"Extra Arguments",
"label.running.vms":"Running VMs",
"label.s3.access_key":"Access Key",
"label.s3.bucket":"Bucket",
Expand Down Expand Up @@ -2103,6 +2107,9 @@ var dictionary = {
"message.desc.zone":"A zone is the largest organizational unit in CloudStack, and it typically corresponds to a single datacenter. Zones provide physical isolation and redundancy. A zone consists of one or more pods (each of which contains hosts and primary storage servers) and a secondary storage server which is shared by all pods in the zone.",
"message.detach.disk":"Are you sure you want to detach this disk?",
"message.detach.iso.confirm":"Please confirm that you want to detach the ISO from this virtual instance.",
"message.diagnostics.exitcode":"exitcode: var",
"message.diagnostics.stderr":"stderr: var",
"message.diagnostics.stdout":"stdout: var",
"message.disable.account":"Please confirm that you want to disable this account. By disabling the account, all users for this account will no longer have access to their cloud resources. All running virtual machines will be immediately shut down.",
"message.disable.snapshot.policy":"You have successfully disabled your current snapshot policy.",
"message.disable.user":"Please confirm that you would like to disable this user.",
Expand Down
Loading