

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi,
In OBM, is it possible to add a node to multiple groups using opr-node command
Sridhara.
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
yes. you just need to execute it several times, for each group one run. 🙂
you can use a loop for this. Bash is your friend


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
yes. you just need to execute it several times, for each group one run. 🙂
you can use a loop for this. Bash is your friend


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Yeah, that is how we handle it. We automate it via a script. In our case we are on Windows. I first create an input file with the each line containing the node and a separator (pipe | in our case) then the list of its node groups that node should belong to separated by a different separator (colon in our case) , then the script loops each line of the file and parses/splits with pipe separator to get the node FQDN into variable and the list of node groups for that node into a string. For each node it loops through the node groups list and assigns the node to the node groups via opr-node command. See my example below.
Example of one input file line:
<actualFQDNofNodeHere>|NodeGrp1:NodeGrp2:NodeGrp3
Example Batch script:
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
cd "<drive>:\<path_to_dir_where inputfile_and_script_reside>"
for /f "tokens=1,2* delims=| " %%a in (<inputfilenamehere>) do (
set FQDN=%%a
echo.
echo FQDN is !FQDN!
set NGLIST=%%b
echo !FQDN! NG List is !NGLIST!
REM the line below replaces the colon delimiter with a comma which is the default delimiter so the following for loop will iterate the unknown number of items in the list using a comma as a delimiter by default
set NGLIST=!NGLIST::=,!
for %%g in (!NGLIST!) do (
set NG=%%g
echo.
echo adding node !FQDN! to Node Group !NG!
cmd /c opr-node -modify_node -node_name "!FQDN!" -node_group !NG! -parent_node_group <parent_nodegroup_name_here> -username <username> -password <pwd>-ssl
)
)
exit /b 0