#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(cmd|command)\s+?=\s?\\?(.*\"|concat\s?\{(?:(?:\{(?:(?:\{(?:[^{}])*\})|(?:[^{}]))*\})|(?:[^{}]))*\})"
Local $sString = "<?xml version="1.0" encoding="UTF-8"?>" & @CRLF & _
"<unload unload_date="2021-09-23 23:48:46">" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>0ae107e39f2032001d753758442e70ec</metadata_id>" & @CRLF & _
"<name>Linux - Network</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Network"" & @CRLF & _
" id = "0ae107e39f2032001d753758442e70ec"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "Check kernel version"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "uname -r |cut -d'.' -f1"" & @CRLF & _
" var_names = "kernel"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get Interfaces"" & @CRLF & _
" if {" & @CRLF & _
" condition = neq {" & @CRLF & _
" get_attr {"use_net_tools"}" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ifconfig -a | awk '{line=$0} {printf \"%s\",line!=\"\"?line:\"\\n\"}'"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "interfaces"" & @CRLF & _
" col_names = "interface_data"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Failover: Get Interfaces"" & @CRLF & _
" set_attr {" & @CRLF & _
" "tmp"" & @CRLF & _
" eval {"javascript: var rtn = \"\";" & @CRLF & _
"var command = \"ip addr\";" & @CRLF & _
"var response = CTX.getCommandManager().shellCommand(command, false, null, null, CTX);" & @CRLF & _
"var spl = response.split(\"\\n\");" & @CRLF & _
"var reg = /^\\d+:\\s+/;" & @CRLF & _
"var data = \"\";" & @CRLF & _
"" & @CRLF & _
"var interfaceData = spl[0];" & @CRLF & _
"var match = /^\\d+:\\s+(.*)/.exec(interfaceData);" & @CRLF & _
"var reqtext = '';" & @CRLF & _
"if(match){" & @CRLF & _
" reqtext = match[1];" & @CRLF & _
" if(reqtext.slice(-1)==':'){" & @CRLF & _
" reqtext = reqtext.slice(0, -1);" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"data = data + reqtext;" & @CRLF & _
"" & @CRLF & _
"var new_table = new Packages.java.util.ArrayList();" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"" & @CRLF & _
"for(var i=1;i<spl.length;i++) {" & @CRLF & _
" if(reg.test(spl[i])) {" & @CRLF & _
" var row = new Packages.java.util.HashMap();" & @CRLF & _
" row.put(\"interface_data\",data);" & @CRLF & _
" new_table.add(row)" & @CRLF & _
" data = \"\";" & @CRLF & _
" " & @CRLF & _
" interfaceData = spl[i];" & @CRLF & _
" match = /^\\d+:\\s+(.*)/.exec(interfaceData);" & @CRLF & _
" reqtext = '';" & @CRLF & _
" if(match){" & @CRLF & _
" reqtext = match[1];" & @CRLF & _
" if(reqtext.slice(-1)==':'){" & @CRLF & _
" reqtext = reqtext.slice(0, -1);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" data = data + reqtext;" & @CRLF & _
" } else {" & @CRLF & _
" data = data + \" \" + spl[i];" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"row.put(\"interface_data\",data);" & @CRLF & _
"new_table.add(row)" & @CRLF & _
"CTX.setAttribute('interfaces_ss', new_table); "}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "merge interfaces and interfaces_ss"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" is_not_empty {get_attr {"interfaces"}}" & @CRLF & _
" is_not_empty {get_attr {"interfaces_ss"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = union {" & @CRLF & _
" table1_name = "interfaces"" & @CRLF & _
" table2_name = "interfaces_ss"" & @CRLF & _
" result_table_name = "interfaces"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract interface data - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "interface_data_kernel3"" & @CRLF & _
" eval {"javascript: var rtn = \"\";" & @CRLF & _
"var command = \"ip -o link show\";" & @CRLF & _
"var response = CTX.getCommandManager().shellCommand(command, false, null, null, CTX);" & @CRLF & _
"var spl = response.split(\" \");" & @CRLF & _
"var data = \"\";" & @CRLF & _
"var flag = false;" & @CRLF & _
"for(var i = 0 ; i < spl.length; i++){" & @CRLF & _
" if (i == 1){" & @CRLF & _
" data = spl[i].replace(\":\",\"\");" & @CRLF & _
" }" & @CRLF & _
" if(flag == true){" & @CRLF & _
" flag = false;" & @CRLF & _
" data = data + \" \" +spl[i] + \" \" + \"NEWLINE\";" & @CRLF & _
" }" & @CRLF & _
" if(spl[i].includes(\"link/\")){" & @CRLF & _
" flag = true;" & @CRLF & _
" }" & @CRLF & _
" if(spl[i].includes(\"brd\")){" & @CRLF & _
" i = i + 2;" & @CRLF & _
" if(i < spl.length)" & @CRLF & _
" data = data +\" \" +spl[i].replace(\":\",\"\");" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"rtn = data;"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get interface names & Mac - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "interface_data_kernel3"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "interfaces_kernel3"" & @CRLF & _
" col_names = "name","mac"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" delimiters = " "" & @CRLF & _
" selected_positions = 1,2" & @CRLF & _
" line_seperator = "NEWLINE"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Gateway - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ip route list | awk ' /^default/ {print $3}'"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "gateway_kernel3"" & @CRLF & _
" col_names = "DefGateway"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract interface name and MAC (if exists) from interfaces data"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"interfaces"}}" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "interfaces"" & @CRLF & _
" target_table_name = "interfaces"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"var interfaceData = ${interfaces[].interface_data};" & @CRLF & _
"var match = /([^:\\s]+).*/.exec(interfaceData);" & @CRLF & _
"var interfaceName='';" & @CRLF & _
"if(match){" & @CRLF & _
"interfaceName = match[1];" & @CRLF & _
"if(interfaceName.slice(-1)==':'){" & @CRLF & _
"interfaceName = interfaceName.slice(0, -1);" & @CRLF & _
"}" & @CRLF & _
"}" & @CRLF & _
"rtrn = interfaceName;" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "mac_address"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"var interfaceData = ${interfaces[].interface_data};" & @CRLF & _
"var match = /[^0-9\\s]+\\S+\\s*:?.*HWaddr (\\S+)/.exec(interfaceData);" & @CRLF & _
"if(!match){" & @CRLF & _
"match = /ether (\\S+)/.exec(interfaceData);" & @CRLF & _
"}" & @CRLF & _
"rtrn = match?match[1]:'';" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove interfaces without name and MAC"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"interfaces"}}" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "interfaces"" & @CRLF & _
" target_table_name = "interfaces"" & @CRLF & _
" condition = all {" & @CRLF & _
" is_not_empty {get_attr {"interfaces[].name"}}" & @CRLF & _
" is_not_empty {get_attr {"interfaces[].mac_address"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "remove duplicates from interfaces"" & @CRLF & _
" set_attr {" & @CRLF & _
" "tmp"" & @CRLF & _
" eval {"javascript: var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${interfaces},[\"name\",\"mac_address\"]);" & @CRLF & _
"CTX.setAttribute(\"interfaces\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Separate IPs"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"interfaces"}}" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "interfaces[*].interface_data"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "ip_addresses"" & @CRLF & _
" col_names = "ip_address_data"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "inet"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract IPv4 and netmask from IPs data"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"ip_addresses"}}" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "ip_addresses"" & @CRLF & _
" target_table_name = "ip_v4_addresses"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip"" & @CRLF & _
" value = eval {"javascript: var rtrn = '';" & @CRLF & _
"var ipAddressData = ${ip_addresses[].ip_address_data};" & @CRLF & _
"var patt = /\\s?(?:addr:)?(\\S+).*?(?:(?:mask:)|(?:netmask ))\\S+/gi;" & @CRLF & _
"var fip = /^(?:\\s+)?(addr:)?(\\d+.\\d+.\\d+.\\d+)/gi;" & @CRLF & _
"var match = patt.exec(ipAddressData);" & @CRLF & _
"var fmatch = fip.exec(ipAddressData);" & @CRLF & _
"if(match) {" & @CRLF & _
" rtrn = match[1];" & @CRLF & _
"} else {" & @CRLF & _
" if(fmatch) {" & @CRLF & _
" rtrn = fmatch[0];" & @CRLF & _
" }" & @CRLF & _
" else{" & @CRLF & _
" rtrn ='';" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"rtrn;"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "netmask"" & @CRLF & _
" value = eval {"javascript: var rtrn = '';" & @CRLF & _
"var ipAddressData = ${ip_addresses[].ip_address_data};" & @CRLF & _
"var patt = /\\s?(?:addr:)?\\S+.*?(?:(?:mask:)|(?:netmask ))(\\S+)/gi;" & @CRLF & _
"var match = patt.exec(ipAddressData);" & @CRLF & _
"rtrn = match?match[1]:'';" & @CRLF & _
"if(match) {" & @CRLF & _
" match[1];" & @CRLF & _
"} else {" & @CRLF & _
" var fmaskpatt = /^.*\\d+.\\d+.\\d+.\\d+\\/([^\\s]+).*/gi;" & @CRLF & _
" var fmatch = fmaskpatt.exec(ipAddressData);" & @CRLF & _
" if(fmatch) {" & @CRLF & _
" try{" & @CRLF & _
" if (fmatch[1]){" & @CRLF & _
" function createNetmaskAddr(bitCount) {" & @CRLF & _
" var mask=[];" & @CRLF & _
" for(i=0;i<4;i++) {" & @CRLF & _
" var n = Math.min(bitCount, 8);" & @CRLF & _
" mask.push(256 - Math.pow(2, 8-n));" & @CRLF & _
" bitCount -= n;" & @CRLF & _
" }" & @CRLF & _
" return mask.join('.');" & @CRLF & _
" }" & @CRLF & _
" rtrn = createNetmaskAddr(fmatch[1]);" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
"} catch(e){" & @CRLF & _
" ms.log(\"Linux Server pattern step Subnet Mask for ip v4 - for kernel 3 and above failed with error: \" + e);" & @CRLF & _
"}" & @CRLF & _
" } else {" & @CRLF & _
" rtrn = '';" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "version"" & @CRLF & _
" value = "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get ip v4 - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ip -4 -o addr show | awk '{print $2,$4}'"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "ip_v4_kernel"" & @CRLF & _
" col_names = "interface_name","ip","net_mask_bits"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" delimiters = "/"," "" & @CRLF & _
" selected_positions = 1,2,3" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Subnet Mask for ip v4 - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "ip_v4_kernel"" & @CRLF & _
" target_table_name = "ip_v4_kernel"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "netmask"" & @CRLF & _
" value = eval {"javascript: " & @CRLF & _
"try{" & @CRLF & _
" if (${ip_v4_kernel[].net_mask_bits}){" & @CRLF & _
" function createNetmaskAddr(bitCount) {" & @CRLF & _
" var mask=[];" & @CRLF & _
" for(i=0;i<4;i++) {" & @CRLF & _
" var n = Math.min(bitCount, 8);" & @CRLF & _
" mask.push(256 - Math.pow(2, 8-n));" & @CRLF & _
" bitCount -= n;" & @CRLF & _
" }" & @CRLF & _
" return mask.join('.');" & @CRLF & _
" }" & @CRLF & _
" createNetmaskAddr(${ip_v4_kernel[].net_mask_bits});" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
"} catch(e){" & @CRLF & _
" ms.log(\"Linux Server pattern step Subnet Mask for ip v4 - for kernel 3 and above failed with error: \" + e);" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
""}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Transform IP v4 - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "ip_v4_kernel"" & @CRLF & _
" target_table_name = "ip_v4_kernel"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip"" & @CRLF & _
" value = get_attr {"ip_v4_kernel[].ip"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "netmask"" & @CRLF & _
" value = get_attr {"ip_v4_kernel[].netmask"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "version"" & @CRLF & _
" value = "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract IPv6 and netmask from IPs data"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"ip_addresses"}}" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "ip_addresses"" & @CRLF & _
" target_table_name = "ip_v6_addresses"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip"" & @CRLF & _
" value = eval {"javascript: var rtrn = '';" & @CRLF & _
"var ipAddressData = ${ip_addresses[].ip_address_data};" & @CRLF & _
"var patt = /6 (?:addr: )?(\\S+)(?:\\/|(?:\\s+prefixlen ))\\d*/gi;" & @CRLF & _
"var match = patt.exec(ipAddressData);" & @CRLF & _
"rtrn = match?match[1]:'';" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "netmask"" & @CRLF & _
" value = eval {"javascript: var rtrn = '';" & @CRLF & _
"var ipAddressData = ${ip_addresses[].ip_address_data};" & @CRLF & _
"var patt = /6 (?:addr: )?\\S+(?:\\/|(?:\\s+prefixlen ))(\\d*)/gi;" & @CRLF & _
"var match = patt.exec(ipAddressData);" & @CRLF & _
"rtrn = match?match[1]:'';" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "version"" & @CRLF & _
" value = "6"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get ip v6 - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ip -6 -o a| awk '{print $2,$4}'"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "ip_v6_kernel"" & @CRLF & _
" col_names = "interface_name","ip"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" delimiters = " ","/"" & @CRLF & _
" selected_positions = 1,2" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Subnet Mask for ip v6 - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ip=$(ip -6 -o addr show | awk '{print $4}' | tail -1 | cut -d'/' -f2);i=0;mask='';full_octets=$(($ip/8));partial_octet=$(($ip%8));for ((i=0;i<4;i+=1)); do if [ $i -lt $full_octets ]; then mask+=255; elif [ $i -eq $full_octets ]; then mask+=$((256 - 2**(8-$partial_octet))); else mask+=0; fi; test $i -lt 3 && mask+=. ;done;echo $mask;"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "subnet_v6"" & @CRLF & _
" col_names = "subnet_mask_v6"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Transform IP v6 - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "ip_v6_kernel"" & @CRLF & _
" target_table_name = "ip_v6_kernel"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip"" & @CRLF & _
" value = get_attr {"ip_v6_kernel[].ip"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "netmask"" & @CRLF & _
" value = get_attr {"subnet_v6[1].subnet_mask_v6"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "version"" & @CRLF & _
" value = "6"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Union IPs tables"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "ip_v4_addresses"" & @CRLF & _
" table2_name = "ip_v6_addresses"" & @CRLF & _
" result_table_name = "ip_addresses"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Union ip_addresses - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = union {" & @CRLF & _
" table1_name = "ip_v4_kernel"" & @CRLF & _
" table2_name = "ip_v6_kernel"" & @CRLF & _
" result_table_name = "ip_addresses_final"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter IP addresses final - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "ip_addresses_final"" & @CRLF & _
" target_table_name = "ip_addresses_final"" & @CRLF & _
" condition = all {" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"ip_addresses_final[].ip"}" & @CRLF & _
" "127.0.0.1"" & @CRLF & _
" }" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"ip_addresses_final[].ip"}" & @CRLF & _
" "0.0.0.0"" & @CRLF & _
" }" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"ip_addresses_final[].ip"}" & @CRLF & _
" "255.255.255.255"" & @CRLF & _
" }" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"ip_addresses_final[].ip"}" & @CRLF & _
" "::1"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge IP & interfaces tables - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "interfaces_kernel3"" & @CRLF & _
" table2_name = "ip_addresses_final"" & @CRLF & _
" result_table_name = "interfaces_kernel3"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"interfaces_kernel3[].name"}" & @CRLF & _
" get_attr {"ip_addresses_final[].interface_name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove lines that doesn't represent an IP"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "ip_addresses"" & @CRLF & _
" target_table_name = "ip_addresses"" & @CRLF & _
" condition = all {" & @CRLF & _
" is_not_empty {get_attr {"ip_addresses[].ip"}}" & @CRLF & _
" is_not_empty {get_attr {"ip_addresses[].netmask"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter unwanted IPs"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "ip_addresses"" & @CRLF & _
" target_table_name = "ip_addresses"" & @CRLF & _
" condition = all {" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"ip_addresses.ip"}" & @CRLF & _
" "127.0.0.1"" & @CRLF & _
" }" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"ip_addresses.ip"}" & @CRLF & _
" "0.0.0.0"" & @CRLF & _
" }" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"ip_addresses.ip"}" & @CRLF & _
" "255.255.255.255"" & @CRLF & _
" }" & @CRLF & _
" not_contains {" & @CRLF & _
" get_attr {"ip_addresses.ip"}" & @CRLF & _
" "::1"" & @CRLF & _
" }" & @CRLF & _
" not_contains {" & @CRLF & _
" get_attr {"ip_addresses.ip"}" & @CRLF & _
" "::"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Match each IP to its interface"" & @CRLF & _
" merge {" & @CRLF & _
" table1_name = "ip_addresses"" & @CRLF & _
" table2_name = "interfaces"" & @CRLF & _
" result_table_name = "ip_addresses"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"interfaces[].interface_data"}" & @CRLF & _
" get_attr {"ip_addresses[].ip_address_data"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_ip_address table"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "ip_addresses"" & @CRLF & _
" target_table_name = "cmdb_ci_ip_address"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"ip_addresses[].ip"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "netmask"" & @CRLF & _
" value = get_attr {"ip_addresses[].netmask"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_version"" & @CRLF & _
" value = get_attr {"ip_addresses[].version"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"ip_addresses[].name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_ip_address table - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "ip_addresses_final"" & @CRLF & _
" target_table_name = "cmdb_ci_ip_address"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"ip_addresses_final[].ip"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "netmask"" & @CRLF & _
" value = get_attr {"ip_addresses_final[].netmask"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_version"" & @CRLF & _
" value = get_attr {"ip_addresses_final[].version"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"ip_addresses_final[].interface_name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate IP addresses"" & @CRLF & _
" set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${cmdb_ci_ip_address},[\"ip_address\",\"netmask\"]);" & @CRLF & _
"CTX.setAttribute(\"cmdb_ci_ip_address\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove interfaces without IP"" & @CRLF & _
" merge {" & @CRLF & _
" table1_name = "ip_addresses"" & @CRLF & _
" table2_name = "interfaces"" & @CRLF & _
" result_table_name = "interfaces"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"interfaces[].interface_data"}" & @CRLF & _
" get_attr {"ip_addresses[].ip_address_data"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate interfaces"" & @CRLF & _
" set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${interfaces},\"name\");" & @CRLF & _
"CTX.setAttribute(\"interfaces\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_network_adapter table"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "interfaces"" & @CRLF & _
" target_table_name = "cmdb_ci_network_adapter"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"interfaces[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"interfaces[].ip"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "mac_address"" & @CRLF & _
" value = get_attr {"interfaces[].mac_address"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "netmask"" & @CRLF & _
" value = get_attr {"interfaces[].netmask"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_network_adapter table - for kernel and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "interfaces_kernel3"" & @CRLF & _
" target_table_name = "cmdb_ci_network_adapter"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"interfaces_kernel3[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"interfaces_kernel3[].ip"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "mac_address"" & @CRLF & _
" value = get_attr {"interfaces_kernel3[].mac"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "netmask"" & @CRLF & _
" value = get_attr {"interfaces_kernel3[].netmask"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate mac from adapter"" & @CRLF & _
" set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript: var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${cmdb_ci_network_adapter},[\"mac_address\", \"name\"]);" & @CRLF & _
"CTX.setAttribute(\"cmdb_ci_network_adapter\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_ip_address and cmdb_ci_network_adapter"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_ip_address"" & @CRLF & _
" table2_name = "cmdb_ci_network_adapter"" & @CRLF & _
" result_table_name = "ip_to_nic"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"cmdb_ci_network_adapter[].name"}" & @CRLF & _
" get_attr {"cmdb_ci_ip_address[].name"}" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "nic"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_network_adapter and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_network_adapter"" & @CRLF & _
" result_table_name = "lix_nic_rel"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Owns::Owned by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "cmdb_ci"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_ip_address and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_ip_address"" & @CRLF & _
" result_table_name = "lix_ip_rel"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Owns::Owned by"" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = """ & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get the routes and gateway"" & @CRLF & _
" if {" & @CRLF & _
" condition = neq {" & @CRLF & _
" get_attr {"use_net_tools"}" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "route -n"" & @CRLF & _
" var_names = "routeOut"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get the routes - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ip r"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "routeTable_kernel_3"" & @CRLF & _
" col_names = "destination","ifName"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" exclude_lines_pattern = "via"" & @CRLF & _
" delimiters = " "" & @CRLF & _
" selected_positions = 1,3" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get the Gateway route - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ip r"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "routeTable_kernel_3G"" & @CRLF & _
" col_names = "destination","gateway","ifName"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" include_lines_pattern = "via"" & @CRLF & _
" delimiters = " "" & @CRLF & _
" selected_positions = 1,3,5" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter gateway"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "gateways_filter_temp"" & @CRLF & _
" eval {"javascript: rtrn = '';" & @CRLF & _
"var originalTable = ${routeTable_kernel_3G};" & @CRLF & _
"var filteredTable = new Packages.java.util.ArrayList();" & @CRLF & _
"var SncIPAddressV4 = Packages.com.snc.commons.networks.IPAddressV4;" & @CRLF & _
"var SncIPAddressV6 = Packages.com.snc.commons.networks.IPAddressV6;" & @CRLF & _
"" & @CRLF & _
"for (var i = 0 ; i < originalTable.size() ; i++) {" & @CRLF & _
" var destination = originalTable.get(i).get('destination');" & @CRLF & _
" var gateway = originalTable.get(i).get('gateway');" & @CRLF & _
" var ifName = originalTable.get(i).get('ifName');" & @CRLF & _
" " & @CRLF & _
" if (destination == 'default')" & @CRLF & _
" destination = '0.0.0.0/0';" & @CRLF & _
" " & @CRLF & _
" var destinationParts = destination.split('/');" & @CRLF & _
" if (!destinationParts)" & @CRLF & _
" continue;" & @CRLF & _
" " & @CRLF & _
" var destIpv4 = SncIPAddressV4.get(destinationParts[0]);" & @CRLF & _
" var destIpv6 = SncIPAddressV6.get(destinationParts[0]);" & @CRLF & _
" if (!destIpv4 && !destIpv6 )" & @CRLF & _
" continue;" & @CRLF & _
" " & @CRLF & _
" if (destIpv4 && destinationParts.length == 1)" & @CRLF & _
" destination = destIpv4 + '/32';" & @CRLF & _
" " & @CRLF & _
" if (destIpv6 && destinationParts.length == 1)" & @CRLF & _
" destination = destIpv4 + '/64';" & @CRLF & _
" " & @CRLF & _
" if (!SncIPAddressV4.get(gateway) && !SncIPAddressV6.get(gateway) )" & @CRLF & _
" continue;" & @CRLF & _
" " & @CRLF & _
" if (!ifName)" & @CRLF & _
" continue;" & @CRLF & _
" " & @CRLF & _
" var entry = new Packages.java.util.HashMap();" & @CRLF & _
" entry.put(\"destination\", destination);" & @CRLF & _
" entry.put(\"gateway\", gateway);" & @CRLF & _
" entry.put(\"ifName\", ifName);" & @CRLF & _
" filteredTable.add(entry);" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"CTX.setAttribute(\"routeTable_kernel_3G\", filteredTable);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract the gateway"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"routeOut"}}" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "routeOut"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "GatewayMap"" & @CRLF & _
" col_names = "DefGateway"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" include_lines_pattern = "G"" & @CRLF & _
" exclude_lines_pattern = "Destination"" & @CRLF & _
" delimiters = " "" & @CRLF & _
" selected_positions = 2" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Failover: Get the routes and gateway"" & @CRLF & _
" set_attr {" & @CRLF & _
" "tmp"" & @CRLF & _
" eval {"javascript: var rtn = \"\";" & @CRLF & _
"var command = \"ip r\";" & @CRLF & _
"var resp = CTX.getCommandManager().shellCommand(command, false, null, null, CTX);" & @CRLF & _
"var spl = resp.split(\"\\r\\n\");" & @CRLF & _
"var new_table = new Packages.java.util.ArrayList();" & @CRLF & _
"var destination= \"\";" & @CRLF & _
"var gateway = \"\";" & @CRLF & _
"var mask = \"\";" & @CRLF & _
"var flag = \"\";" & @CRLF & _
"var ifName = \"\";" & @CRLF & _
"var new_table = new Packages.java.util.ArrayList();" & @CRLF & _
"var gateway_table = new Packages.java.util.ArrayList();" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"function calcFlag(data) {" & @CRLF & _
"" & @CRLF & _
" var res = \"\";" & @CRLF & _
" if(data.contains(\"via\")) {" & @CRLF & _
" res = \"UG\";" & @CRLF & _
" } else {" & @CRLF & _
" res = \"U\";" & @CRLF & _
" }" & @CRLF & _
" return res;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"function findIp(data) {" & @CRLF & _
" var ipPattern =/(\\d+.\\d+.\\d+.\\d+).*/gi;" & @CRLF & _
" var match = ipPattern.exec(data);" & @CRLF & _
" if(match) {" & @CRLF & _
" return match[1];" & @CRLF & _
" } else {" & @CRLF & _
" return '';" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
"function createNetmaskAddr(bitCount) {" & @CRLF & _
" var mask=[];" & @CRLF & _
" for(var j=0;j<4;j++) {" & @CRLF & _
" var n = Math.min(bitCount, 8);" & @CRLF & _
" mask.push(256 - Math.pow(2, 8-n));" & @CRLF & _
" bitCount -= n;" & @CRLF & _
" }" & @CRLF & _
" return mask.join('.');" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
"function findIfName(data) {" & @CRLF & _
" var ifNamePattern =/^.*dev\\s+([^\\s]+).*/gi;" & @CRLF & _
" var match = ifNamePattern.exec(data);" & @CRLF & _
" if(match) {" & @CRLF & _
" return match[1];" & @CRLF & _
" } else {" & @CRLF & _
" return '';" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"function findmask(data) {" & @CRLF & _
" var maskPattern =/\\d+.\\d+.\\d+.\\d+\\/(\\d+)\\s+/gi;" & @CRLF & _
" var match = maskPattern.exec(data);" & @CRLF & _
" if(match) {" & @CRLF & _
" return match[1];" & @CRLF & _
" } else {" & @CRLF & _
" return '';" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"for(var i=0;i<spl.length;i++) {" & @CRLF & _
" if(spl[i] != null && spl[i] != undefined ) {" & @CRLF & _
" if(spl[i].startsWith(\"default\")){" & @CRLF & _
" destination = \"0.0.0.0\";" & @CRLF & _
" gateway = findIp(spl[i]);" & @CRLF & _
" mask = \"0.0.0.0\";" & @CRLF & _
" ifName = findIfName(spl[i]);" & @CRLF & _
" flag = calcFlag(spl[i]);" & @CRLF & _
" } else {" & @CRLF & _
" try {" & @CRLF & _
" gateway = \"0.0.0.0\";" & @CRLF & _
" flag = calcFlag(spl[i]);" & @CRLF & _
" destination = findIp(spl[i]);" & @CRLF & _
" ifName = findIfName(spl[i]);" & @CRLF & _
" mask = createNetmaskAddr(findmask(spl[i]));" & @CRLF & _
" " & @CRLF & _
" } catch (e) {" & @CRLF & _
" ms.log(\"error Failover get routes and gateways: \" + e);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" var row = new Packages.java.util.HashMap();" & @CRLF & _
" " & @CRLF & _
" row.put('destination',destination);" & @CRLF & _
" row.put('gateway',gateway);" & @CRLF & _
" row.put('flag',flag);" & @CRLF & _
" row.put('ifName',ifName);" & @CRLF & _
" row.put('mask',mask);" & @CRLF & _
" new_table.add(row);" & @CRLF & _
" if(flag.contains('G')) {" & @CRLF & _
" var gatewayrow = new Packages.java.util.HashMap();" & @CRLF & _
" gatewayrow.put('DefGateway',gateway);" & @CRLF & _
" gateway_table.add(gatewayrow);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"CTX.setAttribute('route_table_ss', new_table);" & @CRLF & _
"CTX.setAttribute('GatewayMap_ss', gateway_table);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "merge gateway and gateway_ss"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "GatewayMap"" & @CRLF & _
" table2_name = "GatewayMap_ss"" & @CRLF & _
" result_table_name = "GatewayMap"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = " remove duplicates from gateway"" & @CRLF & _
" set_attr {" & @CRLF & _
" "tmp"" & @CRLF & _
" eval {"javascript: var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${GatewayMap},[\"DefGateway\",]);" & @CRLF & _
"CTX.setAttribute(\"GatewayMap\", tableWithoutDuplicates);"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update gateway in NIC CI"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "cmdb_ci_network_adapter"" & @CRLF & _
" target_table_name = "cmdb_ci_network_adapter"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "ip_default_gateway"" & @CRLF & _
" value = get_attr {"GatewayMap[1].DefGateway"}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update gateway in NIC CI - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "cmdb_ci_network_adapter"" & @CRLF & _
" target_table_name = "cmdb_ci_network_adapter"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "ip_default_gateway"" & @CRLF & _
" value = get_attr {"gateway_kernel3[1].DefGateway"}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update gateway in Linux CI"" & @CRLF & _
" set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].default_gateway"" & @CRLF & _
" get_attr {"GatewayMap[1].DefGateway"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update gateway in Linux CI - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].default_gateway"" & @CRLF & _
" get_attr {"gateway_kernel3[1].DefGateway"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update dscy_router_interface"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "cmdb_ci_network_adapter"" & @CRLF & _
" target_table_name = "dscy_router_interface"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"cmdb_ci_network_adapter[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"cmdb_ci_network_adapter[].ip_address"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "mac_address"" & @CRLF & _
" value = get_attr {"cmdb_ci_network_adapter[].mac_address"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between dscy_router_interface and CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "dscy_router_interface"" & @CRLF & _
" result_table_name = "li_to_ri"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Uses::Used by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "cmdb_ci"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract routes"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"routeOut"}}" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "routeOut"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "route_table"" & @CRLF & _
" col_names = "destination","gateway","mask","flag","ifName"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" exclude_lines_pattern = "Destination"," Kernel"" & @CRLF & _
" delimiters = " "" & @CRLF & _
" selected_positions = 1,2,3,4,8" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "merge route_table and route_table_ss"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "route_table"" & @CRLF & _
" table2_name = "route_table_ss"" & @CRLF & _
" result_table_name = "route_table"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "remove duplicates from route_table"" & @CRLF & _
" set_attr {" & @CRLF & _
" "tmp"" & @CRLF & _
" eval {"javascript: var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${route_table},[\"ifName\",\"destination\",\"gateway\"]);" & @CRLF & _
"CTX.setAttribute(\"route_table\", tableWithoutDuplicates);"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Set dest_ip_network for each route"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "route_table"" & @CRLF & _
" target_table_name = "route_table"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "dest_ip_network"" & @CRLF & _
" value = eval {"javascript: rtrn = \"\";" & @CRLF & _
"var dest = ${route_table[].destination};" & @CRLF & _
"var mask = ${route_table[].mask};" & @CRLF & _
"var cidr = 0;" & @CRLF & _
"var parts = mask.split('.');" & @CRLF & _
"for (var i=0; i < parts.length; i++) {" & @CRLF & _
"part = Number(parts[i]);" & @CRLF & _
"while (0x80 == (part & 0x80)) {" & @CRLF & _
"++cidr;" & @CRLF & _
"part = part << 1 & 0xff;" & @CRLF & _
"}" & @CRLF & _
"}" & @CRLF & _
"rtrn= dest + \"/\" + cidr.toString();" & @CRLF & _
""}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter route interfaces"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "route_table"" & @CRLF & _
" target_table_name = "route_tableNG"" & @CRLF & _
" condition = all {" & @CRLF & _
" not_contains {" & @CRLF & _
" get_attr {"route_table[].flag"}" & @CRLF & _
" "G"" & @CRLF & _
" }" & @CRLF & _
" not_starts_with {" & @CRLF & _
" "127"" & @CRLF & _
" get_attr {"route_table[].destination"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update dscy_route_interface"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "route_tableNG"" & @CRLF & _
" target_table_name = "dscy_route_interface"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "dest_ip_network"" & @CRLF & _
" value = get_attr {"route_tableNG[].dest_ip_network"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"route_tableNG[].ifName"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update dscy_route_interface - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "routeTable_kernel_3"" & @CRLF & _
" target_table_name = "dscy_route_interface"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "dest_ip_network"" & @CRLF & _
" value = get_attr {"routeTable_kernel_3[].destination"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"routeTable_kernel_3[].ifName"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate exit interfaces"" & @CRLF & _
" set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${dscy_route_interface},\"dest_ip_network\");" & @CRLF & _
"CTX.setAttribute(\"dscy_route_interface\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between dscy_route_interface and CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "dscy_route_interface"" & @CRLF & _
" result_table_name = "ri_to_li"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Uses::Used by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "cmdb_ci"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between dscy_route_interface and dscy_router_interface"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "dscy_route_interface"" & @CRLF & _
" key1_name = "ifName"" & @CRLF & _
" table2_name = "dscy_router_interface"" & @CRLF & _
" key2_name = "name"" & @CRLF & _
" result_table_name = "rr_to_rr"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "router_interface"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter gateways"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "route_table"" & @CRLF & _
" target_table_name = "route_tableG"" & @CRLF & _
" condition = all {" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"route_table[].flag"}" & @CRLF & _
" "G"" & @CRLF & _
" }" & @CRLF & _
" not_starts_with {" & @CRLF & _
" "127"" & @CRLF & _
" get_attr {"route_table[].destination"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update dscy_route_next_hop"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "route_tableG"" & @CRLF & _
" target_table_name = "dscy_route_next_hop"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "dest_ip_network"" & @CRLF & _
" value = get_attr {"route_tableG[].dest_ip_network"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"route_tableG[].ifName"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "next_hop_ip_address"" & @CRLF & _
" value = get_attr {"route_tableG[].gateway"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update dscy_route_next_hop - for kernel 3 and above"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "3"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"kernel"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "routeTable_kernel_3G"" & @CRLF & _
" target_table_name = "dscy_route_next_hop"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "dest_ip_network"" & @CRLF & _
" value = get_attr {"routeTable_kernel_3G[].destination"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"routeTable_kernel_3G[].ifName"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "next_hop_ip_address"" & @CRLF & _
" value = get_attr {"routeTable_kernel_3G[].gateway"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate from dscy_route_next_hop"" & @CRLF & _
" set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript: var tableWithoutDuplicates = '';" & @CRLF & _
" tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${dscy_route_next_hop},[\"dest_ip_network\",\"next_hop_ip_address\"]);" & @CRLF & _
"CTX.setAttribute(\"dscy_route_next_hop\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between dscy_route_interface and dscy_route_next_hop"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "dscy_route_next_hop"" & @CRLF & _
" key1_name = "ifName"" & @CRLF & _
" table2_name = "dscy_route_interface"" & @CRLF & _
" key2_name = "ifName"" & @CRLF & _
" result_table_name = "hop_to_route"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "route_interface"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between dscy_route_next_hop and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "dscy_route_next_hop"" & @CRLF & _
" result_table_name = "hop_to_ci"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Uses::Used by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "cmdb_ci"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>admin</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:40:01</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>0ae107e39f2032001d753758442e70ec</sys_id>" & @CRLF & _
"<sys_mod_count>120</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Network</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_0ae107e39f2032001d753758442e70ec</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2020-10-13 12:57:18</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_linux_server</ci_type>" & @CRLF & _
"<cpattern_type>3</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>1d2810b14fa12200609b92918110c7a7</metadata_id>" & @CRLF & _
"<name>Linux Server</name>" & @CRLF & _
"<ndl>pattern {" & @CRLF & _
" metadata {" & @CRLF & _
" id = "1d2810b14fa12200609b92918110c7a7"" & @CRLF & _
" name = "Linux Server"" & @CRLF & _
" description = """ & @CRLF & _
" citype = "cmdb_ci_linux_server"" & @CRLF & _
" }" & @CRLF & _
" identification {" & @CRLF & _
" name = "discovery"" & @CRLF & _
" entry_point {type = "*"}" & @CRLF & _
" find_process_strategy {strategy = NONE}" & @CRLF & _
" step {" & @CRLF & _
" name = "Unix\\Linux Name Formatting"" & @CRLF & _
" ref {refid = "46d81a979f10320055063758442e707f"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert OS name, version and name to cmdb_ci_linux_server"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "cmdb_ci_linux_server"" & @CRLF & _
" target_table_name = "cmdb_ci_linux_server"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "os_version"" & @CRLF & _
" value = get_attr {"osVersion"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "os_name"" & @CRLF & _
" value = get_attr {"osName"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"formattedHostname"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Identity"" & @CRLF & _
" ref {refid = "a273cfe39f2032001d753758442e70b7"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "DNS"" & @CRLF & _
" ref {refid = "ede27fe5db652200868a7c841f961984"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get DNS Names for IPs"" & @CRLF & _
" ref {refid = "4bc39226db968010b0fa5635dc96190e"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get DNS name for ManagementIP"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldIncludeDomain"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cmdb_ci_dns_name[1].name"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "DNSName"" & @CRLF & _
" eval {"javascript: var rtrn ='';" & @CRLF & _
"var table =${cmdb_ci_dns_name};" & @CRLF & _
"var ip=${computer_system.managementIP};" & @CRLF & _
"for(var i=0;i < table.size();i++){" & @CRLF & _
" var map=table.get(i);" & @CRLF & _
" if(map.get('ip_address') == ip){" & @CRLF & _
" rtrn =map.get('name');" & @CRLF & _
" break;" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"rtrn =rtrn;"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Set DNS name to name for Linux Server"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"DNSName"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].name"" & @CRLF & _
" get_attr {"DNSName"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Find FQDN"" & @CRLF & _
" ref {refid = "5e1243e39f2032001d753758442e7041"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Distribution"" & @CRLF & _
" ref {refid = "fe32c7e39f2032001d753758442e7065"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "UNIX - OS Uptime"" & @CRLF & _
" ref {refid = "80d2cbe39f2032001d753758442e7092"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update start date on Linux CI"" & @CRLF & _
" set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].start_date"" & @CRLF & _
" get_attr {"start_date"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Memory"" & @CRLF & _
" ref {refid = "4103cbe39f2032001d753758442e709a"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Memory Modules"" & @CRLF & _
" ref {refid = "dc334fe39f2032001d753758442e70b7"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Network ARP Tables"" & @CRLF & _
" ref {refid = "84538fe39f2032001d753758442e7086"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - CPU"" & @CRLF & _
" ref {refid = "e69343279f2032001d753758442e7067"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Storage"" & @CRLF & _
" ref {refid = "303407279f2032001d753758442e708c"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Cloud"" & @CRLF & _
" ref {refid = "4660f86edb057200c12ef9361d96190c"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>bogdan.tomov</sys_created_by>" & @CRLF & _
"<sys_created_on>2016-08-30 11:40:35</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>1d2810b14fa12200609b92918110c7a7</sys_id>" & @CRLF & _
"<sys_mod_count>439</sys_mod_count>" & @CRLF & _
"<sys_name>Linux Server</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_1d2810b14fa12200609b92918110c7a7</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2020-08-31 13:23:52</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>303407279f2032001d753758442e708c</metadata_id>" & @CRLF & _
"<name>Linux - Storage</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Storage"" & @CRLF & _
" id = "303407279f2032001d753758442e708c"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "Run storage script file"" & @CRLF & _
" custom_operation {" & @CRLF & _
" attributes {attribute {" & @CRLF & _
" name = "fileName"" & @CRLF & _
" value = "storage.bash"" & @CRLF & _
" }}" & @CRLF & _
" sys_id_op = "68367a239fc13200e9123758442e7083"" & @CRLF & _
" to_var_names = "stOut"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "NonExistingSeparator"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" is_paginated = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove new lines from storage output"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"stOut"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "stOut"" & @CRLF & _
" eval {"javascript: " & @CRLF & _
"var rtrn = '';" & @CRLF & _
"var stOut = ${stOut};" & @CRLF & _
"var strStOut = new Packages.java.lang.String(stOut);" & @CRLF & _
"" & @CRLF & _
"rtrn = strStOut.replaceAll(\"\\n\",\" \");"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Map output to collection"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"stOut"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "sd_out"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var output = ${stOut};" & @CRLF & _
"var sectionParser = new DiscoveryProbeOutputSectionParser({indentedMarkupSections: [ 'sys_block', 'proc_mounts', 'sys_iscsi', 'fc' ]});" & @CRLF & _
"var results = sectionParser.parse(output);" & @CRLF & _
"var initiator = ''+results.sys_iscsi_initiator;" & @CRLF & _
"if (initiator) " & @CRLF & _
"{" & @CRLF & _
" initiator = initiator.split('=')[1] || '';" & @CRLF & _
" results.sys_iscsi_initiator = initiator.trim();" & @CRLF & _
"}" & @CRLF & _
"rtrn = JSON.stringify(results);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get vxvm"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "command -v vxprint"" & @CRLF & _
" var_names = "vxvm"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_Ide________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get proc_ide data"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_out"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "sd_proc_ide"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var results = JSON.parse(${sd_out});" & @CRLF & _
"rtrn = JSON.stringify(results.proc_ide);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create empty proc_ide table"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "ProcIDE"" & @CRLF & _
" table2_name = "ProcIDE"" & @CRLF & _
" result_table_name = "ProcIDE"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert data to proc_ide"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_proc_ide"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" concat {eval {"javascript: rtrn = \"\";" & @CRLF & _
"var ide = ${sd_proc_ide};" & @CRLF & _
"ide = ide.substring(0,ide.length-2);" & @CRLF & _
"var block = ide.split(\"ide:\");" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"if(block){" & @CRLF & _
"for (var i = 1; i < block.length; i++)" & @CRLF & _
"{" & @CRLF & _
" var blockSp = block[i].split(',');" & @CRLF & _
" var clrow = row.clone(); " & @CRLF & _
" clrow.put(\"deviceID\", blockSp[0]);" & @CRLF & _
" var MkMod = blockSp[1].split(\" \");" & @CRLF & _
" clrow.put(\"vendorName\", MkMod[0]);" & @CRLF & _
" var modelName = \"\";" & @CRLF & _
" for (var j = 1; j < MkMod.length; j++)" & @CRLF & _
" {" & @CRLF & _
" modelName +=MkMod[j] + \" \";" & @CRLF & _
" }" & @CRLF & _
" clrow.put(\"modelName\", modelName);" & @CRLF & _
" clrow.put(\"size\", blockSp[2]);" & @CRLF & _
" clrow.put(\"deviceType\", blockSp[3]);" & @CRLF & _
" ${ProcIDE}.add(clrow); " & @CRLF & _
"}" & @CRLF & _
" CTX.setAttribute('ProcIDE',${ProcIDE});" & @CRLF & _
"" & @CRLF & _
" rtrn = ide;" & @CRLF & _
"}" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Normalize proc_ide columns names"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "ProcIDE"" & @CRLF & _
" target_table_name = "ProcIDE"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"ProcIDE[].deviceID"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "vendor"" & @CRLF & _
" value = get_attr {"ProcIDE[].vendorName"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "model"" & @CRLF & _
" value = get_attr {"ProcIDE[].modelName"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "storage_type"" & @CRLF & _
" value = eval {"javascript:rtrn = \"\";var type = ${ProcIDE[].deviceType};switch (type){ case \"cdrom\": rtrn = \"cd\"; break; case \"CD-ROM\": rtrn = \"cd\"; break; case \"Direct-Access\": rtrn = \"disk\"; break; default: rtrn = \"logical\";}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_Ide________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_SysBlock________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get sys_block data"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_out"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "sd_sysblock"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var results = JSON.parse(${sd_out});" & @CRLF & _
"rtrn = JSON.stringify(results.sys_block.sysBlock);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create empty sys_block table"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "SysBlock"" & @CRLF & _
" table2_name = "SysBlock"" & @CRLF & _
" result_table_name = "SysBlock"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert data to sys_block table"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_sysblock"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" concat {eval {"javascript:" & @CRLF & _
"var rtrn = \"\";" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"var data = ${sd_sysblock};" & @CRLF & _
"data = data.substring(2,data.length-2);" & @CRLF & _
"var datasp = data.split(\"sysBlock:\");" & @CRLF & _
"var count = 0;" & @CRLF & _
"if(datasp){" & @CRLF & _
"var sectorSize = 512;" & @CRLF & _
"var ParentDisk = \"\";" & @CRLF & _
"var nameHolder =\"\";" & @CRLF & _
"for (var i = 0; i < datasp.length; i++)" & @CRLF & _
"{" & @CRLF & _
" var block = datasp[i].split(\" \");" & @CRLF & _
" for (var j = 0; j < block.length; j++)" & @CRLF & _
" {" & @CRLF & _
" if (block[j] == \"name:\" || block[j] == \"[\\\"name:\")" & @CRLF & _
" {" & @CRLF & _
" if (count == 0 )" & @CRLF & _
" {" & @CRLF & _
" var clrow = row.clone();" & @CRLF & _
" clrow.put(\"name\",block[j+1]); nameHolder = block[j+1]; count = 1;" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" ${SysBlock}.add(clrow);" & @CRLF & _
" var clrow = row.clone();" & @CRLF & _
" clrow.put(\"name\",block[j+1]); nameHolder = block[j+1];" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"deviceMajorMinor:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"deviceMajorMinor\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"sectors:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"sectors\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"sectorSize:\")" & @CRLF & _
" {" & @CRLF & _
" sectorSize = block[j+1];" & @CRLF & _
" if (block[j+1] == \"0\")" & @CRLF & _
" {sectorSize = \"512\";}" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"dmName:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"dmName\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"dmId:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"dmId\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"host:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"host\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"vendor:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"vendor\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"model:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"model\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"devType:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"devType\",block[j+1]); ParentDisk = nameHolder;" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"number:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"number\",block[j+1]); clrow.put(\"parentDisk\",ParentDisk);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"beginOffset:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"beginOffset\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" clrow.put(\"sectorSize\",sectorSize);" & @CRLF & _
" }" & @CRLF & _
" if (i == (datasp.length - 1) )" & @CRLF & _
" { " & @CRLF & _
" ${SysBlock}.add(clrow);" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"CTX.setAttribute('SysBlock',${SysBlock});" & @CRLF & _
"" & @CRLF & _
"rtrn = \"test\";" & @CRLF & _
"}" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_SysBlock________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_Partition________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create partitions table"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "SysBlock"" & @CRLF & _
" target_table_name = "partition_table"" & @CRLF & _
" condition = is_not_empty {get_attr {"SysBlock[].number"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_disk_partition"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "partition_table"" & @CRLF & _
" target_table_name = "cmdb_ci_disk_partition"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/"" & @CRLF & _
" get_attr {"partition_table[].name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "start_offset"" & @CRLF & _
" value = concat {eval {"javascript:rtrn=\"\";" & @CRLF & _
"var begin = parseInt(${partition_table[].beginOffset}); " & @CRLF & _
"var size = parseInt(${partition_table[].sectorSize});" & @CRLF & _
"rtrn = ((begin * size) || 0) + '';" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "end_offset"" & @CRLF & _
" value = concat {eval {"javascript:rtrn=\"\";" & @CRLF & _
"var begin = parseInt(${partition_table[].beginOffset});" & @CRLF & _
"var sectors = parseInt(${partition_table[].sectors});" & @CRLF & _
"var size = parseInt(${partition_table[].sectorSize});" & @CRLF & _
"var dataSize = size*sectors;" & @CRLF & _
"rtrn = (begin + dataSize) + '';" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "partition_number"" & @CRLF & _
" value = get_attr {"partition_table[].number"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_major_minor"" & @CRLF & _
" value = get_attr {"partition_table[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "size_bytes"" & @CRLF & _
" value = concat {eval {"javascript:rtrn=\"\";" & @CRLF & _
"var sectors = parseInt(${partition_table[].sectors});" & @CRLF & _
"var size = parseInt(${partition_table[].sectorSize});" & @CRLF & _
"rtrn = (size*sectors) + '';"}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "major"" & @CRLF & _
" value = eval {"javascript: rtrn=\"\";" & @CRLF & _
"var MajMin = ${partition_table[].deviceMajorMinor};" & @CRLF & _
"if (MajMin != null)" & @CRLF & _
"{ " & @CRLF & _
" var Maj = MajMin.split(':');" & @CRLF & _
" rtrn = Maj[0];" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "parent"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/"" & @CRLF & _
" get_attr {"partition_table[].parentDisk"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_disk_partition and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_disk_partition"" & @CRLF & _
" result_table_name = "lin_to_partition"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Contains::Contained by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "computer"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_Partition________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get scsi_path_map"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_out"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "sd_scsi_path"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var results = JSON.parse(${sd_out});" & @CRLF & _
"rtrn = JSON.stringify(results.scsi_path_map);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create empty scsi_path_map"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_not_empty {get_attr {"sd_scsi_path"}}" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"sd_scsi_path"}" & @CRLF & _
" "null"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = union {" & @CRLF & _
" table1_name = "SysBusMap"" & @CRLF & _
" table2_name = "SysBusMap"" & @CRLF & _
" result_table_name = "SysBusMap"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert data to scsi_path_map table"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_not_empty {get_attr {"sd_scsi_path"}}" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"sd_scsi_path"}" & @CRLF & _
" "null"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" concat {eval {"javascript:rtrn = \"\";" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"var data = JSON.parse(${sd_scsi_path});" & @CRLF & _
"" & @CRLF & _
"if(data){" & @CRLF & _
"for (var i = 0; i < data.length; i++)" & @CRLF & _
"{" & @CRLF & _
" var line = data[i];" & @CRLF & _
" var matches = line.match(\"/^(\\d+):(\\d+):(\\d+):(\\d+),(\\w+)$/\");" & @CRLF & _
" if (matches == null)" & @CRLF & _
" {" & @CRLF & _
" continue;" & @CRLF & _
" }" & @CRLF & _
" var data = " & @CRLF & _
" {" & @CRLF & _
" host: matches[1]," & @CRLF & _
" bus: matches[2]," & @CRLF & _
" target: matches[3]," & @CRLF & _
" lun: matches[4]," & @CRLF & _
" deviceId: matches[5]," & @CRLF & _
" deviceMajorMinor: null," & @CRLF & _
" };" & @CRLF & _
" var rowed = row.clone();" & @CRLF & _
" rowed.put(\"host\",data.host);" & @CRLF & _
" rowed.put(\"bus\",data.bus);" & @CRLF & _
" rowed.put(\"target\",data.target);" & @CRLF & _
" rowed.put(\"lun\",data.lun);" & @CRLF & _
" rowed.put(\"deviceId\",data.deviceId);" & @CRLF & _
" ${SCSI_path}.add(rowed); " & @CRLF & _
"}" & @CRLF & _
"CTX.setAttribute('SCSI_path',${SCSI_path})" & @CRLF & _
"rtrn =\"tooMuch\";" & @CRLF & _
"}" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get proc_mounts"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_out"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "sd_proc_mounts"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var results = JSON.parse(${sd_out});" & @CRLF & _
"rtrn = JSON.stringify(results.proc_mounts.procMount);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create empty proc_mounts table"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "procMounts"" & @CRLF & _
" table2_name = "procMounts"" & @CRLF & _
" result_table_name = "procMounts"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update proc_mounts table"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_proc_mounts"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" concat {eval {"javascript:rtrn = \"\";" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"var data = ${sd_proc_mounts};" & @CRLF & _
"var datasp = data.split(\"procMount:\");" & @CRLF & _
"var count = 0;" & @CRLF & _
"if(datasp){" & @CRLF & _
"for (var i = 0; i < datasp.length; i++)" & @CRLF & _
"{" & @CRLF & _
" var block = datasp[i].split(\" \");" & @CRLF & _
" for (var j = 0; j < block.length; j++)" & @CRLF & _
" {" & @CRLF & _
" if (block[j] == \"name:\" || block[j] == \"[\\\"name:\")" & @CRLF & _
" {" & @CRLF & _
" if (count == 0 )" & @CRLF & _
" {" & @CRLF & _
" var clrow = row.clone();" & @CRLF & _
" clrow.put(\"name\",block[j+1]);" & @CRLF & _
" count = 1;" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" ${procMounts}.add(clrow);" & @CRLF & _
" var clrow = row.clone();" & @CRLF & _
" clrow.remove(\"cpu_data\");" & @CRLF & _
" clrow.put(\"name\",block[j+1]); " & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"mountPoint:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"mountPoint\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"filesystem:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"filesystem\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[j] == \"options:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"options\",block[j+1]);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if (i == (datasp.length - 1) )" & @CRLF & _
" { " & @CRLF & _
" ${procMounts}.add(clrow);" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"CTX.setAttribute('procMounts',${procMounts})" & @CRLF & _
"rtrn =\"tooMuch\";" & @CRLF & _
"}" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter rootfs and tmpfs from proc_mounts"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "procMounts"" & @CRLF & _
" target_table_name = "procMounts"" & @CRLF & _
" condition = all {" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"procMounts[].filesystem"}" & @CRLF & _
" "rootfs"" & @CRLF & _
" }" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"procMounts[].filesystem"}" & @CRLF & _
" "tmpfs"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get fdisk"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "sudo fdisk -l | grep 'Disk /'"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "sg_scsi_path_map"" & @CRLF & _
" col_names = "deviceId","size"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" include_lines_pattern = "Disk"" & @CRLF & _
" delimiters = " ",":"" & @CRLF & _
" selected_positions = 2,5" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_SCSI_iSCSI______"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get iscsi_sessions"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_out"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "iscsi_sessions"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var results = JSON.parse(${sd_out});" & @CRLF & _
"rtrn = JSON.stringify(results.sys_iscsi);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create empty iscsi_sessions table"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_not_empty {get_attr {"iscsi_sessions"}}" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"iscsi_sessions"}" & @CRLF & _
" "null"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = union {" & @CRLF & _
" table1_name = "iScsiSession"" & @CRLF & _
" table2_name = "iScsiSession"" & @CRLF & _
" result_table_name = "iScsiSession"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update iscsi_sessions table"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"iscsi_sessions"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" concat {eval {"javascript:" & @CRLF & _
"var rtrn = \"\";" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"var data = ${iscsi_sessions};" & @CRLF & _
"data = data.substring(2,data.length-1);" & @CRLF & _
"var datasp = data.split(\"iscsiSession\\\":\");" & @CRLF & _
"var count = 0;" & @CRLF & _
"var targetIqn;" & @CRLF & _
"var iscsiDisk;" & @CRLF & _
"var iscsiLun;" & @CRLF & _
"if(datasp){" & @CRLF & _
"for (var i = 1; i < datasp.length; i++)" & @CRLF & _
"{" & @CRLF & _
" datasp[i] = datasp[i].substring(2,datasp[i].length-2);" & @CRLF & _
" var block = datasp[i].split(/\\s+/);" & @CRLF & _
" " & @CRLF & _
" for (var j = 0; j < block.length; j++)" & @CRLF & _
" {" & @CRLF & _
" if (block[j] == \"targetIqn:\" || block[j] == \"[\\\"targetIqn:\")" & @CRLF & _
" {" & @CRLF & _
" targetIqn = block[j+1]; " & @CRLF & _
" }" & @CRLF & _
" else if (block[j] == \"id:\")" & @CRLF & _
" {" & @CRLF & _
" var clrow = row.clone();" & @CRLF & _
" clrow.put(\"deviceId\",block[j+1]);" & @CRLF & _
" clrow.put(\"targetIqn\",targetIqn);" & @CRLF & _
" }" & @CRLF & _
" else if (block[j] == \"lun:\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"iscsiLun\",block[j+1]);" & @CRLF & _
" ${iScsiSession}.add(clrow);" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"}" & @CRLF & _
"CTX.setAttribute('iScsiSession',${iScsiSession})" & @CRLF & _
"rtrn = '';" & @CRLF & _
"}" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get sys_iscsi_initiator"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_out"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "sd_sys_iscsi_initiator"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var results = JSON.parse(${sd_out});" & @CRLF & _
"rtrn = JSON.stringify(results.sys_iscsi_initiator);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Add initiator to iSCSI sessions"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_sys_iscsi_initiator"}}" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "iScsiSession"" & @CRLF & _
" target_table_name = "iScsiSession"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "iscsiInitiator"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"var initiator = ${sd_sys_iscsi_initiator};" & @CRLF & _
"rtrn = initiator.substring(1,initiator.length-1);" & @CRLF & _
""}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get proc_scsi"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "cat /proc/scsi/scsi | tr '\\n' ' '"" & @CRLF & _
" var_names = "proc_scsi"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "nonExistingLineSeparator"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Process the proc_scsi"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"proc_scsi"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "proc_tab"" & @CRLF & _
" eval {"javascript: rtrn=\"\";" & @CRLF & _
"var scsi = ${proc_scsi};" & @CRLF & _
"var block = scsi.split(\"Host:\");" & @CRLF & _
"for (var i = 1; i < block.length; i++)" & @CRLF & _
"{" & @CRLF & _
" rtrn += block[i] + \"\\n\";" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse proc_scsi"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"proc_tab"}}" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "proc_tab"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "proc_scsi_table"" & @CRLF & _
" col_names = "hostId","channel","id","lun","vendor","model","rev","type"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "\\D*(\\d+).*Channel: (\\d+).*Id: (\\d+).*Lun: (\\d+).*Vendor: (.*)Model:(.*)Rev:(.*)Type:(.*)A"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create proc_scsi key"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"proc_scsi_table"}}" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "proc_scsi_table"" & @CRLF & _
" target_table_name = "proc_scsi_table"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "key"" & @CRLF & _
" value = eval {"javascript: rtrn=\"\";" & @CRLF & _
"var hostid = parseInt(${proc_scsi_table[].hostId});" & @CRLF & _
"var channel = parseInt(${proc_scsi_table[].channel});" & @CRLF & _
"var id = parseInt(${proc_scsi_table[].id});" & @CRLF & _
"var lun = parseInt(${proc_scsi_table[].lun});" & @CRLF & _
"rtrn = hostid + \":\" + channel + \":\" + id + \":\" + lun;" & @CRLF & _
""}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge sys block and disks"" & @CRLF & _
" merge {" & @CRLF & _
" table1_name = "proc_scsi_table"" & @CRLF & _
" table2_name = "SysBlock"" & @CRLF & _
" result_table_name = "proc_scsi_table"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"proc_scsi_table[].key"}" & @CRLF & _
" get_attr {"SysBlock[].host"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter scsi disk"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "proc_scsi_table"" & @CRLF & _
" target_table_name = "proc_scsi_table_disk"" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"proc_scsi_table[].type"}" & @CRLF & _
" "Direct-Access"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update proc_scsi_table_disk"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "proc_scsi_table_disk"" & @CRLF & _
" target_table_name = "proc_scsi_table_disk"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/"" & @CRLF & _
" get_attr {"proc_scsi_table_disk[].name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "storage_type"" & @CRLF & _
" value = eval {"javascript:rtrn = \"\";var type = ${proc_scsi_table_disk[].type};switch (type){ case \"cdrom\": rtrn = \"cd\"; break; case \"CD-ROM\": rtrn = \"cd\"; break; case \"Direct-Access\": rtrn = \"disk\"; break; default: rtrn = \"logical\";}"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_interface"" & @CRLF & _
" value = "scsi"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Union proc_scsi_table_disk and proc_ide tables"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "ProcIDE"" & @CRLF & _
" table2_name = "proc_scsi_table_disk"" & @CRLF & _
" result_table_name = "ProcIDE"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Add iSCSI data to disks"" & @CRLF & _
" merge {" & @CRLF & _
" table1_name = "ProcIDE"" & @CRLF & _
" table2_name = "iScsiSession"" & @CRLF & _
" result_table_name = "ProcIDE"" & @CRLF & _
" unmatched_lines = keep" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"ProcIDE[].name"}" & @CRLF & _
" get_attr {"iScsiSession[].deviceId"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract iSCSI disks to different table"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "ProcIDE"" & @CRLF & _
" target_table_name = "iSCSIDisks"" & @CRLF & _
" condition = is_not_empty {get_attr {"ProcIDE[].targetIqn"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove iSCSI disks from SCSI table"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "ProcIDE"" & @CRLF & _
" target_table_name = "ProcIDE"" & @CRLF & _
" condition = is_empty {get_attr {"ProcIDE[].targetIqn"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_disk Table"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "ProcIDE"" & @CRLF & _
" target_table_name = "cmdb_ci_disk"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"ProcIDE[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_id"" & @CRLF & _
" value = get_attr {"ProcIDE[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_host_id"" & @CRLF & _
" value = get_attr {"ProcIDE[].hostId"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_bus_id"" & @CRLF & _
" value = get_attr {"ProcIDE[].channel"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_target_id"" & @CRLF & _
" value = get_attr {"ProcIDE[].id"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_lun"" & @CRLF & _
" value = get_attr {"ProcIDE[].lun"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "size_bytes"" & @CRLF & _
" value = concat {eval {"javascript: rtrn = \"\";" & @CRLF & _
"var ide_size = parseInt(${ProcIDE[].size});" & @CRLF & _
"var sect = parseInt(${ProcIDE[].sectors});" & @CRLF & _
"var sectSize = parseInt(${ProcIDE[].sectorSize});" & @CRLF & _
"if(isNaN(ide_size))" & @CRLF & _
"{" & @CRLF & _
" rtrn = (sect*sectSize)+'';" & @CRLF & _
"}" & @CRLF & _
"else" & @CRLF & _
"{" & @CRLF & _
" rtrn = ide_size + '';" & @CRLF & _
"}" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "disk_space"" & @CRLF & _
" value = concat {eval {"javascript:var rtrn='';" & @CRLF & _
"var ide_size = parseInt(${ProcIDE[].size});" & @CRLF & _
"var sect = parseInt(${ProcIDE[].sectors});" & @CRLF & _
"var sectSize = parseInt(${ProcIDE[].sectorSize});" & @CRLF & _
"var spac = 0;" & @CRLF & _
"if(isNaN(ide_size))" & @CRLF & _
"{" & @CRLF & _
" spac = sect*sectSize;" & @CRLF & _
"}" & @CRLF & _
"else" & @CRLF & _
"{" & @CRLF & _
" spac = ide_size;" & @CRLF & _
"}" & @CRLF & _
"rtrn = (spac/1073741824) + '';" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_major_minor"" & @CRLF & _
" value = get_attr {"ProcIDE[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "storage_type"" & @CRLF & _
" value = get_attr {"ProcIDE[].storage_type"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_interface"" & @CRLF & _
" value = eval {"javascript: var rtrn = \"\";" & @CRLF & _
"var devInter = ${ProcIDE[].device_interface};" & @CRLF & _
"if (devInter == \"\")" & @CRLF & _
"{" & @CRLF & _
" rtrn = \"ide\";" & @CRLF & _
"}" & @CRLF & _
"else" & @CRLF & _
"{" & @CRLF & _
" rtrn = devInter;" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "manufacturer"" & @CRLF & _
" value = get_attr {"ProcIDE[].vendor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "model_id"" & @CRLF & _
" value = get_attr {"ProcIDE[].model"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "major"" & @CRLF & _
" value = eval {"javascript: rtrn=\"\";" & @CRLF & _
"var MajMin = ${ProcIDE[].deviceMajorMinor};" & @CRLF & _
"if (MajMin != null)" & @CRLF & _
"{ " & @CRLF & _
" var Maj = MajMin.split(':');" & @CRLF & _
" rtrn = Maj[0];" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_iscsi_disk Table"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "iSCSIDisks"" & @CRLF & _
" target_table_name = "cmdb_ci_iscsi_disk"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_id"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_host_id"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].hostId"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_bus_id"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].channel"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_target_id"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].id"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_lun"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].lun"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "size_bytes"" & @CRLF & _
" value = concat {eval {"javascript: rtrn = \"\";" & @CRLF & _
"var ide_size = parseInt(${iSCSIDisks[].size});" & @CRLF & _
"var sect = parseInt(${iSCSIDisks[].sectors});" & @CRLF & _
"var sectSize = parseInt(${iSCSIDisks[].sectorSize});" & @CRLF & _
"if(isNaN(ide_size))" & @CRLF & _
"{" & @CRLF & _
" rtrn = (sect*sectSize) + '';" & @CRLF & _
"}" & @CRLF & _
"else" & @CRLF & _
"{" & @CRLF & _
" rtrn = ide_size + '';" & @CRLF & _
"}" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "disk_space"" & @CRLF & _
" value = concat {eval {"javascript:var rtrn='';" & @CRLF & _
"var ide_size = parseInt(${iSCSIDisks[].size});" & @CRLF & _
"var sect = parseInt(${iSCSIDisks[].sectors});" & @CRLF & _
"var sectSize = parseInt(${iSCSIDisks[].sectorSize});" & @CRLF & _
"var spac = 0;" & @CRLF & _
"if(isNaN(ide_size))" & @CRLF & _
"{" & @CRLF & _
" spac = sect*sectSize;" & @CRLF & _
"}" & @CRLF & _
"else" & @CRLF & _
"{" & @CRLF & _
" spac = ide_size;" & @CRLF & _
"}" & @CRLF & _
"rtrn = (spac/1073741824) + '';" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_major_minor"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "storage_type"" & @CRLF & _
" value = "network"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_interface"" & @CRLF & _
" value = "iscsi"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "manufacturer"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].vendor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "model_id"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].model"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "major"" & @CRLF & _
" value = eval {"javascript: rtrn=\"\";" & @CRLF & _
"var MajMin = ${iSCSIDisks[].deviceMajorMinor};" & @CRLF & _
"if (MajMin != null)" & @CRLF & _
"{ " & @CRLF & _
" var Maj = MajMin.split(':');" & @CRLF & _
" rtrn = Maj[0];" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "iqn"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].targetIqn"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "initiator_iqn"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].iscsiInitiator"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_lun"" & @CRLF & _
" value = get_attr {"iSCSIDisks[].iscsiLun"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_disk table and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_disk"" & @CRLF & _
" result_table_name = "disk_to_linux"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Contains::Contained by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "computer"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_iscsi_disk table and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_iscsi_disk"" & @CRLF & _
" result_table_name = "iscsi_disk_to_linux"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Contains::Contained by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "computer"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter proc_scsi_table"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "proc_scsi_table"" & @CRLF & _
" target_table_name = "proc_scsi_table_storage"" & @CRLF & _
" condition = neq {" & @CRLF & _
" get_attr {"proc_scsi_table[].type"}" & @CRLF & _
" "Direct-Access"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update proc_scsi_table_storage"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "proc_scsi_table_storage"" & @CRLF & _
" target_table_name = "proc_scsi_table_storage"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/"" & @CRLF & _
" get_attr {"proc_scsi_table_storage[].name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "storage_type"" & @CRLF & _
" value = eval {"javascript:rtrn = \"\";var type = ${proc_scsi_table_storage[].type};switch (type){ case \"cdrom\": rtrn = \"cd\"; break; case \"CD-ROM\": rtrn = \"cd\"; break; case \"Direct-Access\": rtrn = \"disk\"; break; default: rtrn = \"logical\";}"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_interface"" & @CRLF & _
" value = "scsi"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get dmesg_scsi"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "grep -i 'attached scsi' /var/log/dmesg ; grep 'SCSI device' /var/log/dmesg"" & @CRLF & _
" var_names = "dmesg_scsi"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse dmsetup"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_out"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "sd_dmsetup"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var results = JSON.parse(${sd_out});" & @CRLF & _
"rtrn = JSON.stringify(results.dmsetup);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_scsi________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_LVM________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create empty device map table"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "dmMap"" & @CRLF & _
" table2_name = "dmMap"" & @CRLF & _
" result_table_name = "dmMap"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update device map table"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_dmsetup"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" concat {eval {"javascript:rtrn = \"\";" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"var data = ${sd_dmsetup};" & @CRLF & _
"data = data.substring(2,(data.length)-2);" & @CRLF & _
"var datasp = data.split(\"mappedDevice:\");" & @CRLF & _
"var count = 0;" & @CRLF & _
"if(datasp){" & @CRLF & _
"for (var i = 1; i < datasp.length; i++)" & @CRLF & _
"{" & @CRLF & _
" var block = datasp[i].split(\" \"); " & @CRLF & _
" var clrow = row.clone(); " & @CRLF & _
" clrow.put(\"alias\", block[1]);" & @CRLF & _
" clrow.put(\"deviceMajorMinor\", block[2]);" & @CRLF & _
" rtrn += \"i am\" + block[4];" & @CRLF & _
" if (block[4])" & @CRLF & _
" {" & @CRLF & _
" for (var j=4; j < block.length; j++)" & @CRLF & _
" {" & @CRLF & _
" if (block[j] === \"extends\")" & @CRLF & _
" {" & @CRLF & _
" ${dmMap}.add(clrow);" & @CRLF & _
" var clrow = row.clone(); " & @CRLF & _
" clrow.put(\"extends\", block[1]);" & @CRLF & _
" clrow.put(\"startSector\", block[j+1]);" & @CRLF & _
" clrow.put(\"endSector\", block[j+2]);" & @CRLF & _
" clrow.put(\"type\", block[j+3]);" & @CRLF & _
" if (block[j+3] === \"linear\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"deviceMajorMinor\", block[j+4]);" & @CRLF & _
" clrow.put(\"sourceStartSector\", block[j+5]);" & @CRLF & _
" ${dmMap}.add(clrow);" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" ${dmMap}.add(clrow);" & @CRLF & _
" } " & @CRLF & _
" }" & @CRLF & _
" } " & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" { " & @CRLF & _
" ${dmMap}.add(clrow); " & @CRLF & _
" }" & @CRLF & _
" } " & @CRLF & _
" CTX.setAttribute('dmMap',${dmMap});" & @CRLF & _
" rtrn += \"Test\";" & @CRLF & _
"}" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Map device maps to sys blocks"" & @CRLF & _
" merge {" & @CRLF & _
" table1_name = "dmMap"" & @CRLF & _
" table2_name = "SysBlock"" & @CRLF & _
" result_table_name = "dmMap"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"dmMap[].deviceMajorMinor"}" & @CRLF & _
" get_attr {"SysBlock[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter device maps by alias"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "dmMap"" & @CRLF & _
" target_table_name = "dmMapNoExtends"" & @CRLF & _
" condition = is_not_empty {get_attr {"dmMap[].alias"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Change device map table column names"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "dmMapNoExtends"" & @CRLF & _
" target_table_name = "dmMapNoExtends"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_id"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/mapper/"" & @CRLF & _
" get_attr {"dmMapNoExtends[].alias"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "storage_type"" & @CRLF & _
" value = "logical"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_interface"" & @CRLF & _
" value = "lvm"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/mapper/"" & @CRLF & _
" get_attr {"dmMapNoExtends[].alias"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "interface"" & @CRLF & _
" value = "lvm"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "drive_type"" & @CRLF & _
" value = "logical"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Union proc_scsi_table_storage to device maps"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "proc_scsi_table_storage"" & @CRLF & _
" table2_name = "dmMapNoExtends"" & @CRLF & _
" result_table_name = "proc_scsi_table_storage"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_storage_device"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "proc_scsi_table_storage"" & @CRLF & _
" target_table_name = "cmdb_ci_storage_device"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_id"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_host_id"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].hostId"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_bus_id"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].channel"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_target_id"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].id"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_lun"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].lun"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "size_bytes"" & @CRLF & _
" value = concat {eval {"javascript: rtrn=\"\";" & @CRLF & _
"var sectors = parseInt(${proc_scsi_table_storage[].sectors});" & @CRLF & _
"var sectorSize = parseInt(${proc_scsi_table_storage[].sectorSize});" & @CRLF & _
"rtrn = (sectors * sectorSize) + '';" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "disk_space"" & @CRLF & _
" value = concat {eval {"javascript:var rtrn='';" & @CRLF & _
"var sectors = parseInt(${proc_scsi_table_storage[].sectors});" & @CRLF & _
"var sectorSize = parseInt(${proc_scsi_table_storage[].sectorSize});" & @CRLF & _
"var spec = sectors * sectorSize;" & @CRLF & _
"rtrn = (spec / 1073741824) + '';" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_major_minor"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_interface"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].device_interface"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "model_id"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].model"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "manufacturer"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].vendor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "storage_type"" & @CRLF & _
" value = get_attr {"proc_scsi_table_storage[].storage_type"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "major"" & @CRLF & _
" value = eval {"javascript: rtrn=\"\";" & @CRLF & _
"var MajMin = ${proc_scsi_table_storage[].deviceMajorMinor};" & @CRLF & _
"if (MajMin != null)" & @CRLF & _
"{ " & @CRLF & _
" var Maj = MajMin.split(':');" & @CRLF & _
" rtrn = Maj[0];" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_storage_device and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_storage_device"" & @CRLF & _
" result_table_name = "storage_to_linux"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Contains::Contained by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "computer"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_lvm_pool"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "dmMapNoExtends"" & @CRLF & _
" target_table_name = "cmdb_ci_lvm_pool"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "pool_id"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/mapper/"" & @CRLF & _
" get_attr {"dmMapNoExtends[].alias"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/mapper/"" & @CRLF & _
" get_attr {"dmMapNoExtends[].alias"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "size_bytes"" & @CRLF & _
" value = concat {eval {"javascript: rtrn = \"\";" & @CRLF & _
"var size = parseInt(${dmMapNoExtends[].sectorSize});" & @CRLF & _
"var sect = parseInt(${dmMapNoExtends[].sectors});" & @CRLF & _
"rtrn = (size * sect) + '';"}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "disk_space"" & @CRLF & _
" value = concat {eval {"javascript: rtrn = \"\";" & @CRLF & _
"var size = parseInt(${dmMapNoExtends[].sectorSize});" & @CRLF & _
"var sect = parseInt(${dmMapNoExtends[].sectors});" & @CRLF & _
"rtrn = ((size * sect)/1073741824) + '';"}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "major"" & @CRLF & _
" value = eval {"javascript: rtrn=\"\";" & @CRLF & _
"var MajMin = ${dmMapNoExtends[].deviceMajorMinor};" & @CRLF & _
"if (MajMin != null)" & @CRLF & _
"{ " & @CRLF & _
" var Maj = MajMin.split(':');" & @CRLF & _
" rtrn = Maj[0];" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Rel/Ref between cmdb_ci_lvm_pool and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_lvm_pool"" & @CRLF & _
" result_table_name = "pool_to_ci"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Contains::Contained by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "hosted_by"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter device maps by extends column"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "dmMap"" & @CRLF & _
" target_table_name = "dmMapExtend"" & @CRLF & _
" condition = is_not_empty {get_attr {"dmMap[].extends"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Keep multipaths from device maps"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "dmMapExtend"" & @CRLF & _
" target_table_name = "dmMapExtendMulti"" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"dmMapExtend[].type"}" & @CRLF & _
" "multipath"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Keep non-multipaths device maps"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "dmMapExtend"" & @CRLF & _
" target_table_name = "dmMapExtend"" & @CRLF & _
" condition = neq {" & @CRLF & _
" get_attr {"dmMapExtend[].type"}" & @CRLF & _
" "multipath"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_lvm_pool_member"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "dmMapExtend"" & @CRLF & _
" target_table_name = "cmdb_ci_lvm_pool_member"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "extent_type"" & @CRLF & _
" value = get_attr {"dmMapExtend[].type"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "start_offset"" & @CRLF & _
" value = concat {eval {"javascript:rtrn = \"\";" & @CRLF & _
"var startSec = parseInt(${dmMapExtend[].startSector}) || 0;" & @CRLF & _
"var size = parseInt(${dmMapExtend[].sectorSize});" & @CRLF & _
"rtrn = (startSec * size) + '';" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "end_offset"" & @CRLF & _
" value = concat {eval {"javascript:rtrn = \"\";" & @CRLF & _
"var endSec = parseInt(${dmMapExtend[].endSector});" & @CRLF & _
"var size = parseInt(${dmMapExtend[].sectorSize});" & @CRLF & _
"rtrn = ((endSec || 0)*size) + ''; " & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = eval {"javascript:rtrn=\"\";" & @CRLF & _
"var name = ${dmMapExtend[].name};" & @CRLF & _
"var dmName = ${dmMapExtend[].dmName};" & @CRLF & _
"rtrn = ( ( name === null ? dmName : name ) || 'LVM Pool Member' );" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_major_minor"" & @CRLF & _
" value = get_attr {"dmMapExtend[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "source_start_offset"" & @CRLF & _
" value = concat {eval {"javascript:rtrn = \"\";" & @CRLF & _
"var sourSec = parseInt(${dmMapExtend[].sourceStartSector});" & @CRLF & _
"var size = parseInt(${dmMapExtend[].sectorSize});" & @CRLF & _
"rtrn = (sourSec * size) + ''; "}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "source_end_offset"" & @CRLF & _
" value = concat {eval {"javascript:rtrn = \"\";" & @CRLF & _
"var sourSec = parseInt(${dmMapExtend[].sourceStartSector});" & @CRLF & _
"var endSec = parseInt(${dmMapExtend[].endSector});" & @CRLF & _
"var startSec = parseInt(${dmMapExtend[].startSector});" & @CRLF & _
"var size = parseInt(${dmMapExtend[].sectorSize});" & @CRLF & _
"var sourStart = (sourSec * size);" & @CRLF & _
"var endOfc = (endSec || 0)*size;" & @CRLF & _
"var startOfcet = (startSec || 0)*size; " & @CRLF & _
"rtrn = (sourStart + (endOfc - startOfcet)) + ''; "}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "comments"" & @CRLF & _
" value = get_attr {"dmMapExtend[].extends"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_lvm_pool and cmdb_ci_lvm_pool_member"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_lvm_pool"" & @CRLF & _
" key1_name = "alias"" & @CRLF & _
" table2_name = "cmdb_ci_lvm_pool_member"" & @CRLF & _
" key2_name = "extends"" & @CRLF & _
" result_table_name = "pool_to_poolMem"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" relation_type = "Members::Member of"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "pool"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_LVM________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get sd_multipath"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_out"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "sd_multipath"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var results = JSON.parse(${sd_out});" & @CRLF & _
"rtrn = JSON.stringify(results.multipath_ll);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_FileSystem________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get df"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "df -kP ; echo ''"" & @CRLF & _
" var_names = "DF"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "nonExistingDelimeter"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge lines splitted because of length"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"DF"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "DF"" & @CRLF & _
" concat {eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"var fileSystems = ${DF};" & @CRLF & _
"fileSystems = fileSystems.split('\\n');" & @CRLF & _
"var line;" & @CRLF & _
"for (var i = 0; i < fileSystems.length; ++i) {" & @CRLF & _
"line = fileSystems[i];" & @CRLF & _
"if (line.indexOf(' ') == -1 && (i + 1) < fileSystems.length) {" & @CRLF & _
"fileSystems[i] = line + ' ' + fileSystems[(i+1)].trim();" & @CRLF & _
"++i;" & @CRLF & _
"}" & @CRLF & _
"}" & @CRLF & _
"rtrn = fileSystems+'';" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create updated file systems list without headers, and lines start with numbers"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"DF"}}" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "DF"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "DF"" & @CRLF & _
" col_names = "file_system_data"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" exclude_lines_pattern = "Filesystem 1024-blocks Used Available Capacity Mounted on"" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = ","" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter file systems that had errors"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "DF"" & @CRLF & _
" target_table_name = "DF"" & @CRLF & _
" condition = not_starts_with {" & @CRLF & _
" "df:"" & @CRLF & _
" get_attr {"DF[].file_system_data"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter cifs/nfs file systems"" & @CRLF & _
" comment = "OR & ANDconditions can't be at the same step"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "DF"" & @CRLF & _
" target_table_name = "DF"" & @CRLF & _
" condition = any {" & @CRLF & _
" starts_with {" & @CRLF & _
" "/dev/"" & @CRLF & _
" get_attr {"DF[].file_system_data"}" & @CRLF & _
" }" & @CRLF & _
" starts_with {" & @CRLF & _
" "/"" & @CRLF & _
" get_attr {"DF[].file_system_data"}" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"DF[].file_system_data"}" & @CRLF & _
" ":"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove new lines form file system names"" & @CRLF & _
" comment = "Even though \"df\" output was split using \"\\n\", some lines still have new lines characters in them"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"DF"}}" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "DF"" & @CRLF & _
" target_table_name = "DF"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "file_system_data"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"var fileSystem = ${DF[].file_system_data};" & @CRLF & _
"fileSystem = fileSystem.replace(/\\n/g,' ' );" & @CRLF & _
"rtrn = fileSystem;" & @CRLF & _
""}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert file systems into a table"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"DF"}}" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "DF[*].file_system_data"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "DF"" & @CRLF & _
" col_names = "name","size","blocks","freeSpace","capacity","mountPoint"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*)"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Copy the DF to backup table"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "DF"" & @CRLF & _
" table2_name = "DF_orig"" & @CRLF & _
" result_table_name = "DF_orig"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge proc_mount and file systems"" & @CRLF & _
" comment = "We set it to \"Keep\" since not all the file system exist in the procMount table and we need to keep it in the list."" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"procMounts"}}" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "DF"" & @CRLF & _
" table2_name = "procMounts"" & @CRLF & _
" result_table_name = "DF"" & @CRLF & _
" unmatched_lines = keep" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"DF[].name"}" & @CRLF & _
" get_attr {"procMounts[].name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter the DF table to include relevant file system"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "DF"" & @CRLF & _
" target_table_name = "DF"" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"DF_orig[*].name"}" & @CRLF & _
" get_attr {"DF[].name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Find NAS"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "DF"" & @CRLF & _
" target_table_name = "DF"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "type"" & @CRLF & _
" value = eval {"javascript: rtrn = \"\";" & @CRLF & _
"var fullPath = ${DF[].name};" & @CRLF & _
" if (fullPath.startsWith('//')) " & @CRLF & _
" { // cifs" & @CRLF & _
" rtrn = \"cifs\";" & @CRLF & _
" } else if (fullPath.startsWith('\\\\\\\\')) " & @CRLF & _
" { // cifs" & @CRLF & _
" rtrn = \"cifs\";" & @CRLF & _
" } else if (fullPath.indexOf(':') !== -1) " & @CRLF & _
" { // nfs" & @CRLF & _
" rtrn = \"nfs\";" & @CRLF & _
" } else " & @CRLF & _
" { // local" & @CRLF & _
" rtrn = \"local\";" & @CRLF & _
" }"}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Find partition"" & @CRLF & _
" merge {" & @CRLF & _
" table1_name = "DF"" & @CRLF & _
" table2_name = "partition_table"" & @CRLF & _
" result_table_name = "DF"" & @CRLF & _
" unmatched_lines = keep" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"DF[].name"}" & @CRLF & _
" get_attr {"partition_table[].name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter local file systems"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "DF"" & @CRLF & _
" target_table_name = "DFlocal"" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"DF[].type"}" & @CRLF & _
" "local"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_file system"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "DFlocal"" & @CRLF & _
" target_table_name = "cmdb_ci_file_system"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"DFlocal[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "volume_id"" & @CRLF & _
" value = get_attr {"DFlocal[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "mount_point"" & @CRLF & _
" value = get_attr {"DFlocal[].mountPoint"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "file_system"" & @CRLF & _
" value = get_attr {"DFlocal[].filesystem"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "media_type"" & @CRLF & _
" value = "fixed"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "size_bytes"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"rtrn = (${DFlocal[].size}*1024) + '';" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "free_space_bytes"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"rtrn = (${DFlocal[].freeSpace}*1024) + '';" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate file systems"" & @CRLF & _
" set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${cmdb_ci_file_system},\"name\");" & @CRLF & _
"CTX.setAttribute(\"cmdb_ci_file_system\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel cmdb_ci_file_system and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_file_system"" & @CRLF & _
" result_table_name = "file_to_linux"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Contains::Contained by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "computer"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter NAS"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "DF"" & @CRLF & _
" target_table_name = "DFNAS"" & @CRLF & _
" condition = all {" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"DF[].type"}" & @CRLF & _
" "local"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"DF[].type"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update temporary NAS table"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"DFNAS"}}" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "DFNAS"" & @CRLF & _
" target_table_name = "DFNAS"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "nas_hostname"" & @CRLF & _
" value = eval {"javascript: rtrn = \"\";" & @CRLF & _
"var fullPath = ${DFNAS[].name}; " & @CRLF & _
" if (fullPath.startsWith('//')) " & @CRLF & _
" { // cifs" & @CRLF & _
" var pathStartPos = fullPath.indexOf('/', 2); " & @CRLF & _
" rtrn = fullPath.substr(2, pathStartPos - 2); " & @CRLF & _
" } else if (fullPath.startsWith('\\\\\\\\')) " & @CRLF & _
" { // cifs " & @CRLF & _
" var pathStartPos = fullPath.indexOf('\\\\', 2);" & @CRLF & _
" rtrn = fullPath.substr(2, pathStartPos - 2);" & @CRLF & _
" } else if (fullPath.indexOf(':') !== -1) " & @CRLF & _
" { // nfs" & @CRLF & _
" var parts = fullPath.split(':');" & @CRLF & _
" rtrn = parts[0];" & @CRLF & _
" } else { rtrn = \"\";}"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "nas_path"" & @CRLF & _
" value = eval {"javascript: rtrn = \"\";" & @CRLF & _
"var fullPath = ${DFNAS[].name}; " & @CRLF & _
" if (fullPath.startsWith('//')) " & @CRLF & _
" { // cifs" & @CRLF & _
" var pathStartPos = fullPath.indexOf('/', 2); " & @CRLF & _
" rtrn = fullPath.substr(pathStartPos); " & @CRLF & _
" } else if (fullPath.startsWith('\\\\\\\\')) " & @CRLF & _
" { // cifs " & @CRLF & _
" var pathStartPos = fullPath.indexOf('\\\\', 2);" & @CRLF & _
" var path = fullPath.substr(pathStartPos);" & @CRLF & _
" rtrn = path.replace(/\\\\/g, '/');" & @CRLF & _
" } else if (fullPath.indexOf(':') !== -1) " & @CRLF & _
" { // nfs" & @CRLF & _
" var parts = fullPath.split(':');" & @CRLF & _
" rtrn = parts[1];" & @CRLF & _
" } else { rtrn = \"\";}"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "nas_ip_address"" & @CRLF & _
" value = eval {"javascript: rtrn = \"\";" & @CRLF & _
"var fullPath = ${DFNAS[].name}; " & @CRLF & _
"var hostname = '';" & @CRLF & _
" if (fullPath.startsWith('//')) " & @CRLF & _
" { /* cifs */" & @CRLF & _
" var pathStartPos = fullPath.indexOf('/', 2); " & @CRLF & _
" hostname = fullPath.substr(2, pathStartPos - 2); " & @CRLF & _
" } else if (fullPath.startsWith('\\\\\\\\')) " & @CRLF & _
" { /* cifs */ " & @CRLF & _
" var pathStartPos = fullPath.indexOf('\\\\', 2);" & @CRLF & _
" hostname = fullPath.substr(2, pathStartPos - 2);" & @CRLF & _
" } else if (fullPath.indexOf(':') !== -1) " & @CRLF & _
" { /* nfs */" & @CRLF & _
" var parts = fullPath.split(':');" & @CRLF & _
" hostname = parts[0];" & @CRLF & _
" } else { hostname = \"\";}" & @CRLF & _
"" & @CRLF & _
"if(/^\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}$/.test(hostname))" & @CRLF & _
" rtrn = hostname;"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_nas_file_system"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "DFNAS"" & @CRLF & _
" target_table_name = "cmdb_ci_nas_file_system"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"DFNAS[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "volume_id"" & @CRLF & _
" value = get_attr {"DFNAS[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "mount_point"" & @CRLF & _
" value = get_attr {"DFNAS[].mountPoint"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "file_system"" & @CRLF & _
" value = get_attr {"DFNAS[].filesystem"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "media_type"" & @CRLF & _
" value = "network"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "size_bytes"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"rtrn = (${DFNAS[].size}*1024) + '';" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "free_space_bytes"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"rtrn = (${DFNAS[].freeSpace}*1024) + '';" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "nas_hostname"" & @CRLF & _
" value = get_attr {"DFNAS[].nas_hostname"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "nas_path"" & @CRLF & _
" value = get_attr {"DFNAS[].nas_path"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "nas_protocol"" & @CRLF & _
" value = get_attr {"DFNAS[].filesystem"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate NAS file systems"" & @CRLF & _
" set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${cmdb_ci_nas_file_system},\"name\");" & @CRLF & _
"CTX.setAttribute(\"cmdb_ci_nas_file_system\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_nas_file_system and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_nas_file_system"" & @CRLF & _
" result_table_name = "fileNAS_to_linux"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Contains::Contained by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "computer"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_FC________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get sd_fc"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_out"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "sd_fc"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var results = JSON.parse(${sd_out});" & @CRLF & _
"rtrn = JSON.stringify(results.fc.fcHba);"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create empty HBA table"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "FcHBA"" & @CRLF & _
" table2_name = "FcHBA"" & @CRLF & _
" result_table_name = "FcHBA"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create empty FC ports"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "FcPorts"" & @CRLF & _
" table2_name = "FcPorts"" & @CRLF & _
" result_table_name = "FcPorts"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create empty FC targets table"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "FCTargetPorts"" & @CRLF & _
" table2_name = "FCTargetPorts"" & @CRLF & _
" result_table_name = "FCTargetPorts"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert data to HBA table"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_fc"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" concat {eval {"javascript: rtrn = \"\";" & @CRLF & _
"var fcHba = ${sd_fc};" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"var fc = fcHba.substring(2,fcHba.length-2);" & @CRLF & _
"var block = fc.split(\"fcPort:\");" & @CRLF & _
"var hbaFc =block[0].split(\"fcHba:\");" & @CRLF & _
"if(hbaFc){" & @CRLF & _
"var flagidy = [hbaFc.length];" & @CRLF & _
"for (var j = 0; j < hbaFc.length; j++ ){ " & @CRLF & _
"var flag = 0; " & @CRLF & _
"var clrow = row.clone(); " & @CRLF & _
"var fcHbaBlock = hbaFc[j].split(\" \"); " & @CRLF & _
" " & @CRLF & _
"for (var i = 0; i < fcHbaBlock.length; i++) { " & @CRLF & _
"var parts = fcHbaBlock[i].split(':'); " & @CRLF & _
"var name = parts[0].trim(); " & @CRLF & _
"var value = parts[1].trim(); " & @CRLF & _
"if (name == \"serialNumber\") { " & @CRLF & _
"clrow.put(\"serial\", value); " & @CRLF & _
"} " & @CRLF & _
"if (name == \"model\") { " & @CRLF & _
"clrow.put(\"model\", value); " & @CRLF & _
"} " & @CRLF & _
"if (name == \"modelDescription\") { " & @CRLF & _
"clrow.put(\"descr\", value); " & @CRLF & _
"} " & @CRLF & _
"} " & @CRLF & _
" " & @CRLF & _
"for (var z = 0; z < flagidy.length; z++) { " & @CRLF & _
"if (flagidy[z] == clrow.get(\"serial\")) { " & @CRLF & _
" flag = 1; " & @CRLF & _
" } " & @CRLF & _
"} " & @CRLF & _
"if(flag == 0) { " & @CRLF & _
" ${FcHBA}.add(clrow); " & @CRLF & _
"flagidy[j] = clrow.get(\"serial\"); " & @CRLF & _
"}" & @CRLF & _
"}" & @CRLF & _
" CTX.setAttribute('FcHBA',${FcHBA});" & @CRLF & _
"}" & @CRLF & _
""}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert data to FC ports and targets tables"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"sd_fc"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" concat {eval {"javascript: rtrn = \"\";" & @CRLF & _
" var fcHba = ${sd_fc};" & @CRLF & _
" var row = new Packages.java.util.HashMap();" & @CRLF & _
" var fc = fcHba.substring(2,fcHba.length-2);" & @CRLF & _
" var block = fc.split(\"fcHba:\");" & @CRLF & _
" var end = block.length;" & @CRLF & _
" var hbaFc =block[end-1].split(\"fcPort:\");" & @CRLF & _
" var fcPortwwpn = \"\";" & @CRLF & _
" if(hbaFc){" & @CRLF & _
" for (var j = 1; j < hbaFc.length; j++ ){ " & @CRLF & _
" var fcHbaBlock = hbaFc[j].split(\"targetPort\"); " & @CRLF & _
" for (var i = 0; i < fcHbaBlock.length; i++) { " & @CRLF & _
" var fcPortTarget = fcHbaBlock[i].split(\" \"); " & @CRLF & _
" var clrow = row.clone(); " & @CRLF & _
" for ( var z = 0; z < fcPortTarget.length; z++ ) { " & @CRLF & _
" var parts = fcPortTarget[z].split(':'); " & @CRLF & _
" var name = parts[0].trim(); " & @CRLF & _
" var value = parts[1].trim(); " & @CRLF & _
" if (i == 0) { " & @CRLF & _
" if (name == \"wwpn\") { " & @CRLF & _
" clrow.put(\"wwpn\", value); " & @CRLF & _
" fcPortwwpn = value; " & @CRLF & _
" } " & @CRLF & _
" if (name == \"wwnn\") { " & @CRLF & _
" clrow.put(\"wwnn\", value); " & @CRLF & _
" } " & @CRLF & _
" if (name == \"speed\") { " & @CRLF & _
" clrow.put(\"speed\", value); " & @CRLF & _
" } " & @CRLF & _
" if (name == \"port_type\") { " & @CRLF & _
" clrow.put(\"port_type\", value); " & @CRLF & _
" } " & @CRLF & _
" if (name == \"hbaSerialNumber\") { " & @CRLF & _
" clrow.put(\"hbaSerialNumber\", value); " & @CRLF & _
" } " & @CRLF & _
" } " & @CRLF & _
" else { " & @CRLF & _
" if (name == \"wwpn\") { " & @CRLF & _
" clrow.put(\"wwpn\", value); " & @CRLF & _
" clrow.put(\"fcPortWWPN\",fcPortwwpn); " & @CRLF & _
" } " & @CRLF & _
" if (name == \"wwnn\") { " & @CRLF & _
" clrow.put(\"wwnn\", value); " & @CRLF & _
" } " & @CRLF & _
" if (name == \"blockDeviceNames\") { " & @CRLF & _
" clrow.put(\"blockDeviceNames\", value); " & @CRLF & _
" } " & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if (i == 0){ " & @CRLF & _
" ${FcPorts}.add(clrow);" & @CRLF & _
" }" & @CRLF & _
" else { " & @CRLF & _
" ${FCTargetPorts}.add(clrow); " & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" CTX.setAttribute('FCTargetPorts',${FCTargetPorts});" & @CRLF & _
" }"}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_storage_hba"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "FcHBA"" & @CRLF & _
" target_table_name = "cmdb_ci_storage_hba"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_id"" & @CRLF & _
" value = get_attr {"FcHBA[].serial"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number"" & @CRLF & _
" value = get_attr {"FcHBA[].serial"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "model_id"" & @CRLF & _
" value = get_attr {"FcHBA[].model"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = concat {" & @CRLF & _
" get_attr {"FcHBA[].model"}" & @CRLF & _
" " "" & @CRLF & _
" get_attr {"FcHBA[].serial"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove HBA without serial"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "cmdb_ci_storage_hba"" & @CRLF & _
" target_table_name = "cmdb_ci_storage_hba"" & @CRLF & _
" condition = is_not_empty {get_attr {"cmdb_ci_storage_hba[].serial_number"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_storage_hba and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_storage_hba"" & @CRLF & _
" result_table_name = "hba_to_ci"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Owns::Owned by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "computer"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_fc_port"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "FcPorts"" & @CRLF & _
" target_table_name = "cmdb_ci_fc_port"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "wwpn"" & @CRLF & _
" value = concat {eval {"javascript: rtrn = \"\";var wwnp = ${FcPorts[].wwpn};var middle = wwnp.split('x');var ww = middle[1];for (var i = 0; i < ww.length; i++){ if (i%2 != 0 && i != ww.length-1 ) { rtrn +=ww[i]+\":\"; } else { rtrn += ww[i]; }}"}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "wwnn"" & @CRLF & _
" value = concat {eval {"javascript: rtrn = \"\";var wwnn = ${FcPorts[].wwnn};var middle = wwnn.split('x');var ww = middle[1];for (var i = 0; i < ww.length; i++){ if (i%2 != 0 && i != ww.length-1 ) { rtrn +=ww[i]+\":\"; } else { rtrn += ww[i]; }}"}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "speed"" & @CRLF & _
" value = concat {" & @CRLF & _
" get_attr {"FcPorts[].speed"}" & @CRLF & _
" " GFC"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "port_type"" & @CRLF & _
" value = get_attr {"FcPorts[].port_type"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = concat {" & @CRLF & _
" "FC Port "" & @CRLF & _
" get_attr {"FcPorts[].wwpn"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_fc_port and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_fc_port"" & @CRLF & _
" result_table_name = "FcPort_to_CI"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Owns::Owned by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "computer"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_fc_port and cmdb_ci_storage_hba"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_fc_port"" & @CRLF & _
" key1_name = "hbaSerialNumber"" & @CRLF & _
" table2_name = "cmdb_ci_storage_hba"" & @CRLF & _
" key2_name = "serial"" & @CRLF & _
" result_table_name = "port_to_hba"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "controller"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge FC targets and sys blocks"" & @CRLF & _
" merge {" & @CRLF & _
" table1_name = "FCTargetPorts"" & @CRLF & _
" key1_name = "blockDeviceNames"" & @CRLF & _
" table2_name = "SysBlock"" & @CRLF & _
" key2_name = "name"" & @CRLF & _
" result_table_name = "FCTargetPorts"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_fc_disk"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "FCTargetPorts"" & @CRLF & _
" target_table_name = "cmdb_ci_fc_disk"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/"" & @CRLF & _
" get_attr {"FCTargetPorts[].blockDeviceNames"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_id"" & @CRLF & _
" value = concat {" & @CRLF & _
" "/dev/"" & @CRLF & _
" get_attr {"FCTargetPorts[].blockDeviceNames"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_host_id"" & @CRLF & _
" value = eval {"javascript: rtrn =\"\";var ports = ${FCTargetPorts[].host};var blocks = ports.split(':');rtrn = blocks[0];"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_bus_id"" & @CRLF & _
" value = eval {"javascript: rtrn =\"\";var ports = ${FCTargetPorts[].host};var blocks = ports.split(':');rtrn = blocks[1];"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_target_id"" & @CRLF & _
" value = eval {"javascript: rtrn =\"\";var ports = ${FCTargetPorts[].host};var blocks = ports.split(':');rtrn = blocks[2];"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_lun"" & @CRLF & _
" value = eval {"javascript: rtrn =\"\";var ports = ${FCTargetPorts[].host};var blocks = ports.split(':');rtrn = blocks[3];"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "size_bytes"" & @CRLF & _
" value = eval {"javascript: rtrn=\"\";" & @CRLF & _
"var sectors = parseInt(${FCTargetPorts[].sectors});" & @CRLF & _
"var sectorSize = parseInt(${FCTargetPorts[].sectorSize});" & @CRLF & _
"rtrn = (sectors * sectorSize) + '';" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "disk_space"" & @CRLF & _
" value = eval {"javascript:var rtrn='';" & @CRLF & _
"var sectors = parseInt(${FCTargetPorts[].sectors});" & @CRLF & _
"var sectorSize = parseInt(${FCTargetPorts[].sectorSize});" & @CRLF & _
"var spec = sectors * sectorSize;" & @CRLF & _
"rtrn = (spec / 1073741824) + '';"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_major_minor"" & @CRLF & _
" value = get_attr {"FCTargetPorts[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "device_interface"" & @CRLF & _
" value = "fc"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "model_id"" & @CRLF & _
" value = get_attr {"FCTargetPorts[].model"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "manufacturer"" & @CRLF & _
" value = get_attr {"FCTargetPorts[].vendor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "storage_type"" & @CRLF & _
" value = "network"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "major"" & @CRLF & _
" value = eval {"javascript: rtrn=\"\";" & @CRLF & _
"var MajMin = ${FCTargetPorts[].deviceMajorMinor};" & @CRLF & _
"if (MajMin != null)" & @CRLF & _
"{ " & @CRLF & _
" var Maj = MajMin.split(':');" & @CRLF & _
" rtrn = Maj[0];" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "fcPortWWPN"" & @CRLF & _
" value = eval {"javascript: rtrn = \"\";var wwnn = ${FCTargetPorts[].fcPortWWPN};var middle = wwnn.split('x');var ww = middle[1];for (var i = 0; i < ww.length; i++){ if (i%2 != 0 && i != ww.length-1 ) { rtrn +=ww[i]+\":\"; } else { rtrn += ww[i]; }}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_fc_initiator"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "cmdb_ci_fc_disk"" & @CRLF & _
" target_table_name = "cmdb_fc_initiator"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "wwnn"" & @CRLF & _
" value = get_attr {"cmdb_ci_fc_disk[].fcPortWWPN"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "wwpn"" & @CRLF & _
" value = get_attr {"cmdb_ci_fc_disk[].fcPortWWPN"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_fc_target"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "cmdb_ci_fc_disk"" & @CRLF & _
" target_table_name = "cmdb_fc_target"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "wwnn"" & @CRLF & _
" value = concat {eval {"javascript: rtrn = \"\";var wwnn = ${cmdb_ci_fc_disk[].wwnn};var middle = wwnn.split('x');var ww = middle[1];for (var i = 0; i < ww.length; i++){ if (i%2 != 0 && i != ww.length-1 ) { rtrn +=ww[i]+\":\"; } else { rtrn += ww[i]; }}"}}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "wwpn"" & @CRLF & _
" value = concat {eval {"javascript: rtrn = \"\";var wwpn = ${cmdb_ci_fc_disk[].wwpn};var middle = wwpn.split('x');var ww = middle[1];for (var i = 0; i < ww.length; i++){ if (i%2 != 0 && i != ww.length-1 ) { rtrn +=ww[i]+\":\"; } else { rtrn += ww[i]; }}"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_fc_disk and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_fc_disk"" & @CRLF & _
" result_table_name = "fcdisk_to_linux"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Contains::Contained by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "computer"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_fc_disk and cmdb_ci_fc_port"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_fc_disk"" & @CRLF & _
" key1_name = "fcPortWWPN"" & @CRLF & _
" table2_name = "cmdb_ci_fc_port"" & @CRLF & _
" key2_name = "wwpn"" & @CRLF & _
" result_table_name = "fc_disk_to_port"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "provided_by"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_fc_disk and cmdb_fc_initiator"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_fc_initiator"" & @CRLF & _
" key1_name = "blockDeviceNames"" & @CRLF & _
" table2_name = "cmdb_ci_fc_disk"" & @CRLF & _
" key2_name = "blockDeviceNames"" & @CRLF & _
" result_table_name = "fcdisk_to_initiator"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "non_ci"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_fc_disk and cmdb_fc_target"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_fc_target"" & @CRLF & _
" key1_name = "blockDeviceNames"" & @CRLF & _
" table2_name = "cmdb_ci_fc_disk"" & @CRLF & _
" key2_name = "blockDeviceNames"" & @CRLF & _
" result_table_name = "fcdisk_to_target"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "non_ci"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge disks and fc disks"" & @CRLF & _
" merge {" & @CRLF & _
" table1_name = "cmdb_ci_disk"" & @CRLF & _
" table2_name = "cmdb_ci_fc_disk"" & @CRLF & _
" result_table_name = "cmdb_ci_disk"" & @CRLF & _
" unmatched_lines = keep" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"cmdb_ci_disk[].device_id"}" & @CRLF & _
" get_attr {"cmdb_ci_fc_disk[].device_id"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter out FC disks"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "cmdb_ci_disk"" & @CRLF & _
" target_table_name = "cmdb_ci_disk"" & @CRLF & _
" condition = is_empty {get_attr {"cmdb_ci_disk[].wwnn"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "________Proc_FC________"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update total disk space on Linux CI"" & @CRLF & _
" set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].disk_space"" & @CRLF & _
" eval {"javascript: var diskUsage;" & @CRLF & _
"var rtrn ;" & @CRLF & _
"var storageDevices = ${cmdb_ci_storage_device};" & @CRLF & _
"var disks = ${cmdb_ci_disk};" & @CRLF & _
"var fcDisks = ${cmdb_ci_fc_disk};" & @CRLF & _
"var iscsiDisk = ${cmdb_ci_iscsi_disk};" & @CRLF & _
"var fileSystem = ${cmdb_ci_file_system};" & @CRLF & _
"var excludedTypes = ['cd', 'cdrom', 'ram', 'removable', 'logical'];" & @CRLF & _
"" & @CRLF & _
"var getTotalDiskSpaceByTable = function(disksTable){" & @CRLF & _
" var totalDiskSpace = 0;" & @CRLF & _
" var currentDisk;" & @CRLF & _
" for(var i = 0; i < disksTable.size(); i++){" & @CRLF & _
" currentDisk = disksTable.get(i);" & @CRLF & _
"" & @CRLF & _
" var current_disk_storage_type = String(currentDisk.get(\"storage_type\"));" & @CRLF & _
" var current_disk_space = currentDisk.get(\"disk_space\");" & @CRLF & _
" if( current_disk_space && (excludedTypes.indexOf(current_disk_storage_type) == -1)){" & @CRLF & _
" totalDiskSpace =parseFloat(totalDiskSpace) + parseFloat(current_disk_space);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" return totalDiskSpace;" & @CRLF & _
"};" & @CRLF & _
"" & @CRLF & _
"var getTotalDiskSpaceFromFileSystem = function(disksTable){" & @CRLF & _
" var totalDiskSpace = 0;" & @CRLF & _
"" & @CRLF & _
" for(var i = 0; i < disksTable.size(); i++){" & @CRLF & _
" var currentDisk = disksTable.get(i);" & @CRLF & _
" var mediaType = currentDisk.get(\"media_type\");" & @CRLF & _
" if(mediaType == 'fixed'){" & @CRLF & _
" var current_disk_space =currentDisk.get(\"size_bytes\");" & @CRLF & _
" totalDiskSpace =parseFloat(totalDiskSpace) + parseFloat(current_disk_space);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" return totalDiskSpace;" & @CRLF & _
"};" & @CRLF & _
"" & @CRLF & _
"var size = getTotalDiskSpaceFromFileSystem(fileSystem)/(1024*1024*1024)" & @CRLF & _
"diskUsage = parseFloat(getTotalDiskSpaceByTable(storageDevices) + getTotalDiskSpaceByTable(disks) + getTotalDiskSpaceByTable(fcDisks) + getTotalDiskSpaceByTable(iscsiDisk) + parseInt(size)) ;" & @CRLF & _
"" & @CRLF & _
"rtrn=diskUsage.toFixed(2);"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_disk_partition and cmdb_ci_disk"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_disk_partition"" & @CRLF & _
" table2_name = "cmdb_ci_disk"" & @CRLF & _
" result_table_name = "part_to_disk"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"cmdb_ci_disk[].name"}" & @CRLF & _
" get_attr {"cmdb_ci_disk_partition[].parentDisk"}" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "disk"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_disk_partition and cmdb_ci_storage_device"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_disk_partition"" & @CRLF & _
" table2_name = "cmdb_ci_storage_device"" & @CRLF & _
" result_table_name = "part_to_storage"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"cmdb_ci_storage_device[].name"}" & @CRLF & _
" get_attr {"cmdb_ci_disk_partition[].parentDisk"}" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "disk"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_disk_partition and cmdb_ci_fc_disk"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_disk_partition"" & @CRLF & _
" table2_name = "cmdb_ci_fc_disk"" & @CRLF & _
" result_table_name = "part_to_fc_disk"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"cmdb_ci_fc_disk[].name"}" & @CRLF & _
" get_attr {"cmdb_ci_disk_partition[].parentDisk"}" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "disk"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_disk_partition and cmdb_ci_iscsi_disk"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_disk_partition"" & @CRLF & _
" table2_name = "cmdb_ci_iscsi_disk"" & @CRLF & _
" result_table_name = "part_to_iscsi_disk"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"cmdb_ci_iscsi_disk[].name"}" & @CRLF & _
" get_attr {"cmdb_ci_disk_partition[].parentDisk"}" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "disk"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_lvm_pool and cmdb_ci_disk"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_lvm_pool"" & @CRLF & _
" key1_name = "deviceMajorMinor"" & @CRLF & _
" table2_name = "cmdb_ci_disk"" & @CRLF & _
" key2_name = "deviceMajorMinor"" & @CRLF & _
" result_table_name = "lvm_to_disk"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "provided_by"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_lvm_pool and cmdb_ci_storage_device"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_lvm_pool"" & @CRLF & _
" key1_name = "deviceMajorMinor"" & @CRLF & _
" table2_name = "cmdb_ci_storage_device"" & @CRLF & _
" key2_name = "deviceMajorMinor"" & @CRLF & _
" result_table_name = "lvm_to_storage"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "provided_by"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_lvm_pool and cmdb_ci_fc_disk"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_lvm_pool"" & @CRLF & _
" key1_name = "deviceMajorMinor"" & @CRLF & _
" table2_name = "cmdb_ci_fc_disk"" & @CRLF & _
" key2_name = "deviceMajorMinor"" & @CRLF & _
" result_table_name = "lvm_to_fc_disk"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "provided_by"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_lvm_pool and cmdb_ci_iscsi_disk"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_lvm_pool"" & @CRLF & _
" key1_name = "deviceMajorMinor"" & @CRLF & _
" table2_name = "cmdb_ci_iscsi_disk"" & @CRLF & _
" key2_name = "deviceMajorMinor"" & @CRLF & _
" result_table_name = "lvm_to_iscsi_disk"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "provided_by"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_lvm_pool_member and cmdb_ci_disk_partition"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_lvm_pool_member"" & @CRLF & _
" table2_name = "cmdb_ci_disk_partition"" & @CRLF & _
" result_table_name = "pool_member_to_partition"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = all {" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"cmdb_ci_lvm_pool_member[].type"}" & @CRLF & _
" "multipath"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_lvm_pool_member[].deviceMajorMinor"}" & @CRLF & _
" get_attr {"cmdb_ci_disk_partition[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "storage"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_lvm_pool_member and cmdb_ci_disk"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_lvm_pool_member"" & @CRLF & _
" table2_name = "cmdb_ci_disk"" & @CRLF & _
" result_table_name = "pool_member_to_disk"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = all {" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"cmdb_ci_lvm_pool_member[].type"}" & @CRLF & _
" "multipath"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_lvm_pool_member[].deviceMajorMinor"}" & @CRLF & _
" get_attr {"cmdb_ci_disk[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "storage"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_lvm_pool_member and cmdb_ci_storage_device"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_lvm_pool_member"" & @CRLF & _
" table2_name = "cmdb_ci_storage_device"" & @CRLF & _
" result_table_name = "pool_member_to_storage"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = all {" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"cmdb_ci_lvm_pool_member[].type"}" & @CRLF & _
" "multipath"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_lvm_pool_member[].deviceMajorMinor"}" & @CRLF & _
" get_attr {"cmdb_ci_storage_device[].deviceMajorMinor"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "storage"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_file_system and cmdb_ci_storage_device"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_storage_device"" & @CRLF & _
" table2_name = "cmdb_ci_file_system"" & @CRLF & _
" result_table_name = "fs_to_stor"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"cmdb_ci_file_system[].name"}" & @CRLF & _
" get_attr {"cmdb_ci_storage_device[].name"}" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Provides::Provided by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "provided_by"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_file_system and cmdb_ci_disk"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_disk"" & @CRLF & _
" table2_name = "cmdb_ci_file_system"" & @CRLF & _
" result_table_name = "fs_to_disk"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"cmdb_ci_file_system[].name"}" & @CRLF & _
" get_attr {"cmdb_ci_disk[].name"}" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Provides::Provided by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "provided_by"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_file_system and cmdb_ci_disk_partition"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_disk_partition"" & @CRLF & _
" table2_name = "cmdb_ci_file_system"" & @CRLF & _
" result_table_name = "fs_to_part"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"cmdb_ci_file_system[].name"}" & @CRLF & _
" get_attr {"cmdb_ci_disk_partition[].name"}" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Provides::Provided by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "provided_by"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>admin</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:50:01</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>303407279f2032001d753758442e708c</sys_id>" & @CRLF & _
"<sys_mod_count>49</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Storage</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_303407279f2032001d753758442e708c</sys_update_name>" & @CRLF & _
"<sys_updated_by>blah</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2021-08-30 20:38:11</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>3a088d0af3b0130005d9423423612b15</metadata_id>" & @CRLF & _
"<name>UNIX Cluster - Linux Red Hat Cluster</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "UNIX Cluster - Linux Red Hat Cluster"" & @CRLF & _
" id = "3a088d0af3b0130005d9423423612b15"" & @CRLF & _
" description = "UNIX Cluster - Linux Red Hat Cluster"" & @CRLF & _
" step {" & @CRLF & _
" name = "UNIX Cluster - Linux Red Hat Cluster"" & @CRLF & _
" ref {refid = "c4eabd514fe3c3c0a9f9011f0310c730"}" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>admin</sys_created_by>" & @CRLF & _
"<sys_created_on>2018-03-13 15:34:42</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>3a088d0af3b0130005d9423423612b15</sys_id>" & @CRLF & _
"<sys_mod_count>4</sys_mod_count>" & @CRLF & _
"<sys_name>UNIX Cluster - Linux Red Hat Cluster</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_3a088d0af3b0130005d9423423612b15</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2018-03-13 15:51:43</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>3ceb033c13e23200d4013192e144b0f9</metadata_id>" & @CRLF & _
"<name>get service name for Linux server</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "get service name for Linux server"" & @CRLF & _
" id = "3ceb033c13e23200d4013192e144b0f9"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "get list of services - Ubuntu - Linux"" & @CRLF & _
" comment = "Run command to get all the list of the active services." & @CRLF & _
"" & @CRLF & _
"We are parsing the output to have only the service name."" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "UNIX"" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "systemctl list-units --type service 2>/dev/null |grep .service | awk '{print $1}' | sed -e 's/.service//' "" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "linux_service_name_table"" & @CRLF & _
" col_names = "linux_service_name_list"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" exclude_lines_pattern = "systemctl|\u00E2\u0097\u008F"" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "script to get the service status by the process ID"" & @CRLF & _
" comment = "Script which will run the command: service <service_name> status command and insert the output to the table." & @CRLF & _
"" & @CRLF & _
"We are filtering the output only to the relevant pid_info.pid, so the only row with the status data will be the one that related to process pid that we are checking."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "UNIX"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"linux_service_name_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "linux_service_name_table"" & @CRLF & _
" target_table_name = "linux_service_name_table"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "status"" & @CRLF & _
" value = eval {"javascript: " & @CRLF & _
"try{" & @CRLF & _
"var service_name = CTX.getAttribute(\"linux_service_name_table[].linux_service_name_list\");" & @CRLF & _
"//var command=\"sudo service \"+service_name+\" status |grep \"+${pid_info.pid};" & @CRLF & _
"" & @CRLF & _
"var command=\"/bin/systemctl status \"+service_name+\".service 2>/dev/null | grep \"+${pid_info.pid};" & @CRLF & _
"" & @CRLF & _
"var rtrn=CTX.getCommandManager().shellCommand(command, false, null, null, CTX);" & @CRLF & _
"rtrn;" & @CRLF & _
"}" & @CRLF & _
"catch(e){" & @CRLF & _
"var rtrn =e;" & @CRLF & _
"rtrn;" & @CRLF & _
"}"}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "filter the linux_service_name_table table"" & @CRLF & _
" comment = "Filter the $linux_service_name_table table, so we will have a table with one line that include the service name and it's status."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_not_empty {get_attr {"linux_service_name_table[*].status"}}" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "UNIX"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "linux_service_name_table"" & @CRLF & _
" target_table_name = "linux_service_name_table"" & @CRLF & _
" condition = is_not_empty {get_attr {"linux_service_name_table[].status"}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "parse service_name"" & @CRLF & _
" comment = "We are saving the service_name in $linux_service_name variable."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" not_contains {" & @CRLF & _
" get_attr {"linux_service_name_table[1].status"}" & @CRLF & _
" "Redirecting"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "UNIX"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "linux_service_name"" & @CRLF & _
" get_attr {"linux_service_name_table[1].linux_service_name_list"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "set service name - CentOs - Linux start with Running"" & @CRLF & _
" comment = "set service name - CentOs - Linux"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "UNIX"" & @CRLF & _
" }" & @CRLF & _
" is_empty {get_attr {"linux_service_name"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" "service --status-all 2>/dev/null |grep -w "" & @CRLF & _
" get_attr {"pid_info[1].pid"}" & @CRLF & _
" }" & @CRLF & _
" var_names = "linux_service_name"" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "^Running.*\\s+\\(([^\\)]*)"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "set service name - CentOs - Linux"" & @CRLF & _
" comment = "set service name - CentOs - Linux"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "UNIX"" & @CRLF & _
" }" & @CRLF & _
" is_empty {get_attr {"linux_service_name"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" "service --status-all 2>/dev/null |grep "" & @CRLF & _
" get_attr {"pid_info[1].pid"}" & @CRLF & _
" "|awk '{print $1}'"" & @CRLF & _
" }" & @CRLF & _
" var_names = "linux_service_name"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "set service name - RedHat - Linux"" & @CRLF & _
" comment = "set service name - RedHat - Linux"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "UNIX"" & @CRLF & _
" }" & @CRLF & _
" is_empty {get_attr {"linux_service_name"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" "service --status-all 2>/dev/null|grep '"" & @CRLF & _
" get_attr {"pid_info[1].pid"}" & @CRLF & _
" ")' |awk '{print $1}'"" & @CRLF & _
" }" & @CRLF & _
" var_names = "linux_service_name"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>bary.solomon</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-05-03 11:25:54</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>3ceb033c13e23200d4013192e144b0f9</sys_id>" & @CRLF & _
"<sys_mod_count>36</sys_mod_count>" & @CRLF & _
"<sys_name>get service name for Linux server</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_3ceb033c13e23200d4013192e144b0f9</sys_update_name>" & @CRLF & _
"<sys_updated_by>bary.solomon</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2017-06-28 11:09:38</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>4103cbe39f2032001d753758442e709a</metadata_id>" & @CRLF & _
"<name>Linux - Memory</name>" & @CRLF & _
"<ndl>" & @CRLF & _
" library {" & @CRLF & _
" name = "Linux - Memory"" & @CRLF & _
" id = "4103cbe39f2032001d753758442e709a"" & @CRLF & _
" description = """ & @CRLF & _
" step {" & @CRLF & _
" name = "Get memory"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "grep MemTotal /proc/meminfo"" & @CRLF & _
" var_names = "Ram"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" include_lines_pattern = "MemTotal"" & @CRLF & _
" delimiters = " "" & @CRLF & _
" selected_positions = 2" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update RAM on Linux CI"" & @CRLF & _
" set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].ram"" & @CRLF & _
" eval {"javascript:rtrn = \"\";" & @CRLF & _
" var ram = ${Ram} / 1024;" & @CRLF & _
" rtrn = Math.ceil(ram);" & @CRLF & _
" "}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>oron.subayi</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:44:52</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>4103cbe39f2032001d753758442e709a</sys_id>" & @CRLF & _
"<sys_mod_count>0</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Memory</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_4103cbe39f2032001d753758442e709a</sys_update_name>" & @CRLF & _
"<sys_updated_by>oron.subayi</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2017-02-01 13:44:52</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>4660f86edb057200c12ef9361d96190c</metadata_id>" & @CRLF & _
"<name>Linux - Cloud</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Cloud"" & @CRLF & _
" id = "4660f86edb057200c12ef9361d96190c"" & @CRLF & _
" description = """ & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - AWS"" & @CRLF & _
" ref {refid = "5540b86edb057200c12ef9361d9619f6"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Azure"" & @CRLF & _
" ref {refid = "3f7e3e18db5932003398f1351d9619e5"}" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>oron.subayi</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-22 21:01:46</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>4660f86edb057200c12ef9361d96190c</sys_id>" & @CRLF & _
"<sys_mod_count>1</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Cloud</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_4660f86edb057200c12ef9361d96190c</sys_update_name>" & @CRLF & _
"<sys_updated_by>oron.subayi</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2017-03-08 17:46:00</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>46631de51bdc901409c1a64fad4bcb34</metadata_id>" & @CRLF & _
"<name>UNIX Cluster - Linux Pacemaker Cluster</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "UNIX Cluster - Linux Pacemaker Cluster"" & @CRLF & _
" id = "46631de51bdc901409c1a64fad4bcb34"" & @CRLF & _
" description = "UNIX Cluster - Linux Pacemaker Cluster"" & @CRLF & _
" step {" & @CRLF & _
" name = "UNIX Cluster - Linux Pacemaker Cluster"" & @CRLF & _
" ref {refid = "1068bcf41bf3cc584762dd3fbd4bcb61"}" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>admin</sys_created_by>" & @CRLF & _
"<sys_created_on>2020-04-20 15:20:35</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>46631de51bdc901409c1a64fad4bcb34</sys_id>" & @CRLF & _
"<sys_mod_count>13</sys_mod_count>" & @CRLF & _
"<sys_name>UNIX Cluster - Linux Pacemaker Cluster</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Discovery and Service Mapping Patterns" source="sn_itom_pattern">06a71b1367e4130051c9027e2685ef1e</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Discovery and Service Mapping Patterns">06a71b1367e4130051c9027e2685ef1e</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_46631de51bdc901409c1a64fad4bcb34</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2020-04-20 17:23:10</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>46d81a979f10320055063758442e707f</metadata_id>" & @CRLF & _
"<name>Unix-Linux Name Formatting</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Unix-Linux Name Formatting"" & @CRLF & _
" id = "46d81a979f10320055063758442e707f"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "Get system info"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "uname -a"" & @CRLF & _
" var_names = "uname"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract OS name from uname"" & @CRLF & _
" comment = "S"" & @CRLF & _
" set_attr {" & @CRLF & _
" "osName"" & @CRLF & _
" eval {"javascript: var rtrn = '';" & @CRLF & _
"" & @CRLF & _
"try{" & @CRLF & _
" var uname = ${uname};" & @CRLF & _
" rtrn = uname.split(/ /)[0];" & @CRLF & _
"}" & @CRLF & _
"catch(e){" & @CRLF & _
" Packages.com.snc.sw.log.DiscoLog.getLogger(\"Step Failed - Extract OS Name From Uname\").error(e.message);" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract hostname from uname"" & @CRLF & _
" set_attr {" & @CRLF & _
" "osHostname"" & @CRLF & _
" eval {"javascript: var rtrn = '';" & @CRLF & _
"try{" & @CRLF & _
" var uname = ${uname};" & @CRLF & _
" rtrn = uname.split(/ /)[1]?uname.split(/ /)[1]:\"unknown.host\";" & @CRLF & _
"}" & @CRLF & _
"catch(e){" & @CRLF & _
" Packages.com.snc.sw.log.DiscoLog.getLogger(\"Step Failed - Extract Hostname From Uname\").error(e.message);" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract OS version from uname"" & @CRLF & _
" if {" & @CRLF & _
" condition = neq {" & @CRLF & _
" get_attr {"computer_system.osType"}" & @CRLF & _
" "AIX"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "osVersion"" & @CRLF & _
" eval {"javascript: var rtrn = '';" & @CRLF & _
"try{" & @CRLF & _
" var uname = ${uname};" & @CRLF & _
" rtrn = uname.split(/ /)[2]?uname.split(/ /)[2]:'';" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"catch(e){" & @CRLF & _
" Packages.com.snc.sw.log.DiscoLog.getLogger(\"Step Failed - Extract OS Version From Uname\").error(e.message);" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create formattedHostname variable"" & @CRLF & _
" set_attr {" & @CRLF & _
" "formattedHostname"" & @CRLF & _
" get_attr {"osHostname"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Decide whether to use the new name or the old one for formatting"" & @CRLF & _
" if {" & @CRLF & _
" condition = any {" & @CRLF & _
" is_empty {get_attr {"osHostname"}}" & @CRLF & _
" eq {" & @CRLF & _
" "false"" & @CRLF & _
" eval {"javascript: var rtrn = ''" & @CRLF & _
"try{ " & @CRLF & _
" rtrn = ${computer_system.primaryHostname} && ${isSshTrusted}==\"false\";" & @CRLF & _
"}" & @CRLF & _
"catch(e){" & @CRLF & _
" Packages.com.snc.sw.log.DiscoLog.getLogger(\"Step Failed - Decide Old Or New For Formatting \").error(e.message);" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "osHostname"" & @CRLF & _
" get_attr {"computer_system.primaryHostname"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Format hostname"" & @CRLF & _
" set_attr {" & @CRLF & _
" "formattedHostname"" & @CRLF & _
" eval {"javascript: var rtrn = '';" & @CRLF & _
"try{ " & @CRLF & _
" var hostnameFormatter = new Packages.com.glide.util.HostnameFormatter(${fqdnRegex});" & @CRLF & _
" var source = (${computer_system.managementIP})?${computer_system.managementIP}:null;" & @CRLF & _
" hostnameFormatter.setCase(${hostnameCase});" & @CRLF & _
" hostnameFormatter.setIncludeDomain(${shouldIncludeDomain}==\"true\");" & @CRLF & _
" hostnameFormatter.setSource(source);" & @CRLF & _
" var formattedHostname = hostnameFormatter.format(${formattedHostname});" & @CRLF & _
" rtrn = (formattedHostname)?formattedHostname.fFormattedName:${osHostname};" & @CRLF & _
"}" & @CRLF & _
"catch(e){" & @CRLF & _
" Packages.com.snc.sw.log.DiscoLog.getLogger(\"Step Failed - Formatted Hostname \").error(e.message);" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>oron.subayi</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-01-19 05:46:27</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>46d81a979f10320055063758442e707f</sys_id>" & @CRLF & _
"<sys_mod_count>5</sys_mod_count>" & @CRLF & _
"<sys_name>Unix-Linux Name Formatting</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_46d81a979f10320055063758442e707f</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2019-12-09 12:12:56</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>5e1243e39f2032001d753758442e7041</metadata_id>" & @CRLF & _
"<name>Linux - Find FQDN</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Find FQDN"" & @CRLF & _
" id = "5e1243e39f2032001d753758442e7041"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "Run FQDN script file"" & @CRLF & _
" custom_operation {" & @CRLF & _
" attributes {attribute {" & @CRLF & _
" name = "fileName"" & @CRLF & _
" value = "linux_fqdn.sh"" & @CRLF & _
" }}" & @CRLF & _
" sys_id_op = "68367a239fc13200e9123758442e7083"" & @CRLF & _
" to_var_names = "FQDN"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" exclude_lines_pattern = "Unable"" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update the Linux CI FQDN"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"FQDN"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].fqdn"" & @CRLF & _
" get_attr {"FQDN"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>oron.subayi</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:40:51</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>5e1243e39f2032001d753758442e7041</sys_id>" & @CRLF & _
"<sys_mod_count>4</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Find FQDN</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_5e1243e39f2032001d753758442e7041</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2017-09-07 09:20:00</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>656487279f2032001d753758442e705c</metadata_id>" & @CRLF & _
"<name>Linux - Installed Software</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Installed Software"" & @CRLF & _
" id = "656487279f2032001d753758442e705c"" & @CRLF & _
" description = """ & @CRLF & _
" step {" & @CRLF & _
" name = "Run LinuxPKG script file"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = custom_operation {" & @CRLF & _
" attributes {attribute {" & @CRLF & _
" name = "fileName"" & @CRLF & _
" value = "pkg_munger.bash"" & @CRLF & _
" }}" & @CRLF & _
" sys_id_op = "68367a239fc13200e9123758442e7083"" & @CRLF & _
" to_var_names = "pkgMan"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "NonExistingSeparator"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove new lines from LinuxPKG output"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"pkgMan"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "pkgMan"" & @CRLF & _
" eval {"javascript: " & @CRLF & _
"var rtrn = '';" & @CRLF & _
"var pkgMan = ${pkgMan};" & @CRLF & _
"var strPkgMan = new Packages.java.lang.String(pkgMan);" & @CRLF & _
"" & @CRLF & _
"rtrn = strPkgMan.replaceAll(\"\\n\",\"$\");"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Crate empty package table"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = union {" & @CRLF & _
" table1_name = "PKG"" & @CRLF & _
" table2_name = "PKG"" & @CRLF & _
" result_table_name = "PKG"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert data to package table"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var extractFirstMatchWithRegex = function(stringToMatch,regex) {" & @CRLF & _
"var regexObject = new RegExp(regex);" & @CRLF & _
"var match = stringToMatch.match(regexObject);" & @CRLF & _
"return match ? match[1] : null;" & @CRLF & _
"};" & @CRLF & _
"var output = ${pkgMan};" & @CRLF & _
"var outSp = output.split('$');" & @CRLF & _
"var row = new Packages.java.util.HashMap();" & @CRLF & _
"var count = 0;" & @CRLF & _
"for (var i = 0; i < outSp.length; i++)" & @CRLF & _
"{" & @CRLF & _
" var block = outSp[i].split(':');" & @CRLF & _
" if (block[0] == \"Package\")" & @CRLF & _
" {" & @CRLF & _
" if (count > 0)" & @CRLF & _
" {" & @CRLF & _
" ${PKG}.add(clrow);" & @CRLF & _
" }" & @CRLF & _
" var clrow = row.clone();" & @CRLF & _
" clrow.put(\"name\",block[1]);" & @CRLF & _
" count++;" & @CRLF & _
" }" & @CRLF & _
" if (block[0] == \"Status\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"status\",block[1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[0] == \"Maintainer\")" & @CRLF & _
" {" & @CRLF & _
" var vendor = extractFirstMatchWithRegex(block[1], /^(?:.*?)<.+@(?:(?:.+)\\.)*(.+)\\.(?:(?:org)|(?:com)|(?:net))>$/);" & @CRLF & _
" if (vendor){" & @CRLF & _
" clrow.put(\"maintainer\",vendor);" & @CRLF & _
" }" & @CRLF & _
" else{" & @CRLF & _
" clrow.put(\"maintainer\",block[1]);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if (block[0] == \"Version\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"version\",block[1]);" & @CRLF & _
" }" & @CRLF & _
" if (block[0] == \"Release\")" & @CRLF & _
" {" & @CRLF & _
" clrow.put(\"version\",block[1]);" & @CRLF & _
" }" & @CRLF & _
" if (i == (outSp.length - 1) )" & @CRLF & _
" { " & @CRLF & _
" ${PKG}.add(clrow);" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"rtrn = \"test\";" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter packages"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "PKG"" & @CRLF & _
" target_table_name = "PKG"" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"PKG[].status"}" & @CRLF & _
" "installed"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate packages"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${PKG},[\"name\",\"version\"]);" & @CRLF & _
"CTX.setAttribute(\"PKG\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Mark all packages that we should keep according to filter configuration"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "PKG"" & @CRLF & _
" target_table_name = "PKG"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "shouldKeep"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"var isIncludeMethod = ${isSoftwareFilterMethodIsInclude};" & @CRLF & _
"var appName = ${PKG[].name};" & @CRLF & _
"var regex = ${softwareKeywordsRegex};" & @CRLF & _
"var extractFirstMatchWithRegex = function(stringToMatch,regex){" & @CRLF & _
"var regexObject = new RegExp(regex);" & @CRLF & _
"var match = stringToMatch.match(regexObject);" & @CRLF & _
"return match ? match[1] : null;" & @CRLF & _
"};" & @CRLF & _
"var match = extractFirstMatchWithRegex(appName,regex);" & @CRLF & _
"var isMatchFound = (match != null) && (match != \"\");" & @CRLF & _
"if((isIncludeMethod==\"true\" && isMatchFound) || (isIncludeMethod==\"false\" && !isMatchFound)){rtrn = \"true\";}else{rtrn = \"false\";}" & @CRLF & _
""}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Retain only packages chosen by user's filter"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "PKG"" & @CRLF & _
" target_table_name = "PKG"" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"PKG[].shouldKeep"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Trim software data"" & @CRLF & _
" comment = """ & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "PKG"" & @CRLF & _
" target_table_name = "PKG"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"rtrn = ${PKG[].name}.trim();" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "version"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"if(${PKG[].version}){" & @CRLF & _
"rtrn = ${PKG[].version}.trim();" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "maintainer"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"if(${PKG[].maintainer}){" & @CRLF & _
"rtrn = ${PKG[].maintainer}.trim();" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "status"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"var rtrn = '';" & @CRLF & _
"if(${PKG[].status}){" & @CRLF & _
"rtrn = ${PKG[].status}.trim();" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_sam_sw_install"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldPopulateOldSoftwareTables"}" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "PKG"" & @CRLF & _
" target_table_name = "cmdb_sam_sw_install"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "display_name"" & @CRLF & _
" value = get_attr {"PKG[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "publisher"" & @CRLF & _
" value = get_attr {"PKG[].maintainer"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_spkg"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldPopulateOldSoftwareTables"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "PKG"" & @CRLF & _
" target_table_name = "cmdb_ci_spkg"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"PKG[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "version"" & @CRLF & _
" value = get_attr {"PKG[].version"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "vendor"" & @CRLF & _
" value = get_attr {"PKG[].maintainer"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "key"" & @CRLF & _
" value = eval {"javascript: rtrn = \"\";rtrn = ${PKG[].name} + \"_:::_\" + (${PKG[].version}||\"NULL\");"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "package_name"" & @CRLF & _
" value = concat {" & @CRLF & _
" get_attr {"PKG[].name"}" & @CRLF & _
" " "" & @CRLF & _
" get_attr {"PKG[].version"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_software_instance"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldPopulateOldSoftwareTables"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "cmdb_ci_spkg"" & @CRLF & _
" target_table_name = "cmdb_software_instance"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"cmdb_ci_spkg[].name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "vendor"" & @CRLF & _
" value = get_attr {"cmdb_ci_spkg[].maintainer"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_software_instance and cmdb_ci_spkg"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldPopulateOldSoftwareTables"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = relation_reference {" & @CRLF & _
" table1_name = "cmdb_software_instance"" & @CRLF & _
" table2_name = "cmdb_ci_spkg"" & @CRLF & _
" result_table_name = "software_instance_spkg"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_software_instance[].name"}" & @CRLF & _
" get_attr {"cmdb_ci_spkg[].name"}" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_software_instance[].version"}" & @CRLF & _
" get_attr {"cmdb_ci_spkg[].version"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "software"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_sam_sw_install and Linux CI"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldDiscoverSoftware"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"shouldPopulateOldSoftwareTables"}" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = relation_reference {" & @CRLF & _
" table1_name = "cmdb_sam_sw_install"" & @CRLF & _
" table2_name = "cmdb_ci_linux_server"" & @CRLF & _
" result_table_name = "sam_to_linux"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "non_ci"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>oron.subayi</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:50:54</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>656487279f2032001d753758442e705c</sys_id>" & @CRLF & _
"<sys_mod_count>14</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Installed Software</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_656487279f2032001d753758442e705c</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2020-03-09 09:18:46</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>84538fe39f2032001d753758442e7086</metadata_id>" & @CRLF & _
"<name>Linux - Network ARP Tables</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Network ARP Tables"" & @CRLF & _
" id = "84538fe39f2032001d753758442e7086"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "Get ARP"" & @CRLF & _
" if {" & @CRLF & _
" condition = neq {" & @CRLF & _
" get_attr {"use_net_tools"}" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "arp -n"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "ARP_table"" & @CRLF & _
" col_names = "ip","mac","ifName"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" exclude_lines_pattern = "address"" & @CRLF & _
" delimiters = " "" & @CRLF & _
" selected_positions = 1,3,5" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get ARP details using iproute2"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_empty {get_attr {"ARP_table"}}" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ip n"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "ARP_table"" & @CRLF & _
" col_names = "ip","ifName","mac"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "^(\\d+.\\d+.\\d+.\\d+)\\s+(?:[^\\s]+)\\s+([^\\s]+)\\s+(?:[^\\s]+)\\s+([^\\s]+)\\s+"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update discovery_net_arp_table"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "ARP_table"" & @CRLF & _
" target_table_name = "discovery_net_arp_table"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "mac_address"" & @CRLF & _
" value = get_attr {"ARP_table[].mac"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"ARP_table[].ip"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate Network ARP Tables"" & @CRLF & _
" set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${discovery_net_arp_table},[\"ip_address\",\"mac_address\"]);" & @CRLF & _
"CTX.setAttribute(\"discovery_net_arp_table\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between discovery_net_arp_table and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "discovery_net_arp_table"" & @CRLF & _
" table2_name = "cmdb_ci_linux_server"" & @CRLF & _
" result_table_name = "ci_ti_arp"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "non_ci"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>oron.subayi</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:46:09</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>84538fe39f2032001d753758442e7086</sys_id>" & @CRLF & _
"<sys_mod_count>9</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Network ARP Tables</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_84538fe39f2032001d753758442e7086</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2020-09-21 08:13:08</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>98ab8ecf4f7a0b40a9f9011f0310c78d</metadata_id>" & @CRLF & _
"<name>Linux - Cluster</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Cluster"" & @CRLF & _
" id = "98ab8ecf4f7a0b40a9f9011f0310c78d"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Red Hat Cluster"" & @CRLF & _
" ref {refid = "c4eabd514fe3c3c0a9f9011f0310c730"}" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>bary.solomon</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-12-07 12:58:20</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>98ab8ecf4f7a0b40a9f9011f0310c78d</sys_id>" & @CRLF & _
"<sys_mod_count>51</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Cluster</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_98ab8ecf4f7a0b40a9f9011f0310c78d</sys_update_name>" & @CRLF & _
"<sys_updated_by>bary.solomon</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2018-01-08 09:18:24</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>9d38c8b313d7fa00d4013192e144b0ed</metadata_id>" & @CRLF & _
"<name>Initial Linux and Windows env flags</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Initial Linux and Windows env flags"" & @CRLF & _
" id = "9d38c8b313d7fa00d4013192e144b0ed"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "set linux_system_process to \"no\""" & @CRLF & _
" comment = "set linux_system_process flag to \"no\"."" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "UNIX"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "linux_system_process"" & @CRLF & _
" "no"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "set windows_system_process to \"no\""" & @CRLF & _
" comment = "set windows_system_process to \"no\""" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "WINDOWS"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "windows_system_process"" & @CRLF & _
" "no"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "set windows_system.exe process to \"no\""" & @CRLF & _
" comment = "set windows_system.exe process to \"no\""" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "WINDOWS"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "windows_system_exe_process"" & @CRLF & _
" "no"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "check if it is system.exe process on Windows"" & @CRLF & _
" comment = "check if it is system.exe process on Windows"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "WINDOWS"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"process.executable"}" & @CRLF & _
" "System"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"process.pid"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "windows_system_exe_process"" & @CRLF & _
" "yes"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "check if it is system.exe process from pre_cmdb - on Windows"" & @CRLF & _
" comment = "check if it is system.exe process on Windows"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "WINDOWS"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"process.executable"}" & @CRLF & _
" "System"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"pre_cmdb_running_process[1].pid"}" & @CRLF & _
" "4"" & @CRLF & _
" }" & @CRLF & _
" is_empty {get_attr {"windows_system_exe_process"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "windows_system_exe_process"" & @CRLF & _
" "yes"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>bary.solomon</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-06-18 11:39:50</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>9d38c8b313d7fa00d4013192e144b0ed</sys_id>" & @CRLF & _
"<sys_mod_count>8</sys_mod_count>" & @CRLF & _
"<sys_name>Initial Linux and Windows env flags</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_9d38c8b313d7fa00d4013192e144b0ed</sys_update_name>" & @CRLF & _
"<sys_updated_by>bary.solomon</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2017-06-28 11:05:32</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>a273cfe39f2032001d753758442e70b7</metadata_id>" & @CRLF & _
"<name>Linux - Identity</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Identity"" & @CRLF & _
" id = "a273cfe39f2032001d753758442e70b7"" & @CRLF & _
" description = """ & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Hardware Information"" & @CRLF & _
" ref {refid = "c161cfa39f2032001d753758442e70f9"}" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Linux - Network"" & @CRLF & _
" ref {refid = "0ae107e39f2032001d753758442e70ec"}" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>oron.subayi</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:46:52</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>a273cfe39f2032001d753758442e70b7</sys_id>" & @CRLF & _
"<sys_mod_count>0</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Identity</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_a273cfe39f2032001d753758442e70b7</sys_update_name>" & @CRLF & _
"<sys_updated_by>oron.subayi</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2017-02-01 13:46:52</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>c161cfa39f2032001d753758442e70f9</metadata_id>" & @CRLF & _
"<name>Linux - Hardware Information</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Hardware Information"" & @CRLF & _
" id = "c161cfa39f2032001d753758442e70f9"" & @CRLF & _
" description = """ & @CRLF & _
" step {" & @CRLF & _
" name = "Set the privileged command to use"" & @CRLF & _
" set_attr {" & @CRLF & _
" "sudo"" & @CRLF & _
" eval {"return ${ctx}.getDiscoveryProvider(com.snc.sw.dto.ProviderType.SSH).getPrivilegedCommand();"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get DMI type 1"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" get_attr {"sudo"}" & @CRLF & _
" " dmidecode -t 1 | cat"" & @CRLF & _
" }" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "dmiType1"" & @CRLF & _
" col_names = "manufacturer","model_number","system_serial_number","uuid_serial","model_id"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = properties_parsing_strategy {fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "manufacturer"" & @CRLF & _
" xpath = "/Manufacturer/text()"" & @CRLF & _
" delimiters = ":"" & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "model_number"" & @CRLF & _
" xpath = "/Version/text()"" & @CRLF & _
" delimiters = ":"" & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "system_serial_number"" & @CRLF & _
" xpath = "/Serial/text()"" & @CRLF & _
" delimiters = ":"" & @CRLF & _
" position = 2" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "uuid_serial"" & @CRLF & _
" xpath = "/UUID/text()"" & @CRLF & _
" delimiters = ":"" & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "model_id"" & @CRLF & _
" xpath = "/Product/text()"" & @CRLF & _
" delimiters = ":"" & @CRLF & _
" position = 2" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Failover Get DMI type 1 "" & @CRLF & _
" if {" & @CRLF & _
" condition = is_empty {get_attr {"dmiType1"}}" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" get_attr {"sudo"}" & @CRLF & _
" " dmidecode -t 1 | cat"" & @CRLF & _
" }" & @CRLF & _
" execution_mode = "DEFAULT"" & @CRLF & _
" var_names = "output_dmi"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" include_lines_pattern = ":"" & @CRLF & _
" exclude_lines_pattern = "readonly"" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Convert output to JSON"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_empty {get_attr {"dmiType1"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "output_dmi_json"" & @CRLF & _
" eval {"arr = ${output_dmi};" & @CRLF & _
"" & @CRLF & _
"length = arr.size();" & @CRLF & _
"" & @CRLF & _
"res = \"{\";" & @CRLF & _
"" & @CRLF & _
"for( i = 0;i < length;i++){" & @CRLF & _
"" & @CRLF & _
" str = arr[i].split(\":\");" & @CRLF & _
" " & @CRLF & _
" if(arr[i].contains(\"Manufacturer\")){" & @CRLF & _
" res = res + '\"Manufacturer\"' +\":\" + '\"'+str[1].trim()+'\"';" & @CRLF & _
" }" & @CRLF & _
" else if(arr[i].contains('Version')){" & @CRLF & _
" res = res + '\"Version\"' +\":\" + '\"'+str[1].trim()+'\"';" & @CRLF & _
" } " & @CRLF & _
" else if(arr[i].contains('Serial')){" & @CRLF & _
" res = res + '\"Serial\"' +\":\" + '\"'+str[1].trim()+'\"';" & @CRLF & _
" } " & @CRLF & _
" else if(arr[i].contains('UUID')){" & @CRLF & _
" res = res + '\"UUID\"' +\":\" + '\"'+str[1].trim()+'\"';" & @CRLF & _
" } " & @CRLF & _
" else if(arr[i].contains('Product')){" & @CRLF & _
" res = res + '\"Product\"' +\":\" + '\"'+str[1].trim()+'\"';" & @CRLF & _
" }else{" & @CRLF & _
" res = res + '\"na\"' +\":\" + '\"na\"';" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if(i != length -1){" & @CRLF & _
" res = res + \",\";" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"res = res +\"}\";" & @CRLF & _
"" & @CRLF & _
"return res;"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse DMI type 1"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_empty {get_attr {"dmiType1"}}" & @CRLF & _
" is_not_empty {get_attr {"output_dmi_json"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "output_dmi_json"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "dmiType1"" & @CRLF & _
" col_names = "manufacturer","model_id","model_number","system_serial_number","uuid_serial"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = custom_parsing_strategy {" & @CRLF & _
" sys_id = "512a3d5a9f3312003cb191aec32e708a"" & @CRLF & _
" rootXpath = "/root"" & @CRLF & _
" fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "manufacturer"" & @CRLF & _
" xpath = "/root/Manufacturer/text()"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "model_id"" & @CRLF & _
" xpath = "/root/Product/text()"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "model_number"" & @CRLF & _
" xpath = "/root/Version/text()"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "system_serial_number"" & @CRLF & _
" xpath = "/root/Serial/text()"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "uuid_serial"" & @CRLF & _
" xpath = "/root/UUID/text()"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get DMI type 2"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" get_attr {"sudo"}" & @CRLF & _
" " dmidecode -t 2 | cat"" & @CRLF & _
" }" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "dmiType2"" & @CRLF & _
" col_names = "baseboard_serial"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = properties_parsing_strategy {fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "baseboard_serial"" & @CRLF & _
" xpath = "/Serial/text()"" & @CRLF & _
" delimiters = ":"" & @CRLF & _
" position = 2" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Failover Get DMI type 2"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_empty {get_attr {"dmiType2"}}" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" get_attr {"sudo"}" & @CRLF & _
" " dmidecode -t 2 | cat"" & @CRLF & _
" }" & @CRLF & _
" execution_mode = "DEFAULT"" & @CRLF & _
" var_names = "output_dmi"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" include_lines_pattern = ":"" & @CRLF & _
" exclude_lines_pattern = "readonly"" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Convert output to JSON"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_empty {get_attr {"dmiType2"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "output_dmi_json"" & @CRLF & _
" eval {"" & @CRLF & _
"arr = ${output_dmi};" & @CRLF & _
"" & @CRLF & _
"length = arr.size();" & @CRLF & _
"" & @CRLF & _
"res = \"{\";" & @CRLF & _
"" & @CRLF & _
"for( i = 0;i < length;i++){" & @CRLF & _
"" & @CRLF & _
" str = arr[i].split(\":\");" & @CRLF & _
" " & @CRLF & _
" if(arr[i].contains(\"Serial\")){" & @CRLF & _
" res = res + '\"Serial\"' +\":\" + '\"'+str[1].trim()+'\"';" & @CRLF & _
" }else{" & @CRLF & _
" res = res + '\"na\"' +\":\" + '\"na\"';" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" if(i != length -1){" & @CRLF & _
" res = res + \",\";" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"res = res +\"}\";" & @CRLF & _
"" & @CRLF & _
"return res;"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse DMI type 2"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_empty {get_attr {"dmiType2"}}" & @CRLF & _
" is_not_empty {get_attr {"output_dmi_json"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "output_dmi_json"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "dmiType2"" & @CRLF & _
" col_names = "baseboard_serial"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = custom_parsing_strategy {" & @CRLF & _
" sys_id = "512a3d5a9f3312003cb191aec32e708a"" & @CRLF & _
" rootXpath = "/root"" & @CRLF & _
" fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "baseboard_serial"" & @CRLF & _
" xpath = "/root/Serial/text()"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get DMI type 3"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" get_attr {"sudo"}" & @CRLF & _
" " dmidecode -t 3 | cat"" & @CRLF & _
" }" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "dmiType3"" & @CRLF & _
" col_names = "chassis_serial"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = properties_parsing_strategy {fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "chassis_serial"" & @CRLF & _
" xpath = "/Serial/text()"" & @CRLF & _
" delimiters = " "" & @CRLF & _
" position = 2" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Failover Get DMI type 3"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_empty {get_attr {"dmiType3"}}" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" get_attr {"sudo"}" & @CRLF & _
" " dmidecode -t 3 | cat"" & @CRLF & _
" }" & @CRLF & _
" execution_mode = "DEFAULT"" & @CRLF & _
" var_names = "output_dmi"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" include_lines_pattern = ":"" & @CRLF & _
" exclude_lines_pattern = "readonly"" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Convert output to JSON"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_empty {get_attr {"dmiType3"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "output_dmi_json"" & @CRLF & _
" eval {"arr = ${output_dmi};" & @CRLF & _
"" & @CRLF & _
"length = arr.size();" & @CRLF & _
"" & @CRLF & _
"res = \"{\";" & @CRLF & _
"" & @CRLF & _
"for( i = 0;i < length;i++){" & @CRLF & _
"" & @CRLF & _
" str = arr[i].split(\":\");" & @CRLF & _
" " & @CRLF & _
" if(arr[i].contains(\"Serial\")){" & @CRLF & _
" res = res + '\"Serial\"' +\":\" + '\"'+str[1].trim()+'\"';" & @CRLF & _
" }else{" & @CRLF & _
" res = res + '\"na\"' +\":\" + '\"na\"';" & @CRLF & _
" }" & @CRLF & _
" " & @CRLF & _
" if(i != length -1){" & @CRLF & _
" res = res + \",\";" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"res = res +\"}\";" & @CRLF & _
"" & @CRLF & _
"return res;"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse DMI type 3"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_empty {get_attr {"dmiType3"}}" & @CRLF & _
" is_not_empty {get_attr {"output_dmi_json"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "output_dmi_json"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "dmiType3"" & @CRLF & _
" col_names = "chassis_serial"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = custom_parsing_strategy {" & @CRLF & _
" sys_id = "512a3d5a9f3312003cb191aec32e708a"" & @CRLF & _
" rootXpath = "/root"" & @CRLF & _
" fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "chassis_serial"" & @CRLF & _
" xpath = "/root/Serial/text()"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update system serial number"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "dmiType1"" & @CRLF & _
" target_table_name = "serial_system"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number"" & @CRLF & _
" value = eval {"javascript:var rtrn = \"\";var tri = ${dmiType1[].system_serial_number};rtrn = tri.trim();"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number_type"" & @CRLF & _
" value = "system"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "valid"" & @CRLF & _
" value = "true"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update UUID serial number"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "dmiType1"" & @CRLF & _
" target_table_name = "serial_uuid"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number"" & @CRLF & _
" value = eval {"javascript:var rtrn = \"\";var tri = ${dmiType1[].uuid_serial};rtrn = tri.trim();"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number_type"" & @CRLF & _
" value = "uuid"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "valid"" & @CRLF & _
" value = "true"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update baseboard serial number"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "dmiType2"" & @CRLF & _
" target_table_name = "serial_baseboard"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number"" & @CRLF & _
" value = eval {"javascript:var rtrn = \"\";var tri = ${dmiType2[].baseboard_serial};rtrn = tri.trim();"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number_type"" & @CRLF & _
" value = "baseboard"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "valid"" & @CRLF & _
" value = "true"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update chassis serial number"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "dmiType3"" & @CRLF & _
" target_table_name = "serial_chassis"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number"" & @CRLF & _
" value = eval {"javascript:var rtrn = \"\";var tri = ${dmiType3[].chassis_serial};rtrn = tri.trim();"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number_type"" & @CRLF & _
" value = "chassis"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "valid"" & @CRLF & _
" value = "true"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Combine serial_system and serial_baseboard"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "serial_system"" & @CRLF & _
" table2_name = "serial_baseboard"" & @CRLF & _
" result_table_name = "serial_system"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Combine serial_system and serial_uuid"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "serial_system"" & @CRLF & _
" table2_name = "serial_uuid"" & @CRLF & _
" result_table_name = "serial_system"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Combine serial_system and serial_chassis"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "serial_system"" & @CRLF & _
" table2_name = "serial_chassis"" & @CRLF & _
" result_table_name = "serial_system"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_serial_number table"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "serial_system"" & @CRLF & _
" target_table_name = "cmdb_serial_number"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number"" & @CRLF & _
" value = get_attr {"serial_system[].serial_number"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "serial_number_type"" & @CRLF & _
" value = get_attr {"serial_system[].serial_number_type"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "valid"" & @CRLF & _
" value = get_attr {"serial_system[].valid"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove \"None\" serials"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "cmdb_serial_number"" & @CRLF & _
" target_table_name = "cmdb_serial_number"" & @CRLF & _
" condition = all {" & @CRLF & _
" not_contains {" & @CRLF & _
" get_attr {"cmdb_serial_number[].serial_number"}" & @CRLF & _
" "None"" & @CRLF & _
" }" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"cmdb_serial_number[].serial_number"}" & @CRLF & _
" "Not"" & @CRLF & _
" }" & @CRLF & _
" not_contains {" & @CRLF & _
" get_attr {"cmdb_serial_number[].serial_number"}" & @CRLF & _
" "Not"" & @CRLF & _
" }" & @CRLF & _
" not_contains {" & @CRLF & _
" get_attr {"cmdb_serial_number[].serial_number"}" & @CRLF & _
" "Number:"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate serials"" & @CRLF & _
" set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${cmdb_serial_number},['serial_number','serial_number_type','valid']);" & @CRLF & _
"CTX.setAttribute(\"cmdb_serial_number\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Keep rows in dmiType1 that contain manufacturer"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "dmiType1"" & @CRLF & _
" target_table_name = "potentialManufacturers"" & @CRLF & _
" condition = is_not_empty {get_attr {"dmiType1[].manufacturer"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update manufacturer in cmdb_ci_linux_server"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"potentialManufacturers"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].manufacturer"" & @CRLF & _
" get_attr {"potentialManufacturers[1].manufacturer"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Keep rows in dmiType1 that contain model number"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "dmiType1"" & @CRLF & _
" target_table_name = "potentialModelNumbers"" & @CRLF & _
" condition = is_not_empty {get_attr {"dmiType1[].model_number"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update model number in cmdb_ci_linux_server"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"potentialModelNumbers"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].model_number"" & @CRLF & _
" get_attr {"potentialModelNumbers[1].model_number"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Keep rows in dmiType1 that contain model id"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "dmiType1"" & @CRLF & _
" target_table_name = "potentialModelIds"" & @CRLF & _
" condition = is_not_empty {get_attr {"dmiType1[].model_id"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update model id cmdb_ci_linux_server"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"potentialModelIds"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].model_id"" & @CRLF & _
" get_attr {"potentialModelIds[1].model_id"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel Linux Serial"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_serial_number"" & @CRLF & _
" table2_name = "cmdb_ci_linux_server"" & @CRLF & _
" result_table_name = "linx_to_serial"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "non_ci"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>admin</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:37:46</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>c161cfa39f2032001d753758442e70f9</sys_id>" & @CRLF & _
"<sys_mod_count>16</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Hardware Information</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_c161cfa39f2032001d753758442e70f9</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2021-04-16 13:26:36</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>c4eabd514fe3c3c0a9f9011f0310c730</metadata_id>" & @CRLF & _
"<name>Linux - Red Hat Cluster</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Red Hat Cluster"" & @CRLF & _
" id = "c4eabd514fe3c3c0a9f9011f0310c730"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = " ________Linux Red Hat Cluster________"" & @CRLF & _
" comment = "This step is for label only to mention that we starting the Linux Red Hat Cluster library."" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Determine sudo"" & @CRLF & _
" comment = "Run script to find the privileged command to use."" & @CRLF & _
" set_attr {" & @CRLF & _
" "sudo"" & @CRLF & _
" eval {"return ${ctx}.getDiscoveryProvider(com.snc.sw.dto.ProviderType.SSH).getPrivilegedCommand();"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create isCluster variable"" & @CRLF & _
" comment = "Indicates whether the server we are trying to discover is running in Unix cluster env. Default is \u201Cfalse\u201D."" & @CRLF & _
" set_attr {" & @CRLF & _
" "isCluster"" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Verify if corosync process is running"" & @CRLF & _
" comment = "We are checking if corosync process is running." & @CRLF & _
"" & @CRLF & _
"In case that corosync process is running we understand that the system is running in Red Hat Cluster env." & @CRLF & _
"" & @CRLF & _
"This condition will be check during all the Red Hat cluster discovery."" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "ps -ef | grep corosync | grep -v grep"" & @CRLF & _
" var_names = "cluster_process"" & @CRLF & _
" parsing_strategy = regex_parsing {regex = ".*(corosync).*"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Set isCluster variable"" & @CRLF & _
" comment = "In case that the corosync is running we are setting the \"isCluster\" variable to \"true\"."" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"cluster_process"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "isCluster"" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create isVIP variable"" & @CRLF & _
" comment = "Indicates whether the IP we are trying to discover is Unix cluster\u2019s VIP. Default is \u201Cfalse\u201D."" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "isVIP"" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Populate cluster.conf file"" & @CRLF & _
" comment = "The \"/etc/cluster/cluster.conf\" file contains the cluster configuration and setup." & @CRLF & _
"" & @CRLF & _
"From \"/etc/cluster/cluster.conf\" we can analyze all the cluster settings."" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_text_file_to_var {" & @CRLF & _
" file_path = get_files_by_filter {" & @CRLF & _
" expression = "/etc/cluster/cluster.conf"" & @CRLF & _
" foreach_attribute_name = "forEach"" & @CRLF & _
" }" & @CRLF & _
" var_names = "cluster_conf"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "XXXXXXXXXXXXX"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Set Red Hat Cluster Version"" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" get_attr {"sudo"}" & @CRLF & _
" " clustat -v"" & @CRLF & _
" }" & @CRLF & _
" var_names = "red_hat_cluster_version"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" delimiters = " "" & @CRLF & _
" selected_positions = 3" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Collect cluster name and cluster nodes name"" & @CRLF & _
" comment = "Collect cluster name and cluster nodes name from \"/etc/cluster/cluster.conf\"."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "cluster_conf"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "cluster_name_nodes_multicast"" & @CRLF & _
" col_names = "cluster_name","cluster_node","multicast_addr"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = xml_parsing_strategy {" & @CRLF & _
" rootXpath = "/cluster"" & @CRLF & _
" fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "cluster_name"" & @CRLF & _
" xpath = "/cluster/@name"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "cluster_node"" & @CRLF & _
" xpath = "/cluster/clusternodes/clusternode/@name"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "multicast_addr"" & @CRLF & _
" xpath = "/cluster/cman/multicast/@addr"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Populate VIP service information from cluster.conf"" & @CRLF & _
" comment = "Populate VIP service information from cluster.conf"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "cluster_conf"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "redhat_cluster_services_ip_info"" & @CRLF & _
" col_names = "service_name","ip_ip_address","ip_monitor_link"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = xml_parsing_strategy {" & @CRLF & _
" rootXpath = "/cluster"" & @CRLF & _
" fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_name"" & @CRLF & _
" xpath = "/cluster/rm/service/@name"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "ip_ip_address"" & @CRLF & _
" xpath = "/cluster/rm/service/ip/@address"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "ip_monitor_link"" & @CRLF & _
" xpath = "/cluster/rm/service/ip/@monitor_link"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse services from cluster.conf"" & @CRLF & _
" comment = "Parse services from cluster.conf." & @CRLF & _
"" & @CRLF & _
"We are splitting the services to lines every \"<service\" section to cluster_conf_all_services table."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "cluster_conf"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "cluster_conf_all_services"" & @CRLF & _
" col_names = "service"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "<service"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter non service from the cluster_conf_all_services table"" & @CRLF & _
" comment = "Filter non service from the cluster_conf_all_services table." & @CRLF & _
"" & @CRLF & _
"This step is removing the first line from the cluster_conf_all_services table which includes not a service information."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "cluster_conf_all_services"" & @CRLF & _
" target_table_name = "cluster_conf_all_services"" & @CRLF & _
" condition = not_contains {" & @CRLF & _
" get_attr {"cluster_conf_all_services[].service"}" & @CRLF & _
" "xml version="" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse services from $cluster_conf_all_services table"" & @CRLF & _
" comment = "Parse services from $cluster_conf_all_services table." & @CRLF & _
"" & @CRLF & _
"We are splitting every resource from the services to separate line in order to create a table that includes only the resources."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "cluster_conf_all_services[*].service"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "resources"" & @CRLF & _
" col_names = "resource"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" exclude_lines_pattern = "autostart"," nfsexport"," /nfsexport"," nfsclient"," <service"," /service"," /fs"" & @CRLF & _
" delimiters = ">"" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "<"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter non resource content from resources table"" & @CRLF & _
" comment = "Filter non resource content from resources table." & @CRLF & _
"" & @CRLF & _
"Lines that doesn't include \"=\" or start with \"/\", doesn't include resource relevant information."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "resources"" & @CRLF & _
" target_table_name = "resources"" & @CRLF & _
" condition = all {" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"resources[].resource"}" & @CRLF & _
" "="" & @CRLF & _
" }" & @CRLF & _
" not_starts_with {" & @CRLF & _
" "/"" & @CRLF & _
" get_attr {"resources[].resource"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Split resources to type and properties"" & @CRLF & _
" comment = "Split resources to type and properties." & @CRLF & _
"" & @CRLF & _
"The first word of every resource line represent its type, the other information is it's properties information."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "resources[*].resource"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "resource_table"" & @CRLF & _
" col_names = "resource_type","resource_properties"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "^([^ \\s]+)\\s+(.*=.*)"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter lines from resources table which start with autostart"" & @CRLF & _
" comment = "Filter lines from resources table which start with autostart"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "resource_table"" & @CRLF & _
" target_table_name = "resource_table"" & @CRLF & _
" condition = not_starts_with {" & @CRLF & _
" "autostart"" & @CRLF & _
" get_attr {"resource_table[].resource_type"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Populate resources name from resources table"" & @CRLF & _
" comment = "Populate resources name from resources table." & @CRLF & _
"" & @CRLF & _
"Create a table that include all the resources name - resource_name_table."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "resources[*].resource"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "resource_name_table"" & @CRLF & _
" col_names = "resource_name"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "\\sname=\\\"(.*?)\\\""}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Populate resources ip from resources table"" & @CRLF & _
" comment = "Populate resources ip from resources table." & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"Create a table that include all the resources name - resource_ip_table."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "resources[*].resource"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "resource_ip_table"" & @CRLF & _
" col_names = "resource_ip_address"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "^ip\\s+.*address=\\\"(\\d+.\\d+.\\d+.\\d+)\\\""}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Populate resources sap_database from resources table"" & @CRLF & _
" comment = "Populate resources sap_database from resources table." & @CRLF & _
"" & @CRLF & _
"Create a table that include all the resources name - resource_sap_database_table." & @CRLF & _
"" & @CRLF & _
"Since this resource doesn't contains a name attribute, we are using the SID as the SAP Database Name."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "resources[*].resource"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "resource_sap_database_table"" & @CRLF & _
" col_names = "resource_sap_database"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "^SAPDatabase\\s+.*SID=\\\"(.*?)\\\""}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Populate resources sap_instance from resources table"" & @CRLF & _
" comment = "Populate resources sap_instance from resources table." & @CRLF & _
"" & @CRLF & _
"Create a table that include all the SAP Instances name - resource_sap_instance_table." & @CRLF & _
"" & @CRLF & _
"Since this resource doesn't contains a name attribute, we are using the Instance name as the SAP instance name."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_var_to_var {" & @CRLF & _
" from_var_name = "resources[*].resource"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "resource_sap_instance_table"" & @CRLF & _
" col_names = "resource_sap_instance"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "^SAPInstance\\s+.*InstanceName =\\\"(.*?)\\\""}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Transform resource type to readable name"" & @CRLF & _
" comment = "The step contains a script which transform the resource type to readable name."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "resource_table"" & @CRLF & _
" target_table_name = "resource_table"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "type"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
"rtrn = '';" & @CRLF & _
"var type = ${resource_table[].resource_type};" & @CRLF & _
"switch (type)" & @CRLF & _
"{ " & @CRLF & _
"case \"lvm\": rtrn = \"HA LVM\";" & @CRLF & _
"break; " & @CRLF & _
"case \"fs\": rtrn = \"Filesystem\"; " & @CRLF & _
"break; " & @CRLF & _
"case \"ip\": rtrn = \"IP Address\";" & @CRLF & _
"break;" & @CRLF & _
"" & @CRLF & _
"case \"apache\": rtrn = \"Apache\";" & @CRLF & _
"break; " & @CRLF & _
"case \"bind-mount\": rtrn = \"Bind Mount\"; " & @CRLF & _
"break; " & @CRLF & _
"case \"condor\": rtrn = \"Condor Instance\";" & @CRLF & _
"break;" & @CRLF & _
"" & @CRLF & _
"case \"clusterfs\": rtrn = \"GFS2\";" & @CRLF & _
"break; " & @CRLF & _
"case \"bind-mount\": rtrn = \"Bind Mount\"; " & @CRLF & _
"break; " & @CRLF & _
"case \"mysql\": rtrn = \"MySQL\";" & @CRLF & _
"break;" & @CRLF & _
"" & @CRLF & _
"case \"named\": rtrn = \"Named Resource\";" & @CRLF & _
"break; " & @CRLF & _
"case \"netfs\": rtrn = \"NFS/CIFS Mount\"; " & @CRLF & _
"break; " & @CRLF & _
"case \"nfsclient\": rtrn = \"NFS Client\";" & @CRLF & _
"break;" & @CRLF & _
"" & @CRLF & _
"case \"nfsexport\": rtrn = \"NFS v3 Export\";" & @CRLF & _
"break; " & @CRLF & _
"case \"nfsserver\": rtrn = \"NFS Server\"; " & @CRLF & _
"break; " & @CRLF & _
"case \"oracledb\": rtrn = \"Oracle 10g/11g Failover Instance\";" & @CRLF & _
"break;" & @CRLF & _
"" & @CRLF & _
"case \"orainstance\": rtrn = \"Oracle 10g/11g Instance\";" & @CRLF & _
"break; " & @CRLF & _
"case \"oralistener\": rtrn = \"Oracle 10g/11g Listener\"; " & @CRLF & _
"break; " & @CRLF & _
"case \"openldap\": rtrn = \"Open LDAP\";" & @CRLF & _
"break;" & @CRLF & _
"" & @CRLF & _
"case \"SAPDatabase\": rtrn = \"SAP Database\";" & @CRLF & _
"break; " & @CRLF & _
"case \"SAPInstance\": rtrn = \"SAP Instance\"; " & @CRLF & _
"break; " & @CRLF & _
"case \"samba\": rtrn = \"Samba Server\";" & @CRLF & _
"break;" & @CRLF & _
"" & @CRLF & _
"case \"script\": rtrn = \"Script\";" & @CRLF & _
"break; " & @CRLF & _
"case \"ASEHAagent\": rtrn = \"Sybase ASE Failover Instance\"; " & @CRLF & _
"break; " & @CRLF & _
"case \"tomcat\": rtrn = \"Tomcat 6\";" & @CRLF & _
"break;" & @CRLF & _
"case \"vm\": rtrn = \"Virtual Machine\";" & @CRLF & _
"break; " & @CRLF & _
"" & @CRLF & _
"default: rtrn = \"logical\";" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge resource_table and resource_name_table"" & @CRLF & _
" comment = "Merge resource_table and resource_name_table, so we will have the resource details and its name in the same table." & @CRLF & _
"" & @CRLF & _
"The merge created with \"Keep\" since there are resources without a name like the \"ip_address\" that we wants to keep them in the table."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "resource_table"" & @CRLF & _
" table2_name = "resource_name_table"" & @CRLF & _
" result_table_name = "resource_table"" & @CRLF & _
" unmatched_lines = keep" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"resource_table[].resource_properties"}" & @CRLF & _
" concat {" & @CRLF & _
" "name=\""" & @CRLF & _
" get_attr {"resource_name_table[].resource_name"}" & @CRLF & _
" "\""" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge resource_table and resource_ip_table"" & @CRLF & _
" comment = "Merge resource_table and resource_ip_table, so we will have the resource details and its ip address in the same table." & @CRLF & _
"" & @CRLF & _
"The merge created with \"Keep\" since there are resources without a \"ip_address\" like the \"File System\" that we wants to keep them in the table."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "resource_table"" & @CRLF & _
" table2_name = "resource_ip_table"" & @CRLF & _
" result_table_name = "resource_table"" & @CRLF & _
" unmatched_lines = keep" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"resource_table[].resource_properties"}" & @CRLF & _
" concat {" & @CRLF & _
" "address=\""" & @CRLF & _
" get_attr {"resource_ip_table[].resource_ip_address"}" & @CRLF & _
" "\""" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge resource_table and resource_sap_database_table"" & @CRLF & _
" comment = "Merge resource_table and resource_sap_database_table." & @CRLF & _
"" & @CRLF & _
"The merge created with \"Keep\" since there are resources without a \"SAP database\" like the \"File System\" that we wants to keep them in the table."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "resource_table"" & @CRLF & _
" table2_name = "resource_sap_database_table"" & @CRLF & _
" result_table_name = "resource_table"" & @CRLF & _
" unmatched_lines = keep" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"resource_table[].resource_properties"}" & @CRLF & _
" concat {" & @CRLF & _
" "SID =\""" & @CRLF & _
" get_attr {"resource_sap_database_table[].resource_sap_database"}" & @CRLF & _
" "\""" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge resource_table and resource_sap_instance_table"" & @CRLF & _
" comment = "Merge resource_table and resource_sap_instance_table." & @CRLF & _
"" & @CRLF & _
"The merge created with \"Keep\" since there are resources without a \"SAP instance\" like the \"File System\" that we wants to keep them in the table."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "resource_table"" & @CRLF & _
" table2_name = "resource_sap_instance_table"" & @CRLF & _
" result_table_name = "resource_table"" & @CRLF & _
" unmatched_lines = keep" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"resource_table[].resource_properties"}" & @CRLF & _
" concat {" & @CRLF & _
" "SID =\""" & @CRLF & _
" get_attr {"resource_sap_instance_table[].resource_sap_instance"}" & @CRLF & _
" "\""" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Script to initial the resource name for IP and SAP "" & @CRLF & _
" comment = "The script is initializing the resource name for \"IP address\" and \"SAP Database\" and \"SAP Instance\" since there is no \"name\" tag for them in the cluster.conf file." & @CRLF & _
"" & @CRLF & _
"The script also is initializing the file system resource name for type nfsclient and nfsexport." & @CRLF & _
"" & @CRLF & _
"The script will return for IP address:" & @CRLF & _
"\"Virtual IP Address\" +\"_\"+ip" & @CRLF & _
"" & @CRLF & _
"The script will return for SAP Database:" & @CRLF & _
"\"SAP Database\" +\"_\"+sapdatabase" & @CRLF & _
"" & @CRLF & _
"The script will return for SAP Instance:" & @CRLF & _
"\"SAP Instance\" +\"_\"+sapinstance" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"For nfsclient and nfsexport, it will initial the name with the value of the type + ref attribute."" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "resource_table"" & @CRLF & _
" target_table_name = "resource_table"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "resource_name"" & @CRLF & _
" value = eval {"javascript: " & @CRLF & _
"" & @CRLF & _
"var resource = ${resource_table[].resource_name};" & @CRLF & _
"var ip = ${resource_table[].resource_ip_address};" & @CRLF & _
"var type = ${resource_table[].resource_type};" & @CRLF & _
"var sapdatabase = ${resource_table[].resource_sap_database};" & @CRLF & _
"var sapinstance = ${resource_table[].resource_sap_instance};" & @CRLF & _
"var resource_properties = ${resource_table[].resource_properties};" & @CRLF & _
"" & @CRLF & _
"var rtrn='';" & @CRLF & _
"" & @CRLF & _
"if (!resource || resource == \"null\")" & @CRLF & _
"{" & @CRLF & _
" if (type == \"ip\")" & @CRLF & _
" {" & @CRLF & _
" rtrn=\"Virtual IP address\" +\"_\"+ip;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if (type == \"SAPDatabase\")" & @CRLF & _
" {" & @CRLF & _
" rtrn=\"SAP Database\" +\"_\"+sapdatabase;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if (type == \"SAPInstance\")" & @CRLF & _
" {" & @CRLF & _
" rtrn=\"SAP Instance\" +\"_\"+sapinstance;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if (type == \"nfsclient\" || type==\"nfsexport\")" & @CRLF & _
" {" & @CRLF & _
" regexp = /ref=\\\"(.*)\\\"/g;" & @CRLF & _
" var code = regexp.exec(resource_properties);" & @CRLF & _
" if ( code != null && code[1] != null ) " & @CRLF & _
" rtrn=type+\"_\"+code[1];" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"else" & @CRLF & _
"{" & @CRLF & _
" rtrn=resource;" & @CRLF & _
"}"}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Set isVIP variable"" & @CRLF & _
" comment = "Are we trying to discover a VIP address?Check if our management ip is a VIP"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"redhat_cluster_services_ip_info[*].ip_ip_address"}" & @CRLF & _
" get_attr {"computer_system.managementIP"}" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "isVIP"" & @CRLF & _
" "yes"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Fail Pattern If VIP Address Is Discovered"" & @CRLF & _
" comment = "We are not discovering a VIPs of the services." & @CRLF & _
"" & @CRLF & _
"In case the discovered server is a VIP, we will stop the discovery."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = match {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isVIP"}" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" terminate_op = terminate" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Collect nodes information from clustat -x command output"" & @CRLF & _
" comment = "Collect nodes information from clustat -x command output." & @CRLF & _
"" & @CRLF & _
"Running the command \"sudo clustat -x\" to collect the current cluster nodes information and status." & @CRLF & _
"" & @CRLF & _
"We are collecting the following data from the node:" & @CRLF & _
"node_name, node_state, node_local, node_estranged, node_rgmanager, node_rgmanager_master, node_qdisk, node_nodeid, cluster_name, cluster_id, cluster_generation"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" get_attr {"sudo"}" & @CRLF & _
" " clustat -x"" & @CRLF & _
" }" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "clustat_nodes_info_table"" & @CRLF & _
" col_names = "node_name","node_state","node_local","node_estranged","node_rgmanager","node_rgmanager_master","node_qdisk","node_nodeid","cluster_name","cluster_id","cluster_generation"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = xml_parsing_strategy {" & @CRLF & _
" rootXpath = "/clustat"" & @CRLF & _
" fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "node_name"" & @CRLF & _
" xpath = "/clustat/nodes/node/@name"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "node_state"" & @CRLF & _
" xpath = "/clustat/nodes/node/@state"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "node_local"" & @CRLF & _
" xpath = "/clustat/nodes/node/@local"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "node_estranged"" & @CRLF & _
" xpath = "/clustat/nodes/node/@estranged"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "node_rgmanager"" & @CRLF & _
" xpath = "/clustat/nodes/node/@rgmanager"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "node_rgmanager_master"" & @CRLF & _
" xpath = "/clustat/nodes/node/@rgmanager_master"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "node_qdisk"" & @CRLF & _
" xpath = "/clustat/nodes/node/@qdisk"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "node_nodeid"" & @CRLF & _
" xpath = "/clustat/nodes/node/@nodeid"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "cluster_name"" & @CRLF & _
" xpath = "/clustat/cluster/@name"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "cluster_id"" & @CRLF & _
" xpath = "/clustat/cluster/@id"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "cluster_generation"" & @CRLF & _
" xpath = "/clustat/cluster/@generation"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Set cluster_id in clustat_nodes_info_table table"" & @CRLF & _
" comment = "Set cluster_id in clustat_nodes_info_table table"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "clustat_nodes_info_table"" & @CRLF & _
" target_table_name = "clustat_nodes_info_table"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "cluster_id"" & @CRLF & _
" value = concat {" & @CRLF & _
" get_attr {"clustat_nodes_info_table[1].cluster_name"}" & @CRLF & _
" "_"" & @CRLF & _
" get_attr {"clustat_nodes_info_table[1].cluster_id"}" & @CRLF & _
" }" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Collect services information from clustat -x command output"" & @CRLF & _
" comment = "Collect services information from clustat -x command output" & @CRLF & _
"" & @CRLF & _
"Running the command \"sudo clustat -x\" to collect the current cluster services information and status."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" get_attr {"sudo"}" & @CRLF & _
" " clustat -x"" & @CRLF & _
" }" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "clustat_services_info_table"" & @CRLF & _
" col_names = "service_name","service_state","service_state_str","service_flags","service_owner","service_last_owner","service_restarts","service_last_transition","service_last_transition_str"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = xml_parsing_strategy {" & @CRLF & _
" rootXpath = "/clustat"" & @CRLF & _
" fields {" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_name"" & @CRLF & _
" xpath = "/clustat/groups/group/@name"" & @CRLF & _
" delimiters = ":"" & @CRLF & _
" position = 2" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_state"" & @CRLF & _
" xpath = "/clustat/groups/group/@state"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_state_str"" & @CRLF & _
" xpath = "/clustat/groups/group/@state_str"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_flags"" & @CRLF & _
" xpath = "/clustat/groups/group/@flags"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_owner"" & @CRLF & _
" xpath = "/clustat/groups/group/@owner"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_last_owner"" & @CRLF & _
" xpath = "/clustat/groups/group/@last_owner"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_restarts"" & @CRLF & _
" xpath = "/clustat/groups/group/@restarts"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_last_transition"" & @CRLF & _
" xpath = "/clustat/groups/group/@last_transition"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "service_last_transition_str"" & @CRLF & _
" xpath = "/clustat/groups/group/@last_transition_str"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" field {" & @CRLF & _
" col_name = "forEach"" & @CRLF & _
" for_each = "forEach"" & @CRLF & _
" delimiters = """ & @CRLF & _
" position = 1" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge cluster_conf_all_services and clustat_services_info_table tables"" & @CRLF & _
" comment = "Merge tables $clustat_services_info_table and $cluster_conf_all_services to cluster_conf_all_services in order to have a table that include the service name and the related resources to the service."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "cluster_conf_all_services"" & @CRLF & _
" table2_name = "clustat_services_info_table"" & @CRLF & _
" result_table_name = "cluster_conf_all_services"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"cluster_conf_all_services[].service"}" & @CRLF & _
" concat {" & @CRLF & _
" "name=\""" & @CRLF & _
" get_attr {"clustat_services_info_table[].service_name"}" & @CRLF & _
" "\""" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge cluster_conf_all_services and resource_table tables"" & @CRLF & _
" comment = "Merge tables $resource_table and $cluster_conf_all_services to cluster_conf_all_services in order to have a table that includes the service name + resource details + on which host they are running."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "cluster_conf_all_services"" & @CRLF & _
" table2_name = "resource_table"" & @CRLF & _
" result_table_name = "cluster_conf_all_services"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"cluster_conf_all_services[].service"}" & @CRLF & _
" concat {" & @CRLF & _
" get_attr {"resource_table[].resource_type"}" & @CRLF & _
" " "" & @CRLF & _
" get_attr {"resource_table[].resource_properties"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Adding the service address to every resource"" & @CRLF & _
" comment = "Script for adding the service ip address to every resource line."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "cluster_conf_all_services"" & @CRLF & _
" target_table_name = "cluster_conf_all_services"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "ip_address_service"" & @CRLF & _
" value = eval {"javascript: var service = ${cluster_conf_all_services[].service};" & @CRLF & _
"var regexp = /ip[\\s+]?addr[ess]?=.\\b(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\\b/g;" & @CRLF & _
"var ip_address = regexp.exec(service); " & @CRLF & _
"var rtrn =''; " & @CRLF & _
"" & @CRLF & _
"rtrn = ip_address[1];" & @CRLF & _
""}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Transform hostname to IP address"" & @CRLF & _
" comment = "Transform hostname to IP address." & @CRLF & _
"" & @CRLF & _
"The script is searching for the node_name record in the /etc/hosts file of the server and save the ip address of this server to the node_ip_address table attribute."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "clustat_nodes_info_table"" & @CRLF & _
" target_table_name = "clustat_nodes_info_table"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "node_ip_address"" & @CRLF & _
" value = eval {"if (${clustat_nodes_info_table[].node_qdisk} == \"0\") {" & @CRLF & _
"def full_line= com.snc.sw.commands.SshCommand.getSSHProvider(ctx).execCommand(\"cat /etc/hosts |grep \"+${clustat_nodes_info_table[].node_name} );" & @CRLF & _
"return full_line.split()[0];" & @CRLF & _
"} else {" & @CRLF & _
"return \"\";" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Adding cluster name to the cluster_conf_all_services table"" & @CRLF & _
" comment = "Adding cluster name to the cluster_conf_all_services table." & @CRLF & _
"In the resouce_name we are converting the VIP IP address to it's FQDN."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "cluster_conf_all_services"" & @CRLF & _
" target_table_name = "cluster_conf_all_services"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "resource_name"" & @CRLF & _
" value = eval {"javascript: " & @CRLF & _
"" & @CRLF & _
"try{" & @CRLF & _
"" & @CRLF & _
" var rtrn='';" & @CRLF & _
" var str='';" & @CRLF & _
" var ip = CTX.getAttribute(\"cluster_conf_all_services[].ip_address_service\");" & @CRLF & _
" var resource_type=CTX.getAttribute(\"cluster_conf_all_services[].resource_type\");" & @CRLF & _
" var name=CTX.getAttribute(\"cluster_conf_all_services[].resource_name\");" & @CRLF & _
"" & @CRLF & _
" if (resource_type == \"ip\")" & @CRLF & _
" {" & @CRLF & _
" var run_command =\"nslookup \"+ip+\"| egrep 'name' | awk '{print $4}' | sort | head -1\";" & @CRLF & _
" str=CTX.getCommandManager().shellCommand(run_command, false, null, null, CTX);" & @CRLF & _
" str=str.slice(0, -1);" & @CRLF & _
" rtrn = str;" & @CRLF & _
" rtrn;" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" {" & @CRLF & _
" rtrn=name;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
"}" & @CRLF & _
"catch(e){" & @CRLF & _
"var rtrn =e;" & @CRLF & _
"rtrn;" & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cluster_name"" & @CRLF & _
" value = get_attr {"cluster_name_nodes_multicast[1].cluster_name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse /etc/hosts"" & @CRLF & _
" comment = "Steps 7.1.33-7.1.41 are created in order to be able to do step " & @CRLF & _
"" & @CRLF & _
"\"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\"." & @CRLF & _
"" & @CRLF & _
"Since we are discovering a cluster node and the IP address that we are running the discovery can be different from the cluster node, we want to make sure that the cluster node and the current server that we are discovering are the same server for creating the \"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\" step."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = parse_text_file_to_var {" & @CRLF & _
" file_path = get_files_by_filter {" & @CRLF & _
" expression = "/etc/hosts"" & @CRLF & _
" foreach_attribute_name = "forEach"" & @CRLF & _
" }" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "etc_hosts"" & @CRLF & _
" col_names = "ip_etc","hostname_etc"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "(\\d+\\.\\d+\\.\\d+\\.\\d+).*\\s+(.*)"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get ifconfig command to string"" & @CRLF & _
" comment = "Steps 7.1.33-7.1.41 are created in order to be able to do step " & @CRLF & _
"" & @CRLF & _
"\"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\"." & @CRLF & _
"" & @CRLF & _
"Since we are discovering a cluster node and the IP address that we are running the discovery can be different from the cluster node, we want to make sure that the cluster node and the current server that we are discovering are the same server for creating the \"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\" step."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"use_net_tools"}" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ifconfig | grep 'inet addr:' |awk '{print $1, $2 }'"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "ifconfig_res"" & @CRLF & _
" col_names = "string"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "xxxxxxxxxxxx"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Failover Get ifconfig command to string"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"use_net_tools"}" & @CRLF & _
" "false"" & @CRLF & _
" }" & @CRLF & _
" is_empty {get_attr {"ifconfig_res"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ifconfig | grep 'inet ' |awk '{print $1, $2 }'"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "ifconfig_res"" & @CRLF & _
" col_names = "string"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" line_seperator = "xxxxxxxxxxxx"" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get ip addr command to string"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osType"}" & @CRLF & _
" "LINUX"" & @CRLF & _
" }" & @CRLF & _
" is_empty {get_attr {"ifconfig_res"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "ip addr | grep 'inet ' |awk '{print $1, $2 }'"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "ifconfig_res"" & @CRLF & _
" col_names = "string"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" delimiters = "/"" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse hostname -s command"" & @CRLF & _
" comment = "Steps 7.1.33-7.1.41 are created in order to be able to do step " & @CRLF & _
"" & @CRLF & _
"\"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\"." & @CRLF & _
"" & @CRLF & _
"Since we are discovering a cluster node and the IP address that we are running the discovery can be different from the cluster node, we want to make sure that the cluster node and the current server that we are discovering are the same server for creating the \"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\" step."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "hostname -s"" & @CRLF & _
" var_names = "short_hostname"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse hostname -f command"" & @CRLF & _
" comment = "Steps 7.1.33-7.1.41 are created in order to be able to do step " & @CRLF & _
"" & @CRLF & _
"\"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\"." & @CRLF & _
"" & @CRLF & _
"Since we are discovering a cluster node and the IP address that we are running the discovery can be different from the cluster node, we want to make sure that the cluster node and the current server that we are discovering are the same server for creating the \"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\" step."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = "hostname -f"" & @CRLF & _
" var_names = "long_hostname"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter etc_host table to current hostname"" & @CRLF & _
" comment = "Steps 7.1.33-7.1.41 are created in order to be able to do step " & @CRLF & _
"" & @CRLF & _
"\"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\"." & @CRLF & _
"" & @CRLF & _
"Since we are discovering a cluster node and the IP address that we are running the discovery can be different from the cluster node, we want to make sure that the cluster node and the current server that we are discovering are the same server for creating the \"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\" step."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "etc_hosts"" & @CRLF & _
" target_table_name = "local_hosts"" & @CRLF & _
" condition = starts_with {" & @CRLF & _
" get_attr {"short_hostname"}" & @CRLF & _
" get_attr {"etc_hosts[].hostname_etc"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge local_hosts and ifconfig_res tables"" & @CRLF & _
" comment = "Steps 7.1.33-7.1.41 are created in order to be able to do step " & @CRLF & _
"" & @CRLF & _
"\"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\"." & @CRLF & _
"" & @CRLF & _
"Since we are discovering a cluster node and the IP address that we are running the discovery can be different from the cluster node, we want to make sure that the cluster node and the current server that we are discovering are the same server for creating the \"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\" step."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "local_hosts"" & @CRLF & _
" table2_name = "ifconfig_res"" & @CRLF & _
" result_table_name = "local_hosts"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = any {" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"ifconfig_res[].string"}" & @CRLF & _
" concat {" & @CRLF & _
" "inet addr:"" & @CRLF & _
" get_attr {"local_hosts[].ip_etc"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"ifconfig_res[].string"}" & @CRLF & _
" concat {" & @CRLF & _
" "inet "" & @CRLF & _
" get_attr {"local_hosts[].ip_etc"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter etc_hosts table to local_hosts"" & @CRLF & _
" comment = "Steps 7.1.33-7.1.41 are created in order to be able to do step " & @CRLF & _
"" & @CRLF & _
"\"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\"." & @CRLF & _
"" & @CRLF & _
"Since we are discovering a cluster node and the IP address that we are running the discovery can be different from the cluster node, we want to make sure that the cluster node and the current server that we are discovering are the same server for creating the \"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\" step."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "etc_hosts"" & @CRLF & _
" target_table_name = "etc_hosts"" & @CRLF & _
" condition = neq {" & @CRLF & _
" get_attr {"etc_hosts[].ip_etc"}" & @CRLF & _
" get_attr {"local_hosts[1].ip_etc"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Adding the long name format to the local_host table"" & @CRLF & _
" comment = "Steps 7.1.33-7.1.41 are created in order to be able to do step " & @CRLF & _
"" & @CRLF & _
"\"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\"." & @CRLF & _
"" & @CRLF & _
"Since we are discovering a cluster node and the IP address that we are running the discovery can be different from the cluster node, we want to make sure that the cluster node and the current server that we are discovering are the same server for creating the \"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\" step."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "local_hosts"" & @CRLF & _
" target_table_name = "local_hosts"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "long_hostname"" & @CRLF & _
" value = get_attr {"long_hostname"}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Merge local_hosts and clustat_nodes_info_table tables"" & @CRLF & _
" comment = "Merge clustat_nodes_info_table and local_hosts table, so we will know if the ip exist in the table." & @CRLF & _
"" & @CRLF & _
"We are using Condition with \"Keep\" in order to keep all the cluster " & @CRLF & _
" nodes in the table even if they are not in the same host that we are running the discovery." & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"Steps 7.1.33-7.1.41 are created in order to be able to do step " & @CRLF & _
"" & @CRLF & _
"\"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\"." & @CRLF & _
"" & @CRLF & _
"Since we are discovering a cluster node and the IP address that we are running the discovery can be different from the cluster node, we want to make sure that the cluster node and the current server that we are discovering are the same server for creating the \"Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server\" step."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = merge {" & @CRLF & _
" table1_name = "local_hosts"" & @CRLF & _
" table2_name = "clustat_nodes_info_table"" & @CRLF & _
" result_table_name = "clustat_nodes_info_table"" & @CRLF & _
" unmatched_lines = keep" & @CRLF & _
" condition = contains {" & @CRLF & _
" get_attr {"local_hosts[].string"}" & @CRLF & _
" get_attr {"clustat_nodes_info_table[].node_ip_address"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert clusters nodes data to cmdb_ci_unix_cluster_node"" & @CRLF & _
" comment = "Insert clusters nodes data to cmdb_ci_unix_cluster_node"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "clustat_nodes_info_table"" & @CRLF & _
" target_table_name = "cmdb_ci_unix_cluster_node"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"clustat_nodes_info_table[].node_name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "node_state"" & @CRLF & _
" value = get_attr {"clustat_nodes_info_table[].node_state"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"clustat_nodes_info_table[].node_ip_address"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "node_status"" & @CRLF & _
" value = eval {"javascript: " & @CRLF & _
"" & @CRLF & _
"var state = ${clustat_nodes_info_table[*].node_state};" & @CRLF & _
"state = state.toArray();" & @CRLF & _
"var rtrn='';" & @CRLF & _
"var node_status=\"Offline\";" & @CRLF & _
"" & @CRLF & _
"for (var i = 0; i < state.length; i++)" & @CRLF & _
"{" & @CRLF & _
" if (state[i] == \"1\")" & @CRLF & _
" { " & @CRLF & _
" node_status=\"Online\";" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"rtrn=node_status;"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate cmdb_ci_unix_cluster_node"" & @CRLF & _
" comment = "Remove duplicate cmdb_ci_unix_cluster_node"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript: var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${cmdb_ci_unix_cluster_node},\"name\");" & @CRLF & _
"CTX.setAttribute(\"cmdb_ci_unix_cluster_node\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert clusters vips data to cmdb_ci_cluster_vip"" & @CRLF & _
" comment = "Insert clusters vips data to cmdb_ci_cluster_vip"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "cluster_conf_all_services"" & @CRLF & _
" target_table_name = "cmdb_ci_cluster_vip"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"cluster_conf_all_services[].resource_name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"cluster_conf_all_services[].resource_ip_address"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cluster_id"" & @CRLF & _
" value = get_attr {"clustat_nodes_info_table[1].cluster_id"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter cmdb_ci_cluster_vip to include ip_address only"" & @CRLF & _
" comment = "Filter cmdb_ci_cluster_vip to include ip_address only."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = filter {" & @CRLF & _
" src_table_name = "cmdb_ci_cluster_vip"" & @CRLF & _
" target_table_name = "cmdb_ci_cluster_vip"" & @CRLF & _
" condition = is_not_empty {get_attr {"cmdb_ci_cluster_vip[].ip_address"}}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate cmdb_ci_cluster_vip"" & @CRLF & _
" comment = "Remove duplicate cmdb_ci_cluster_vip"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${cmdb_ci_cluster_vip},\"ip_address\");" & @CRLF & _
"CTX.setAttribute(\"cmdb_ci_cluster_vip\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert cluster data to cmdb_ci_unix_cluster"" & @CRLF & _
" comment = "Insert cluster data to cmdb_ci_unix_cluster"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "cluster_name_nodes_multicast"" & @CRLF & _
" target_table_name = "cmdb_ci_unix_cluster"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"cluster_name_nodes_multicast[1].cluster_name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cluster_status"" & @CRLF & _
" value = eval {"javascript: " & @CRLF & _
"" & @CRLF & _
"var state = ${clustat_nodes_info_table[*].node_state};" & @CRLF & _
"state = state.toArray();" & @CRLF & _
"var rtrn='';" & @CRLF & _
"var cluster_status=\"Offline\";" & @CRLF & _
"" & @CRLF & _
"for (var i = 0; i < state.length; i++)" & @CRLF & _
"{" & @CRLF & _
" if (state[i] == \"1\")" & @CRLF & _
" { " & @CRLF & _
" cluster_status=\"Online\";" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"rtrn=cluster_status;"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"cluster_name_nodes_multicast[1].multicast_addr"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "short_description"" & @CRLF & _
" value = "Linux Red Hat Cluster"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cluster_type"" & @CRLF & _
" value = "Linux Red Hat Cluster"" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cluster_version"" & @CRLF & _
" value = get_attr {"red_hat_cluster_version"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cluster_id"" & @CRLF & _
" value = get_attr {"clustat_nodes_info_table[1].cluster_id"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate cmdb_ci_unix_cluster"" & @CRLF & _
" comment = "Remove duplicate cmdb_ci_unix_cluster"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript:" & @CRLF & _
"var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${cmdb_ci_unix_cluster},\"name\");" & @CRLF & _
"CTX.setAttribute(\"cmdb_ci_unix_cluster\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert clusters resources data to cmdb_ci_unix_cluster_resource"" & @CRLF & _
" comment = "Insert clusters resources data to cmdb_ci_unix_cluster_resource" & @CRLF & _
"" & @CRLF & _
"The properties attribute is manipulate to remove \"/\" from the end of the line if exist." & @CRLF & _
"" & @CRLF & _
"The resource_status attribute is manipulate to transform the resource state from number to string \"Online\" or \"Offline\"."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = transform {" & @CRLF & _
" src_table_name = "cluster_conf_all_services"" & @CRLF & _
" target_table_name = "cmdb_ci_unix_cluster_resource"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "name"" & @CRLF & _
" value = get_attr {"cluster_conf_all_services[].resource_name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "resource_type"" & @CRLF & _
" value = get_attr {"cluster_conf_all_services[].type"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "properties"" & @CRLF & _
" value = eval {"javascript: " & @CRLF & _
"" & @CRLF & _
"var prop = ${cluster_conf_all_services[].resource_properties};" & @CRLF & _
"var rtrn='';" & @CRLF & _
"" & @CRLF & _
"if (prop.charAt(prop.length - 1) == '/') {" & @CRLF & _
" rtrn = prop.substr(0, prop.length - 1);" & @CRLF & _
"}" & @CRLF & _
"else" & @CRLF & _
"{" & @CRLF & _
" rtrn=prop;" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "resource_status"" & @CRLF & _
" value = eval {"javascript:" & @CRLF & _
" var state = ${cluster_conf_all_services[*].service_state};" & @CRLF & _
"state = state.toArray();" & @CRLF & _
"var rtrn='';" & @CRLF & _
"var resource_status=\"Offline\";" & @CRLF & _
"" & @CRLF & _
"for (var i = 0; i < state.length; i++)" & @CRLF & _
"{" & @CRLF & _
" if (state[i] == \"112\")" & @CRLF & _
" { " & @CRLF & _
" resource_status=\"Online\";" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"rtrn=resource_status;"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "ip_address"" & @CRLF & _
" value = get_attr {"cluster_conf_all_services[].ip_address_service"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cluster_id"" & @CRLF & _
" value = get_attr {"clustat_nodes_info_table[1].cluster_id"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Remove duplicate cmdb_ci_unix_cluster_resource"" & @CRLF & _
" comment = "Remove duplicate cmdb_ci_unix_cluster_resource"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript: var tableWithoutDuplicates = '';" & @CRLF & _
"tableWithoutDuplicates = DuplicateRemover.removeDuplicates(${cmdb_ci_unix_cluster_resource},\"name\");" & @CRLF & _
"CTX.setAttribute(\"cmdb_ci_unix_cluster_resource\", tableWithoutDuplicates);" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Reference and relation between cmdb_ci_cluster_vip to cmdb_ci_unix_cluster"" & @CRLF & _
" comment = "Creating Reference and relation between cmdb_ci_cluster_vip to cmdb_ci_unix_cluster"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_unix_cluster"" & @CRLF & _
" table2_name = "cmdb_ci_cluster_vip"" & @CRLF & _
" result_table_name = "cluster_vip_unix_cluster"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_cluster_vip[].cluster_name"}" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster[].cluster_name"}" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_cluster_vip[].cluster_id"}" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster[].cluster_id"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Virtualized by::Virtualizes"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "cluster"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Reference and relation between cmdb_ci_cluster_vip to cmdb_ci_unix_cluster_node"" & @CRLF & _
" comment = "Creating Reference and relation between cmdb_ci_cluster_vip to cmdb_ci_unix_cluster_node."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_cluster_vip"" & @CRLF & _
" table2_name = "cmdb_ci_unix_cluster_node"" & @CRLF & _
" result_table_name = "cluster_vip_cluster_node"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_cluster_vip[].cluster_name"}" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_node[].cluster_name"}" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_cluster_vip[].cluster_id"}" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_node[].cluster_id"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Uses::Used by"" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "node"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_cluster"" & @CRLF & _
" comment = "Creating Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_cluster."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_unix_cluster_node"" & @CRLF & _
" key1_name = "cluster_id"" & @CRLF & _
" table2_name = "cmdb_ci_unix_cluster"" & @CRLF & _
" key2_name = "cluster_id"" & @CRLF & _
" result_table_name = "cluster_node_unix_cluster"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" relation_type = "Cluster of::Cluster"" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "cluster"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Reference and relation between cmdb_ci_unix_cluster_resource to cmdb_ci_unix_cluster"" & @CRLF & _
" comment = "Creating Reference and relation between cmdb_ci_unix_cluster_resource to cmdb_ci_unix_cluster."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_unix_cluster_resource"" & @CRLF & _
" table2_name = "cmdb_ci_unix_cluster"" & @CRLF & _
" result_table_name = "cluster_resource_unix_cluster"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_resource[].cluster_name"}" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster[].cluster_name"}" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_resource[].cluster_id"}" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster[].cluster_id"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Defines resources for::Gets resources from"" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "cluster"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Relation between cmdb_ci_unix_cluster_resource to cmdb_ci_unix_cluster_node"" & @CRLF & _
" comment = "Creating Relation between cmdb_ci_unix_cluster_resource to cmdb_ci_unix_cluster_node."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_unix_cluster_resource"" & @CRLF & _
" table2_name = "cmdb_ci_unix_cluster_node"" & @CRLF & _
" result_table_name = "cluster_resource_unix_cluster_node"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_resource[].service_owner"}" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_node[].node_name"}" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_resource[].cluster_id"}" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_node[].cluster_id"}" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_resource[].cluster_name"}" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_node[].cluster_name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Defines resources for::Gets resources from"" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = """ & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_linux_server"" & @CRLF & _
" comment = "Creating Reference and relation between cmdb_ci_unix_cluster_node to cmdb_ci_unix_server."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" is_not_empty {get_attr {"cmdb_ci_unix_cluster_node"}}" & @CRLF & _
" is_not_empty {get_attr {"cmdb_ci_linux_server"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_unix_cluster_node"" & @CRLF & _
" table2_name = "cmdb_ci_linux_server"" & @CRLF & _
" result_table_name = "cluster_node_unix_server"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = any {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_node[].long_hostname"}" & @CRLF & _
" get_attr {"cmdb_ci_linux_server[].name"}" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_node[].hostname_etc"}" & @CRLF & _
" get_attr {"cmdb_ci_linux_server[].name"}" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"cmdb_ci_unix_cluster_node[].node_name"}" & @CRLF & _
" get_attr {"cmdb_ci_linux_server[].name"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Hosted on::Hosts"" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = "server"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Relation between cmdb_ci_unix_cluster to cmdb_ci_linux_server"" & @CRLF & _
" comment = "Creating Relation between cmdb_ci_unix_cluster to cmdb_ci_linux_server."" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"isCluster"}" & @CRLF & _
" "true"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"cluster_conf"}}" & @CRLF & _
" is_not_empty {get_attr {"clustat_nodes_info_table"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_unix_cluster"" & @CRLF & _
" table2_name = "cmdb_ci_linux_server"" & @CRLF & _
" result_table_name = "cluster_unix_server"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = is_not_empty {get_attr {"cmdb_ci_unix_cluster[].cluster_name"}}" & @CRLF & _
" relation_type = "Hosted on::Hosts"" & @CRLF & _
" ref_direction = parentToChild" & @CRLF & _
" ref_field_name = """ & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = " ________End of Linux Red Hat Cluster________"" & @CRLF & _
" comment = "This step is for label only to mention that we finished the Linux Red Hat Cluster library."" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "2"" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "blq"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>admin</sys_created_by>" & @CRLF & _
"<sys_created_on>2018-01-08 08:02:52</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>c4eabd514fe3c3c0a9f9011f0310c730</sys_id>" & @CRLF & _
"<sys_mod_count>52</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Red Hat Cluster</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_c4eabd514fe3c3c0a9f9011f0310c730</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2020-10-09 05:36:19</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>dbd4fd0813677e00d4013192e144b0b8</metadata_id>" & @CRLF & _
"<name>populate label from service name - Windows and Linux</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "populate label from service name - Windows and Linux"" & @CRLF & _
" id = "dbd4fd0813677e00d4013192e144b0b8"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "get windows service name by tasklist command"" & @CRLF & _
" comment = "get windows service name by tasklist command."" & @CRLF & _
" if {" & @CRLF & _
" condition = eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "WINDOWS"" & @CRLF & _
" }" & @CRLF & _
" on_true = runcmd_to_var {" & @CRLF & _
" cmd = concat {" & @CRLF & _
" "tasklist /svc /fi \" pid eq "" & @CRLF & _
" get_attr {"pid_info[1].pid"}" & @CRLF & _
" "\" | findstr "" & @CRLF & _
" get_attr {"pid_info[1].pid"}" & @CRLF & _
" }" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "services"" & @CRLF & _
" col_names = "service_name"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "\\S+\\s+\\S*(.*\\S)"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "populate label from service name - Windows"" & @CRLF & _
" comment = "populate label from service name - Windows"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_not_empty {get_attr {"services[1].service_name"}}" & @CRLF & _
" neq {" & @CRLF & _
" get_attr {"services[1].service_name"}" & @CRLF & _
" "N/A"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "Windows"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "name"" & @CRLF & _
" get_attr {"services[1].service_name"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "populate label from request queue name - Windows"" & @CRLF & _
" comment = "populate label from request queue name - Windows"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "Windows"" & @CRLF & _
" }" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"services[1].service_name"}" & @CRLF & _
" "N/A"" & @CRLF & _
" }" & @CRLF & _
" is_not_empty {get_attr {"request_queue_name"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "name"" & @CRLF & _
" get_attr {"request_queue_name"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "populate label from service name - Linux"" & @CRLF & _
" comment = "populate label from service name - Linux"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_not_empty {get_attr {"linux_service_name"}}" & @CRLF & _
" eq {" & @CRLF & _
" get_attr {"computer_system.osFamily"}" & @CRLF & _
" "UNIX"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "name"" & @CRLF & _
" get_attr {"linux_service_name"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>bary.solomon</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-06-19 14:13:02</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>dbd4fd0813677e00d4013192e144b0b8</sys_id>" & @CRLF & _
"<sys_mod_count>7</sys_mod_count>" & @CRLF & _
"<sys_name>populate label from service name - Windows and Linux</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_dbd4fd0813677e00d4013192e144b0b8</sys_update_name>" & @CRLF & _
"<sys_updated_by>bary.solomon</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2017-06-28 11:09:39</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>dc334fe39f2032001d753758442e70b7</metadata_id>" & @CRLF & _
"<name>Linux - Memory Modules</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Memory Modules"" & @CRLF & _
" id = "dc334fe39f2032001d753758442e70b7"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "Get memory modules"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "sudo dmidecode -t 17 | cat"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "mem_mod"" & @CRLF & _
" col_names = "Mod"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "^(.*)"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "translate GB to MB"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "mem_mod"" & @CRLF & _
" target_table_name = "mem_mod"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "Mod"" & @CRLF & _
" value = eval {"str = \"\"" & @CRLF & _
"if (${mem_mod[].Mod}.startsWith('Size:') && ${mem_mod[].Mod}.endsWith('GB'))" & @CRLF & _
"{" & @CRLF & _
"str = ${mem_mod[].Mod}.split(' ')[1]" & @CRLF & _
"str = str.toInteger()" & @CRLF & _
"str = str * 1024" & @CRLF & _
"return \"Size: \"+str+\" MB\"" & @CRLF & _
"}" & @CRLF & _
"else " & @CRLF & _
"{return ${mem_mod[].Mod}}"}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter modules"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "mem_mod"" & @CRLF & _
" target_table_name = "mem_mod"" & @CRLF & _
" condition = any {" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Total Width"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Data Width"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Size"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Form Factor"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Locator"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Bank Locator"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Type"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Speed"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Serial Number"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "Part Number"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter DMI"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "mem_mod"" & @CRLF & _
" target_table_name = "mem_mod"" & @CRLF & _
" condition = not_contains {" & @CRLF & _
" get_attr {"mem_mod[].Mod"}" & @CRLF & _
" "DMI"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Create new modules table"" & @CRLF & _
" union {" & @CRLF & _
" table1_name = "MModules"" & @CRLF & _
" table2_name = "MModules"" & @CRLF & _
" result_table_name = "MModules"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Fill modules table"" & @CRLF & _
" if {" & @CRLF & _
" condition = is_not_empty {get_attr {"mem_mod"}}" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "dump_var"" & @CRLF & _
" eval {"javascript: rtrun = function() {" & @CRLF & _
"" & @CRLF & _
"rtrn = \"\";" & @CRLF & _
"var table = ${mem_mod};" & @CRLF & _
"if (table.size() == 0 )" & @CRLF & _
" return;" & @CRLF & _
" " & @CRLF & _
"var rowed = table.get(0);" & @CRLF & _
"var row = rowed.clone();" & @CRLF & _
"for (var i = 0; i < table.size(); i++) " & @CRLF & _
"{" & @CRLF & _
" var map = table.get(i);" & @CRLF & _
" var str = map.get(\"Mod\");" & @CRLF & _
" var parts = str.split(\":\");" & @CRLF & _
" var name = parts[0].trim();" & @CRLF & _
" var value = parts[1].trim();" & @CRLF & _
" if (name == \"Total Width\")" & @CRLF & _
" {" & @CRLF & _
" row.remove(\"Mod\");" & @CRLF & _
" row.put(\"total_width\",value.split(\" \")[0]);" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Data Width\")" & @CRLF & _
" {" & @CRLF & _
" row.put(\"data_width\",value.split(\" \")[0]);" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Size\")" & @CRLF & _
" {" & @CRLF & _
" row.put(\"capacity\",((value == \"No Module Installed\") ? null : value.split(\" \")[0]));" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Form Factor\")" & @CRLF & _
" {" & @CRLF & _
" row.put(\"form_factor\",(value.startsWith(\"FB-\")) ? value.split(\"-\")[1] : value);" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Locator\")" & @CRLF & _
" {" & @CRLF & _
" row.put(\"device_locator\",value);" & @CRLF & _
" row.put(\"name\",value);" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Bank Locator\")" & @CRLF & _
" {" & @CRLF & _
" row.put(\"bank_label\",((value == \"Not Specified\") ? null : value));" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Type\")" & @CRLF & _
" {" & @CRLF & _
" row.put(\"type\",value.split(\" \")[0]);" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Type Detail\")" & @CRLF & _
" {" & @CRLF & _
" row.put(\"type_detail\",value);" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Speed\")" & @CRLF & _
" { " & @CRLF & _
" row.put(\"speed\",((value == \"Unknown\") ? null : value.split(\" \")[0]));" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Serial Number\")" & @CRLF & _
" {" & @CRLF & _
" row.put(\"serial_number\",value);" & @CRLF & _
" }" & @CRLF & _
" if (name == \"Part Number\")" & @CRLF & _
" {" & @CRLF & _
" row.put(\"part_number\",value);" & @CRLF & _
" ${MModules}.add(row);" & @CRLF & _
" row = rowed.clone();" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"rtrn = row;" & @CRLF & _
" " & @CRLF & _
"return rtrn;" & @CRLF & _
"}();"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter modules"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "MModules"" & @CRLF & _
" target_table_name = "MModules"" & @CRLF & _
" condition = is_not_empty {get_attr {"MModules[].capacity"}}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update cmdb_ci_memory_module"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "MModules"" & @CRLF & _
" target_table_name = "cmdb_ci_memory_module"" & @CRLF & _
" operation {set_field {" & @CRLF & _
" field_name = "total_width"" & @CRLF & _
" value = get_attr {"MModules[].total_width"}" & @CRLF & _
" }}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Ref/Rel between cmdb_ci_memory_module and Linux CI"" & @CRLF & _
" relation_reference {" & @CRLF & _
" table1_name = "cmdb_ci_linux_server"" & @CRLF & _
" table2_name = "cmdb_ci_memory_module"" & @CRLF & _
" result_table_name = "mem_to_linux"" & @CRLF & _
" unmatched_lines = remove" & @CRLF & _
" condition = eq {" & @CRLF & _
" "1"" & @CRLF & _
" "1"" & @CRLF & _
" }" & @CRLF & _
" relation_type = "Contains::Contained by"" & @CRLF & _
" ref_direction = childToParent" & @CRLF & _
" ref_field_name = "cmdb_ci"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>admin</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:45:37</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>dc334fe39f2032001d753758442e70b7</sys_id>" & @CRLF & _
"<sys_mod_count>5</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Memory Modules</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_dc334fe39f2032001d753758442e70b7</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2019-11-06 12:21:26</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>e69343279f2032001d753758442e7067</metadata_id>" & @CRLF & _
"<name>Linux - CPU</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - CPU"" & @CRLF & _
" id = "e69343279f2032001d753758442e7067"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "Get CPU info"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "cat /proc/cpuinfo"" & @CRLF & _
" var_names = table {" & @CRLF & _
" name = "cpu_info"" & @CRLF & _
" col_names = "cpu_data"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "^(.*)"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get flags data"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "grep hypervisor /proc/cpuinfo "" & @CRLF & _
" var_names = "hasHyper"" & @CRLF & _
" parsing_strategy = regex_parsing {regex = ".*(hypervisor)"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Check if is virtual"" & @CRLF & _
" set_attr {" & @CRLF & _
" "isVirtual"" & @CRLF & _
" eval {"javascript: rtrn =\"\";" & @CRLF & _
"var isReal = ${hasHyper};" & @CRLF & _
"if (isReal)" & @CRLF & _
"{" & @CRLF & _
" rtrn = true;" & @CRLF & _
"}" & @CRLF & _
"else" & @CRLF & _
"{" & @CRLF & _
" rtrn = false;" & @CRLF & _
"}" & @CRLF & _
""}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Filter CPU data"" & @CRLF & _
" filter {" & @CRLF & _
" src_table_name = "cpu_info"" & @CRLF & _
" target_table_name = "cpu_info"" & @CRLF & _
" condition = any {" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"cpu_info[].cpu_data"}" & @CRLF & _
" "processor"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"cpu_info[].cpu_data"}" & @CRLF & _
" "cpu MHz"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"cpu_info[].cpu_data"}" & @CRLF & _
" "physical id"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"cpu_info[].cpu_data"}" & @CRLF & _
" "core id"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"cpu_info[].cpu_data"}" & @CRLF & _
" "cpu cores"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"cpu_info[].cpu_data"}" & @CRLF & _
" "model name"" & @CRLF & _
" }" & @CRLF & _
" contains {" & @CRLF & _
" get_attr {"cpu_info[].cpu_data"}" & @CRLF & _
" "vendor_id"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Get thread core"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "lscpu"" & @CRLF & _
" var_names = "thread_core"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" include_lines_pattern = "Thread"" & @CRLF & _
" delimiters = " "" & @CRLF & _
" selected_positions = 4" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Parse CPU data"" & @CRLF & _
" set_attr {" & @CRLF & _
" "cpu_data"" & @CRLF & _
" eval {"javascript: rtrn = \"\";" & @CRLF & _
"var table = ${cpu_info};" & @CRLF & _
"var physicalIds = {}; " & @CRLF & _
"physicalIds.count = 0;" & @CRLF & _
"var coreIds = {};" & @CRLF & _
"coreIds.count = 0;" & @CRLF & _
"var cpu_cores = 0;" & @CRLF & _
"var physical_id_in_curr_block = '';" & @CRLF & _
"var result = {};" & @CRLF & _
"var processors = 0;" & @CRLF & _
"var threadCore = ${thread_core};" & @CRLF & _
"for (var i = 0; i < table.size(); i++) " & @CRLF & _
"{ " & @CRLF & _
" var map = table.get(i);" & @CRLF & _
" var str = map.get(\"cpu_data\");" & @CRLF & _
" var parts = str.split(\":\");" & @CRLF & _
" if (parts.length < 2)" & @CRLF & _
" {" & @CRLF & _
" continue;" & @CRLF & _
" }" & @CRLF & _
" var name = parts[0].trim(); " & @CRLF & _
" var value = parts[1].trim();" & @CRLF & _
" if (name == \"processor\")" & @CRLF & _
" {" & @CRLF & _
" processors++;" & @CRLF & _
" }" & @CRLF & _
" if (name == \"cpu MHz\") " & @CRLF & _
" {" & @CRLF & _
" var cpu_speed = parseInt(value);" & @CRLF & _
" result.cpu_speed = (cpu_speed != Number.NaN ? cpu_speed : \"\");" & @CRLF & _
" }" & @CRLF & _
" if (name == \"physical id\") " & @CRLF & _
" {" & @CRLF & _
" physical_id_in_curr_block = value;" & @CRLF & _
" if (!physicalIds[value]) " & @CRLF & _
" {" & @CRLF & _
" physicalIds[value] = true;" & @CRLF & _
" physicalIds.count++;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if (name == \"core id\" && !coreIds[physical_id_in_curr_block + '.' + value]) " & @CRLF & _
" {" & @CRLF & _
" coreIds[physical_id_in_curr_block + '.' + value] = true;" & @CRLF & _
" coreIds.count++;" & @CRLF & _
" }" & @CRLF & _
" if (name == \"cpu cores\")" & @CRLF & _
" {" & @CRLF & _
" cpu_cores = parseInt(value);" & @CRLF & _
" }" & @CRLF & _
" if (name == \"model name\")" & @CRLF & _
" {" & @CRLF & _
" result.cpu_name = value;" & @CRLF & _
" }" & @CRLF & _
" if (name == \"vendor_id\")" & @CRLF & _
" {" & @CRLF & _
" result.cpu_vendor = value;" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"var cpuCount = 1;" & @CRLF & _
"if (physicalIds.count > 0) " & @CRLF & _
"{" & @CRLF & _
" cpuCount = physicalIds.count;" & @CRLF & _
" result.hasPhysicalId = true;" & @CRLF & _
" } " & @CRLF & _
" else{" & @CRLF & _
" cpuCount = processors;" & @CRLF & _
" result.hasPhysicalId = false;" & @CRLF & _
" }" & @CRLF & _
"result.cpu_count = cpuCount;" & @CRLF & _
"var cpuCoreCount = 1;" & @CRLF & _
"if (coreIds.count > 0 || cpu_cores > 0) " & @CRLF & _
"{" & @CRLF & _
" if (cpu_cores > coreIds.count)" & @CRLF & _
" { " & @CRLF & _
" cpuCoreCount = cpu_cores;" & @CRLF & _
" }" & @CRLF & _
" else" & @CRLF & _
" { " & @CRLF & _
" cpuCoreCount = coreIds.count / cpuCount;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"result.cpu_core_count = cpuCoreCount;" & @CRLF & _
"if (${isVirtual} == true && !JSUtil.toBoolean(result.hasPhysicalId)) " & @CRLF & _
"{" & @CRLF & _
"result.cpu_core_count = result.cpu_count;" & @CRLF & _
"result.cpu_count = 1;" & @CRLF & _
"}" & @CRLF & _
"if(threadCore != null){" & @CRLF & _
" result.cpu_core_thread = parseInt(threadCore);" & @CRLF & _
"}" & @CRLF & _
"result.processors = processors;" & @CRLF & _
"rtrn = JSON.stringify(result);"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract CPU data"" & @CRLF & _
" parse_var_to_var {" & @CRLF & _
" from_var_name = "cpu_data"" & @CRLF & _
" to_var_names = table {" & @CRLF & _
" name = "cpu_parsed"" & @CRLF & _
" col_names = "cpu_vendor","cpu_name","cpu_speed","hasPhysical","cpu_count","cpu_core_count","cpu_core_thread","processors"" & @CRLF & _
" }" & @CRLF & _
" parsing_strategy = regex_parsing {regex = "\"cpu_vendor\":\"(.*?)\",\"cpu_name\":\"(.*?)\",\"cpu_speed\":(.*?),\"hasPhysicalId\":(.*?),\"cpu_count\":(\\d+),\"cpu_core_count\":(\\d+),\"cpu_core_thread\":(\\d+),\"processors\":(\\d+)"}" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Insert CPU data to cmdb_ci_linux_server"" & @CRLF & _
" transform {" & @CRLF & _
" src_table_name = "cmdb_ci_linux_server"" & @CRLF & _
" target_table_name = "cmdb_ci_linux_server"" & @CRLF & _
" operation {" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cpu_speed"" & @CRLF & _
" value = get_attr {"cpu_parsed[1].cpu_speed"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cpu_name"" & @CRLF & _
" value = get_attr {"cpu_parsed[1].cpu_name"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cpu_count"" & @CRLF & _
" value = get_attr {"cpu_parsed[1].cpu_count"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cpu_core_count"" & @CRLF & _
" value = get_attr {"cpu_parsed[1].cpu_core_count"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cpu_core_thread"" & @CRLF & _
" value = get_attr {"cpu_parsed[1].cpu_core_thread"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cpu_manufacturer"" & @CRLF & _
" value = get_attr {"cpu_parsed[1].cpu_vendor"}" & @CRLF & _
" }" & @CRLF & _
" set_field {" & @CRLF & _
" field_name = "cpu_type"" & @CRLF & _
" value = get_attr {"cpu_parsed[1].cpu_vendor"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>oron.subayi</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:47:25</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>e69343279f2032001d753758442e7067</sys_id>" & @CRLF & _
"<sys_mod_count>2</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - CPU</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_e69343279f2032001d753758442e7067</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2020-06-21 20:41:03</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<sa_pattern action="INSERT_OR_UPDATE">" & @CRLF & _
"<active>true</active>" & @CRLF & _
"<ci_type>cmdb_ci_appl_generic</ci_type>" & @CRLF & _
"<cpattern_type>2</cpattern_type>" & @CRLF & _
"<description/>" & @CRLF & _
"<directory>false</directory>" & @CRLF & _
"<enforce_proc_classy>false</enforce_proc_classy>" & @CRLF & _
"<has_draft>false</has_draft>" & @CRLF & _
"<invoke_per_account>false</invoke_per_account>" & @CRLF & _
"<metadata_id>fe32c7e39f2032001d753758442e7065</metadata_id>" & @CRLF & _
"<name>Linux - Distribution</name>" & @CRLF & _
"<ndl>library {" & @CRLF & _
" name = "Linux - Distribution"" & @CRLF & _
" id = "fe32c7e39f2032001d753758442e7065"" & @CRLF & _
" description = "null"" & @CRLF & _
" step {" & @CRLF & _
" name = "Get distribution"" & @CRLF & _
" runcmd_to_var {" & @CRLF & _
" cmd = "cat /etc/*release | grep -v ID_LIKE"" & @CRLF & _
" var_names = "release_output"" & @CRLF & _
" parsing_strategy = delimited_parsing {" & @CRLF & _
" selected_positions = 1" & @CRLF & _
" }" & @CRLF & _
" if_not_found_do = nop {}" & @CRLF & _
" cache_flag = 0" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract OS distribution"" & @CRLF & _
" set_attr {" & @CRLF & _
" "os_distribution"" & @CRLF & _
" eval {"javascript: var rtrn = \"\";" & @CRLF & _
"var rel = ${release_output};" & @CRLF & _
"var relStr = rel.toString();" & @CRLF & _
"var lowercaseOutput = relStr.toLowerCase();" & @CRLF & _
"if (lowercaseOutput.indexOf('oracle linux server') != -1) " & @CRLF & _
"{ " & @CRLF & _
" rtrn = \"Oracle Linux 4/5/6 (64-bit)\";" & @CRLF & _
"}" & @CRLF & _
"else if (lowercaseOutput.indexOf('red hat') != -1) " & @CRLF & _
"{ " & @CRLF & _
" rtrn = \"Linux Red Hat\";" & @CRLF & _
"}" & @CRLF & _
"else if (lowercaseOutput.indexOf('fedora') != -1) " & @CRLF & _
"{ " & @CRLF & _
" rtrn = \"Linux Fedora\";" & @CRLF & _
"}" & @CRLF & _
"else if (lowercaseOutput.indexOf('suse') != -1) " & @CRLF & _
"{ " & @CRLF & _
" rtrn = \"Linux SuSE\";" & @CRLF & _
"}" & @CRLF & _
"else if (lowercaseOutput.indexOf('centos') != -1)" & @CRLF & _
"{ " & @CRLF & _
" rtrn = \"Linux CentOS\";" & @CRLF & _
"}" & @CRLF & _
"else if (lowercaseOutput.indexOf('ubuntu') != -1) " & @CRLF & _
"{ " & @CRLF & _
" rtrn = \"Linux Ubuntu\";" & @CRLF & _
"} " & @CRLF & _
"else " & @CRLF & _
"{ " & @CRLF & _
" rtrn = \"GNU/Linux\"; " & @CRLF & _
"}"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Extract distribution version"" & @CRLF & _
" set_attr {" & @CRLF & _
" "os_version"" & @CRLF & _
" eval {"javascript: var rtrn = \"\";" & @CRLF & _
"var rel = ${release_output};" & @CRLF & _
"var relStr = rel.toString();" & @CRLF & _
"var lowercaseOutput = relStr.toLowerCase();" & @CRLF & _
"var versionMatch = null;" & @CRLF & _
"if (lowercaseOutput.indexOf('red hat') != -1) { " & @CRLF & _
" versionMatch = /release ([0-9\\.]+)/.exec(lowercaseOutput.substring(lowercaseOutput.indexOf('red hat')));" & @CRLF & _
"}" & @CRLF & _
"else if (lowercaseOutput.indexOf('fedora') != -1) {" & @CRLF & _
"versionMatch = /release ([0-9\\.]+)/.exec(lowercaseOutput.substring(lowercaseOutput.indexOf('fedora')));" & @CRLF & _
"}" & @CRLF & _
"else if (lowercaseOutput.indexOf('suse') != -1) {" & @CRLF & _
"versionMatch = /version ?= ?([0-9\\.]+)/.exec(lowercaseOutput.substring(lowercaseOutput.indexOf('suse')));" & @CRLF & _
"}" & @CRLF & _
"else if (lowercaseOutput.indexOf('centos') != -1) {" & @CRLF & _
"versionMatch = /release ([0-9\\.]+)/.exec(lowercaseOutput.substring(lowercaseOutput.indexOf('centos')));" & @CRLF & _
"}" & @CRLF & _
"else if (lowercaseOutput.indexOf('ubuntu') != -1) {" & @CRLF & _
"versionMatch = /version=\"([0-9\\.]+)/.exec(lowercaseOutput.substring(lowercaseOutput.indexOf('ubuntu')));" & @CRLF & _
"}" & @CRLF & _
"if (versionMatch != null)" & @CRLF & _
" rtrn = versionMatch[1];"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update OS on Linux CI"" & @CRLF & _
" set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].os"" & @CRLF & _
" get_attr {"os_distribution"}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" step {" & @CRLF & _
" name = "Update OS version on Linux CI"" & @CRLF & _
" if {" & @CRLF & _
" condition = all {" & @CRLF & _
" is_not_empty {get_attr {"os_version"}}" & @CRLF & _
" is_not_empty {get_attr {"cmdb_ci_linux_server[1].os_version"}}" & @CRLF & _
" }" & @CRLF & _
" on_true = set_attr {" & @CRLF & _
" "cmdb_ci_linux_server[*].os_version"" & @CRLF & _
" get_attr {"os_version"}" & @CRLF & _
" }" & @CRLF & _
" on_false = nop {}" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"</ndl>" & @CRLF & _
"<parent display_value=""/>" & @CRLF & _
"<serverless>false</serverless>" & @CRLF & _
"<source/>" & @CRLF & _
"<sync_to_mid>true</sync_to_mid>" & @CRLF & _
"<sys_class_name>sa_pattern</sys_class_name>" & @CRLF & _
"<sys_created_by>oron.subayi</sys_created_by>" & @CRLF & _
"<sys_created_on>2017-02-01 13:41:25</sys_created_on>" & @CRLF & _
"<sys_customer_update>false</sys_customer_update>" & @CRLF & _
"<sys_domain>global</sys_domain>" & @CRLF & _
"<sys_domain_path>/</sys_domain_path>" & @CRLF & _
"<sys_id>fe32c7e39f2032001d753758442e7065</sys_id>" & @CRLF & _
"<sys_mod_count>5</sys_mod_count>" & @CRLF & _
"<sys_name>Linux - Distribution</sys_name>" & @CRLF & _
"<sys_overrides display_value=""/>" & @CRLF & _
"<sys_package display_value="Pattern Designer" source="com.snc.pattern.designer">79c934314f310300261de57d0210c70c</sys_package>" & @CRLF & _
"<sys_policy/>" & @CRLF & _
"<sys_replace display_value=""/>" & @CRLF & _
"<sys_replace_on_upgrade>false</sys_replace_on_upgrade>" & @CRLF & _
"<sys_scope display_value="Global">global</sys_scope>" & @CRLF & _
"<sys_update_name>sa_pattern_fe32c7e39f2032001d753758442e7065</sys_update_name>" & @CRLF & _
"<sys_updated_by>admin</sys_updated_by>" & @CRLF & _
"<sys_updated_on>2020-04-09 07:36:54</sys_updated_on>" & @CRLF & _
"<version/>" & @CRLF & _
"</sa_pattern>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"</unload>" & @CRLF & _
""
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm