Virtualize Planet

    Getting Started, writing VMware APPs
                           for novice programmers




                             Sponsored by




www.virtualizeplanet.com                            Author: Ricky El-Qasem: 2011
Breaking the magicians code




                      11/23/2012   2
No Programmers Allowed

 I’m not a programmer
 I do not speak in
  Fortran or C++
 The point of this
  session is that its for
  novices like me




                            www.virtualizeplanet.com   11/23/2012   3
A word from the sponsors

All apps mentioned in this presentation are not the
products of Canopy Cloud. Ricky developed these
apps before joining Canopy.
                                                      Canopy Private Cloud

                                                        Solutions Catalogue: Vertical &
                                                            Horizontal Workloads



                                                        Management & Orchestration
                                                         vCloud Director - vSphere
                                        Canopy
                                       Appstore




                                                         Canopy Cloud Infrastructure
                                                           Vblock - Best-of-Breed




                           www.virtualizeplanet.com   11/23/2012                          4
My Apps

 VPsnapper = where it all started
 Resource Pool Scheduler
 vDisk Waste Finder
 vSphere Plug-in Wizard = Best Free Tools VMworld
  2011
 vDisk Informer




                            www.virtualizeplanet.com   11/23/2012   5
Different APIs

 COM API
 Web server API = SDK
 PowerCLI
 Etc etc




                         www.virtualizeplanet.com   11/23/2012   6
What you need before you begin

 .Net IDE = Visual Studio .Net
or
 Java IDE = Netbeans




                             www.virtualizeplanet.com   11/23/2012   7
So how did I do it?

 VPsnapper

 I needed a way to revert the default snapshots on all my VMs with one click




                                          + COM API Document




                                           www.virtualizeplanet.com   11/23/2012   8
VPSnapper




            www.virtualizeplanet.com   11/23/2012   9
The SDK is the future
 Resource Pool Scheduler
•Student gave me an idea. I needed to be able to shift resource allocation from pool
to pool
• Once again I used the book and the SDK programmers guide but failed at stage 1
• Stage 1 was to list all VMs running
• I posted my failure on VMTN = VMware Communities
• Few days later VMware sent me a fixed version of my test app.
• This was a huge springboard




                                             www.virtualizeplanet.com   11/23/2012     10
Another Useful Book

 Samples are in JAVA
 However I found I could
  easily copy from JAVA
  to C# .NET




                            www.virtualizeplanet.com   11/23/2012   11
The SDK Tree
                                             ExtensibleManagedObject




                                                     ManagedEntity




ResourcePool      ComputeResource       Hostsystem          Datacenter              Folder             VirtualMachine




               ClusterComputeResource




                                                               www.virtualizeplanet.com   11/23/2012                    12
MOB = Managed Object Browser

 https://yourserver/mob




                           www.virtualizeplanet.com   11/23/2012   13
How to work with the SDK

 Make a connection
 Filter only what you need – Proprerty Spec
 Which hierarchy objects to search - Traversal Spec




                            www.virtualizeplanet.com   11/23/2012   14
VIMAPI in .net

 2 x Dlls – import in to your code




 Using Statement:




                              www.virtualizeplanet.com   11/23/2012   15
MOREF Managed Object Reference

 You do not manipulate the VMware objects like
  VMs, Folders, Hosts and Datastores directly
 You work with a representation of those objects
  known as a Managed Object Reference aka MOREF
 Its all about the MOREF!




                             www.virtualizeplanet.com   11/23/2012   16
Data model

 Managed Object Types = objects that have
  properties and methods
 MOREF = local representation
 Data Object = just pure data and no actions




                            www.virtualizeplanet.com   11/23/2012   17
vSphere Plug-in Wizard

 Finalist in Best Free
  vSphere Tools VMworld
  2011
 Plugs in Website of
  your choice into
  vSphere Client




                          www.virtualizeplanet.com   11/23/2012   18
vSphere Plug-in Wizard




                www.virtualizeplanet.com   11/23/2012   19
vDisk Informer

 Helps you find wasted
  vDisk space
 Helps you find
  misaligned vDisks
 Use Gparted to fix




                          www.virtualizeplanet.com   11/23/2012   20
vDisk Waste Finder

 Previous version of
  vDisk Informer
 VMUG can have copy
  of code.
 Demo




                        www.virtualizeplanet.com   11/23/2012   21
Extreme GUI Makeover

 Before        After




                www.virtualizeplanet.com   11/23/2012   22
Tips on creating a sexy GUI




                www.virtualizeplanet.com   11/23/2012   23
Tips on creating a sexy GUI




                www.virtualizeplanet.com   11/23/2012   24
Tips on creating a sexy GUI




                www.virtualizeplanet.com   11/23/2012   25
www.virtualizeplanet.com   11/23/2012   26
Writing Config




                 www.virtualizeplanet.com   11/23/2012   27
Performing an action



ManagedObjectReference moref_task = _service.PowerOffVM
(moref_VM, moref_Host);




                                     www.virtualizeplanet.com   11/23/2012   28
My best tip as a novice

 Take an existing example and hack it to death with
  trial and error until you get it working for your
  needs
 If something doesn’t work post it on VMware's
  Community forum
 After today code for vDisk Waste Finder will be
  available from my blog www.virtualizeplanet.com




                            www.virtualizeplanet.com   11/23/2012   29
Disclaimer:

Virtualize Planet will not be held liable for any actions you perform in
your environment. Anything you learn from this material should be used
at your own discretion and be warned actions you perform can be
damaging. Always consult a professional.




                    www.virtualizeplanet.com               11/23/2012      30

Getting started vmware apps

  • 1.
    Virtualize Planet Getting Started, writing VMware APPs for novice programmers Sponsored by www.virtualizeplanet.com Author: Ricky El-Qasem: 2011
  • 2.
    Breaking the magicianscode 11/23/2012 2
  • 3.
    No Programmers Allowed I’m not a programmer  I do not speak in Fortran or C++  The point of this session is that its for novices like me www.virtualizeplanet.com 11/23/2012 3
  • 4.
    A word fromthe sponsors All apps mentioned in this presentation are not the products of Canopy Cloud. Ricky developed these apps before joining Canopy. Canopy Private Cloud Solutions Catalogue: Vertical & Horizontal Workloads Management & Orchestration vCloud Director - vSphere Canopy Appstore Canopy Cloud Infrastructure Vblock - Best-of-Breed www.virtualizeplanet.com 11/23/2012 4
  • 5.
    My Apps  VPsnapper= where it all started  Resource Pool Scheduler  vDisk Waste Finder  vSphere Plug-in Wizard = Best Free Tools VMworld 2011  vDisk Informer www.virtualizeplanet.com 11/23/2012 5
  • 6.
    Different APIs  COMAPI  Web server API = SDK  PowerCLI  Etc etc www.virtualizeplanet.com 11/23/2012 6
  • 7.
    What you needbefore you begin  .Net IDE = Visual Studio .Net or  Java IDE = Netbeans www.virtualizeplanet.com 11/23/2012 7
  • 8.
    So how didI do it?  VPsnapper I needed a way to revert the default snapshots on all my VMs with one click + COM API Document www.virtualizeplanet.com 11/23/2012 8
  • 9.
    VPSnapper www.virtualizeplanet.com 11/23/2012 9
  • 10.
    The SDK isthe future  Resource Pool Scheduler •Student gave me an idea. I needed to be able to shift resource allocation from pool to pool • Once again I used the book and the SDK programmers guide but failed at stage 1 • Stage 1 was to list all VMs running • I posted my failure on VMTN = VMware Communities • Few days later VMware sent me a fixed version of my test app. • This was a huge springboard www.virtualizeplanet.com 11/23/2012 10
  • 11.
    Another Useful Book Samples are in JAVA  However I found I could easily copy from JAVA to C# .NET www.virtualizeplanet.com 11/23/2012 11
  • 12.
    The SDK Tree ExtensibleManagedObject ManagedEntity ResourcePool ComputeResource Hostsystem Datacenter Folder VirtualMachine ClusterComputeResource www.virtualizeplanet.com 11/23/2012 12
  • 13.
    MOB = ManagedObject Browser  https://yourserver/mob www.virtualizeplanet.com 11/23/2012 13
  • 14.
    How to workwith the SDK  Make a connection  Filter only what you need – Proprerty Spec  Which hierarchy objects to search - Traversal Spec www.virtualizeplanet.com 11/23/2012 14
  • 15.
    VIMAPI in .net 2 x Dlls – import in to your code  Using Statement: www.virtualizeplanet.com 11/23/2012 15
  • 16.
    MOREF Managed ObjectReference  You do not manipulate the VMware objects like VMs, Folders, Hosts and Datastores directly  You work with a representation of those objects known as a Managed Object Reference aka MOREF  Its all about the MOREF! www.virtualizeplanet.com 11/23/2012 16
  • 17.
    Data model  ManagedObject Types = objects that have properties and methods  MOREF = local representation  Data Object = just pure data and no actions www.virtualizeplanet.com 11/23/2012 17
  • 18.
    vSphere Plug-in Wizard Finalist in Best Free vSphere Tools VMworld 2011  Plugs in Website of your choice into vSphere Client www.virtualizeplanet.com 11/23/2012 18
  • 19.
    vSphere Plug-in Wizard www.virtualizeplanet.com 11/23/2012 19
  • 20.
    vDisk Informer  Helpsyou find wasted vDisk space  Helps you find misaligned vDisks  Use Gparted to fix www.virtualizeplanet.com 11/23/2012 20
  • 21.
    vDisk Waste Finder Previous version of vDisk Informer  VMUG can have copy of code.  Demo www.virtualizeplanet.com 11/23/2012 21
  • 22.
    Extreme GUI Makeover Before  After www.virtualizeplanet.com 11/23/2012 22
  • 23.
    Tips on creatinga sexy GUI www.virtualizeplanet.com 11/23/2012 23
  • 24.
    Tips on creatinga sexy GUI www.virtualizeplanet.com 11/23/2012 24
  • 25.
    Tips on creatinga sexy GUI www.virtualizeplanet.com 11/23/2012 25
  • 26.
  • 27.
    Writing Config www.virtualizeplanet.com 11/23/2012 27
  • 28.
    Performing an action ManagedObjectReferencemoref_task = _service.PowerOffVM (moref_VM, moref_Host); www.virtualizeplanet.com 11/23/2012 28
  • 29.
    My best tipas a novice  Take an existing example and hack it to death with trial and error until you get it working for your needs  If something doesn’t work post it on VMware's Community forum  After today code for vDisk Waste Finder will be available from my blog www.virtualizeplanet.com www.virtualizeplanet.com 11/23/2012 29
  • 30.
    Disclaimer: Virtualize Planet willnot be held liable for any actions you perform in your environment. Anything you learn from this material should be used at your own discretion and be warned actions you perform can be damaging. Always consult a professional. www.virtualizeplanet.com 11/23/2012 30

Editor's Notes

  • #31 I hope you enjoyed this material and look out for my next one what ever that may be.