Monday, December 22, 2008

Don't Go Away Mad...

Ok, it has been a little while since the last post, but hey, I don't create magic that often (never if you ask my wife).

One of the things we were dealing with is an automated flow that deleted our Virtual Machines. This is a good thing if you want the VM's gone but in our case we kind of wanted them there but they kept getting deleted. Needless to say this was NOT a good thing. I was able to come up with a solution. We modified the delete script to a rename script.

Here is how it works....

The script was using "rm vm_name" and with a little trial and error I came up with...



mv vm_name vm_name.`date +"%Y%m%d"`_`date +"%H%m"`

Now that seems complex but it moves (hence the mv command" from the vm_name directory to vm_name.yearmonthday_hourminute .. for example a VM named vm01 decomissioned on December 19th at 11:15 am would be...

vm01.20081219_1115

Now it it would still be resident on the disk but it would show when it was decomissioned. This will help if you want to keep VM's around for 30 days or so before deleting them.

Also some other steps were not covered.. the vmware-cmd was used for all the shutdown and unregistering of the VM's..

Hope this helps somone..

No comments: