September 19, 2016

Tags VirtualGuest

Provision a virtual guest

Example of provisioning a virtual guest from a template object.
package main

import (


// A virtual guest template
// (use convenience functions to get pointers from literals, as needed)
var vGuestTemplate = datatypes.Virtual_Guest{
    Hostname:                     sl.String("sample"),
    Domain:                       sl.String(""),
    MaxMemory:                    sl.Int(4096),
    StartCpus:                    sl.Int(1),
    Datacenter:                   &datatypes.Location{Name: sl.String("wdc01")},
    OperatingSystemReferenceCode: sl.String("UBUNTU_LATEST"),
    LocalDiskFlag:                sl.Bool(true),

func main() {
    // Create a session
    sess := session.New()

    service := services.GetVirtualGuestService(sess)

    // Create the virtual guest from the template
    // We also specify an (optional) object mask, to read back some values
    vGuest, err := service.Mask("id,hostname,domain").CreateObject(&vGuestTemplate)
    if err != nil {
    } else {
            "\nNew Virtual Guest with ID %d being provisioned\n", *vGuest.Id)


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue