Script to reset NIM state and deallocate resources


Sometimes we need to reset the state of a lpar on our NIM server. You can use smitty, but it’s simpler to use a shell script.
First, we check the which NIM resources our LPAR has inside NIM:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@nim] lsnim -l lpar1
lpar1:
   class          = machines
   type           = standalone
   current_master = nim
   connect        = nimsh (secure)
   sync_required  = yes
   platform       = chrp
   netboot_kernel = mp
   if1            = ent-Network9 lpar1 0
   cable_type1    = N/A
   Cstate         = BOS installation has been enabled
   prev_state     = ready for a NIM operation
   Mstate         = currently running
   lpp_source     = LPP_INS_AIX61
   spot           = spotimagen_aix6
   cpuid          = 000U040AD401
   control        = master

As you can see, lpar1 has two resources, one lpp_source and a spot resource.
Now. it’s time for this script (resetaix.ksh):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/ksh
# Copyright (C) 2012 Israel Garcia iga3725 @ yahoo.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
# You need to add parameter $1 as the name of the lpar (machine resource) to the script:
#
# Check machine resource exist on NIM:
lsnim -c machines|grep "$1" 1>/dev/null
if [[ $? -eq 0 ]] ; then
   echo
    else
       echo "ERROR: $1 machine resource does not exists on NIM." && exit 1
fi
#
nim -Fo reset $1
nim -Fo deallocate -a subclass=all $1

Check again machine resources:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@nim:/usr/local/bin] lsnim -l lpar1
lpar1:
   class          = machines
   type           = standalone
   current_master = nim
   connect        = nimsh (secure)
   sync_required  = yes
   platform       = chrp
   netboot_kernel = mp
   if1            = ent-Network9 lpar1 0
   cable_type1    = N/A
   Cstate         = ready for a NIM operation
   prev_state     = BOS installation has been enabled
   Mstate         = currently running
   cpuid          = 000E050AD400
   Cstate_result  = reset

Just thanks if the post was helpful



Article Number: 515
Posted: Thu, Feb 21, 2019 8:13 PM
Last Updated: Thu, Feb 21, 2019 8:13 PM

Online URL: http://kb.ictbanking.net/article.php?id=515