Skip to content

Commit 4bfa0e1

Browse files
authored
Merge branch 'ablecloud-team:ablestack-diplo' into mold-main#2025
2 parents ae6ac67 + 4a8df5b commit 4bfa0e1

7 files changed

Lines changed: 95 additions & 24 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ public class ApiConstants {
13061306
public static final String EXPIRY_DATE = "expirydate";
13071307
public static final String LICENSE_CHECK = "licensecheck";
13081308
public static final String HAS_LICENSE = "haslicense";
1309-
1309+
public static final String ISSUED_DATE = "issueddate";
13101310
/**
13111311
* This enum specifies IO Drivers, each option controls specific policies on I/O.
13121312
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).

api/src/main/java/org/apache/cloudstack/api/command/admin/outofbandmanagement/LicenseCheckCmd.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public class LicenseCheckCmd extends BaseCmd {
5555
description = "license expiry date")
5656
private Date expiryDate;
5757

58+
@Parameter(name = ApiConstants.ISSUED_DATE,
59+
type = CommandType.DATE,
60+
description = "license issued date")
61+
private Date issuedDate;
62+
5863

5964
/////////////////////////////////////////////////////
6065
/////////////////// Accessors ///////////////////////
@@ -68,6 +73,10 @@ public Date getExpiryDate() {
6873
return expiryDate;
6974
}
7075

76+
public Date getIssuedDate() {
77+
return issuedDate;
78+
}
79+
7180

7281
public void setHostId(Long hostId) {
7382
this.hostId = hostId;
@@ -76,6 +85,10 @@ public void setExpiryDate(Date expiryDate) {
7685
this.expiryDate = expiryDate;
7786
}
7887

88+
public void setIssuedDate(Date issuedDate) {
89+
this.issuedDate = issuedDate;
90+
}
91+
7992
/////////////////////////////////////////////////////
8093
/////////////// API Implementation///////////////////
8194
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/LicenseCheckerResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public class LicenseCheckerResponse extends BaseResponse {
3333
@Param(description = "license expiry date")
3434
private Date expiryDate;
3535

36+
@SerializedName(ApiConstants.ISSUED_DATE)
37+
@Param(description = "license issued date")
38+
private Date issuedDate;
39+
3640
@SerializedName(ApiConstants.SUCCESS)
3741
@Param(description = "license success")
3842
private String success;
@@ -49,6 +53,10 @@ public Date getExpiryDate() {
4953
return expiryDate;
5054
}
5155

56+
public Date getIssuedDate() {
57+
return issuedDate;
58+
}
59+
5260
public String getSuccess() {
5361
return success;
5462
}
@@ -65,6 +73,10 @@ public void setExpiryDate(Date expiryDate) {
6573
this.expiryDate = expiryDate;
6674
}
6775

76+
public void setIssuedDate(Date issuedDate) {
77+
this.issuedDate = issuedDate;
78+
}
79+
6880
public void setSuccess(boolean isValid) {
6981
this.success = Boolean.toString(isValid);
7082
}

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,36 +1256,58 @@ private void checkLicenseAndControlAgent(HostVO host) {
12561256
// 라이센스 상태 확인
12571257
JsonNode licenseStatus = getLicenseStatus(licenseApiUrl, ipAddress);
12581258
boolean isExpired = licenseStatus.get("expiry_date").asBoolean();
1259+
boolean isIssued = licenseStatus.get("issued_date").asBoolean();
1260+
String expiryDateStr = licenseStatus.get("expired").asText();
1261+
String issuedDateStr = licenseStatus.get("issued").asText();
12591262

1260-
// 라이센스 상태에 따라 에이전트 제어
1261-
if (isExpired) {
1262-
// 만료된 경우 에이전트 중지
1263-
controlHostAgent(host, "stop");
1264-
logger.info("License expired - stopping agent for host: " + host.getId());
1263+
logger.info("License check - isIssued: " + isIssued + ", isExpired: " + isExpired);
1264+
logger.info("License dates - issued: " + issuedDateStr + ", expired: " + expiryDateStr);
12651265

1266-
// HA 비활성화 처리
1267-
handleExpiredLicense(host);
1266+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
1267+
Date currentDate = new Date();
1268+
Date issuedDate = null;
1269+
Date expiryDate = null;
1270+
1271+
if (issuedDateStr != null && !issuedDateStr.isEmpty()) {
1272+
issuedDate = sdf.parse(issuedDateStr);
1273+
}
1274+
1275+
if (expiryDateStr != null && !expiryDateStr.isEmpty()) {
1276+
expiryDate = sdf.parse(expiryDateStr);
1277+
}
1278+
1279+
// 라이선스 유효성 검사: 발급되지 않았거나 만료되었으면 false
1280+
boolean isValid = !isExpired && isIssued;
1281+
1282+
// 라이선스 상태에 따라 에이전트 제어
1283+
if (isValid) {
1284+
// 유효한 경우 에이전트 시작
1285+
controlHostAgent(host, "start");
1286+
logger.info("License valid - starting agent for host: " + host.getId());
12681287

12691288
// 알림 전송
12701289
_alertMgr.sendAlert(
12711290
AlertManager.AlertType.ALERT_TYPE_HOST,
12721291
host.getDataCenterId(),
12731292
host.getId(),
1274-
"License expired for host " + host.getName(),
1275-
"The license has expired. Agent has been stopped for host " + host.getName()
1293+
"License valid for host " + host.getName(),
1294+
"The license is valid. Agent has been started for host " + host.getName()
12761295
);
12771296
} else {
1278-
// 유효한 경우 에이전트 시작
1279-
controlHostAgent(host, "start");
1280-
logger.info("License valid - starting agent for host: " + host.getId());
1297+
// 만료된 경우 에이전트 중지
1298+
controlHostAgent(host, "stop");
1299+
logger.info("License expired or not yet valid - stopping agent for host: " + host.getId());
1300+
1301+
// HA 비활성화 처리
1302+
handleExpiredLicense(host);
12811303

12821304
// 알림 전송
12831305
_alertMgr.sendAlert(
12841306
AlertManager.AlertType.ALERT_TYPE_HOST,
12851307
host.getDataCenterId(),
12861308
host.getId(),
1287-
"License valid for host " + host.getName(),
1288-
"The license is valid. Agent has been started for host " + host.getName()
1309+
"License expired or not yet valid for host " + host.getName(),
1310+
"The license has expired or is not yet valid. Agent has been stopped for host " + host.getName()
12891311
);
12901312
}
12911313
} catch (Exception e) {
@@ -5939,15 +5961,30 @@ public LicenseCheckerResponse checkLicense(LicenseCheckCmd cmd) {
59395961
response.setExpiryDate(null);
59405962
} else {
59415963
boolean isExpired = jsonNode.get("expiry_date").asBoolean();
5964+
boolean isIssued = jsonNode.get("issued_date").asBoolean();
59425965
String expiryDateStr = jsonNode.get("expired").asText();
5966+
String issuedDateStr = jsonNode.get("issued").asText();
5967+
5968+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
5969+
Date currentDate = new Date();
5970+
Date issuedDate = null;
5971+
Date expiryDate = null;
5972+
5973+
if (issuedDateStr != null && !issuedDateStr.isEmpty()) {
5974+
issuedDate = sdf.parse(issuedDateStr);
5975+
response.setIssuedDate(issuedDate);
5976+
}
59435977

5944-
response.setSuccess(!isExpired);
5945-
response.setHasLicense(true);
59465978
if (expiryDateStr != null && !expiryDateStr.isEmpty()) {
5947-
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
5948-
Date expiryDate = sdf.parse(expiryDateStr);
5979+
expiryDate = sdf.parse(expiryDateStr);
59495980
response.setExpiryDate(expiryDate);
59505981
}
5982+
5983+
// 라이선스 유효성 검사: 발급되지 않았거나 만료되었으면 false
5984+
boolean isValid = !isExpired && isIssued;
5985+
5986+
response.setSuccess(isValid);
5987+
response.setHasLicense(true);
59515988
}
59525989
} else {
59535990
response.setHasLicense(false);

ui/public/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4751,7 +4751,7 @@
47514751
"message.dr.mirrored.cluster.disable": "If you disable the selected disaster recovery cluster, all mirroring virtual machines in the secondary cluster will be deleted. If you wish to disable, please enter the phrase 'I would like to disable it'.",
47524752
"message.success.disable.disaster.recovery.cluster": "Successfully disabled disaster recovery cluster",
47534753
"message.error.confirm.create.dr.mirroring.vm": "Mirroring virtual machines cannot be created if compression deduplication is enabled.",
4754-
"message.alert.licenseexpired": "License Expired Date",
4754+
"message.alert.licenseexpired": "License Effective Date",
47554755
"message.license.renewal.required": "It's past work. Please renew.",
47564756
"message.license.not.found": "License file not found. Please register.",
47574757
"message.license.days.left": "Expires in a few days."

ui/public/locales/ko_KR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4751,7 +4751,7 @@
47514751
"message.dr.mirrored.cluster.disable": "\uc120\ud0dd\ud55c \uc7ac\ud574\ubcf5\uad6c \ud074\ub7ec\uc2a4\ud130\ub97c \ube44\ud65c\uc131\ud654\ud558\ub294 \uacbd\uc6b0 Secondary \ud074\ub7ec\uc2a4\ud130\uc758 \ubbf8\ub7ec\ub9c1 \uac00\uc0c1\uba38\uc2e0\uc774 \uc804\ubd80 \uc0ad\uc81c\ub429\ub2c8\ub2e4. \ube44\ud65c\uc131\ud654\ub97c \uc6d0\ud558\uc2dc\uba74 '\ube44\ud65c\uc131\ud654\ud558\uaca0\uc2b5\ub2c8\ub2e4' \ubb38\uad6c\ub97c \uc785\ub825\ud558\uc2ed\uc2dc\uc624.",
47524752
"message.success.disable.disaster.recovery.cluster": "\uc7ac\ud574\ubcf5\uad6c \ud074\ub7ec\uc2a4\ud130\ub97c \uc131\uacf5\uc801\uc73c\ub85c \ube44\ud65c\uc131\ud654\ud588\uc2b5\ub2c8\ub2e4.",
47534753
"message.error.confirm.create.dr.mirroring.vm": "\uc555\ucd95/\uc911\ubcf5\uc81c\uac70 \uae30\ub2a5\uc774 \ud65c\uc131\ud654\ub418\uc5b4\uc788\ub294 \uacbd\uc6b0 \ubbf8\ub7ec\ub9c1 \uac00\uc0c1\uba38\uc2e0\uc744 \uc0dd\uc131\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.",
4754-
"message.alert.licenseexpired": "\ub77c\uc774\uc13c\uc2a4 \ub9cc\ub8cc \uc77c\uc790",
4754+
"message.alert.licenseexpired": "\ub77c\uc774\uc13c\uc2a4 \uc720\ud6a8 \uc77c\uc790",
47554755
"message.license.renewal.required": "\ub77c\uc774\uc13c\uc2a4 \uc720\ud6a8\uae30\uac04\uc774 \uc9c0\ub0ac\uc2b5\ub2c8\ub2e4. \uc2e0\uaddc \ub77c\uc774\uc120\uc2a4\ub97c \ub4f1\ub85d \ud6c4 \uc0ac\uc6a9\ud574 \uc8fc\uc138\uc694.",
47564756
"message.license.not.found": "\ub77c\uc774\uc120\uc2a4 \uc815\ubcf4\ub97c \ud655\uc778\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. \uc2e0\uaddc \ub77c\uc774\uc120\uc2a4 \ub4f1\ub85d \ud6c4 \uc0ac\uc6a9\ud574 \uc8fc\uc138\uc694.",
47574757
"message.license.days.left": "\uc77c \ud6c4 \ub9cc\ub8cc"

ui/src/components/view/DetailsTab.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
</a-alert>
2626
<div v-if="['host'].includes($route.meta.name)">
2727
<a-alert type="error" :showIcon="true" v-if="!dataResource.licenseExpiryDate" :message="$t('message.license.not.found')" />
28-
<a-alert type="error" :showIcon="true" v-else-if="isLicenseExpired(dataResource.licenseExpiryDate)" :message="$t('message.alert.licenseexpired') + ' : ' + dataResource.licenseExpiryDate + '(' + $t('message.license.renewal.required') + ')'" />
29-
<a-alert type="success" :showIcon="true" v-else :message="$t('message.alert.licenseexpired') + ' : ' + dataResource.licenseExpiryDate + '(' + calculateDday(dataResource.licenseExpiryDate) + $t('message.license.days.left') + ')'" />
28+
<a-alert type="error" :showIcon="true" v-else-if="isLicenseNotStarted(dataResource.licenseStartDate)" :message="$t('message.alert.licenseexpired') + ' : ' + dataResource.licenseStartDate + ' ~ ' + dataResource.licenseExpiryDate+ '(' + calculateDday(dataResource.licenseExpiryDate) + $t('message.license.days.left') + ')'" />
29+
<a-alert type="error" :showIcon="true" v-else-if="isLicenseExpired(dataResource.licenseExpiryDate)" :message="$t('message.alert.licenseexpired') + ' : ' + dataResource.licenseStartDate + ' ~ ' + dataResource.licenseExpiryDate + '(' + $t('message.license.renewal.required') + ')'" />
30+
<a-alert type="success" :showIcon="true" v-else :message="$t('message.alert.licenseexpired') + ' : ' + dataResource.licenseStartDate + ' ~ ' + dataResource.licenseExpiryDate + '(' + calculateDday(dataResource.licenseExpiryDate) + $t('message.license.days.left') + ')'" />
3031
</div>
3132
<a-alert v-if="ip4routes" type="info" :showIcon="true" :message="$t('label.add.upstream.ipv4.routes')">
3233
<template #description>
@@ -474,8 +475,10 @@ export default {
474475
fetchLicenseInfo () {
475476
api('licenseCheck', { hostid: this.resource.id }).then(response => {
476477
const licenseData = response?.null?.licensecheck
477-
if (licenseData.expirydate) {
478+
if (licenseData) {
478479
var expiryDate = new Date(licenseData.expirydate)
480+
var issuedDate = new Date(licenseData.issueddate)
481+
this.dataResource.licenseStartDate = issuedDate.getFullYear() + '-' + this.leftPad(issuedDate.getMonth() + 1) + '-' + this.leftPad(issuedDate.getDate())
479482
this.dataResource.licenseExpiryDate = expiryDate.getFullYear() + '-' + this.leftPad(expiryDate.getMonth() + 1) + '-' + this.leftPad(expiryDate.getDate())
480483
this.dataResource.hostId = licenseData.hostid
481484
this.dataResource.hasLicense = licenseData.haslicense === 'true'
@@ -486,6 +489,7 @@ export default {
486489
this.licenseStateType = 'success'
487490
}
488491
} else {
492+
this.dataResource.licenseStartDate = ''
489493
this.dataResource.licenseExpiryDate = ''
490494
this.dataResource.hasLicense = false
491495
this.dataResource.licenseValid = false
@@ -510,6 +514,11 @@ export default {
510514
return value
511515
}
512516
return `0${value}`
517+
},
518+
isLicenseNotStarted (startDate) {
519+
const today = new Date()
520+
const start = new Date(startDate)
521+
return today < start
513522
}
514523
}
515524
}

0 commit comments

Comments
 (0)