4
4
5
5
package oracle .kubernetes .operator .utils ;
6
6
7
- import java .io .File ;
8
- import java .io .FileInputStream ;
9
- import java .io .InputStream ;
10
7
import java .util .Map ;
11
- import java .util .Objects ;
12
8
import oracle .kubernetes .operator .BaseTest ;
13
- import org .yaml .snakeyaml .Yaml ;
14
9
15
10
/** JRF Domain class with all the utility methods */
16
11
public class JRFDomain extends Domain {
17
12
18
13
private static final String FMWINFRA_DOCKER_IMAGENAME =
19
14
"phx.ocir.io/weblogick8s/oracle/fmw-infrastructure" ;
20
15
private static final String FMWINFRA_DOCKER_IMAGETAG = "12.2.1.3" ;
21
- private static final String OCIR_REPO_SERVER = "phx.ocir.io" ;
22
16
23
17
/**
24
18
* JRFDomain constructor
@@ -41,6 +35,7 @@ public JRFDomain(String inputYaml) throws Exception {
41
35
*/
42
36
public JRFDomain (Map <String , Object > inputDomainMap ) throws Exception {
43
37
initialize (inputDomainMap );
38
+ updateDomainMapForJRF ();
44
39
createPV ();
45
40
createSecret ();
46
41
generateInputYaml ();
@@ -50,166 +45,28 @@ public JRFDomain(Map<String, Object> inputDomainMap) throws Exception {
50
45
}
51
46
52
47
/**
53
- * initialize the domain creation input properties
48
+ * update the domainMap with jrf specific information
54
49
*
55
- * @param inputDomainMap - jrf domain input properties map
56
50
* @throws Exception - if any error occurs
57
51
*/
58
- private void initialize (Map <String , Object > inputDomainMap ) throws Exception {
59
- domainMap = inputDomainMap ;
60
- this .userProjectsDir = BaseTest .getUserProjectsDir ();
61
- this .projectRoot = BaseTest .getProjectRoot ();
52
+ private void updateDomainMapForJRF () throws Exception {
62
53
63
- clusterType = (String ) domainMap .getOrDefault ("clusterType" , "CONFIGURED" );
64
- domainMap .put ("clusterType" , clusterType );
65
-
66
- // copy samples to RESULT_DIR
67
- TestUtils .exec (
68
- "cp -rf " + BaseTest .getProjectRoot () + "/kubernetes/samples " + BaseTest .getResultDir ());
69
-
70
- this .voyager =
71
- System .getenv ("LB_TYPE" ) != null && System .getenv ("LB_TYPE" ).equalsIgnoreCase ("VOYAGER" );
72
- if (System .getenv ("INGRESSPERDOMAIN" ) != null ) {
73
- INGRESSPERDOMAIN = Boolean .parseBoolean (System .getenv ("INGRESSPERDOMAIN" ));
74
- }
75
-
76
- domainMap .put ("domainName" , domainMap .get ("domainUID" ));
77
-
78
- // read sample domain inputs
79
- String sampleDomainInputsFile =
80
- "/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-inputs.yaml" ;
81
- if (domainMap .containsKey ("domainHomeImageBase" )) {
82
- sampleDomainInputsFile =
83
- "/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain-inputs.yaml" ;
84
- }
85
- Yaml dyaml = new Yaml ();
86
- InputStream sampleDomainInputStream =
87
- new FileInputStream (new File (BaseTest .getResultDir () + sampleDomainInputsFile ));
88
- logger .info (
89
- "loading domain inputs template file " + BaseTest .getResultDir () + sampleDomainInputsFile );
90
- Map <String , Object > sampleDomainMap = dyaml .load (sampleDomainInputStream );
91
- sampleDomainInputStream .close ();
92
-
93
- // add attributes with default values from sample domain inputs to domain map
94
- sampleDomainMap .forEach (domainMap ::putIfAbsent );
95
-
96
- domainUid = (String ) domainMap .get ("domainUID" );
97
- // Customize the create domain job inputs
98
- domainNS = (String ) domainMap .get ("namespace" );
99
- adminServerName = (String ) domainMap .get ("adminServerName" );
100
- managedServerNameBase = (String ) domainMap .get ("managedServerNameBase" );
101
-
102
- initialManagedServerReplicas =
103
- ((Integer ) domainMap .get ("initialManagedServerReplicas" )).intValue ();
104
- configuredManagedServerCount =
105
- ((Integer ) domainMap .get ("configuredManagedServerCount" )).intValue ();
106
- exposeAdminT3Channel = ((Boolean ) domainMap .get ("exposeAdminT3Channel" )).booleanValue ();
107
- exposeAdminNodePort = ((Boolean ) domainMap .get ("exposeAdminNodePort" )).booleanValue ();
108
- t3ChannelPort = ((Integer ) domainMap .get ("t3ChannelPort" )).intValue ();
109
- clusterName = (String ) domainMap .get ("clusterName" );
110
- clusterType = (String ) domainMap .get ("clusterType" );
111
- serverStartPolicy = (String ) domainMap .get ("serverStartPolicy" );
112
-
113
- // write hostname in domain input map for public address
114
- if (exposeAdminT3Channel ) {
115
- domainMap .put ("t3PublicAddress" , TestUtils .getHostName ());
116
- }
117
-
118
- String imageName = FMWINFRA_DOCKER_IMAGENAME ;
119
- if (System .getenv ("IMAGE_NAME_FMWINFRA" ) != null ) {
120
- imageName = System .getenv ("IMAGE_NAME_FMWINFRA" );
121
- logger .info ("IMAGE_NAME_FMWINFRA " + imageName );
122
- }
123
-
124
- String imageTag = FMWINFRA_DOCKER_IMAGETAG ;
125
- if (System .getenv ("IMAGE_TAG_FMWINFRA" ) != null ) {
126
- imageTag = System .getenv ("IMAGE_TAG_FMWINFRA" );
127
- logger .info ("IMAGE_TAG_FMWINFRA " + imageTag );
128
- }
129
- domainMap .put ("logHome" , "/shared/logs/" + domainUid );
54
+ // jrf specific input parameter
55
+ domainMap .put ("image" , FMWINFRA_DOCKER_IMAGENAME + ":" + FMWINFRA_DOCKER_IMAGETAG );
130
56
131
57
if (!domainMap .containsKey ("domainHomeImageBase" )) {
132
- domainMap .put ("domainHome" , "/shared/domains/" + domainUid );
133
-
134
58
// update jrf/create-domain-script.sh with domain_name and rcuprefix
135
59
TestUtils .replaceStringInFile (
136
60
BaseTest .getResultDir () + "/jrf/create-domain-script.sh" , "%RCUPREFIX%" , domainUid );
137
61
TestUtils .replaceStringInFile (
138
62
BaseTest .getResultDir () + "/jrf/create-domain-script.sh" , "%DOMAIN_NAME%" , domainUid );
139
63
domainMap .put ("createDomainFilesDir" , BaseTest .getResultDir () + "/jrf" );
140
- domainMap .put ("image" , imageName + ":" + imageTag );
141
64
}
142
65
143
- if (domainMap .containsKey ("domainHomeImageBuildPath" )) {
144
- domainMap .put (
145
- "domainHomeImageBuildPath" ,
146
- BaseTest .getResultDir () + "/" + domainMap .get ("domainHomeImageBuildPath" ));
147
- }
148
66
if (System .getenv ("IMAGE_PULL_SECRET_FMWINFRA" ) != null ) {
149
67
domainMap .put ("imagePullSecretName" , System .getenv ("IMAGE_PULL_SECRET_FMWINFRA" ));
150
- if (System .getenv ("WERCKER" ) != null ) {
151
- // create docker registry secrets
152
- TestUtils .createDockerRegistrySecret (
153
- System .getenv ("IMAGE_PULL_SECRET_FMWINFRA" ),
154
- System .getenv (OCIR_REPO_SERVER ),
155
- System .getenv ("OCIR_REPO_USERNAME" ),
156
- System .getenv ("OCIR_REPO_PASSWORD" ),
157
- System .getenv ("OCIR_REPO_EMAIL" ),
158
- domainNS );
159
- }
160
68
} else {
161
- domainMap .put ("imagePullSecretName" , "docker-store" );
162
- }
163
- // remove null values if any attributes
164
- domainMap .values ().removeIf (Objects ::isNull );
165
-
166
- // create config map and secret for custom sit config
167
- if ((domainMap .get ("configOverrides" ) != null )
168
- && (domainMap .get ("configOverridesFile" ) != null )) {
169
-
170
- String configOverridesFile = domainMap .get ("configOverridesFile" ).toString ();
171
-
172
- String cmd =
173
- "kubectl -n "
174
- + domainNS
175
- + " create cm "
176
- + domainUid
177
- + "-"
178
- + domainMap .get ("configOverrides" )
179
- + " --from-file "
180
- + BaseTest .getProjectRoot ()
181
- + configOverridesFile ;
182
- ExecResult result = ExecCommand .exec (cmd );
183
- if (result .exitValue () != 0 ) {
184
- throw new Exception ("FAILURE: command " + cmd + " failed, returned " + result .stderr ());
185
- }
186
- cmd =
187
- "kubectl -n "
188
- + domainNS
189
- + " label cm "
190
- + domainUid
191
- + "-"
192
- + domainMap .get ("configOverrides" )
193
- + " weblogic.domainUID="
194
- + domainUid ;
195
- result = ExecCommand .exec (cmd );
196
- if (result .exitValue () != 0 ) {
197
- throw new Exception ("FAILURE: command " + cmd + " failed, returned " + result .stderr ());
198
- }
199
- // create secret for custom sit config t3 public address
200
- cmd =
201
- "kubectl -n "
202
- + domainNS
203
- + " create secret generic "
204
- + domainUid
205
- + "-"
206
- + "t3publicaddress "
207
- + " --from-literal=hostname="
208
- + TestUtils .getHostName ();
209
- result = ExecCommand .exec (cmd );
210
- if (result .exitValue () != 0 ) {
211
- throw new Exception ("FAILURE: command " + cmd + " failed, returned " + result .stderr ());
212
- }
69
+ domainMap .put ("imagePullSecretName" , "ocir-store}" );
213
70
}
214
71
}
215
72
}
0 commit comments