Skip to content

Commit f9074e5

Browse files
gosurya-oraclejshum2479
authored andcommitted
Pwd on patch only
1 parent 12c358d commit f9074e5

File tree

4 files changed

+60
-88
lines changed

4 files changed

+60
-88
lines changed

src/main/java/com/oracle/weblogicx/imagebuilder/cli/menu/CreateImage.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public CommandResponse call() throws Exception {
7979
Path tmpPatchesDir = Files.createDirectory(Paths.get(tmpDirPath, "patches"));
8080
Files.createFile(Paths.get(tmpPatchesDir.toAbsolutePath().toString(), "dummy.txt"));
8181

82-
// this handles wls, jdk, opatch_1394 and wdt install files.
82+
// this handles wls, jdk and wdt install files.
8383
cmdBuilder.addAll(handleInstallerFiles(tmpDir));
8484

8585
if (fromImage != null && !fromImage.isEmpty()) {
@@ -105,13 +105,18 @@ public CommandResponse call() throws Exception {
105105
baseImageProperties.getProperty("ORACLE_HOME"));
106106
}
107107

108-
String pkgMgr = Utils.getPackageMgrStr(baseImageProperties.getProperty("ID", "ol"));
109-
if (!Utils.isEmptyString(pkgMgr)) {
110-
filterStartTags.add(pkgMgr);
108+
if (useCache != ALWAYS) {
109+
String pkgMgr = Utils.getPackageMgrStr(baseImageProperties.getProperty("ID", "ol"));
110+
if (!Utils.isEmptyString(pkgMgr)) {
111+
filterStartTags.add(pkgMgr);
112+
}
111113
}
112114
} else {
113-
filterStartTags.add("_YUM");
115+
if (useCache != ALWAYS) {
116+
filterStartTags.add("_YUM");
117+
}
114118
}
119+
115120
// build wdt args if user passes --wdtModelPath
116121
cmdBuilder.addAll(handleWDTArgsIfRequired(tmpDir));
117122

@@ -169,7 +174,7 @@ private List<String> handleInstallerFiles(Path tmpDir) throws Exception {
169174

170175
@Override
171176
List<String> handlePatchFiles(Path tmpDir, Path tmpPatchesDir) throws Exception {
172-
if (Utils.compareVersions(installerVersion, DEFAULT_WLS_VERSION) == 0) {
177+
if ((latestPSU || !patches.isEmpty()) && Utils.compareVersions(installerVersion, DEFAULT_WLS_VERSION) == 0) {
173178
addOPatch1394ToImage(tmpDir);
174179
}
175180
//we need a local installerVersion variable for the command line Option. so propagate to super.

src/main/java/com/oracle/weblogicx/imagebuilder/cli/menu/ImageOperation.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ public abstract class ImageOperation implements Callable<CommandResponse> {
5656

5757
@Override
5858
public CommandResponse call() throws Exception {
59-
password = handlePasswordOptions();
6059
handleProxyUrls();
61-
62-
// check user support credentials
63-
if (!ARUUtil.checkCredentials(userId, password)) {
64-
return new CommandResponse(-1, "user Oracle support credentials do not match");
60+
// check user support credentials if we are applying any patches
61+
if (latestPSU || !patches.isEmpty()) {
62+
password = handlePasswordOptions();
63+
if (!ARUUtil.checkCredentials(userId, password)) {
64+
return new CommandResponse(-1, "user Oracle support credentials do not match");
65+
}
6566
}
6667
return new CommandResponse(0, null);
6768
}
@@ -164,8 +165,7 @@ void handleProxyUrls() throws IOException {
164165

165166
void addOPatch1394ToImage(Path tmpDir) throws Exception {
166167
String filePath = new PatchFile(useCache, "opatch", "13.9.4.0.0", "28186730", userId, password).resolve(cacheStore);
167-
Files.copy(Paths.get(filePath), Paths.get(tmpDir.toAbsolutePath().toString(), new File(filePath).getName())
168-
);
168+
Files.copy(Paths.get(filePath), Paths.get(tmpDir.toAbsolutePath().toString(), new File(filePath).getName()));
169169
filterStartTags.add("OPATCH_1394");
170170
}
171171

@@ -236,8 +236,7 @@ FileHandler setupLogger(boolean isCLIMode) {
236236
@Option(
237237
names = {"--user"},
238238
paramLabel = "<support email>",
239-
description = "Oracle Support email id",
240-
required = true
239+
description = "Oracle Support email id"
241240
)
242241
String userId;
243242

src/main/java/com/oracle/weblogicx/imagebuilder/cli/menu/UpdateImage.java

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package com.oracle.weblogicx.imagebuilder.cli.menu;
66

7+
import com.oracle.weblogicx.imagebuilder.api.model.CachePolicy;
78
import com.oracle.weblogicx.imagebuilder.api.model.CommandResponse;
89
import com.oracle.weblogicx.imagebuilder.api.model.WLSInstallerType;
910
import com.oracle.weblogicx.imagebuilder.util.ARUUtil;
@@ -27,6 +28,8 @@
2728
import java.util.logging.FileHandler;
2829
import java.util.logging.Logger;
2930

31+
import static com.oracle.weblogicx.imagebuilder.api.model.CachePolicy.ALWAYS;
32+
3033
@Command(
3134
name = "update",
3235
description = "Update WebLogic docker image with selected patches",
@@ -86,34 +89,44 @@ public CommandResponse call() throws Exception {
8689
installerVersion = baseImageProperties.getProperty("WLS_VERSION", Constants.DEFAULT_WLS_VERSION);
8790

8891
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+
}
95102
}
96103

97104
baseImageProperties.keySet().forEach(x -> logger.info(x + "=" + baseImageProperties.getProperty(x.toString())));
98105

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);
111109
} 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+
}
117130
}
118131
}
119132

src/main/java/com/oracle/weblogicx/imagebuilder/impl/PatchFile.java

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,20 @@ public class PatchFile extends AbstractFile {
2626
private String version;
2727
private final Logger logger = Logger.getLogger(PatchFile.class.getName());
2828

29-
/*
30-
public PatchFile(String category, String version, String patchId, String userId, String password) {
31-
super(null);
32-
Objects.requireNonNull(userId, "userId cannot be null");
33-
Objects.requireNonNull(password, "password cannot be null");
34-
this.category = category;
35-
this.version = version;
36-
this.patchId = patchId;
37-
this.userId = userId;
38-
this.password = password;
39-
}
40-
*/
41-
4229
public PatchFile(CachePolicy cachePolicy, String category, String version, String patchId, String userId, String password) {
4330
super(null, cachePolicy, userId, password);
44-
Objects.requireNonNull(userId, "userId cannot be null");
45-
Objects.requireNonNull(password, "password cannot be null");
31+
// if (cachePolicy != ALWAYS) {
32+
// Objects.requireNonNull(userId, "userId cannot be null");
33+
// Objects.requireNonNull(password, "password cannot be null");
34+
// }
4635
this.category = category;
4736
this.version = version;
4837
this.patchId = patchId;
4938
}
5039

5140
@Override
5241
public String resolve(CacheStore cacheStore) throws Exception {
42+
//patchId is null in case of latestPSU
5343
if (Utils.isEmptyString(patchId)) {
5444
if (cachePolicy == ALWAYS) {
5545
throw new Exception("CachePolicy prohibits download. Cannot determine latestPSU");
@@ -95,39 +85,4 @@ private String downloadPatch(CacheStore cacheStore) throws IOException {
9585
}
9686
return filePath;
9787
}
98-
99-
/*
100-
@Override
101-
public String resolve(CacheStore cacheStore) throws Exception {
102-
103-
String releaseNumber = ARUUtil.getReleaseNumber(category, version, userId, password);
104-
if (Utils.isEmptyString(patchId)) {
105-
patchId = ARUUtil.getLatestPSUNumber(category, version, userId, password);
106-
if (Utils.isEmptyString(patchId)) {
107-
throw new Exception(String.format("Failed to find latest psu for product category %s, version %s",
108-
category, version));
109-
}
110-
}
111-
key = patchId + CACHE_KEY_SEPARATOR + releaseNumber;
112-
String filePath = cacheStore.getValueFromCache(key);
113-
114-
if (filePath == null || !Files.isRegularFile(Paths.get(filePath))) {
115-
// try downloading it
116-
List<String> patches = ARUUtil.getPatchesFor(category, version, Collections.singletonList(patchId),
117-
userId, password, cacheStore.getCacheDir());
118-
patches.forEach(x -> cacheStore.addToCache(x.substring(0, x.indexOf('=')), x.substring(x.indexOf('=') + 1)));
119-
if (!patches.isEmpty()) {
120-
key = patches.get(0).substring(0, patches.get(0).indexOf('='));
121-
}
122-
filePath = cacheStore.getValueFromCache(key);
123-
if (filePath == null || !Files.isRegularFile(Paths.get(filePath))) {
124-
throw new Exception(String.format("Failed to find patch %s for product category %s, version %s",
125-
patchId, category, version));
126-
}
127-
} else {
128-
logger.info("Found matching cache entry: key=" + key + ", value=" + filePath);
129-
}
130-
return filePath;
131-
}
132-
*/
13388
}

0 commit comments

Comments
 (0)