|
4 | 4 | */
|
5 | 5 | package com.oracle.weblogicx.imagebuilder.cli.menu;
|
6 | 6 |
|
| 7 | +import com.oracle.weblogicx.imagebuilder.api.model.CachePolicy; |
7 | 8 | import com.oracle.weblogicx.imagebuilder.api.model.CommandResponse;
|
8 | 9 | import com.oracle.weblogicx.imagebuilder.api.model.WLSInstallerType;
|
9 | 10 | import com.oracle.weblogicx.imagebuilder.util.ARUUtil;
|
|
27 | 28 | import java.util.logging.FileHandler;
|
28 | 29 | import java.util.logging.Logger;
|
29 | 30 |
|
| 31 | +import static com.oracle.weblogicx.imagebuilder.api.model.CachePolicy.ALWAYS; |
| 32 | + |
30 | 33 | @Command(
|
31 | 34 | name = "update",
|
32 | 35 | description = "Update WebLogic docker image with selected patches",
|
@@ -86,34 +89,44 @@ public CommandResponse call() throws Exception {
|
86 | 89 | installerVersion = baseImageProperties.getProperty("WLS_VERSION", Constants.DEFAULT_WLS_VERSION);
|
87 | 90 |
|
88 | 91 | String opatchVersion = baseImageProperties.getProperty("OPATCH_VERSION");
|
89 |
| - opatch_1394_required = (Utils.compareVersions(installerVersion, Constants.DEFAULT_WLS_VERSION) >= 0 && |
90 |
| - Utils.compareVersions(opatchVersion, "13.9.4.0.0") < 0); |
91 |
| - |
92 |
| - String pkgMgr = Utils.getPackageMgrStr(baseImageProperties.getProperty("ID", "ol")); |
93 |
| - if (!Utils.isEmptyString(pkgMgr)) { |
94 |
| - filterStartTags.add(pkgMgr); |
| 92 | + opatch_1394_required = (latestPSU || !patches.isEmpty()) && |
| 93 | + (Utils.compareVersions(installerVersion, Constants.DEFAULT_WLS_VERSION) >= 0 && |
| 94 | + Utils.compareVersions(opatchVersion, "13.9.4.0.0") < 0); |
| 95 | + |
| 96 | + //Do not update or install packages in offline only mode |
| 97 | + if (useCache != ALWAYS) { |
| 98 | + String pkgMgr = Utils.getPackageMgrStr(baseImageProperties.getProperty("ID", "ol")); |
| 99 | + if (!Utils.isEmptyString(pkgMgr)) { |
| 100 | + filterStartTags.add(pkgMgr); |
| 101 | + } |
95 | 102 | }
|
96 | 103 |
|
97 | 104 | baseImageProperties.keySet().forEach(x -> logger.info(x + "=" + baseImageProperties.getProperty(x.toString())));
|
98 | 105 |
|
99 |
| - String lsInvFile = tmpDir2.toAbsolutePath().toString() + File.separator + "opatch-lsinventory.txt"; |
100 |
| - if (Files.exists(Paths.get(lsInvFile)) && Files.size(Paths.get(lsInvFile)) > 0) { |
101 |
| - logger.info("opatch-lsinventory file exists at: " + lsInvFile); |
102 |
| - Set<String> toValidateSet = new HashSet<>(); |
103 |
| - if (latestPSU) { |
104 |
| - toValidateSet.add(ARUUtil.getLatestPSUNumber(installerType.toString(), installerVersion, userId, password)); |
105 |
| - } |
106 |
| - toValidateSet.addAll(patches); |
107 |
| - ValidationResult validationResult = ARUUtil.validatePatches(lsInvFile, new ArrayList<>(toValidateSet), |
108 |
| - installerType.toString(), installerVersion, userId, password); |
109 |
| - if (!validationResult.isSuccess()) { |
110 |
| - return new CommandResponse(-1, validationResult.getErrorMessage()); |
| 106 | + if (latestPSU || !patches.isEmpty()) { |
| 107 | + if (useCache == ALWAYS) { |
| 108 | + logger.warning("skipping patch conflict check. useCache set to " + useCache); |
111 | 109 | } else {
|
112 |
| - logger.info("patch conflict check successful"); |
113 |
| - } |
114 |
| - } else { |
115 |
| - if (latestPSU || !patches.isEmpty()) { |
116 |
| - return new CommandResponse(-1, "inventory file missing. required to check for conflicts"); |
| 110 | + String lsInvFile = tmpDir2.toAbsolutePath().toString() + File.separator + "opatch-lsinventory.txt"; |
| 111 | + if (Files.exists(Paths.get(lsInvFile)) && Files.size(Paths.get(lsInvFile)) > 0) { |
| 112 | + logger.info("opatch-lsinventory file exists at: " + lsInvFile); |
| 113 | + Set<String> toValidateSet = new HashSet<>(); |
| 114 | + if (latestPSU) { |
| 115 | + toValidateSet.add(ARUUtil.getLatestPSUNumber(installerType.toString(), installerVersion, |
| 116 | + userId, password)); |
| 117 | + } |
| 118 | + toValidateSet.addAll(patches); |
| 119 | + ValidationResult validationResult = ARUUtil.validatePatches(lsInvFile, |
| 120 | + new ArrayList<>(toValidateSet), installerType.toString(), installerVersion, userId, |
| 121 | + password); |
| 122 | + if (!validationResult.isSuccess()) { |
| 123 | + return new CommandResponse(-1, validationResult.getErrorMessage()); |
| 124 | + } else { |
| 125 | + logger.info("patch conflict check successful"); |
| 126 | + } |
| 127 | + } else { |
| 128 | + return new CommandResponse(-1, "inventory file missing. required to check for conflicts"); |
| 129 | + } |
117 | 130 | }
|
118 | 131 | }
|
119 | 132 |
|
|
0 commit comments