CloudStackDevOps and AutomationVMware

Automating sVS to dVS migration on single NIC VMware ESXi hosts

We recently came across an issue where we needed to migrate VMware ESXi hosts from standard vSwitches to distributed vSwitches at build time and before putting the hosts into production. This is straight forward from vCenter by just using the normal migration wizards, but proved to be a little trickier from command line:

  • On a single NIC host the uplink migration has to be done at the same time as port groups and service consoles / VMkernels.
  • This can not be done from the ESXi side (happy to be proven wrong on this point) but has to be managed from VC.
  • In addition this had to be handled by Ansible automated ESXi / VC build playbooks, preferably without involving any other intermediary build hosts.

The conclusion was the migration can be handled by using PowerCLI under Powershell. Microsoft have this year released Powershell for Linux – which meant it could be installed on the Ansible build hosts. PowerCLI can then just be added to the same host:

Once the pre-requisites are in place the following script will handle the migration. Input parameters are named:

  • vchost: IP address of VC host
  • vcuser: VC user account
  • vcpass: VC password
  • esxihosts: comma delimited list of ESXi hosts to migrate
  • dvswitchname: name of distributed vSwitch. The script assumes this has already been created through other means, e.g. the Ansible VMware modules.
param(
[String] $vchost,
[String] $vcuser,
[String] $vcpass,
[String] $esxihosts,
[String] $dvswitchname
)

# Stop spam
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false

# Ignore certificates
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -confirm:$false

# VC connectivity
Write-Host "Connecting to VC host " $vchost
Connect-VIServer -Server $vchost -User $vcuser -Pass $vcpass

# Array of esxi hosts
$esxihostarray = $esxihosts -split ','
foreach ($esxihost in $esxihostarray) {
$dvswitch = Get-VDSwitch $dvswitchname

# Add ESXi host to dvSwitch
Write-Host "Adding" $esxihost "to" $dvswitchname
Add-VDSwitchVMHost -VMHost $esxihost -VDSwitch $dvswitch
$management_vmkernel = Get-VMHostNetworkAdapter -VMHost $esxihost -Name "vmk0"
$management_vmkernel_portgroup = Get-VDPortgroup -name "Management Network" -VDSwitch $dvswitchname

# Migration esxi host networking to dvSwitch
Write-Host "Adding vmnic0 to" $dvswitchname
$esxihostnic = Get-VMHost $esxihost | Get-VMHostNetworkAdapter -Physical -Name vmnic0
Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $esxihostnic -DistributedSwitch $dvswitch -VMHostVirtualNic $management_vmkernel -VirtualNicPortgroup $management_vmkernel_portgroup -Confirm:$false
}
Disconnect-VIServer -Server $global:DefaultVIServers -Force -Confirm:$false

 

The script can be ran either directly, or by a “local_action shell” from Ansible:

/usr/bin/pwsh esxi-dvs-mgmt.ps1 -vchost [VC host IP] -vcuser [VC user] -vcpass [VC password] -esxihosts "[ESXihost1,ESXihost2]" -dvswitchname [dvSwitch name]
Personal - bikes and travel

KTM adventure rally – Italy 2017

KTM arranged their first European KTM adventure rally in Bardonecchia, Italy this summer. I decided early in the year to take the 1190 Adventure R down – and had an absolute blast. 4 days of exploring some of the best offroad tracks Europe has to offer, with great company and fantastic weather (bit too fantastic a couple of days – 35 deg C is a bit too much). Loved the trip, was absolutely fantastic and very much looking forward to the  2018 rally.

Read More

CloudStack

VPC to VPC VPN configuration in CloudStack

This blog post was originally posted on the ShapeBlue website: http://www.shapeblue.com/vpc-to-vpc-vpn-configuration-in-cloudstack/

Introduction

Configuring connectivity between CloudStack hosted VPCs can be done by either using private gateways – which has to be configured by CloudStack root administrators to use dedicated network segments – or by using VPC-to-VPC connections, which can be configured by the CloudStack end user without admin input.

Read More

CloudStack

ApacheCon Miami / CCCNA 2017 talk May 2017 – Apache CloudStack upgrade best practices

This year the CloudStack Collaboration Conference was held as part of ApacheCon Miami. CloudStack upgrades is a topic which makes some users nervous – so I decided to do my main talk going over some of the best practices we have picked up over the years.

Slide deck up on SlideShare:

Also check our ShapeBlue blog post on the Miami conference – http://www.shapeblue.com/cloudstack-collaboration-conference-miami-may-16-18/

CloudStack

ApacheCon Miami / CCCNA 2017 talk 17/May/17 – Using KVM in Apache CloudStack

This year the CloudStack Collaboration Conference was held as part of ApacheCon Miami. Setup of KVM for use with CloudStack can be a little challenging – hence I brought along a previous talk from an EU user group in London to go into a bit more detail on this.

Slide deck on SlideShare:

Also check our ShapeBlue blog post on the Miami conference – http://www.shapeblue.com/cloudstack-collaboration-conference-miami-may-16-18/

CloudStackDevOps and Automation

Virtualisation / TechUG talk 22/Feb/17 – Configuration Management best practices

In February I was invited by Mike, Brendon and Gavin to do another talk at the TechUG / Virtualisation user group in Glasgow. Having done a talk about one of my favourite topics – Ansible – previously, I decided to do a little bit more of a getting started and best practices talk this time, as well showing what we do with our Trillian framework at ShapeBlue.

Slide deck is up on SlideShare:

CloudStack

CloudStack upgrades – best practices

This blog post was originally posted on the ShapeBlue website: http://www.shapeblue.com/cloudstack-upgrades-best-practices/

Introduction

Upgrading CloudStack can sometimes be a little daunting – but as the 5P’s proverb goes – Proper Planning Prevents Poor Performance. With planning, testing and the right strategy upgrades will have a high chance of success and have minimal impact on your CloudStack end users. Read More