@@ -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 );
0 commit comments