Skip to content

Commit

Permalink
UI Fixes: allow filtering on alertype in UI & add events tab (#8630)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishesh92 committed Apr 4, 2024
1 parent b8f8321 commit c25264b
Show file tree
Hide file tree
Showing 30 changed files with 448 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ private static AlertType getAlertType(short type) {
return null;
}

public static Set<AlertType> getAlertTypes() {
return defaultAlertTypes;
}

@Override
public String toString() {
return String.valueOf(this.getType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.cloudstack.acl.ProjectRole;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
Expand Down Expand Up @@ -70,4 +71,13 @@ public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}

@Override
public Long getApiResourceId() {
return getProjectId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.Parameter;
Expand Down Expand Up @@ -96,4 +97,14 @@ private void setupResponse(final ProjectRolePermission rolePermission, final Pro
response.setObjectName("projectrolepermission");
setResponseObject(response);
}

@Override
public Long getApiResourceId() {
return getProjectId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
Expand Down Expand Up @@ -79,4 +80,14 @@ public void execute() {
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}

@Override
public Long getApiResourceId() {
return getProjectId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
Expand Down Expand Up @@ -80,4 +81,14 @@ public void execute() {
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}

@Override
public Long getApiResourceId() {
return getProjectId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
Expand Down Expand Up @@ -76,4 +77,14 @@ public void execute() {
public long getEntityOwnerId() {
return 0;
}

@Override
public Long getApiResourceId() {
return getProjectId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
Expand Down Expand Up @@ -154,4 +155,14 @@ private boolean updateProjectRolePermissionOrder(ProjectRole projectRole) {
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}

@Override
public Long getApiResourceId() {
return getProjectId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -102,4 +103,14 @@ public String getEventType() {
public String getEventDescription() {
return "change out-of-band management password for host: " + getHostId();
}

@Override
public Long getApiResourceId() {
return getHostId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
Expand Down Expand Up @@ -112,4 +113,14 @@ protected void putOptionIfIsNotEmpty(ImmutableMap.Builder<OutOfBandManagement.Op
builder.put(option, value);
}
}

@Override
public Long getApiResourceId() {
return getHostId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -94,4 +95,14 @@ public String getEventType() {
public String getEventDescription() {
return "disable out-of-band management password for cluster: " + getClusterId();
}

@Override
public Long getApiResourceId() {
return getClusterId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Cluster;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -95,4 +96,14 @@ public String getEventType() {
public String getEventDescription() {
return "disable out-of-band management password for host: " + getHostId();
}

@Override
public Long getApiResourceId() {
return getHostId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -94,4 +95,14 @@ public String getEventType() {
public String getEventDescription() {
return "disable out-of-band management password for zone: " + getZoneId();
}

@Override
public Long getApiResourceId() {
return getZoneId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Zone;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -94,4 +95,14 @@ public String getEventType() {
public String getEventDescription() {
return "enable out-of-band management password for cluster: " + getClusterId();
}

@Override
public Long getApiResourceId() {
return getClusterId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Cluster;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -95,4 +96,14 @@ public String getEventType() {
public String getEventDescription() {
return "enable out-of-band management password for host: " + getHostId();
}

@Override
public Long getApiResourceId() {
return getHostId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -94,4 +95,14 @@ public String getEventType() {
public String getEventDescription() {
return "enable out-of-band management password for zone: " + getZoneId();
}

@Override
public Long getApiResourceId() {
return getZoneId();
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Zone;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,9 @@ public String getEventDescription() {
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Host;
}

@Override
public Long getApiResourceId() {
return getHostId();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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.resource;

import com.cloud.user.Account;
import org.apache.cloudstack.alert.AlertService;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.response.AlertResponse;
import org.apache.cloudstack.api.response.AlertTypeResponse;
import org.apache.cloudstack.api.response.ListResponse;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@APICommand(name = "listAlertTypes", description = "Lists all alerts types", responseObject = AlertResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListAlertTypesCmd extends BaseCmd {

@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}

@Override
public void execute() {
Set<AlertService.AlertType> result = AlertService.AlertType.getAlertTypes();
ListResponse<AlertTypeResponse> response = new ListResponse<>();
List<AlertTypeResponse> typeResponseList = new ArrayList<>();
for (AlertService.AlertType alertType : result) {
AlertTypeResponse alertResponse = new AlertTypeResponse(alertType.getType(), alertType.getName());
alertResponse.setObjectName("alerttype");
typeResponseList.add(alertResponse);
}
response.setResponses(typeResponseList, result.size());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}
Loading

0 comments on commit c25264b

Please sign in to comment.