+function configure_karaf_log_for_apex() {
+ # TODO: add the extra steps to this function to do any extra work
+ # in this apex environment like we do in our standard environment.
+ # EX: log size, rollover, etc.
+
+ # Modify ODL Log Levels, if needed, for new distribution. This will modify
+ # the control nodes hiera data which will be used during the puppet deploy
+ # CONTROLLERDEBUGMAP is expected to be a key:value map of space separated
+ # values like "module:level module2:level2" where module is abbreviated and
+ # does not include "org.opendaylight."
+
+ local -r controller_ip=$1
+
+ unset IFS
+ # shellcheck disable=SC2153
+ echo "CONTROLLERDEBUGMAP: ${CONTROLLERDEBUGMAP}"
+ if [ -n "${CONTROLLERDEBUGMAP}" ]; then
+ logging_config='\"opendaylight::log_levels\": {'
+ for kv in ${CONTROLLERDEBUGMAP}; do
+ module="${kv%%:*}"
+ level="${kv#*:}"
+ echo "module: $module, level: $level"
+ # shellcheck disable=SC2157
+ if [ -n "${module}" ] && [ -n "${level}" ]; then
+ orgmodule="org.opendaylight.${module}"
+ logging_config="${logging_config} \\\"${orgmodule}\\\": \\\"${level}\\\","
+ fi
+ done
+ # replace the trailing comma with a closing brace followed by trailing comma
+ logging_config=${logging_config%,}" },"
+ echo $logging_config
+
+ # fine a sane line number to inject the custom logging json
+ lineno=$(ssh $OPENSTACK_CONTROL_NODE_1_IP "sudo grep -Fn 'opendaylight::log_mechanism' /etc/puppet/hieradata/service_configs.json" | awk -F: '{print $1}')
+ ssh $controller_ip "sudo sed -i \"${lineno}i ${logging_config}\" /etc/puppet/hieradata/service_configs.json"
+ ssh $controller_ip "sudo cat /etc/puppet/hieradata/service_configs.json"
+ fi
+} # function configure_karaf_log_for_apex()
+
+function configure_odl_features_for_apex() {
+
+ # if the environment variable $ACTUALFEATURES is not null, then rewrite
+ # the puppet config file with the features given in that variable, otherwise
+ # this function is a noop
+
+ local -r controller_ip=$1
+ local -r config_file=/etc/puppet/hieradata/service_configs.json
+
+cat > /tmp/set_odl_features.sh << EOF
+sudo jq '.["opendaylight::extra_features"] |= []' $config_file > tmp.json && mv tmp.json $config_file
+for feature in $(echo $ACTUALFEATURES | sed "s/,/ /g"); do
+ sudo jq --arg jq_arg \$feature '.["opendaylight::extra_features"] |= . + [\$jq_arg]' $config_file > tmp && mv tmp $config_file;
+done
+echo "Modified puppet-opendaylight service_configs.json..."
+cat $config_file
+EOF
+
+ echo "Feature configuration script..."
+ cat /tmp/set_odl_features.sh
+
+ if [ -n "${ACTUALFEATURES}" ]; then
+ scp /tmp/set_odl_features.sh $controller_ip:/tmp/set_odl_features.sh
+ ssh $controller_ip "sudo bash /tmp/set_odl_features.sh"
+ fi
+
+} # function configure_odl_features_for_apex()
+