ODM: The domain on the element contains an invalid entry - ibm-odm

I'm getting the following error when trying to synchronize a dynamic domain retrieved from the database:
The domain on the element '[domain object]' contains an invalid entry: '[entry]'.
This only seems to happen for values that start with digits or non alpha characters. Here are my domain values:
And these are the errors:
Note that only the first two domain entries result in errors. Are there restrictions to what names can be used for dynamic domains?

Domain item names follow the same rules as for Java variable names:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html
You can start with something like this:
public String normalize(String str) {
String result = str;
if (Pattern.matches("^\\d\\w*$", result)) {
result = "_" + result;
}
return result.replaceAll("[^A-Za-z0-9]", "_");
}
... to remove non letter/number characters from your item names, and prefix them with an underscore in the case where they start with a number, as in your example.

Related

Extract a string in terraform

I have the following string value that comes from a YAML file. I want to extract the first two parts of the string within the terraform file. Let me know how it can be done. I tried the split function.
String: "sg:dev:crm"
Expected value: "sg:dev"
Tried: split(":","sg:dev:crm")[1,2] // This doesn't work
You would have to split it into two separate values and concatenate them. For example:
locals {
sg = "sg:dev:crm"
split_sg = split(":","sg:dev:crm")
wanted_str = "${local.split_sg[0]}:${local.split_sg[1]}"
}
Also, you tried referencing wrong indexes after you split the string because indexes start from 0, and sg is at index 0 while dev is at index 1.

Groovy string comparison in Jenkins pipeline

I'm trying to compare two strings in Jenkins pipeline. The code more or less look like this:
script {
def str1 = 'test1.domainname-test.com'
def str2 = 'test1.domainname-test.com'
if ( str1 == str2 ) {
currentBuild.result = 'ABORT'
error("TENANT_NAME $TENANT_NAME.domainname-test.com is already defined in domainname-test.com record set. Please specify unique name. Exiting...")
}
}
str1 is fed by a preceeding command I skipped here due to simplicity. I am getting this error:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field java.lang.String domainname
What am I doing wrong? I tried equals method too, same result. As if it stucked on those dots, thinking it's some kind of property. Thanks in advance
You're missing curly brackets surrounding the TENANT_NAME variable name. In your example:
error("TENANT_NAME $TENANT_NAME.domainname-test.com is already defined in domainname-test.com record set. Please specify unique name. Exiting...")
the $ sign gets applied to TENANT_NAME.domainname. And because TENANT_NAME is a string, Groovy interprets the following part as you were trying to access domainname property from a String class, and you get No such field found: field java.lang.String domainname exception.
To avoid such problems, wrap your variable name with {} and you will be fine.
error("TENANT_NAME ${TENANT_NAME}.domainname-test.com is already defined in domainname-test.com record set. Please specify unique name. Exiting...")

Node.JS - if a string includes some strings with any characters in between

I am testing a string that contains an identifier for which type of device submitted the string. The device type identifier will be something like "123456**FF789000AB" where the * denote any character could be used at this position. I run a series of functions to parse additional data and set variables based on the type of device submitting the data. Currently, I have the following statement:
if (payload[4].includes("02010612FF590080BC")) { function(topic, payload, intpl)};
The string tested in the includes() test will always start with 020106, but the next two characters could be anything. Is there a quick regex I could throw in the includes function, or should I organize the test in a different way?
To match the "020106**FF590080BC" pattern, where * can be anything, you can use RegExp.test() and the regular expression /020106..FF590080BC/:
if (/020106..FF590080BC/.test(payload[4])) { ... }
Also, if you require that the pattern must match the beginning of the string:
if (/^020106..FF590080BC/.test(payload[4])) { ... }

Go how can i efficient split string into parts

i am fighting with a string splitting. I want to split string by wildcards into a slice, but this slice should contain this wildcards as well.
For example: /applications/{name}/tokens/{name} should be split into [/applications/ {name} /tokens/ {name}] etc.
Here is a sample code i wrote, but it is not working correctly, and i don't feel good about it either.
https://play.golang.org/p/VMOsJeaI4l
There are some example routes to be tested. Method splitPath split path into parts and display both: before and after.
Here is a solution:
var validPathRe = regexp.MustCompile("^(/{[[:alpha:]]+}|/[-_.[:alnum:]]+)+$")
var splitPathRe = regexp.MustCompile("({[[:alpha:]]+}|[-_.[:alnum:]]+)")
func splitPath(path string) parts{
var retPaths parts
if !validPathRe.MatchString(path) {
return retPaths
}
retPaths = splitPathRe.FindAllString(path, -1)
return retPaths
}
I made this by creating two regular expressions, one to check if the path was valid or not, the other to extract the various parts of the path and return them. If the path is not valid it will return an empty list. The return of this will look like this:
splitPath("/path/{to}/your/file.txt")
["path" "{to}" "your" "file.txt"]
This doesn't include the '/' character because you already know that all strings in the return but the last string is a directory and the last string is the file name. Because of the validity check you can assume this.

Thoughts on ways to re order network routes file with bash / sed / awk script

Re framing to try and clarify the issue ...
I have multiple network route files which have configurations issues. In the static routes file, routes are grouped in blocks of 3 and identified by the numbered appended to the ADDRRES/NETMASK/GATEWAY before the =:
ADDRESS0=X.X.X.X
NETMASK0=X.X.X.X
GATEWAY0=X.X.X.X
ADDRESS0=X.X.X.X is the network number for the static route.
NETMASK0=X.X.X.X is the netmask for the network number defined with ADDRESS0=X.X.X.X
GATEWAY0=X.X.X.X is the default gateway, or an IP address that can be used to reach ADDRESS0=X.X.X.X
Linux will then add the route, based on the number assigned to each group.
Subsequent static routes (The ADDRESS# , NETMASK# , GATEWAY# portion) must be numbered sequentially, and must not skip any values. For example, ADDRESS0,NETMASK0,GATEWAY0 , THEN, ADDRESS1,NETMASK1,GATEWAY1 and so on.
For example a good configuration would like but the hosts could have >20 entries :
ADDRESS0=xxxxxxxxxxxxxxx
NETMASK0=xxxxxxxxxxxxxxx
GATEWAY0=xxxxxxxxxxxxxxx
ADDRESS1=xxxxxxxxxxxxxxx
NETMASK1=xxxxxxxxxxxxxxx
GATEWAY1=xxxxxxxxxxxxxxx
ADDRESS2=xxxxxxxxxxxxxxx
NETMASK2=xxxxxxxxxxxxxxx
GATEWAY2=xxxxxxxxxxxxxxx
ADDRESS3=xxxxxxxxxxxxxxx
NETMASK3=xxxxxxxxxxxxxxx
GATEWAY3=xxxxxxxxxxxxxxx
ADDRESS4=xxxxxxxxxxxxxxx
NETMASK4=xxxxxxxxxxxxxxx
GATEWAY4=xxxxxxxxxxxxxxx
My issue to two fold...
ONE : Duplicate static routes. In this configuration it will iterate through the file adding the routes for each numbered
group 0 - 2. However because there is two ADDRESS1/NETMASK1/GATEWAY1 entries one of them will not be added...
GATEWAY2=xxxxxxxxxxxxxxx
NETMASK2=xxxxxxxxxxxxxxx
ADDRESS2=xxxxxxxxxxxxxxx
GATEWAY1=xxxxxxxxxxxxxxx
NETMASK1=xxxxxxxxxxxxxxx
ADDRESS1=xxxxxxxxxxxxxxx
GATEWAY0=xxxxxxxxxxxxxxx
NETMASK0=xxxxxxxxxxxxxxx
ADDRESS0=xxxxxxxxxxxxxxx
ADDRESS1=xxxxxxxxxxxxxxx
NETMASK1=xxxxxxxxxxxxxxx
GATEWAY1=xxxxxxxxxxxxxxx
TWO: They are not in sequential order. In this example it will iterate from the numbered groups of routes 0-2, but it will stop there because ADDRESS3/NETMASK3/GATEWAY3 does not exist. Therefore it thinks routes ADDRESS4 and ADDRESS5 do not exist and therefore aren't added.
ADDRESS0=xxxxxxxxxxxxxxx
NETMASK0=xxxxxxxxxxxxxxx
GATEWAY0=xxxxxxxxxxxxxxx
ADDRESS1=xxxxxxxxxxxxxxx
NETMASK1=xxxxxxxxxxxxxxx
GATEWAY1=xxxxxxxxxxxxxxx
ADDRESS2=xxxxxxxxxxxxxxx
NETMASK2=xxxxxxxxxxxxxxx
GATEWAY2=xxxxxxxxxxxxxxx
ADDRESS4=xxxxxxxxxxxxxxx
NETMASK4=xxxxxxxxxxxxxxx
GATEWAY4=xxxxxxxxxxxxxxx
ADDRESS5=xxxxxxxxxxxxxxx
NETMASK5=xxxxxxxxxxxxxxx
GATEWAY5=xxxxxxxxxxxxxxx
I would like to remove / change the numbers appended to ADDRESS/NETMASK/GATEWAY and increment them, but not change the values
assigned to them designated by the "=xxxxxxxxxxxxxxx"
So for instance in Example two it would become. Therefore I'm looking for a way to iterate through a file, change the number appended to ADDRESS/NETMASK/GATEWAY and increment that number :
ADDRESS0=xxxxxxxxxxxxxxx
NETMASK0=xxxxxxxxxxxxxxx
GATEWAY0=xxxxxxxxxxxxxxx
ADDRESS1=xxxxxxxxxxxxxxx
NETMASK1=xxxxxxxxxxxxxxx
GATEWAY1=xxxxxxxxxxxxxxx
ADDRESS2=xxxxxxxxxxxxxxx
NETMASK2=xxxxxxxxxxxxxxx
GATEWAY2=xxxxxxxxxxxxxxx
ADDRESS3=xxxxxxxxxxxxxxx
NETMASK3=xxxxxxxxxxxxxxx
GATEWAY3=xxxxxxxxxxxxxxx
ADDRESS4=xxxxxxxxxxxxxxx
NETMASK4=xxxxxxxxxxxxxxx
GATEWAY4=xxxxxxxxxxxxxxx
I was thinking for iterating through the file for every instance ^ADDRESS and changing/incrementing that number from 0. And repeating with ^NETMASK and ^GATEWAY. But I've failed to find a way to implement it. If you need further clarification, please let me know. Many thanks in advance
The following script does roughly what you want.
collect 3-tuples by the appended id in the input
renumber them consecutively
check for duplicate ids
check for "short tuples", where one of the three is missing
(I added the last requirement.) :-)
#! /usr/bin/awk -f
BEGIN { FS = "=" }
/^ADDRESS|^NETMASK|^GATEWAY/ {
id = substr($1, 8)
sub(id "=", "%d=", $0)
if( id in matched && 3 == split(matched[id], foo, "\n") ) {
printf("error: %d already encountered", id) > "/dev/stderr"
next
}
matched[id] = matched[id] $0 "\n"
}
END {
for( id in matched ) {
if( 3 != split(matched[id], foo, "\n") ) {
printf("error: short set for %d: %s\n", id, matched[id]) > "/dev/stderr"
next
}
printf(matched[id], i, i, i)
i++
}
}
Note the output will be ordered consecutively, but the rules will be in a different order. To keep them in order, I'd probably collect and emit one tuple at a time.

Resources