ESXi

Back on vCenter in my home lab

Oh yeah; anyone else have the warm fuzzy feeling right now; Hashtags: #‎VMware‬ ‪#‎vCenter‬ ‪#‎ESXi‬

 

All in my home lab. Once again I have the management capabilities over systems that I prefer. VMware vCenter 6 is awesome and I am in love with the web interface

Next — Storage upgrade 3.0. That will be 16TB of usable RAID10 storage


There will be NFS, iSCSI and DLNA, and SAMBA

Power Off & On VMware Guest with a Scheduled Task

 

Using Windows task scheduler you can schedule power off and on events for guest systems running in VMware vCenter or a standalone ESXi host.

My steps:

  1. Create a basic task – give it a name and description (optional)
  2. Choose when you want this task to stat
  3. Select the start date and time
  4. Choose “Start a program”
  5. Choose the program you would like to run.  In this setup we will be running the following:
  6. C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NonInteractive -File “C:\work\task\jermsmit.ps1”

     
  7. Click Next, Select Yes when Task Scheduler prompts you
  8. On the Finish screen, click Finish  – You can open properties to set this to run unattended

 

The script I am now using does the following:

  1. Loads the VMware PowerCli modules to powershell
  2. Connects to Specified ESXi or vCenter Server
  3. Issues a stop to specific VM Guests
  4. Issues a start to the VM Guest

Script Example:

 

Use cases:

  1. Powering systems down to conserve energy (earth day initiative)
  2. Allow for systems with large workloads to have full system resources without contention during scheduled down periods of the systems that are offline.
  3. Quick restore of nonpersistant environments

 

Thanks for visiting – jermal

VMware vSphere PowerCLI – Power Off & On Guests

Looking for a method to restart a non-persistent environment in ESXi or vCenter, I was able to use PowerCLI to issue the commands needed. Originally I was looking to automate the recovery of a snapshot when it dawned on me that a non-persistent disk would facilitate the same thing.  However I would need to power off the server and back on again for it to work.

And this is what came from my searching and trial and error

Powering Off

Powering On

Both – Power Off wait then Power On

Next was to use a batch file to run a task to execute the PowerCLI commands. This was done by doing the following set as a scheduled task

 Thanks Hristo for your help

Quest to automate snapshots in ESXi

I am looking for a way to run a instance and have it revert back to its snapshot every 24 hours. I started toying around with the idea to use the vim-cmd features however there doesn’t seem to be a way to set a task for this.

So far here are the steps I used

Looked up the ID of the VM in question by running:

vim-cmd vmsvc/getallvms

View your VM’s snapshot tree by passing its ID to this command (this example uses the VM with ID 50):

vim-cmd vmsvc/get.snapshotinfo 80

And issues the command to revert the snapshot

vim-cmd vmsvc/snapshot.revert VM_ID 0 SNAPSHOT_ID suppressPowerOff

 

The output looks something like this in my testing

This works and now all I need is to somehow automate and schedule this.

Unmount local ISO before making it an OVF Template

So you have made an awesome system in VMware ESXi and exported it an OVF Template. Later to find that something has gone very wrong and the template will not import and gives you the following error

If you have encountered this it means that your Template was originally created with a ISO image still attached to the device .

By this point you may be thinking that the template is broken. Don’t  worry yet, you still have a chance to fix this and move forward.

One method is to use the OFV Tools from VMware to extract and repackage your OVA Template, or you can use the method I have used (more than once) and turn to our two open source friends; 7-Zip and Notepad++

Here are the steps I normal take to tackle this problem 

Step 1 –  is to extract your ova template (after all its only a zip)

You will notice 3 files once extracted

*.vmdk – is your disk containing all your data

*.ovf  – is the configuration (also the file that we will edit)

*.mf  – is a manifest containing a reference to the vmdk and ovf, also holding a SHA1 hash which ESXi will check for validation.  This file needs to be deleted as we are making a change to the ovf and this will surely break that hash.

Example of what the contents of the .mf file looks like:

SHA1(template.ovf)= 908e804f140ffa58083b8bd154dace330b440c78
SHA1(template-disk1.vmdk)= 29c2d44d908d0207005360dabb58967f01a13c2e

Step 2 – open the *.ovf file with Notepad++ and search for vmware.cdrom.iso

You will notice that this is contained in a blog which looks like this:

Example – just in-case you can see the screenshot above

<Item ovf:required=”false”>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:ElementName>CD/DVD drive 1</rasd:ElementName>
<rasd:InstanceID>8</rasd:InstanceID>
<rasd:Parent>4</rasd:Parent>
<rasd:ResourceSubType>vmware.cdrom.iso</rasd:ResourceSubType>
<rasd:ResourceType>15</rasd:ResourceType>
</Item>

Remove those lines and save the *.ovf file

Step 3 – Delete the file with the *.mf extension. If this exists ESXi will attempt to validate and throw an error about the templates integrity being invalid

So once this has been deleted you can deploy your OVF Template

I hope these steps help someone  and I am giving a twitter to twitter shout-out to Jonathan Frappier @jfrappier who followed me and one of his posts titled “ProTip – don’t forget to unmount local ISO from your VM before turning it into a template” inspired me to do this little write up.

Thanks