My Real-World VCAP Scenario to test scripting

I’ve been racking my brains thinking of a real-life VCAP-esque scenario that would force me to write a PowerCLI script.

I know Josh Andrews offered up “create 100 powered off VMs with a certain config or clones of an existing template” which is good but not something I’d normally do in my role.  Then one came to me.  So here it is

*****Disclaimer.  I have not sat the VCAP-DCA yet so have no visibility of the questions.  This question is based on a real-life scenario from my work but modified a bit.  It’s main purpose is to test/teach you PowerCLI so you get the hang of the main components of a basic vSphere PowerCLI script.  *****


 

Scenario 1

Your company has reviewed storage use and found that a large amount of storage has been taken up by a group of VMs with names starting VMP.
Upon further inspection an engineer identifies that the pagefiles ARE on a separate drive, which is a the secondary virtual disk, but they are using Tier1/Premium storage.
Your storage team identify sufficient space on Tier2 storage and present an empty LUN which is visible to all your hosts.

You need to ensure that page files on the existing VMs are on Tier2 storage.
A new LUN has been presented with identifier naa.6001405df3d2046d4a02d3fe4db20bd5
Use iSCSI01 as the new datastore name and  use host 192.168.88.211 to create the lun from.
All secondary vmdks were created using the default naming convention.
1) Create a datastore on the new LUN
2) Migrate all VMs second virtual disk for the VMP* VMs to the new LUN


This isn’t rocket science and on a small number of VMs you could easily drag and drop in the GUI. But let’s say it’s 100 VMs or 1000.  Then you really want to be getting home some time today!
Breaking down the first step.  We have a host and a device identifier for the lun.  We have a host to create it from and we have a name for the new datastore.  If some of these weren’t given then they could be found using Get-ScsiLun -vmhost 192.168.88.211

new-datastore -vmhost 192.168.88.211 -name iSCSI01 -path “naa.6001405df3d2046d4a02d3fe4db20bd5” -vmfs -FileSystemVersion 5
lunadd0

Our Datastore is created.  You can watch that happen in vSphere client if you like.
lunadd

Now we need to move all the secondary disks.
We know the VMs are all named with the prefix VMP
We know that their secondary disk follows the default naming convention.  e.g. vmname_1.vmdk
We know they need to be moved to Datastore iSCSI01

This snippet stores the name of the Datastore in one variable and then stores the harddisk details for any VMs hard disk where the VMname matches VMP* and the hard disk filename matches *_1*
It then invokes the move hard disk cmdlet to actually relocate the vmdks.

$myDS = get-datastore -Name “iSCSI01”
$myDisk = get-vm | where-object {$_.name -like “VMP*”} | get-harddisk | where-object {$_.filename -like “*_1*”}
move-harddisk -harddisk $mydisk -datastore $myDS

As seen from the command line, I notice I need to add a -Confirm $false to the New-Datastore command to stop the interactive prompt 🙂
lunadd3

And viewed from VI Client

lunadd2

So there we have it.  To make it a standalone runnable script, simply add 2 lines to the top.  One to add the Powershell Snapin for vSphere automation.  Then connect to a vCenter server.

add-pssnapin vmware.vimautomation.core
connect-viserver vc

$newLun = get-scsilun -vmhost 192.168.88.211 | Where-Object {$_.canonicalName -like “naa*”}
new-datastore -vmhost 192.168.88.211 -name iSCSI01 -path “naa.6001405df3d2046d4a02d3fe4db20bd5” -vmfs -FileSystemVersion 5

$myDS = get-datastore -Name “iSCSI01”
$myDisk = get-vm | where-object {$_.name -like “VMP*”} | get-harddisk | where-object {$_.filename -like “*_1*”}
move-harddisk -harddisk $mydisk -datastore $myDS -Confirm $false

I left out the bit where it took me an hour to see the iSCSI Lun because the networking on my virtual hosts went screwy…!  But otherwise it felt like a productive night!

 

Advertisements

Google doesn’t answer Forums/Communities posts…..YOU do!

Have you ever been here?

It happens, but it’s rare.  You might call it a Googlewhack or something similar but it isn’t.  Google, like a library doesn’t creates content, they merely make it easier to find other people’s work.  What’s really happened is you have found a post that the right person hasn’t looked at and answered.  Which is a shame…like an unloved child every question deserves an answer 🙂

 

