Skip to content

Commit 1f57fc0

Browse files
Merge pull request #2988 from craigcomstock/ENT-12653/master
Adjust nova API rest URL for custom https port
2 parents 217c51a + f1b3b24 commit 1f57fc0

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

cfe_internal/enterprise/CFE_hub_specific.cf

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,34 +115,50 @@ bundle agent update_cli_rest_server_url_config
115115
# Both share and live versions must be changed at once since httpd will be restarted later in the same agent run.
116116
"mp_config_file" string => "$(cfe_internal_hub_vars.docroot)/application/config/config.php";
117117
"mp_share_config_file" string => "$(sys.workdir)/share/GUI/application/config/config.php";
118-
"regex_test_pattern" string => ".*localhost:$(cfe_internal_hub_vars.https_port).*";
118+
"api_config_file" string => "$(cfe_internal_hub_vars.docroot)/api/modules/inventory/config/config.php";
119+
"mp_test_pattern" string => ".*localhost:$(cfe_internal_hub_vars.https_port).*";
120+
"api_test_pattern" string => ".*127\.0\.0\.1:$(cfe_internal_hub_vars.https_port).*";
119121

120122
files:
121123
mpf_enable_mission_portal_docroot_sync_from_share_gui::
122124
"$(mp_share_config_file)"
123125
handle => "cfe_internal_edit_share_gui_mp_config",
124-
edit_line => change_cli_rest_server_url_port,
126+
edit_line => change_mp_server_url_port,
125127
if => and(
126128
fileexists("$(mp_share_config_file)"),
127-
islessthan(countlinesmatching("$(regex_test_pattern)", "$(mp_share_config_file)"), 1)
129+
islessthan(countlinesmatching("$(mp_test_pattern)", "$(mp_share_config_file)"), 1)
128130
);
129131

130132
any::
131133
"$(mp_config_file)"
132134
handle => "cfe_internal_edit_mp_config",
133-
edit_line => change_cli_rest_server_url_port,
135+
edit_line => change_mp_server_url_port,
134136
if => and(
135137
fileexists("$(mp_config_file)"),
136-
islessthan(countlinesmatching("$(regex_test_pattern)", "$(mp_config_file)"), 1)
138+
islessthan(countlinesmatching("$(mp_test_pattern)", "$(mp_config_file)"), 1)
137139
);
140+
141+
"$(api_config_file)"
142+
edit_line => change_api_server_url_port,
143+
if => and(
144+
fileexists("$(api_config_file)"),
145+
islessthan(countlinesmatching("$(api_test_pattern)", "$(api_config_file)"), 1)
146+
);
138147
}
139148

140-
bundle edit_line change_cli_rest_server_url_port
149+
bundle edit_line change_mp_server_url_port
141150
{
142151
replace_patterns:
143-
"^\s*\$config\['cli_rest_server_url'\]\s*=\s*\"https://localhost(?::(?!$(cfe_internal_hub_vars.https_port))\d{1,5})?/api/\";\s*$"
152+
"^\s*\$config\['cli_rest_server_url'\]\s*=\s*\"https:\/\/localhost(?::(?!$(cfe_internal_hub_vars.https_port))\d{1,5})?\/api\/\";\s*$"
144153
replace_with => value(" $config['cli_rest_server_url'] = \"https://localhost:$(cfe_internal_hub_vars.https_port)/api/\";"),
145-
comment => "Change port CLI REST server URL port";
154+
comment => "Change port MP REST server URL port";
155+
}
156+
bundle edit_line change_api_server_url_port
157+
{
158+
replace_patterns:
159+
"^\s*define\(\"API_URL\",\s*\"https:\/\/127\.0\.0\.1(?::(?!$(cfe_internal_hub_vars.https_port))\d{1,5})?\/api\"\);\s*$"
160+
replace_with => value("define(\"API_URL\", \"https://127.0.0.1:$(cfe_internal_hub_vars.https_port)/api\");"),
161+
comment => "Change port API REST server URL port";
146162
}
147163

148164
##################################################################

cfe_internal/enterprise/CFE_knowledge.cf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ bundle agent cfe_internal_setup_knowledge
4949
copy_from => no_backup_cp_compare("$(sys.workdir)/share/GUI", "binary"),
5050
depth_search => recurse("inf");
5151

52+
"$(cfe_internal_hub_vars.docroot)/.htaccess"
53+
comment => "Correct up htaccess file in doc root",
54+
handle => "cfe_internal_setup_knowledge_files_doc_root_htaccess",
55+
copy_from => no_backup_cp("$(sys.workdir)/share/GUI/Apache-htaccess");
56+
5257
any::
5358

5459
"$(install_logs)" -> { "ENT-4506" }
@@ -129,12 +134,6 @@ bundle agent cfe_internal_setup_knowledge
129134
handle => "cfe_internal_setup_knowledge_dir_httpd",
130135
perms => mog("755", "root", "root");
131136

132-
"$(cfe_internal_hub_vars.docroot)/.htaccess" -> { "ENT-13173" }
133-
comment => "Correct up htaccess file in doc root",
134-
handle => "cfe_internal_setup_knowledge_files_doc_root_htaccess",
135-
copy_from => no_backup_cp("$(sys.workdir)/share/GUI/Apache-htaccess"),
136-
if => "mpf_enable_mission_portal_docroot_sync_from_share_gui";
137-
138137
"$(cfe_internal_hub_vars.public_docroot)/scripts/." -> { "CFE-951" }
139138
comment => "Ensure permissions for $(cfe_internal_hub_vars.public_docroot)/scripts",
140139
handle => "cfe_internal_setup_knowledge_files_doc_root_scripts_dir",

cfe_internal/enterprise/mission_portal.cf

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,19 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
284284
expression => returnszero("$(paths.systemctl) -q is-active cf-apache > /dev/null 2>&1", "useshell"),
285285
if => fileexists( $(paths.systemctl) );
286286

287+
"httpd_config_validated"
288+
expression => strcmp("$(validate_result[exit_code])", "0");
289+
"httpd_config_error"
290+
expression => not(strcmp("$(validate_result[exit_code])", "0"));
291+
287292
vars:
288293

289294
"validate_config"
290295
string => "$(sys.workdir)/httpd/bin/httpd -t -f $(staged_config)";
291296

297+
"validate_result"
298+
data => execresult_as_data("$(validate_config)", "useshell", "both");
299+
292300
# The location of the apache pid file moved from httpd/logs/httpd.pid to
293301
# httpd/httpd.pid in 3.15.5, 3.18.1 and, 3.19.0
294302

@@ -311,7 +319,7 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
311319
if => and( or( "apache_stop_after_new_staged_config_repaired",
312320
not( fileexists( "$(httpd_pid_file)" ) ),
313321
isnewerthan( $(config), $(staged_config) ) ),
314-
returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell")),
322+
"httpd_config_validated"),
315323
classes => results("bundle", "mission_portal_apache_config"),
316324
comment => "We make sure that the deployed config is a copy of the staged
317325
config if the staged config passes a syntax check. We redirect
@@ -328,7 +336,7 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
328336
!systemd_supervised::
329337
"LD_LIBRARY_PATH=$(sys.workdir)/lib:$LD_LIBRARY_PATH $(sys.workdir)/httpd/bin/apachectl"
330338
args => "stop",
331-
if => and( returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"),
339+
if => and( "httpd_config_validated",
332340
isnewerthan( $(staged_config), $(config) ),
333341
fileexists( "$(httpd_pid_file)" ) ),
334342
contain => in_shell,
@@ -355,7 +363,8 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
355363
systemd_supervised::
356364
"cf-apache"
357365
service_policy => "stop",
358-
if => and( returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"),
366+
if => and( "httpd_config_validated",
367+
359368
isnewerthan( $(staged_config), $(config) ) ),
360369
classes => results( "bundle", "apache_stop_after_new_staged_config" ),
361370
comment => concat( "We have to stop apache before trying to start with a",
@@ -375,12 +384,14 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
375384
comment => "We restart apache after the new valid config is in place";
376385

377386
reports:
387+
httpd_config_error::
388+
"'$(staged_config)' failed to validate: $(validate_result[output])";
378389
DEBUG|DEBUG_mission_portal_apache_from_stage::
379390
"DEBUG $(this.bundle): '$(config)' should be a copy of '$(staged_config)' because it validates with '$(validate_config)'"
380-
if => returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell");
391+
if => "httpd_config_validated";
381392

382393
"DEBUG $(this.bundle): '$(config)' should *not* be a copy of '$(staged_config)' because it failed to validate with '$(validate_config)'"
383-
if => not(returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"));
394+
if => not( "httpd_config_validated" );
384395
}
385396

386397
##################################################################

0 commit comments

Comments
 (0)