func ValidateHost(client *govmomi.Client, pool *object.ResourcePool, host *object.HostSystem) error {
	if host == nil {
		// Nothing to validate here, move along
		log.Printf("[DEBUG] ValidateHost: no host supplied, nothing to do")
		return nil
	}
	log.Printf("[DEBUG] Validating that host %q is a member of resource pool %q", host.Reference().Value, pool.Reference().Value)
	pprops, err := Properties(pool)
	if err != nil {
		return err
	}
	cprops, err := computeresource.BasePropertiesFromReference(client, pprops.Owner)
	if err != nil {
		return err
	}
	for _, href := range cprops.Host {
		if href.Value == host.Reference().Value {
			log.Printf("[DEBUG] Validated that host %q is a member of resource pool %q.", host.Reference().Value, pool.Reference().Value)
			return nil
		}
	}
	return fmt.Errorf("host ID %q is not a member of resource pool %q", host.Reference().Value, pool.Reference().Value)
}
func ValidateHost(client *govmomi.Client, pool *object.ResourcePool, host *object.HostSystem) error {
	if host == nil {
		// Nothing to validate here, move along
		log.Printf("[DEBUG] ValidateHost: no host supplied, nothing to do")
		return nil
	}
	log.Printf("[DEBUG] Validating that host %q is a member of resource pool %q", host.Reference().Value, pool.Reference().Value)
	pprops, err := Properties(pool)
	if err != nil {
		return err
	}
	cprops, err := computeresource.BasePropertiesFromReference(client, pprops.Owner)
	if err != nil {
		return err
	}
	for _, href := range cprops.Host {
		if href.Value == host.Reference().Value {
			log.Printf("[DEBUG] Validated that host %q is a member of resource pool %q.", host.Reference().Value, pool.Reference().Value)
			return nil
		}
	}
	return fmt.Errorf("host ID %q is not a member of resource pool %q", host.Reference().Value, pool.Reference().Value)
}
func ValidateHost ( client * govmomi . Client , pool * object . ResourcePool , host * object . HostSystem ) error { if host == nil { // Nothing to validate here, move along log . Printf ( " " ) return nil } log . Printf ( " " , host . Reference ( ) . Value , pool . Reference ( ) . Value ) pprops , err := Properties ( pool ) if err != nil { return err } cprops , err := computeresource . BasePropertiesFromReference ( client , pprops . Owner ) if err != nil { return err } for _ , href := range cprops . Host { if href . Value == host . Reference ( ) . Value { log . Printf ( " " , host . Reference ( ) . Value , pool . Reference ( ) . Value ) return nil } } return fmt . Errorf ( " " , host . Reference ( ) . Value , pool . Reference ( ) . Value ) }
// ValidateHost checks to see if a HostSystem is a member of a ResourcePool
// through cluster membership, or if the HostSystem ID matches the ID of a
// standalone host ComputeResource. An error is returned if it is not a member
// of the cluster to which the resource pool belongs, or if there was some sort
// of other error with checking.
//
// This is used as an extra validation before a VM creation happens, or vMotion
// to a specific host is attempted.
ValidateHost checks to see if a HostSystem is a member of a ResourcePool through cluster membership or if the HostSystem ID matches the ID of a standalone host ComputeResource . An error is returned if it is not a member of the cluster to which the resource pool belongs or if there was some sort of other error with checking . This is used as an extra validation before a VM creation happens or vMotion to a specific host is attempted .