Maybe that right person is you?  I’ve been contributing to the VMware communities forums recently https://communities.vmware.com/community/vmtn#src=vmw_so_vex_cneal_850 and I’ve found it interesting and satisfying for a number of reasons.

  1. You get to feel clever 🙂
    Rummage around.  No-one’s expecting you to go and buy a Brocade Fibre Switch and FC HBAs just to help another stranger, but there will almost certainly be a question you can answer.  Being able to explain the solution to another’s problem will help you demonstrate to yourself that you have the understanding of the topic.  Be it SRM handling unique UUIDs, how to run a script inside a VM by calling Powercli’s Invoke-Script.
  2. You can try out a solution on your homelab/work-lab set up.
    It may be that you read all about AutoDeploy for your VCP and passed with flying colours, but you’ve never exported a host profile in your life because your particular environment was inherited or maybe you haven’t got Enterprise Plus licenses in your Prod environment.
  3. You might get corrected by someone cleverer.
    I’m not ashamed to admit I answered someone’s query with a definitive “no that’s not possible in vsphere” only to have a guru type user with thousands of posts and solutions under their belt correct me and inform the person that “it is possible using the following method as of version x.y”.
    So free learning for me!
  4. Free Learning
    If you’re revising for an exam or certification then look in the topics you’re struggling on in the forums and by finding the answer for others, particularly as their problems are real-world, you are getting free exam scenarios/questions that you have to work out the answer to!
  5. You get to feel helpful and be part of the solution 🙂
    As I said at the top.  If the forums were just full of questions…they wouldn’t be much use and it wouldn’t matter how well indexed Google had the site.
    It takes someone to devote a little of their time to helping others.

I’m going to start aiming to do 2hrs per week on the forums minimum, 30 minutes here and there soon adds up.  Give it a try, you just might like it!

So think of it as digital altruism in a subject you are knowledgeable or passionate about.  VMware!

