Where I work, we use VMware to virtualize the majority of our servers. Last year, we bought four new servers in order to provide more resources to our virtual evironment, and also to aid in the upgrade to vSphere 4 from VI3. The plan was to power off all virtual machines and perform an offline migration of all the VMs from the old cluster to the new cluster. However, we were also migrating from the vSwitch to the distributed virtual switch (dvSwitch).

The Setup:
To start out, I upgraded VMware vCenter Server to version 4.x. After that was done, I created a new cluster and added all four new hosts to it. I then mapped all of the same LUNs to the new cluster that were already mapped to the old cluster. This allowed me to do a migration from the old cluster to the new without having to worry about storage migrations. Next, I created the new dvSwitch with all the same port groups as the old vSwitch. It was important to make sure all VLAN IDs were present. Finally, I powered off all virtual machines.

The Code
Now for the interesting part. I wrote a PowerShell script to automate the migration of the VMs from the old cluster to the new. At the same time, it looks at the vSwitches and maps them to their equivalent dvSwitch port group by looking for matching VLALN IDs. For example, if there is a vSwitch port group called “Monkey” with VLAN ID of 123, it will check the dvSwitch port groups and map that to whichever one also has VLAN ID 123.

# Generate a hash of dvSwitch port group VLAN IDs and names, using ID as key.
function CreateDVMap() {
        $vlanmap = @{}
        $pgs = Get-VIew -ViewType DistributedVirtualPortgroup
        foreach ($pg in $pgs) {
                $vlan = $pg.Config.DefaultPortConfig.vlan.vlanid

                if ($vlan -and !$vlanmap.ContainsKey($vlan)) {
                        $vlanmap.Add($vlan, $pg.name)
                }
        }
        return $vlanmap
}
function MigrateVM($vm, $target, $dvMap) {
        # Is the virtual machine in the "Test Dev" resource pool?
        $resPool = Get-ResourcePool -VM $vm
        if ($resPool -and $resPool.Name.CompareTo("Test Dev") -eq 0) {
                $TestDev = $true
        } else {
                $TestDev = $false
        }

        $newnetnames = @()
        Write-Host "Migrating VM", $vm.Name

        # Translate the vSwitch PG of each NIC to the equivalent dvSwitch PG
        foreach ($nic in $vm.NetworkAdapters) {
                Write-Host $nic.name -ForegroundColor Blue
                Write-Host $nic.NetworkName -ForegroundColor Green
                $vlanid = (Get-VirtualPortGroup -Name $nic.NetworkName -VMHost $vm.Host).VlanId
                Write-Host "VLAN ID is" $vlanid
                $newnetnames += $dvMap.get_item($vlanid)
        }

        $newvm = Move-VM -VM $vm -Destination $target

        if ($TestDev) {
                # If it is a Test/Dev VM, move it to the new resource pool
                $rp = Get-ResourcePool -Location $newvm.host.parent -Name "Test Dev"
                $newvm = Move-VM -vm $newvm -Destination $rp
        }

        # Now, set all the NICs to their new dvSwitch port group
        $i = 0
        foreach ($nic in $newvm.NetworkAdapters) {
                Set-NetworkAdapter -NetworkAdapter $nic -NetworkName $newnetnames[$i++] -Confirm:$false
        }
}
# Connect to the vCenter Server
$vihost = Connect-VIServer "vCenter-Server-Hostname"

# Target host in the new cluster to deposit all VMs on
$targetHost = Get-VMHost "Some-Hostname-Here"

# Generate a hash of all dvSwitch PGs
$vlanmap = CreateDVMap

# Get a list of all VMs in "Production cluster
$vmlist = Get-VM -Location (Get-Cluster "Production") | Where { $_.PowerState -eq "PoweredOff" } | Select "Name"

# Iterate through the VMs and migrate them
foreach ($vmname in $vmlist) {
        $vm = Get-VM $vmname.name
        MigrateVM $vm $targetHost $vlanmap
}
Disconnect-VIServer $vihost -Confirm:$false
 

