Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void execute() {
response.setHost((String)capabilities.get("host"));
response.setBalancingServiceEnabled((Boolean)capabilities.get("balancingServiceEnabled"));
response.setEventDeleteEnabled((Boolean)capabilities.get("eventDeleteEnabled"));
response.setWallAlertsEnabled((Boolean) capabilities.get("wallAlertsEnabled"));

if (capabilities.containsKey("apiLimitInterval")) {
response.setApiLimitInterval((Integer)capabilities.get("apiLimitInterval"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ public class CapabilitiesResponse extends BaseResponse {
@Param(description = "the min Ram size for the service offering used by the shared filesystem instance", since = "4.20.0")
private Integer sharedFsVmMinRamSize;

@SerializedName("wallalertsenabled")
@Param(description = "Whether Wall Alerts integration is enabled")
private boolean wallAlertsEnabled;

public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) {
this.securityGroupsEnabled = securityGroupsEnabled;
}
Expand Down Expand Up @@ -310,4 +314,8 @@ public void setSharedFsVmMinCpuCount(Integer sharedFsVmMinCpuCount) {
public void setSharedFsVmMinRamSize(Integer sharedFsVmMinRamSize) {
this.sharedFsVmMinRamSize = sharedFsVmMinRamSize;
}

public void setWallAlertsEnabled(boolean wallAlertsEnabled) {
this.wallAlertsEnabled = wallAlertsEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ private WallConfigKeys() {}

public static final ConfigKey<Boolean> WALL_ALERT_ENABLED =
new ConfigKey<>("Advanced", Boolean.class, "wall.alerts.enable", "true",
"Enable Wall alerts integration.", true);
"Enable Wall alerts integration.", false);

public static final ConfigKey<String> WALL_BASE_URL =
new ConfigKey<>("Advanced", String.class, "wall.base.url", "http://localhost:3000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,28 +798,34 @@ public WallSilenceResponse createWallAlertSilence(final CreateWallAlertSilenceCm
return org.apache.cloudstack.wallAlerts.mapper.WallMappers.toResponse(created);
}

// 와일드카드 임포트 금지 선호에 맞춰 FQN 그대로 사용했습니다.
private void ensureWallConfiguredForRules() {
final String baseUrl = org.apache.cloudstack.wallAlerts.config.WallConfigKeys.WALL_BASE_URL.value();
final String token = wallTokenNow();
// 1) 기능이 꺼져 있으면 모든 룰 관련 API를 즉시 차단합니다.
if (!org.apache.cloudstack.wallAlerts.config.WallConfigKeys.WALL_ALERT_ENABLED.value()) {
throw new org.apache.cloudstack.api.ServerApiException(
org.apache.cloudstack.api.ApiErrorCode.UNSUPPORTED_ACTION_ERROR,
"Wall Alerts is disabled by configuration (wall.alerts.enable=false)."
);
}

// 2) 켜져 있을 때만 URL/토큰 유효성을 검사합니다.
final String baseUrl = org.apache.cloudstack.wallAlerts.config.WallConfigKeys.WALL_BASE_URL.value();
if (org.apache.commons.lang3.StringUtils.isBlank(baseUrl)) {
throw new org.apache.cloudstack.api.ServerApiException(
org.apache.cloudstack.api.ApiErrorCode.INTERNAL_ERROR,
"Wall base URL (wall.base.url) is not configured."
);
}

// enable=true 인데 토큰이 없으면 바로 오류입니다.
// 여기서 토큰은 “글로벌 설정 우선, 없으면 env 폴백” 결과입니다.
if (org.apache.cloudstack.wallAlerts.config.WallConfigKeys.WALL_ALERT_ENABLED.value()) {
if (org.apache.commons.lang3.StringUtils.isBlank(token)) {
throw new org.apache.cloudstack.api.ServerApiException(
org.apache.cloudstack.api.ApiErrorCode.UNSUPPORTED_ACTION_ERROR,
"Wall API token (wall.api.token) is not configured. " +
"Please set a valid service account token in global settings " +
"or provide WALL_API_TOKEN environment variable."
);
}
// enable=true 인데 토큰이 없으면 오류입니다.
final String token = wallTokenNow();
if (org.apache.commons.lang3.StringUtils.isBlank(token)) {
throw new org.apache.cloudstack.api.ServerApiException(
org.apache.cloudstack.api.ApiErrorCode.UNSUPPORTED_ACTION_ERROR,
"Wall API token (wall.api.token) is not configured. " +
"Please set a valid service account token in global settings " +
"or provide WALL_API_TOKEN environment variable."
);
}
}

Expand Down Expand Up @@ -1622,6 +1628,10 @@ private String slug(String v) {
@Override
public List<Class<?>> getCommands() {
final List<Class<?>> cmds = new ArrayList<>();
// 기능이 꺼져 있으면 어떤 API도 등록하지 않습니다.
if (!WallConfigKeys.WALL_ALERT_ENABLED.value()) {
return cmds;
}
cmds.add(ListWallAlertRulesCmd.class);
cmds.add(UpdateWallAlertRuleThresholdCmd.class);
cmds.add(PauseWallAlertRuleCmd.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7213,6 +7213,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
final String host = _configDao.getValue("host");
final boolean balancingServiceEnabled = Boolean.parseBoolean(_configDao.getValue("cloud.balancing.service.enabled"));
final boolean eventDeleteEnabled = Boolean.parseBoolean(_configDao.getValue("event.delete.enabled"));
final boolean wallAlertsEnabled = Boolean.parseBoolean(_configDao.getValue("wall.alerts.enable"));

// check if region-wide secondary storage is used
boolean regionSecondaryEnabled = false;
Expand Down Expand Up @@ -7250,6 +7251,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
capabilities.put("host", host);
capabilities.put("balancingServiceEnabled", balancingServiceEnabled);
capabilities.put("eventDeleteEnabled", eventDeleteEnabled);
capabilities.put("wallAlertsEnabled", wallAlertsEnabled);
capabilities.put(ApiServiceConfiguration.DefaultUIPageSize.key(), ApiServiceConfiguration.DefaultUIPageSize.value());

capabilities.put(ApiConstants.INSTANCES_STATS_RETENTION_TIME, StatsCollector.vmStatsMaxRetentionTime.value());
Expand Down
Loading