(You could become a forum rockstar like these guys https://communities.vmware.com/people?filterID=all&sortKey=all~statusLevelDesc&sortOrder=0&src=vmw_so_vex_cneal_850)

If you have any queries about the forums then contact VMware’s – Corey Romero https://communities.vmware.com/people/Corey_R?view=profile&src=vmw_so_vex_cneal_850

My vSphere HomeLab

Everyone’s got one, and like petrolheads showing off their v8 or GTI here’s my vSphere homelab.

Originally it was just an HP Microserver accessed via a pc running virtualised esxi hosts.

But I needed to upgrade my main PC and I still had a VMWorkstation 10 license from my VCP5 in June to use up.

So I went for a Core i7 4770s.  It’s quad core with HT so 8 threads for VMs to consume.  Currently only 16gb but it was only built in December and now Christmas is out of the way the first thing after January’s payday will be another 16Gb to take it to 32Gb.  I have a 256Gb Samsung Pro SSD in and run Windows 7 Home Premium +VMWorkstation 10.

I already had the SSD/PSU/Blu-Ray Drive so the upgrade for case/Mobo/CPU/Memory cost me around £500 which is a bargain considering I haven’t upgraded my PC for around 5 years and had been running an E6550 with 4Gb Memory.  Future Proofing doesn’t exist but I think I’ll get another 5 years at least out of this (once I add the next 16Gb) so £100/year for a Micro-ATX sized vSphere Lab+PC is good value in my book!

I will probably at some point recommission the HP N36L Microserver which has a puny CPU but has 16Gb too so I could do real, proper vmotions not virtual vmotions over virtually nested vswitches inside VMWorkstation (serious Inception style confusion).  However it doesn’t support Passthrough/Direct I/O so I’m not rushing on that one 🙂

To help understand iSCSI and NFS storage I use my Synology DS212j NAS with 2x1Tb Western Digital HDDs in, running mirrored (well it’s Synology Hybrid RAID, whatever that is 🙂 but with just two drives it behaves like RAID 1 and eats up 50% of your capacity).  I use the NAS for storing all my other personal stuff so it work quite well as a Lab NAS as well as a home NAS without one impacting on the other.  I’d really recommend it for Lab and home/media/backup/dlna use.  They even support VAAI which makes them a great choice for a vSphere lab.

Here it is as a Google Drawing (I don’t have a visio license!) alongside a photo of the kit.

HomeLabIMG_20150103_000850

I’ve been using it for a week or so now in anger as a lab to learn the VCAP-DCA510 objectives on.  I know I need to build/add a server for VUM (don’t really want or need to install it on the DC) and I need to create some more client VMs on the nested ESXi hosts, but for now it’s running fine and with NAT’d networking as I haven’t had chance to “Design” a network for the vSphere layer and isolate is and manage it properly (I’ll do that for the DCD 🙂

My VCAP-DCA exam is on the 15th Jan.  I got the voucher for VCAP-DCA510 in September but got seconded to a very very very very non-technical piece of work so my hands-on skills started to atrophy quickly.  Like many of us I postponed it as I knew the assignment was temporary.  It finished just before Christmas and when I came to reschedule I got a shock because I couldn’t.  Obviously, now, that is because it is being retired at the end of Jan.  So I am cramming in as much practice and focus as I can leading up to that and am taking some study leave the 3 days leading up to the exam.  I am fortunate that I only have to drive one hour to the test centre.  I have seen tales of people having to fly across the US or drive/fly around Europe.  However relatively speaking it is three to four times further than I normally travel to sit VMware/MS exams.  I would like to see VMware expand the locations in which you can sit the exam by working with testing partners to get their sites up to whatever spec is required.

Administrator Tools and Network Administration Done.
On to my next Chapter/Objective of the Official Cert Guide!

Storage Concepts

 

Best VCAP Study Aid is another person’s time & help

Like many I’m currently cramming for my VCAP-DCA.

The reason behind the cramming is that it’s on the 15th Jan and it’s DCA510 which has been retired so I couldn’t push it back despite not getting the voucher long ago or starting studying long ago enough.

That’s my excuses out of the way early.

So I could write my own blog posts breaking down the blueprint.  Well that is useful to me, being able to explain something to a level where someone else can understand it is a good demonstration of your knowledge of something usually….but that’s been done to death.  There are hundreds of VCAP Blueprint blogs out there, some great, some ok.  I’ll list out some resources at the end.

The reason for this post is that in searching for study aids I found Josh Andrews blog http://sostechblog.com/ There are lots of VCAP blog posts on there, including interesting ones about setting up your own lab, something I’ve done (another post coming on that too!), and most importantly his Test Track Lab.  Hmmm my interest was piqued here.  There was an RDP file and a mention of login instructions!??

I read on and Josh had set a basic lab, 2 nested hosts, DC, VC and some powered off VMs on the nested hosts.  He had tried to make it as representative of a VCAP test without breaching any NDAs.  As you will have seen from the description of a VCAP exam and the demo flash http://mylearn.vmware.com/courseware/82526/VCAPDCA_Tutorial.swf much of the setup is described here and is what 99% of us will have in our home labs:

  • 2 nested hosts (or running on an HP Microserver or equivalent)
  • DC (with Powercli and putty and viclient installed)
  • vCenter
  • It didn’t have VMA, it didn’t have a VUM server. Both of those you can configure and add easily yourself

Nothing amazing thus far.  But here is the great bit.  Just before VMworld 2012 Josh created his lab on a laptop roughly described above.

  • He then went further and wrote some scenarios that you should know if you’re going to attempt VCAP-DCA.  Currently these focus on VM management, Storage Management, Network Management and Miscellaneous tasks.
  • He wrote four sets of these.
  • His lab also contains scripts to reboot and reset the lab in between Sets of tasks
  • He also wrote powershell scripts to check your homework!
    It’s pretty amazing and the final amazing part is……….
  • He let’s strangers on to this lab remotely!!!!  Giving away his compute, electricity and hard work for the benefit of fellow VMware enthusiasts.

I think this is a great example of how the VMware community can really do amazing things.  Taking time out of his day to setup and schedule me a slot to use his lab and scenarios has really boosted my thirst for learning.  I quickly realised there were some areas I needed to brush up.  But in others I confirmed what I knew and I even found a glitch in one of the scoring scripts 😉  (That is in no way a criticism as the lab was set up some time ago and any edits can easily be lost with the non-persistent disks and also covers 5.1 and 5.5)

Josh is already, unsurprisingly, a vExpert and a VCI/VCP/VCAP……  If you’re looking for something to test our your skills and to inspire you to better automate and configure you own home lab then I highly recommend looking through Josh’s posts and getting in touch with him via Twitter or e-mail.

Here’s where I got started with Josh’s Test Track

http://sostechblog.com/2014/02/07/vcap-test-track-lab-on-a-lap/

Network: North-South, East-West. Don’t be embarrassed to ask

Networking traffic described as points of the compass.

It’s day 3 of vmworld for me and NSX is big. The keynotes feature it heavily, it’s great new technology and the queues for standby to the breakout sessions where NSX is in the title are like queues for a new iPhone release.

So it took me this long to stop and say, wait! What is this north south east west stuff? Everyone refers to it to talk about traffic in data centres but no one has defined it. Is guessed but want sure. So I’ve checked and it is quite simple.

Because network diagrams historically always put the Core Switch at the top. It’s the North.

So
North-South Traffic = Traffic in and out of the DC
East-West Traffic = Traffic between servers (VMs) within the DC

Each has it’s own challenge and as workloads change from simple client server where almost all traffic was North-South, to now the traditional 3-tier web fronted application which generates lots more East-West traffice between the web, app and db layers.

More in the “Why does everyone presume you know this already?” series to come 😉

VMworld: Finally at the Frontier!

I am here.  I’m in Barcelona.  Tomorrow I will be attending the partner day activities and following that such amazing things as the vExpert party!

I lie here in my Chintz Pink Hotel (Picture attached at the end) marvelling that this has actually come off.

I have spent 2-3 weeks sorting this out.  I won’t go into details but suffice to say the red tape I’ve had to negotiate has involved things that, in peace-time, no person should have to endure.

But I’m here.  It’s happening.  I’m registered (ok not to everything I might have liked…surprise surpise…if you book your schedule late, all the NSX bits have gone 🙂

I even managed to spend a pleasant evening in a Cerveceria sampling some nice random tortillas and gambas.  So not all bad.

 

This is my first VMworld and I’m already learning.  Due to my late approval I didn’t have the luxury of selecting flights, but a tip for any new VMworlders next time is

  • Get a flight in normal hours and you can save money on cab-fare by getting the vmworld shuttle bus. (I arrived after the shuttle stopped at 8pm)
  • Get there the day before early and register and get your pass. (A colleague has done this as he’s a 2nd timer)
  • Getting there daytime the day before lets you scope out the local area around your hotel, find cash points (ATMs to you American types) and Metro stations if you’re brave enough to travel by subway, Barca style.

This is my second “trip” to Barcelona.  My stag-do (read Bachelor party for USA) was here and it was an amazing weekend, and funnily enough I passed through here in July on a friends Stag-do on the way to Lloret de mar and Perpignon to watch Wigan vs Perpignon play Rugby.  It’s a beautiful city and the café bar culture that means that 11.30pm on a Sunday is a normal time to get a drink and some food.  It means a weary traveller arriving at 10.30pm has no worry that everything is closed (even if all the ATMs in the Airport are broken!).

I’m fed, watered and ready to attack Partner Day tomorrow with Zeal, Vim and Vigour!

So watch out Gran Fira, or Fira Gran……….I’m coming!

 

(promised pink chintz hotel picture)

hotel1

 

🙂

vExpert: Why go for it?

I was driving home Friday night when my phone bleeped to tell me a colleague had DM’d me on Twitter. I made a mental note to check when I got home.

After a couple of hours spent building MetalBeard out of Lego I remembered and read it.

“Congratulations vExpert” it said.
I checked the VMware blog and found this
http://blogs.vmware.com/vmtn/2014/10/vexpert-2014-q3-announcement.html#src=vmw_so_vex_cneal_850

I was very pleased that my efforts evangelising around virtualisation and in particular VMware had been recognised.

I have been using VMware since around 2005 when I started my current employer.  It was a brave new world, lots of resistance, people being concerned what consolidating their servers would mean, and vmotion!?!?! Voodoo!

“Which host are my VMs on?”

<Insert scream of frustration here>

Things have changed lots.  Virtualisation is the now, cloud is now-ish and Agile/OpenStack/Devops is the future.

I’ve started blogging on VMware not long ago and before that I had discovered that the VM communities are a great place to help people, build your own knowledge up and demonstrate your qualifications and experience.  It’s also a great source of revision for VCP/VCAP 😉  So two birds one stone as they say.  My score on the communities is currently at the heady 212 mark.  This is puny compared to those moderators, VMware employees and other gurus who have helped so many for so long and hit crazy scores of 50,000 (Some have been on the forums since 2003 and amazingly active).

There are some benefits, which I truly honestly only found out since being given the appointment which is great but not why I did it nor why I’ll continue.  I enjoy helping people…even those who are pretty unashamedly trying to get you to design their whole vSphere environment for them via the forum 🙂

In other news there is a slim chance I may be attending VMworld Europe on Monday which would be my fist VMworld ever!!!

Fingers and toes Crossed!

 

(Thanks go out to Darryl http://darrylcauldwell.com/ for nudging me to apply for vexpert and Corey Romero for the tips around blog tracking and his encouragement too!)