Category Archives: CentOS

PowervRA – Now available on OS X and Linux via PowerShell Core!

Back Story

For a while Craig and I have had a number of requests regarding offering OS X and Linux support to PowervRA, particularly since in case you weren’t aware PowerShell is now available on those OSs and 3rd party modules such as PowerCLI are heading towards supporting that. We first looked at offering this support for PowervRA when the first Alpha release of PowerShell Core was shipped, however we were blocked by a couple of issues, particularly this one regarding certificate checking.

However, back in December I read about how the guys who maintain PowerNSX had been able to offer PowerShell Core support and they had also been blocked by that same issue which has now been resolved. So we updated to PowerShell Core Alpha 14 and started testing again – it seemed that another blocking issue around JSON responses had also been resolved, so things were looking good.

As it turned out, there weren’t a significantly large amount of changes which actually needed to be made on our side – some changes to the Connect-vRAServer and Invoke-vRARestMethod functions to do different things depending on whether PowerShell Core is being used. The scale of community feedback to the alpha releases of PowerShell Core and the efforts of the PowerShell team at Microsoft look like they have had a great impact and covered off a lot of the issues we might have had and the feedback has been quickly taken into subsequent alpha releases.

We benefited from the fact that we have previously invested quality time in producing integration tests for PowervRA, consequently we were able to run the same tests using a PowerShell Core client and only ended up with a couple of bugs that we are currently unable to resolve (here and here) , but looks like at least one of them is scheduled to be fixed for us via a milestone of PowerShell Core beta.

So in release 2.0.0 of PowervRA we are very pleased to bring you support for PowerShell Core!

Requirements

You will need:

PowerShell Core Alpha 14 + ….instructions on getting it installed for different OS flavours can be found here.

PowervRA 2.0.0 + . Get a copy of PowervRA onto the Linux  or OS X machine you want to run it from. Use the following to download it  from the PowerShell Gallery:

or manually copy the module yourself to one of the locations listed in $env:PSModulePath, for example:

In Action

OS X

Here’s PowervRA on my Macbook:

Connect to vRA

Retrieve Blueprint Details

Update a Reservation Policy

Ubuntu 16.04

Here’s PowervRA on Ubuntu 16.04:

Connect to vRA

Retrieve Business Group Details

Update a Network Profile

 

Docker

Craig has done some cool work to make PowervRA available via Docker. Check out his blog post for more details.

Also, many thanks to Alan Renouf for suggesting PowervRA now be made available hosted in the PowerCLI Core Docker Hub too.

Side Note

In PowervRA 2.0.0 we have also made some under the hood changes that it is worth being aware of (check the changelog for more details):

  • Module Restructure Part 1: we changed the functions from being their own individual nested modules in *.psm1 files to more simply being in *.ps1 files and made part of the module in a different way. This was a way I had historically put my modules together, but now have spent some time improving on it to a better way.
  • Module Restructure Part 2:  a number of functions had been marked in recent releases as deprecated, they have now been removed.
  • Module Restructure Part 3: we had previously started moving the functions into folders based on their API endpoint, this is now complete across all of the functions:

Issues

We believe we have covered off most issues with using PowervRA on PowerShell Core via our testing process, but if you do experience anything we have missed then please let us know here.

We are aware of one issue with running PowervRA on CentOS, which appears to be something not just relevant for us and should get fixed upstream in .Net Core.

Summary

We’re really pleased to be able to bring this support to PowervRA and much kudos to the PowerShell team and the wider community for making it both possible and relatively straightforward. We hope you find it useful given we know a significant part of our potentially user base are OS X users.

Also stay tuned because we are not stopping there. There is other planned new PowervRA functionality on the horizon ……

vSphere: Importing a CentOS VM Exported as a VMDK from KVM

I was recently given a VMDK file which I was informed had been exported from a KVM system and needed to be used to create a VM in vSphere. Initially I thought this would be quite a straightforward task, but turned out to be a bit of an effort, so thought I would share it here since most of the info on the interwebs seems to be for moving VMs in the other direction.

First of all I created a blank VM with no hard disk, ready to attach the VMDK to.

KVMImport01

Attaching the supplied hard disk to the VM brought three different issues. I’m not sure if all of these are typical for VMs exported from KVM, but hopefully this information will help you if you experience any of them.

  1. The disk supplied was in 2gbsparse format.  Consequently, there were issues taking snapshots and backing it up, so needed to be converted to  an alternative format.
  2. When adding the disk to the VM it had been marked as an IDE disk, not SCSI.
  3. Post converting to the disk to SCSI the VM would no longer boot.

 

1) Convert the disk from 2gbsparse to thin

Use the ESXi command vmkfstools to convert the disk between the required format. Note that in ESXi 5.1 it is necessary to first load the multiextent module:

esxcli system module load -m multiextent

Having copied the vmdk file to the VM directory, make the conversion. (Since my volume was NFS I did not need to specify the format, thin, to convert to)

vmkfstools -i /vmfs/volumes/datastore01/VM01/supplied.vmdk /vmfs/volumes/datastore01/VM01/VM01.vmdk

 

2) Convert the disk from IDE to SCSI

At this point adding the newly thin VM01.vmdk disk to the VM resulted in an IDE based disk being offered, which of course could have performance issues.

KVMImport02

This VMware KB explains how to convert the IDE disk to SCSI. Essentially edit the VM01.vmdk file and change ddb.adapterType = “ide” to ddb.adapterType = “lsilogic” .

Now when adding the disk to the VM it’s a SCSI disk.

KVMImport03

 

3) Post Converting to SCSI Disk – Getting the VM to Boot

Having made the previous change to a SCSI disk though, the VM would no longer boot. Sits on the below screen and gets no further.

KVMImport04

I couldn’t find the any key to fix this problem, so I hauled in some additional Linux expertise and worked through the following resolution.

Boot off the Centos 5.9 (or other version) CDRom

At the Linux Boot Menu type : linux rescue

KVMImport05

Take the defaults, remembering not to click Read-Only access to the disks.

KVMImport06

Mount the hardware mapped file systems to the mount point of the rescue system :-

Enter the following commands

mount –o bind /dev /mnt/sysimage/dev

mount –o bind /sys /mnt/sysimage/sys

mount –o bind /proc /mnt/sysimage/proc

mount –o bind /selinux /mnt/sysimage/selinux 

Chroot the environment to the rescued system

The final screen of the rescue boot showed the below:

KVMImport07

So enter the following command:

chroot /mnt/sysimage

Check you can see the disks if you can’t you need to exit and remap the hardware devices.

Enter the following command:

Ls /dev/sd* (looking for /dev/sda1 etc)

KVMImport08

Reinstall Grub

Enter the following command:

grub-install /dev/sda

Rebuild the boot init

Enter the following commands, note your versions may be different:

rm /boot/initrd-2.6.18-348.el5.img

mkinitrd –force-scsi-probe –force-lvm-probe /boot/initrd-2.6.18-348.el5.img 2.6.18-348.el5

 

Optional: You may wish to update the kernel to finish off

yum remove kernel-2.6.18-348.el5

yum update kernel*

Then all you need to do is exit the chroot environment and reboot.

I expect there may be a better way to have approached this issue from the start. I’m not aware that VMware Converter will take VMs directly from KVM (?) and I didn’t have access to the KVM system anyway to try exporting via other means. Would be interested to hear your thoughts.