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

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
Getting bosboot errors, don’t reboot just yet
Viewed 2831 times since Tue, Apr 16, 2019
Undocumented AIX command lquerypv
Viewed 3587 times since Mon, Jul 16, 2018
Rootvg Mirroring in AIX
Viewed 2682 times since Mon, May 21, 2018
Configure log file for cron daemon on AIX
Viewed 10521 times since Thu, Feb 21, 2019
SNAP in AIX
Viewed 11490 times since Mon, Sep 17, 2018
Many Choices for AIX File Integrity
Viewed 2660 times since Wed, May 30, 2018
NMON nmon
Viewed 11836 times since Tue, Apr 16, 2019
Tips I Picked up at the Power Systems Technical University
Viewed 2771 times since Mon, Jun 11, 2018
AIX Booting
Viewed 10251 times since Tue, Apr 16, 2019
AIX, Red Hat, Security, System Admin↑ System-wide separated shell history files for each user and session
Viewed 2214 times since Fri, Apr 19, 2019