Пример #1
0
func vSphereSessionGet(sessconfig *session.Config) (*session.Session, error) {
	session := session.NewSession(sessconfig)
	ctx := context.Background()
	_, err := session.Connect(ctx)
	if err != nil {
		log.Warnf("Unable to connect: %s", err)
		return nil, err
	}

	_, err = session.Populate(ctx)
	if err != nil {
		// not a critical error for vicadmin
		log.Warnf("Unable to populate session: %s", err)
	}
	return session, nil
}
Пример #2
0
func client() (*session.Session, error) {
	defer trace.End(trace.Begin(""))

	ctx := context.Background()

	session := session.NewSession(&config.Config)
	_, err := session.Connect(ctx)
	if err != nil {
		return nil, err
	}

	_, err = session.Populate(ctx)
	if err != nil {
		// no a critical error for vicadmin
		log.Warn(err)
	}

	return session, nil
}