// return an initialized Openldap
548565
func NewOpenldap() *Openldap {
	return &Openldap{
		Host:               "localhost",
		Port:               389,
		SSL:                "",
		TLS:                "",
		InsecureSkipVerify: false,
		SSLCA:              "",
		TLSCA:              "",
		BindDn:             "",
		BindPassword:       "",
		ReverseMetricNames: false,
	}
}
404929
func (auth *AuthProxy) GetUserIDViaLDAP() (int64, *Error) {
	query := &models.LoginUserQuery{
		ReqContext: auth.ctx,
		Username:   auth.header,
	}

	config := readLDAPConfig()
	if len(config.Servers) == 0 {
		return 0, newError("No LDAP servers available", nil)
	}

	for _, server := range config.Servers {
		author := auth.LDAP(server)
		if err := author.SyncUser(query); err != nil {
			return 0, newError(err.Error(), nil)
		}
	}

	return query.User.Id, nil
}
1003310
func NewLDAPQuery(config config.LDAPQuery) (LDAPQuery, error) {
	scope, err := DetermineLDAPScope(config.Scope)
	if err != nil {
		return LDAPQuery{}, err
	}

	derefAliases, err := DetermineDerefAliasesBehavior(config.DerefAliases)
	if err != nil {
		return LDAPQuery{}, err
	}

	return LDAPQuery{
		BaseDN:       config.BaseDN,
		Scope:        scope,
		DerefAliases: derefAliases,
		TimeLimit:    config.TimeLimit,
		Filter:       config.Filter,
		PageSize:     config.PageSize,
	}, nil
}
1040868
func Init(root string, _ []string) (volume.Driver, error) {
	if !volume.IsBtrfsFilesystem(root) {
		return nil, ErrBtrfsInvalidFilesystem
	}
	// get the driver object id
	objectID := "5" // root driver is always 5 unless it is a subvolume
	raw, err := volume.RunBtrFSCmd(volume.IsSudoer(), "subvolume", "show", root)
	if err != nil {
		glog.Errorf("Could not initialize btrfs driver for %s: %s (%s)", root, raw, err)
		return nil, volume.ErrBtrfsCommand
	}
	if obidmatch := regexp.MustCompile("Object ID:\\s+(\\w+)").FindSubmatch(raw); len(obidmatch) == 2 {
		objectID = string(obidmatch[1])
	}
	driver := &BtrfsDriver{
		sudoer:   volume.IsSudoer(),
		root:     root,
		objectID: objectID,
	}
	// Create future metadata dir, into which we can put stuff, but for now is
	// used for detection of type
	if err := os.MkdirAll(driver.MetadataDir(), 0755); err != nil && !os.IsExist(err) {
		return nil, err
	}
	if err := volume.TouchFlagFile(driver.poolDir()); err != nil {
		return nil, err
	}
	return driver, nil
}
738661
func (t *Team) GetLDAPDN() string {
	if t == nil || t.LDAPDN == nil {
		return ""
	}
	return *t.LDAPDN
}
453748
func init() {
	log.Out = os.Stdout
	if debug {
		log.Level = logger.DebugLevel
	}
}
118907
func WithHelloWorldApp(f func(dir string)) {
	dir, err := ioutil.TempDir("", "simple-app")
	Expect(err).ToNot(HaveOccurred())
	defer os.RemoveAll(dir)

	tempfile := filepath.Join(dir, "index.html")
	err = ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %d", rand.Int())), 0666)
	Expect(err).ToNot(HaveOccurred())

	err = ioutil.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666)
	Expect(err).ToNot(HaveOccurred())

	f(dir)
}
968774
func (t *TeamLDAPMapping) GetLDAPDN() string {
	if t == nil || t.LDAPDN == nil {
		return ""
	}
	return *t.LDAPDN
}
682107
func init() {
	// Registry archci database models.
	models.RegisterModels()

	// Initialize database with environment variables.
	server := ""
	username := "root"
	password := "root"
	database := "mysql"

	if os.Getenv(ENV_MYSQL_SERVER) != "" {
		server = os.Getenv(ENV_MYSQL_SERVER)
	}
	if os.Getenv(ENV_MYSQL_USERNAME) != "" {
		username = os.Getenv(ENV_MYSQL_USERNAME)
	}
	if os.Getenv(ENV_MYSQL_PASSWORD) != "" {
		password = os.Getenv(ENV_MYSQL_PASSWORD)
	}
	if os.Getenv(ENV_MYSQL_DATABASE) != "" {
		database = os.Getenv(ENV_MYSQL_DATABASE)
	}

	// The datasource looks like "root:root@/archci?charset=utf8".
	DATASOURCE := username + ":" + password + "@" + server + "/" + database + "?charset=utf8"
	fmt.Println("Connect to database with " + DATASOURCE)

	orm.RegisterDriver(MYSQL_DRIVER, orm.DR_MySQL)
	orm.RegisterDataBase("default", MYSQL_DRIVER, DATASOURCE, 30)
	orm.RunSyncdb("default", false, true)
}
940055
func (r *MachineInitReader) GetInitConfig() (map[string]interface{}, error) {
	series := r.config.Series

	containerOS, err := utilsseries.GetOSFromSeries(series)
	if err != nil {
		return nil, errors.Trace(err)
	}
	switch containerOS {
	case utilsos.Ubuntu, utilsos.CentOS, utilsos.OpenSUSE:
		if series != utilsseries.MustHostSeries() {
			logger.Debugf("not attempting to get init config for %s, series of machine and container differ", series)
			return nil, nil
		}
	default:
		logger.Debugf("not attempting to get init config for %s container", series)
		return nil, nil
	}

	machineCloudInitData, err := r.getMachineCloudCfgDirData()
	if err != nil {
		return nil, errors.Trace(err)
	}

	file := filepath.Join(r.config.CloudInitInstanceConfigDir, "vendor-data.txt")
	vendorData, err := r.unmarshallConfigFile(file)
	if err != nil {
		return nil, errors.Trace(err)
	}
	for k, v := range vendorData {
		machineCloudInitData[k] = v
	}

	_, curtinData, err := fileAsConfigMap(r.config.CurtinInstallConfigFile)
	if err != nil {
		return nil, errors.Trace(err)
	}
	for k, v := range curtinData {
		machineCloudInitData[k] = v
	}

	return machineCloudInitData, nil
}
206171
func Init(ic ipamapi.Callback, l, g interface{}) error {
	var (
		ok                bool
		localDs, globalDs datastore.DataStore
	)

	if l != nil {
		if localDs, ok = l.(datastore.DataStore); !ok {
			return errors.New("incorrect local datastore passed to built-in ipam init")
		}
	}

	if g != nil {
		if globalDs, ok = g.(datastore.DataStore); !ok {
			return errors.New("incorrect global datastore passed to built-in ipam init")
		}
	}

	ipamutils.ConfigLocalScopeDefaultNetworks(GetDefaultIPAddressPool())

	a, err := ipam.NewAllocator(localDs, globalDs)
	if err != nil {
		return err
	}

	cps := &ipamapi.Capability{RequiresRequestReplay: true}

	return ic.RegisterIpamDriverWithCapabilities(ipamapi.DefaultIPAM, a, cps)
}
1156360
func (sdn *OpenShiftSDN) Init() error {
	// Build the informers
	var err error
	err = sdn.buildInformers()
	if err != nil {
		return fmt.Errorf("failed to build informers: %v", err)
	}

	// Configure SDN
	err = sdn.initSDN()
	if err != nil {
		return fmt.Errorf("failed to initialize SDN: %v", err)
	}

	// Configure the proxy
	err = sdn.initProxy()
	if err != nil {
		return fmt.Errorf("failed to initialize proxy: %v", err)
	}

	return nil
}
567608
func (n *NewTeam) GetLDAPDN() string {
	if n == nil || n.LDAPDN == nil {
		return ""
	}
	return *n.LDAPDN
}
465435
func GLLoadLibrary(path string) error {
	return errorFromInt(int(
		C.SDL_GL_LoadLibrary(C.CString(path))))
}
1145929
func Init(root string, options []string) (volume.Driver, error) {
	driver := &DeviceMapperDriver{
		root:    root,
		options: options,
	}

	if err := driver.ensureInitialized(); err != nil {
		return nil, err
	}

	driver.cleanUpSnapshots()

	return driver, nil
}
1154091
func isOld(rootDir string) (bool, error) {
	d, err := os.Open(rootDir)
	if err != nil {
		return false, trace.ConvertSystemError(err)
	}
	defer d.Close()

	files, err := d.Readdir(0)
	if err != nil {
		return false, trace.ConvertSystemError(err)
	}

	for _, fi := range files {
		if fi.IsDir() {
			return true, nil
		}
	}

	return false, nil
}
679331
func InitMultiFileAndConsole(rootdir, filename string, toStderrLevel logger.Level) error {
	multifileOpts := makeMultiFileOpts(rootdir, filename)
	consoleOpts := makeConsoleOpts(toStderrLevel)
	p := provider.NewMixProvider(provider.NewMultiFile(multifileOpts), provider.NewConsole(consoleOpts))
	return InitWithProvider(p)
}