Mass editing vmx files to include uuid.action
jibbajabba
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
I am trying to find a way to mass do this using 'find' and 'exec'.
Something like
But I can't seem to find a way to use the echo command and find / exec.
Anyone got an idea ...
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
Comments
-
tiersten Member Posts: 4,505Write a small shell script that does it and then make find execute that.
-
MentholMoose 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 -
astorrs Member Posts: 3,139 ■■■■■■□□□□Shouldn't uuid.action = "move" really be uuid.action = "keep" ?
-
jibbajabba Member Posts: 4,317 ■■■■■■■■□□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 -
jibbajabba Member Posts: 4,317 ■■■■■■■■□□MentholMoose wrote: »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 - cheersMy own knowledge base made public: http://open902.com -
astorrs Member Posts: 3,139 ■■■■■■□□□□Yes and no .. it is fine if you never touch the VM anymore but it might cause issues when cloning at a later date ...
VMX File Parameters -
jibbajabba Member Posts: 4,317 ■■■■■■■■□□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 -
MentholMoose Member Posts: 1,525 ■■■■■■■■□□lol - feel kinda stupid now ... you are of course right .. now I need a mass "sed" script *snigger* ....
# 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 -
jibbajabba Member Posts: 4,317 ■■■■■■■■□□MentholMoose wrote: »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
Thanks anyway for your continues help - much appreciated ...My own knowledge base made public: http://open902.com