vsphere/config.go
func (c *Config) SavedVimSessionOrNew(u *url.URL) (*govmomi.Client, error) {
	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()

	client, err := c.LoadVimClient()
	if err != nil {
		return nil, fmt.Errorf("error trying to load vSphere SOAP session from disk: %s", err)
	}
	if client == nil {
		log.Printf("[DEBUG] Creating new SOAP API session on endpoint %s", c.VSphereServer)
		client, err = govmomi.NewClient(ctx, u, c.InsecureFlag)
		if err != nil {
			return nil, fmt.Errorf("error setting up new vSphere SOAP client: %s", err)
		}
		log.Println("[DEBUG] SOAP API session creation successful")
	}
	return client, nil
}
func (c *Config) SavedVimSessionOrNew(u *url.URL) (*govmomi.Client, error) {
	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()

	client, err := c.LoadVimClient()
	if err != nil {
		return nil, fmt.Errorf("error trying to load vSphere SOAP session from disk: %s", err)
	}
	if client == nil {
		log.Printf("[DEBUG] Creating new SOAP API session on endpoint %s", c.VSphereServer)
		client, err = govmomi.NewClient(ctx, u, c.InsecureFlag)
		if err != nil {
			return nil, fmt.Errorf("error setting up new vSphere SOAP client: %s", err)
		}
		log.Println("[DEBUG] SOAP API session creation successful")
	}
	return client, nil
}
func ( c * Config ) SavedVimSessionOrNew ( u * url . URL ) ( * govmomi . Client , error ) { ctx , cancel := context . WithTimeout ( context . Background ( ) , defaultAPITimeout ) defer cancel ( ) client , err := c . LoadVimClient ( ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if client == nil { log . Printf ( " " , c . VSphereServer ) client , err = govmomi . NewClient ( ctx , u , c . InsecureFlag ) if err != nil { return nil , fmt . Errorf ( " " , err ) } log . Println ( " " ) } return client , nil }
// SavedVimSessionOrNew either loads a saved SOAP session from disk, or creates
// a new one.
SavedVimSessionOrNew either loads a saved SOAP session from disk or creates a new one .