Options

Mass editing vmx files to include uuid.action

jibbajabbajibbajabba Member Posts: 4,317 ■■■■■■■■□□
It seems that uuid.action cannot be added using setconfig and vmware-cmd

Now using a single command I can add this line into a VMX, for example
echo 'uuid.action = "move"' >> EQL1-Vol1/VM-02/VM-02.vmx 

I am trying to find a way to mass do this using 'find' and 'exec'.

Something like
find . -name '*.vmx' -exec vmware-cmd -s register {} \;
or
find . -name '*.vmx' -exec vmware-cmd '{}' stop hard \;

But I can't seem to find a way to use the echo command and find / exec.

Anyone got an idea ...
My own knowledge base made public: http://open902.com :p

Comments

  • Options
    tierstentiersten Member Posts: 4,505
    Write a small shell script that does it and then make find execute that.
  • Options
    MentholMooseMentholMoose Member Posts: 1,525 ■■■■■■■■□□
    Do you just want to append that line to the VMX files? Do you need to do anything with vmware-cmd? To just append that line to VMX files found by a find you can use a loop.
    # for i in `find . -iname '*.vmx'` ; do echo 'uuid.action = "move"' >> $i ; done
    
    MentholMoose
    MCSA 2003, LFCS, LFCE (expired), VCP6-DCV
  • Options
    astorrsastorrs Member Posts: 3,139 ■■■■■■□□□□
    Shouldn't uuid.action = "move" really be uuid.action = "keep" ?
  • Options
    jibbajabbajibbajabba Member Posts: 4,317 ■■■■■■■■□□
    astorrs wrote: »
    Shouldn't uuid.action = "move" really be uuid.action = "keep" ?

    Yes and no .. it is fine if you never touch the VM anymore but it might cause issues when cloning at a later date ...
    My own knowledge base made public: http://open902.com :p
  • Options
    jibbajabbajibbajabba Member Posts: 4,317 ■■■■■■■■□□
    Do you just want to append that line to the VMX files? Do you need to do anything with vmware-cmd? To just append that line to VMX files found by a find you can use a loop.
    # for i in `find . -iname '*.vmx'` ; do echo 'uuid.action = "move"' >> $i ; done
    

    Score - works like a charm - cheers :D:D
    My own knowledge base made public: http://open902.com :p
  • Options
    MentholMooseMentholMoose Member Posts: 1,525 ■■■■■■■■□□
    Gomjaba wrote: »
    Score - works like a charm - cheers :D:D
    Great!!
    MentholMoose
    MCSA 2003, LFCS, LFCE (expired), VCP6-DCV
  • Options
    astorrsastorrs Member Posts: 3,139 ■■■■■■□□□□
    Gomjaba wrote: »
    Yes and no .. it is fine if you never touch the VM anymore but it might cause issues when cloning at a later date ...
    I think you misunderstood. I meant "move" isn't a valid parameter for uuid.action. The correct parameter (which equals choosing move in the vSphere Client GUI) is "keep".

    VMX File Parameters
  • Options
    jibbajabbajibbajabba Member Posts: 4,317 ■■■■■■■■□□
    astorrs wrote: »
    I think you misunderstood. I meant "move" isn't a valid parameter for uuid.action. The correct parameter (which equals choosing move in the vSphere Client GUI) is "keep".

    VMX File Parameters

    lol - feel kinda stupid now ... you are of course right .. now I need a mass "sed" script *snigger* ....
    My own knowledge base made public: http://open902.com :p
  • Options
    MentholMooseMentholMoose Member Posts: 1,525 ■■■■■■■■□□
    Gomjaba wrote: »
    lol - feel kinda stupid now ... you are of course right .. now I need a mass "sed" script *snigger* ....
    That is more dangerous, but I think the command below will do it. It will backup the original VMX file to *.backup, but make sure the sed installed on the COS supports -i (I don't have a test ESX server available right now, so I'm testing on Fedora 12 with some test files). Also maybe backup the VMX files yourself before continuing. With sed I matched on the entire line so there's less chance of the wrong line being changed.
    # for i in `find . -iname '*.vmx'` ; do sed -e 's/^uuid.action\ =\ \"move\"$/uuid.action\ =\ \"keep\"/g' -i.backup $i; done
    
    To delete the backup files:
    # for i in `find . -iname '*.backup'` ; do rm $i ; done
    
    MentholMoose
    MCSA 2003, LFCS, LFCE (expired), VCP6-DCV
  • Options
    jibbajabbajibbajabba Member Posts: 4,317 ■■■■■■■■□□
    That is more dangerous, but I think the command below will do it. It will backup the original VMX file to *.backup, but make sure the sed installed on the COS supports -i (I don't have a test ESX server available right now, so I'm testing on Fedora 12 with some test files). Also maybe backup the VMX files yourself before continuing. With sed I matched on the entire line so there's less chance of the wrong line being changed.
    # for i in `find . -iname '*.vmx'` ; do sed -e 's/^uuid.action\ =\ \"move\"$/uuid.action\ =\ \"keep\"/g' -i.backup $i; done
    
    To delete the backup files:
    # for i in `find . -iname '*.backup'` ; do rm $i ; done
    

    Ah bless you lol .. I wasn't that serious when I said I have to use sed :P

    I haven't used this in production and I knew I have to reinstall the test cluster anyway which is why I didn't bother :D

    Thanks anyway for your continues help - much appreciated ...
    My own knowledge base made public: http://open902.com :p
Sign In or Register to comment.