A restructure of the returned 'get_redis_info' has been done.
The function is now returning a set of host/port collection
based on the required service: pair, central, ha or norep.
This change takes also into account the migration of the redis
configuration parameters from config.yml to constant.yml.
In particular the ports of the redis/valkey services are now
fully defined under the database.xxxx.redis_... keys.
The commit also consider the case of the multi-site config
where the connections to the ha nodes has to be switched to
the port used by haproxy service.
Change-Id: Ie33f2630fde9926391dd5906c0518b0618887621
* ngcp.get_redis_ports() requires no arguments and returns
a hash ref, containing Redis/Valkey related info e.g.:
redis = ngcp.get_redis_info
redis.ports.local
Local database port by default or HA port if mutli site
is enabled and the node has 'db' role
redis.ports.central
Central database port by default or HA port if multi site
is enabled
redis.ports.norep
No replication port, used when certain services configured
to write concurrently on the pair of nodes.
Defaults to redis.port + 1
* fix indentation of "Current known meta-variables"
Change-Id: I97bb06d0d8d5c29930d8176ade2c958a9a0b36c0
When we pass an empty string the current to_yaml() function generates
broken YAML such as "--- ''", which then breaks code parsing that
expecting valid YAML. If we pass an empty string, return an empty string
as well.
Change-Id: I010cd9d544bd505446f0016ecc6302a987921570
The sort function is undefined in scalar context, which means a call
site that calls these functions in scalar context will trigger undefined
behavior.
Sort the result and return the list.
Fixes: Subroutines::ProhibitReturnSort
Warned-by: perlcritic
Change-Id: I355b5e3e412bc91c297a46a73bb6caba6e969f54
some templates need to produce yaml output
(ie. copy entire portions of config.yml), which
supported with this change, ie.
[% Utils.to_yaml(element_from_configyml) %]
there is libtemplate-plugin-yaml-perl, which is
avoided to not (re-) introduce deps other than
YAML::XS.
Change-Id: Iec7f9dd6d13270d9afa78fbe126f0e41d21b6ed7
After some experimentation it was found to best to keep these platforms
independent, and integrate them externally as usual, instead of trying
to merge them into a single platform.
Change-Id: I19d721dece38d104b73cae573332571c4bef0fbf
This makes this function spN ready, by getting the entire list of
siblings and returning the first of them.
Change-Id: Ifc69b1764bc6d8c1007b8b567f4158a66eca81d8
This method returns a sorted list of hostnames for the pair of the
specified hostname, except itself. This is useful for spN support.
Change-Id: I4e7d46de4f480f4c56701b1663877812f74e3640
Let's remove the duplicate implementation, and simply off-load to the
command, so that we only need to modify one place.
As a side effect, this removes a bogus fallback value of 'self' for
CE systems, which should have been 'spce'.
Change-Id: I70b48caad3da4123a3399254deda73c381ae67d9
Add support for getting the nodename for any hostname in an NGCP
cluster.
We switch from fetching this information from the filesystem to the one
contained now in network.yml.
We accept up to 9 nodes per "pair", from sp1 to sp9, so for Carrier
setups that means hostnames ending from 'a' to 'i'. On CE the nodename
is called "spce".
If we cannot match the hostname to a known pattern we will error out.
Change-Id: I80c287046d02f60193479febee427615474043e3
The YAML::XS module handles its passed or returned data for Load() and
Dump() as raw UTF-8, irrespective of perl's UTF-8 string markers. When
we use these functions we need to use a «:raw» encoding or we will end
up with doubly encoded strings.
We also need to tell the Template Toolkit to use UTF-8 as encoding, and
then setup the file handles to use the appropriate encodings.
Change-Id: I37a6811f0680763d7177c3ad92ddf9b890869e66
This will be used in the templates for values that are scaled based on
the number of online CPUs on the system, such as process pools, or load
averages.
Change-Id: I3666873f327becc3f7a02be02dba82493b29252e
This method takes a string and replaces %-style meta-variables in it.
Current supported meta-variable is %v for the NGCP version.
Change-Id: I9c932e603a5791115a176b9fea25baff87cab6b9
These have been around for enough time to leave admins room to switch to
the new alternatives. Time for cleanup.
Change-Id: I40a51c8107daf53a6d7fd24b5035bbc2aff77bb6
Serializing data structures via TT Template::Plugin::Utils::to_perl()
uses Data::Dumper internally.
But Data::Dumper does not sort hash keys by default, which causes
different output with each run of ngcpcfg.
->Sortkeys(1) therefor will no ensure concise output.
Change-Id: Ia3954db042e9ddab675d1d582c2ea6e7ad56b807
The li role needs to be active also when the li_dist is active, as per
our own documentation. This also has the nice effect of simplifying the
code.
Change-Id: I34845e58130c6cdebb933c608006b6a4979c2ad6
admin_export_fields and reseller_export_fields were
each exposed as arrays of plain strings (respective
sql fragments).
now objects will be used instead, to carry perl snippets.
Change-Id: Iccf1d4675d8bb433a17aabb34e14d5dfff2cf318
These are redundant and bogus aliases for get_mgmt_node, which were
reading from a generated templated file instead of getting the
information from the source. Keep the alias around for now in case a
customer is still using this function.
Change-Id: I5aec69313d97bef5bbc655d18f03e7c9af0dbc21
"Utils" TT plugin, to be extended.
provides base64 encoding for now, used by
provisioningtemplates feature.
Change-Id: I2980b57e5dae3d2595ba7017efcdc7e0bd00e469
When the hostname is self or unknown, we do not return any peername,
so should cope with that to avoid doing comparisons that will end up
emitting warnings.
Change-Id: Ib7e70666991a76b99e1f64ca365a3018320728ec
The li match was triggering for all wildcards and when li mode was not
enabled in some way then we were getting negative results.
The proper way to solve the original problem is to relegate the matching
of the li modes to the end, so that we can properly match on wildcards
and not interfere with other roles.
Change-Id: I7cb559a8dc10e8a832c2e2bcd78f1effc1cc101a
Fixes: commit 236b56d990
To be able to generate an authorized_keys file from templates we need
to fetch the public ssh keys for the root user. This function will make
this task easier.
Change-Id: If8edef0e77a5f3c1167fe8dfd0e92e4d9e468a6a
This partially reverts commit bc8ae9e795.
We should not match li_dist with regexes as then we would trap cases
that we should not be covering by the li_dist mapping logic. Just do
exact matches.
This also fixes the hypothetical case with other regexes that are not
the wrongly specified '*'.
Change-Id: I9d9d850969e03fa9dc587f2d47a688bc0359e63c
Otherwise it matches on 'li/li_dist' cases and the library get_all_ips
returns no IPs if called like:
> argv.role='*';
> argv.type='*';
> PROCESS '/usr/lib/ngcp-ngcpcfg/get_all_ips';
> all_ips = out;
This is a hotfix commit for backporting into mr6.4.1 while the "proper" fix
should be re-considered and committed for mr6.5+
P.S we have 3 tt2 templates where we have * in argv parameters.
P.P.S. The code is from Andreas, tnx for the fix!
Change-Id: I119a687389075d2ebdcd824ed457f768b5fb2123
This adds an additional virtual li_dist role on top of the existing li
role. The difference is that li is the cluster simpli acting in central
mode, while li_dist is the cluster acting in distributed mode.
Change-Id: I930c93380a0e88649c325b7faf3c0fb86d78e5ff