|
44 | 44 | public class MaintenanceLink extends ManagementLink { |
45 | 45 | private static final Logger LOGGER = Logger.getLogger(MaintenanceLink.class.getName()); |
46 | 46 |
|
47 | | - private static final CloudUuidStore CLOUD_UUID_STORE = CloudUuidStore.getInstance(); |
48 | | - |
49 | 47 | private transient Throwable error; |
50 | 48 |
|
51 | 49 | @Override |
@@ -114,8 +112,7 @@ public List<MaintenanceAction> getTargets() throws IOException { |
114 | 112 | // New: Adding clouds to the list |
115 | 113 | for (Cloud cloud : j.clouds) { |
116 | 114 | try { |
117 | | - String uuid = CloudUuidStore.getInstance().getUuidIfPresent(cloud); |
118 | | - MaintenanceTarget target = new MaintenanceTarget(MaintenanceTarget.TargetType.CLOUD, cloud.name, uuid); |
| 115 | + MaintenanceTarget target = new MaintenanceTarget(MaintenanceTarget.TargetType.CLOUD, cloud.name); |
119 | 116 | MaintenanceAction action = new MaintenanceAction(target); |
120 | 117 |
|
121 | 118 | if (action.hasMaintenanceWindows()) { |
@@ -348,34 +345,15 @@ public void doAdd(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, |
348 | 345 |
|
349 | 346 | MaintenanceWindow maintenanceWindow = new MaintenanceWindow(startTime, endTime, reason); |
350 | 347 |
|
351 | | - for (String cloudParam : cloudParams) { |
352 | | - String[] parts = cloudParam.split("::", 2); |
353 | | - if (parts.length != 2) { |
354 | | - LOGGER.log(Level.WARNING, "Invalid cloud parameter format: {0}", cloudParam); |
355 | | - continue; |
356 | | - } |
357 | | - String cloudName = parts[0]; |
358 | | - String uuidStr = parts[1]; |
359 | | - String uuid = "null".equals(uuidStr) ? null : uuidStr; |
360 | | - Cloud cloud = null; |
361 | | - if (uuid == null) { |
362 | | - cloud = j.getCloud(cloudName); |
363 | | - } else { |
364 | | - for (Cloud c : j.clouds) { |
365 | | - if (c.name.equals(cloudName) && uuid.equals(CLOUD_UUID_STORE.getUuidIfPresent(c))) { |
366 | | - cloud = c; |
367 | | - break; |
368 | | - } |
369 | | - } |
370 | | - } |
371 | | - |
| 348 | + for (String cloudName : cloudParams) { |
| 349 | + Cloud cloud = j.clouds.getByName(cloudName); |
372 | 350 | if (cloud == null) { |
373 | | - LOGGER.warning("Could not find cloud with name " + cloudName + " and UUID " + uuid); |
| 351 | + LOGGER.warning("Could not find cloud: " + cloudName); |
374 | 352 | continue; |
375 | 353 | } |
376 | 354 |
|
377 | 355 | try { |
378 | | - MaintenanceTarget target = new MaintenanceTarget(MaintenanceTarget.TargetType.CLOUD, cloud.name, uuid); |
| 356 | + MaintenanceTarget target = new MaintenanceTarget(MaintenanceTarget.TargetType.CLOUD, cloud.name); |
379 | 357 | MaintenanceHelper.getInstance().addMaintenanceWindow(target.toKey(), maintenanceWindow); |
380 | 358 | } catch (Exception e) { |
381 | 359 | LOGGER.log(Level.WARNING, "Error adding cloud maintenance window", e); |
@@ -414,23 +392,6 @@ public void doAdd(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, |
414 | 392 | rsp.sendRedirect("."); |
415 | 393 | } |
416 | 394 |
|
417 | | - /** |
418 | | - * Helper class for cloud selection in the UI. |
419 | | - */ |
420 | | - public record CloudOption(String name, String uuid, String shortUuid, boolean hasDuplicate) { |
421 | | - |
422 | | - public String getValue() { |
423 | | - return name + "::" + (uuid == null ? "null" : uuid); |
424 | | - } |
425 | | - |
426 | | - public String getDisplayName() { |
427 | | - if (hasDuplicate) { |
428 | | - return name + " (" + shortUuid + ")"; |
429 | | - } |
430 | | - return name; |
431 | | - } |
432 | | - } |
433 | | - |
434 | 395 | public Class<MaintenanceWindow> getMaintenanceWindowClass() { |
435 | 396 | return MaintenanceWindow.class; |
436 | 397 | } |
|
0 commit comments