예제 #1
0
func atlasListenerFactory(config map[string]string, logger io.Writer) (net.Listener, map[string]string, ReloadFunc, error) {
	scadaConfig := &scada.Config{
		Service:      "vault",
		Version:      version.GetVersion().String(),
		ResourceType: "vault-cluster",
		Meta: map[string]string{
			"node_id": config["node_id"],
		},
		Atlas: scada.AtlasConfig{
			Endpoint:       config["endpoint"],
			Infrastructure: config["infrastructure"],
			Token:          config["token"],
		},
	}

	provider, list, err := scada.NewHTTPProvider(scadaConfig, logger)
	if err != nil {
		return nil, nil, nil, err
	}

	ln := &SCADAListener{
		ln:            list,
		scadaProvider: provider,
	}

	props := map[string]string{
		"addr":           "Atlas/SCADA",
		"infrastructure": scadaConfig.Atlas.Infrastructure,
	}

	return listenerWrapTLS(ln, props, config)
}
예제 #2
0
파일: command.go 프로젝트: hashicorp/consul
// startScadaClient is used to start a new SCADA provider and listener,
// replacing any existing listeners.
func (c *Command) setupScadaConn(config *Config) error {
	// Shut down existing SCADA listeners
	if c.scadaProvider != nil {
		c.scadaProvider.Shutdown()
	}
	if c.scadaHttp != nil {
		c.scadaHttp.Shutdown()
	}

	// No-op if we don't have an infrastructure
	if config.AtlasInfrastructure == "" {
		return nil
	}

	c.Ui.Error("WARNING: The hosted version of Consul Enterprise will be deprecated " +
		"on March 7th, 2017. For details, see " +
		"https://atlas.hashicorp.com/help/consul/alternatives")

	scadaConfig := &scada.Config{
		Service:      "consul",
		Version:      fmt.Sprintf("%s%s", config.Version, config.VersionPrerelease),
		ResourceType: "infrastructures",
		Meta: map[string]string{
			"auto-join":  strconv.FormatBool(config.AtlasJoin),
			"datacenter": config.Datacenter,
			"server":     strconv.FormatBool(config.Server),
		},
		Atlas: scada.AtlasConfig{
			Endpoint:       config.AtlasEndpoint,
			Infrastructure: config.AtlasInfrastructure,
			Token:          config.AtlasToken,
		},
	}

	// Create the new provider and listener
	c.Ui.Output("Connecting to Atlas: " + config.AtlasInfrastructure)
	provider, list, err := scada.NewHTTPProvider(scadaConfig, c.logOutput)
	if err != nil {
		return err
	}
	c.scadaProvider = provider
	c.scadaHttp = newScadaHttp(c.agent, list)
	return nil
}
예제 #3
0
파일: command.go 프로젝트: hooklift/nomad
// setupSCADA is used to start a new SCADA provider and listener,
// replacing any existing listeners.
func (c *Command) setupSCADA(config *Config) error {
	// Shut down existing SCADA listeners
	if c.scadaProvider != nil {
		c.scadaProvider.Shutdown()
	}
	if c.scadaHttp != nil {
		c.scadaHttp.Shutdown()
	}

	// No-op if we don't have an infrastructure
	if config.Atlas == nil || config.Atlas.Infrastructure == "" {
		return nil
	}

	// Create the new provider and listener
	c.Ui.Output("Connecting to Atlas: " + config.Atlas.Infrastructure)

	scadaConfig := &scada.Config{
		Service:      "nomad",
		Version:      fmt.Sprintf("%s%s", config.Version, config.VersionPrerelease),
		ResourceType: "nomad-cluster",
		Meta: map[string]string{
			"auto-join":  strconv.FormatBool(config.Atlas.Join),
			"region":     config.Region,
			"datacenter": config.Datacenter,
			"client":     strconv.FormatBool(config.Client != nil && config.Client.Enabled),
			"server":     strconv.FormatBool(config.Server != nil && config.Server.Enabled),
		},
		Atlas: scada.AtlasConfig{
			Endpoint:       config.Atlas.Endpoint,
			Infrastructure: config.Atlas.Infrastructure,
			Token:          config.Atlas.Token,
		},
	}

	provider, list, err := scada.NewHTTPProvider(scadaConfig, c.logOutput)
	if err != nil {
		return err
	}
	c.scadaProvider = provider
	c.scadaHttp = newScadaHttp(c.agent, list)
	return nil
}
예제 #4
0
func atlasListenerFactory(config map[string]string, logger io.Writer) (net.Listener, map[string]string, vault.ReloadFunc, error) {
	scadaConfig := &scada.Config{
		Service:      "vault",
		Version:      version.GetVersion().VersionNumber(),
		ResourceType: "vault-cluster",
		Meta: map[string]string{
			"node_id":      config["node_id"],
			"cluster_name": config["cluster_name"],
		},
		Atlas: scada.AtlasConfig{
			Endpoint:       config["endpoint"],
			Infrastructure: config["infrastructure"],
			Token:          config["token"],
		},
	}

	provider, list, err := scada.NewHTTPProvider(scadaConfig, logger)
	if err != nil {
		return nil, nil, nil, err
	}

	ln := &SCADAListener{
		ln:            list,
		scadaProvider: provider,
	}

	props := map[string]string{
		"addr":           "Atlas/SCADA",
		"infrastructure": scadaConfig.Atlas.Infrastructure,
	}

	// The outer connection is already TLS-enabled; this is just the listener
	// that reaches back inside that connection
	config["tls_disable"] = "1"

	return listenerWrapTLS(ln, props, config)
}