Up until last week, this website was run on a generic shared hosting account. For the most part, this worked well. At times, it could be slow. I went through all kinds of trouble to tune WordPress as much as I could to make it respond faster. Unfortunately, a lot of the slowness was in the shared MySQL server that they provided. I had them move me between servers a few times, but it never fully resolved the issues.

Despite the slowness problems, there were other things I was missing by using a shared hosting provider. For one, I was very limited in the amount of tweaking  I could do. This is partly because of the ban on background processes, but also because I didn’t have administrative access. This meant I couldn’t try different web servers, PHP modules, change MySQL cache configurations, and all that good stuff. You know, all that stuff that normal people don’t care about as long as stuff works.

Well, I’ve now made the jump to a virtual server hosted by Linode! Linode provides a virtual server in the cloud running Linux. They leverage the Xen hypervisor to do this, and you can run pretty much any Linux distribution you want.

So far, my Linode server has these specs:

  • 512MB RAM
  • 20GB storage
  • 200GB transfer/month
  • Debian GNU/Linux 6 (64-bit)
So far, I’ve transferred both my and my wife’s websites to the new server. Even better, I’m experimenting with a different web server other than the standard Apache. This site is currently being served by Lighttpd leveraging PHP via FastCGI.
If you are interested in trying out Linode for yourself, I’d appreciate it if you used my referral code: de5e9915427e40f9bae981e58ba9b5ca2c3cee69
 

This evening, I was staying late at work. I decided to go grab a bag of chips from the vending machine. I punched in the code to see what the price was for my chips, since I couldn’t see it behind the glass. Instead of showing the price on the LCD, I heard a plunk noise. My chips were free?!

Thinking that the last guy just probably put in a $1 and walked away, I typed a random code. Plunk! I got some Ruffles. Now I figured maybe the last guy put in a $5, so I tried a few more codes. Keep in mind that I have extremely poor eyesight, and I couldn’t see anywhere where it showed how much money was on tab already. Finally, I came to the conclusion that it was totally broken.

Until I could figure out who to notify, I made a sign:

 

One year ago today, I married my wonderful wife Amanda. To celebrate, we are going to The Grey Plume for dinner. As if celebrating our anniversary isn’t enough, we also just finished celebrating her graduation from pharmacy school. My wife is now Dr. Amanda L. Kelly, PharmD.Congratulations!We are all very proud.

 

For a long time now, I’ve been looking for a new content management system for my website. Over the years, I’ve tried all sorts of solutions and never found one that I found to be a satisfying solution. Finally, I think I may have found something I don’t absolutely hate.

In the beginning, there was Geocities. Back in those days, GeoCities websites were broken down into “cities” and addresses. For example, a URL may have looked something like http://www.geocities.com/broadway/1138. My first website was somewhere under /broadway/. I believe I used a GeoCities tool to generate the HTML. Later, for some reason I don’t remember, I relocated to /SiliconValley/. By that point, I had started tinkering with HTML and created my website with some shareware website authoring tool for Windows 3.1, though mainly writing my own HTML. This was back before CSS, kids.

Time passed. I learned Linux. I bought a domain or eight. By this point, I had learned PHP. I created a new website and self-hosted it on my Linux desktop at home.  It used a mixture of HTML and PHP, though it was all within the same file. Eventually, I moved to FreeBSD and the website moved as well. Over time, I added some CSS into the page. I also migrated towards XHTML, I think. This page hung around for quite a while, and was only replace in the last year or two.

Next up, Drupal. I got a web hosting provider to host my website. I deployed on Drupal 6 and tweaked it over time. Drupal is very complicated, so it kept me busy customizing things to my liking. When Drupal 7 was in beta, I migrated over to it and pretty much had to start all over again. While Drupal is highly customizable, it ended up burning me out. It was just too big and unwieldy. So, I experimented with Joomla, concrete5, WordPress, and a pile of other CMSes.

And finally, to the point! After all that experimentation, I have decided to stick with WordPress for now. So, I’ve redone my website for yet another time. This time, WordPress. I am liking it so far, but we’ll see how it goes. If you have any WordPress tips, please send them my way.

© 2011 Sean Kelly Suffusion theme by Sayontan Sinha