Category Archives: VMware

vHighlights #004

Some highlights from VMware ecosystem and Virtualisation in general from the past 7 days. Announcements, discoveries, and useful bits-and-bobs found on  the internet. Week ending 2nd April 2017

VMworld

VMworld 2017 Session Voting

On Tuesday VMware announced that voting for VMworld sessions had started. This is an opportunity for members of the VMware community to “help shape the agenda” for the conference. Lots of people voting for one session isn’t a guarantee that it will appear but high ratings definitely direct the conference organisers to popular topics from the nearly 2,000 submitted in the CFP.

Here’s some of my highlights from the catalogue – have a look yourself and see if you agree with me. Voting runs till April 13th 2017.

The Power Hour – PowerCLI 10th Birthday Edition [1875]

VMworld Europe 2016 Power Hour

Always a staple in my VMworld viewing calendar –  the corresponding session was top of my Sessions to look out for list last year. This session marks the 10th anniversary of PowerCLI and Luc Dekens and Alan Renouf promise to accompany a history lesson with some new features and deep dives into the tool.

Ask the vCenter Server Experts Panel [2894] and/or Meet the vCenter Server Experts Panel [1440]

I’m not sure what the difference between these two proposals is, but these sessions offer the chance to ask questions of some of VMware’s top experts. There’s a benefit here from being a passive audience member or catching up online, but the real bonus is the opportunity for in-person attendees to ask questions based on their real-world vCenter experience.

How to Prepare for VMware Certified Professional 6 – Data Center Virtualization [1533] with Steven Baca

An interesting looking session covering what the VCP certification involves and resources available and then diving into exam questions in the second half. Presented by one of the authors of the official certification guide.

What’s New with…..

As always there’s a whole series of “What’s New” sessions – I counted at least twelve titled proposals in the list. The new/recent developments are often the biggest talking points at VMworld – delivered through the Keynote and then in detail at breakouts like these- and always feed the discussions outside of the sessions. In particular I’d like to see what the latest and greatest developments are in vSphere (What’s New with vSphere [2342]) , vCenter (What’s New with vCenter [2779]), and vSAN (What’s New in VMware vSAN? [3054]).

Customer Story: Real world deployment of App Volumes for 20,000 users [1653]

Working in Higher Education IT, this session co-hosted by VMware and Maastricht University on their experience rolling out AppVolumes got me interested. It’s always interesting to see the real-world use cases of the existing technology being demonstrated at these events alongside the fresh-from-the-factory new features.

Battle of the Vs (vSAN vs VVols) [2248]

Drawn in by the title, the abstract of this talk looks interesting too. Pete Flecha and Duncan Epping take VSAN and VVols “head to head” to find out when each technology should be used.

Auto-Deploy 6.5 – you can SEE the Future! [1059]

This session caught my eye- Rebecca Fitzhugh and Mike Burkhart plan to cover the enhancements in Auto Deploy released in vSphere6.5, in particular the new GUI.

vSAN Troubleshooting Deep Dive [1315]

This looks like a heavy-duty session. It’s always interesting to see what the experts do when something goes wrong as opposed to what they do to make things go right. Any session that increases knowledge in a way that might just save the business time and support calls makes sense.

Quick Talks

There are 82 “Quick Talks” listed on the voting pages. These often overlooked sessions, many of which seem to end up on the Monday (in Barcelona at least), are a useful addition to the schedule in my opinion. Shorter than the usual breakouts these sessions either give an introduction to a technology or focus on a small feature in detail. The introduction sessions are great for getting a look at something in the portfolio that is perhaps outside of your regular sphere, but without committing a full precious hour of your planner to at the conference.

Examples from the Quick Talks category that caught my eye include “Exploring Photon Platform [2349]”, “Kubernetes Networking 101 [2603]”, “Site Recovery Manager – Disaster Recovery Testing at it’s finest [2076]”, and of course “Virtually Speaking Podcast – Live Edition! [1948]”

 

The voting catalogue has lots to choose from and I’m just skimming the surface in this post. I couldn’t possibly list all the ones I’m interested in here and I’ve undoubtedly missed some potential favourites . Check out the VMworld blog for more information and a link to the voting pages containing all the proposed sessions. If there’s any sessions that I’ve missed above that you think should definitely be included, drop a comment below and let me know which ones and why.

Using PowerShell and REST-API to create a VM in vCenter

VMware vSphere 6.5 comes with a RESTful API implementation and there’s some great documentation out there- starting with the API Explorer (http://my.vcenter.name/apiexplorer ). Here’s a quick piece on how to use this API to create a VM from the PowerShell command line. This is intentionally not using PowerCLI,  just the native PowerShell cmdlets- partly as a REST learning experience for me, and partly so the API code can be transferred to another language at a later date.

Step 1- Authenticate with the Server.

This step is well documented by Chris Wahl. I’ve borrowed some of his code here, and accompanied it with a section to get around the lack of trusted certificates on my homelab. 192.168.0.240 is the IP of my VCSA, so if you’re reusing this anywhere remember to replace that hard coded value where it appears.

#----------------------------------------------------------------------------------------------
#Step 1- Authenticate with the Server
#Ignore Server Certs- This is on my not-very-well-certified home lab.
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback=@"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback
{
public static void Ignore()
{
if(ServicePointManager.ServerCertificateValidationCallback ==null)
{
ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
Object obj,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors errors
)
{
return true;
};
}
}
}
"
@
Add-Type $certCallback
}
[ServerCertificateValidationCallback]::Ignore();

