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
List AIX File Systems the Easy Way With the lsvgfs Command
Viewed 2282 times since Thu, Sep 20, 2018
Part 1, Network overview - Monitoring the hardware
Viewed 5452 times since Mon, Jun 4, 2018
How To Mirror Your Root Disk On AIX (a.k.a. rootvg)
Viewed 5799 times since Mon, May 21, 2018
HOWTO: Copy a filesystem on AIX
Viewed 2605 times since Mon, May 28, 2018
AIX smtctl The smtctl command controls the enabling and disabling of processor simultaneous multithreading mode.
Viewed 15367 times since Fri, Jan 18, 2019
Mirroring the rootvg Volume Group for AIX 4.1/4.2
Viewed 3237 times since Mon, May 21, 2018
How to set Kernel Parameters in AIX ?
Viewed 15180 times since Tue, Jul 2, 2019
AIX POWERHA/HACMP: Basic commands
Viewed 5579 times since Sat, Jun 2, 2018
Tunneling With SSH to Your Destination
Viewed 4521 times since Wed, May 30, 2018
AIX, Installation, NIM↑ Creating an LPP source and SPOT in NIM
Viewed 15162 times since Fri, Apr 19, 2019
Recently Viewed
NTLMSSP, SPN and AIX CIFS