Please login or register. May 20, 2018, 09:33:29 AM

Author Topic: lsnim sorting question  (Read 14241 times)

0 Members and 1 Guest are viewing this topic.

pgymjp

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
lsnim sorting question
« on: January 27, 2013, 11:02:58 PM »
How does the lsnim command sort its output? I went through and renamed my lpp_source resources to a standardized naming convention and ran an lsnim command, but my output was not sorted. NOTE: yes, I know I can pipe the output to the sort command, but that doesn't fully address my question. The byproduct problem is that SMIT NIM menus also spit out this unsorted list. I'm going to have a long list of resources by the time I'm done standardizing things and I'd like to understand how lsnim sorts its stuff. I want nicely sorted lists in alphabetical order, whether it's the CLI or SMIT being used.

Michael

  • Administrator
  • Hero Member
  • *****
  • Posts: 1075
  • Karma: +0/-0
Re: lsnim sorting question
« Reply #1 on: January 29, 2013, 06:14:04 AM »
I'll have to do a bit of research on this.

nim stores it's information in ODM files, and from your question, it does not sound like the underlying odmget commands are based on a sorted "-q name=..." syntax.

If there is any sort it may be on a numerical sort, but as I wait for my nim server to boot, I am guessing it is just the order of the ODM objects from an unsorted odmget query.

Hope this helps your understanding, even though I do not think it solves your request.

Michael

  • Administrator
  • Hero Member
  • *****
  • Posts: 1075
  • Karma: +0/-0
Re: lsnim sorting question
« Reply #2 on: January 29, 2013, 07:02:14 AM »
As I suspected, at least as far as I can tell :) -- the order is dependent on order of creation.

Code: [Select]
root@x106:[/]cd $ODMDIR

root@x106:[/etc/objrepos]ls *nim*
nim_attr       nim_object     nim_pdattr
nim_attr.vc    nim_object.vc  nim_pdattr.vc

root@x106:[/etc/objrepos]lsnim | head -5
master               machines        master
boot                 resources       boot
nim_script           resources       nim_script
n129                 networks        ent
lpp_6106             resources       lpp_source

root@x106:[/etc/objrepos]odmget nim_object | grep name | head -5
        name = "master"
        name = "boot"
        name = "nim_script"
        name = "n129"
        name = "lpp_6106"

The order of the names from the lsnim output is the same as the "name" entries in the nim_object database.

Now - what you can do!

First backup the nimdatabase (saves the ODM files in a text format I believe)

    odmget nim_object >nim_object.sorted
    use an editor to sort the objects in the order you want them
    use odmdelete to rem

ove all the objects, and then odmadd to put them back in the order you want.

It is a lot of "work" and the moment you add a new object your sort order may be broken.

Hope this answers your question - and helps!

pgymjp

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
Re: lsnim sorting question
« Reply #3 on: January 31, 2013, 02:54:22 AM »
Thank you for such a detailed reply. I should've figured ODM was involved. Since the sort would be broken the minute a new resource is added to the list, there doesn't seem to be much sense in messing with the ODM just to get a nice sort.

Thank you again!

Michael

  • Administrator
  • Hero Member
  • *****
  • Posts: 1075
  • Karma: +0/-0
Re: lsnim sorting question
« Reply #4 on: January 31, 2013, 08:46:01 AM »
 ;) Your welcome - Keep the questions coming!