#Get Some Credentials and Determine Authorisation Methods
$Credential = Get-Credential
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Credential.UserName+':'+$Credential.GetNetworkCredential().Password))
$head = @{
'Authorization' = "Basic $auth"
}

#Authenticate against vCenter
$r = Invoke-WebRequest -Uri https://192.168.0.240/rest/com/vmware/cis/session -Method Post -Headers $head
$token = (ConvertFrom-Json $r.Content).value
$session = @{'vmware-api-session-id' = $token}

Now we have the Session ($session) we can test this by retrieving a list of VMs.

#----------------------------------------------------------------------------------------------
#Get a List of VMs
$r1 = Invoke-WebRequest -Uri https://192.168.0.240/rest/vcenter/vm -Method Get -Headers $session
$vms = (ConvertFrom-Json $r1.Content).value
$vms

Step 2- Construct the JSON specification

To create a new VM we need to provide a minimal spec for the machine, in JSON format. We need to tell it the intended Guest OS, what datastore is going to hold the VM, and where the VM will be placed in the resource/folder structure. To complete this we need to establish what options are available- just sticking in the display names of a datastore or folder from the Web Client will not work and will likely generate 404 responses to the API call.

To find these names we can use the API, API explorer gives us the following urls

Datastore:       /rest/vcenter/datastore
Folder:              /rest/vcenter/folder
Resource Pool: /rest/vcenter/resource-pool

So we can use PowerShell to retrieve a list of Datastores using this line of code

(Invoke-RestMethod -Uri https://192.168.0.240/rest/vcenter/datastore -Method Get -Headers $session ).value

which will produce a list of datastores, each looking something like this:

datastore  : datastore-11
name       : Datastore2
type       : VMFS
free_space : 100553195520
capacity   : 249913409536

From this example we want the value of the “datastore” field, e.g “datastore-11”.

Once we have this information we can combine it all to create a JSON spec file. My example looks like this:

{
"spec": {
"guest_OS": "RHEL_7_64",
"placement" : {
"datastore": "datastore-11",
"folder": "group-v224",
"resource_pool": "resgroup-182"
}
}
}

Step 3- Create the Virtual Machine.

Now we’ve done all this prep work, creating a Virtual Machine comes down to a single line of PowerShell pointing at the data.txt file containing the JSON code from Step 2.

Invoke-WebRequest -Uri https://192.168.0.240/rest/vcenter/vm -Method Post -Headers $session -ContentType "application/json" -Body (Get-Content data.txt)

Example Output:

StatusCode        : 200
StatusDescription : OK
Content           : {"value":"vm-462"}
RawContent        : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: application/json
Date: Mon, 27 Mar 2017 09:41:34 GMT

{"value":"vm-462"}
Forms             : {}
Headers           : {[Transfer-Encoding, chunked], [Content-Type, application/json], [Date, Mon, 27 Mar 2017 09:41:34 GMT]}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 18

The VM is created and we can check this from the vSphere Client:

2017-03-27 (10)

So, to summarise. Native PowerShell, with a little bit of JSON, can be used to communicate with the vSphere APIs and create new Virtual Machines. Depending on your use case there may be better ways of implementing automation processes through this API (PowerCLI is a good start) but if you want to drop to the raw RESTful API, possibly as a stepping stone to a larger project, PowerShell provides a handy method to get started down that path.

vHighlights #003

Some highlights from VMware ecosystem and Virtualisation in general from the past 7 days. Announcements, discoveries, and useful bits-and-bobs found on  the internet. Week ending 26th March 2017

  • vSphere 6.0 U3a has been released– this patches the Apache Struts vulnerability which was fixed in 6.5 last week. However- note that it mentions in the release notes that upgrading from vCenter Server 6.0 Update 3 to vCenter Server 6.5 is not supported.
  • AmazonWebservices Logo.svgAlex Galbraith’s talk with the Datanauts podcast crew titled “AWS Warts And All” – definitely worth a listen if you have even the slightest interest in AWS.
  • Step-by-Step instructions on enabling HA on a vSphere 6.5 Infrastructure– I followed these on my HomeLab this week.

Rolling back a failed VCSA HA deployment

The deployment of High Availability in the vCenter Server Appliance 6.5 is very slick and there’s a great step-by-step walkthrough of how to implement it. However, sometimes things go wrong – in my case a misconfiguration in the underlying network meant that the hosts I was trying to deploy to couldn’t reach each other on the new HA network.

The good news is the smooth Installation process is accompanied by a smooth uninstaller when things have gone wrong. It’s nice to see that this part of the application lifecycle process hasn’t been ignored by the development team at VMware. With the right planning and a bit of luck, you’ll never have to see this yourself- but here’s some example screenshots.

The install has failed, the wizard was unable to configure HA, and we are left with a situation looking like this:

image

The vSphere Web Client is telling me “vCenter HA has an invalid configuration. Click the remove button to destroy the current vCenter HA cluster configuration”. And it is really as simple as that, clicking Remove starts the process- this doesn’t destroy your vCenter environment- just the failed HA attempt – and vCenter reverts back to the model it was using beforehand. We get a nice clear explanation of what is going to be done, details of what manual steps may be necessary, and an option to change our mind.

image

The task proceeds like any other vCenter operation, showing as Completed in the Recent Tasks bar- in my homelab this removal task took just 11 seconds.

image

Once done it was just a case of powering down and removing the defunct Passive and Witness VMs, fixing the pre-existing fault that had caused the error in the first place, and then running the install again.It should end up looking something like this:image

It’s always good to see that development effort has been put into helping the user when something unexpected has occurred and this is a good example of that.