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
AIX Replacing a failed disk (rootvg)
Viewed 8545 times since Tue, Jul 17, 2018
Create volume groups on AIX - Normal Big Scalable
Viewed 6692 times since Thu, Feb 21, 2019
Useful AIX commands
Viewed 9502 times since Sun, Jun 17, 2018
Part 2, Detailed diagnosis and troubleshooting
Viewed 2789 times since Tue, May 22, 2018
How to Configure Sendmail not to Look up MX records
Viewed 3589 times since Fri, Apr 19, 2019
Altering LVM Configuration When a Disk is Not in ODM Anymore
Viewed 3035 times since Mon, Jun 3, 2019
This document discusses a new feature implemented for JFS2 filesystems to prevent simultaneous mounting.
Viewed 2791 times since Sat, Jun 1, 2019
How to mirror the rootvg in AIX?
Viewed 5027 times since Mon, May 21, 2018
Oslevel shows wrong AIX’s level. Why
Viewed 4703 times since Thu, Feb 21, 2019
AIX Reviewing AIX Error and Boot Logs
Viewed 2778 times since Wed, Mar 20, 2019