Пример #1
0
func main() {
	processCmdLineFlags()

	log.WithFields(log.Fields{
		"gitcommit": GITCOMMIT,
	}).Info("Starting go-machine-service...")
	eventHandlers := map[string]events.EventHandler{
		"physicalhost.create":    handlers.CreateMachine,
		"physicalhost.bootstrap": handlers.ActivateMachine,
		"physicalhost.remove":    handlers.PurgeMachine,
		"ping":                   handlers.PingNoOp,
	}

	apiUrl := os.Getenv("CATTLE_URL")
	accessKey := os.Getenv("CATTLE_ACCESS_KEY")
	secretKey := os.Getenv("CATTLE_SECRET_KEY")

	router, err := events.NewEventRouter("goMachineService", 2000, apiUrl, accessKey, secretKey,
		nil, eventHandlers, "physicalhost", 10)
	if err != nil {
		log.WithFields(log.Fields{
			"Err": err,
		}).Error("Unable to create EventRouter")
	} else {
		err := router.Start(nil)
		if err != nil {
			log.WithFields(log.Fields{
				"Err": err,
			}).Error("Unable to start EventRouter")
		}
	}
	log.Info("Exiting go-machine-service...")
}
Пример #2
0
func ConnectToEventStream(conf config.Config) error {

	kClient := kubernetesclient.NewClient(conf.KubernetesURL, false)
	dClient, err := dockerclient.NewDockerClient()
	if err != nil {
		return err
	}
	sh := syncHandler{
		kClient: kClient,
		dClient: dClient,
	}
	ph := PingHandler{}

	eventHandlers := map[string]revents.EventHandler{
		"compute.instance.providelabels": sh.Handler,
		"config.update":                  ph.Handler,
		"ping":                           ph.Handler,
	}

	router, err := revents.NewEventRouter("", 0, conf.CattleURL, conf.CattleAccessKey, conf.CattleSecretKey, nil, eventHandlers, "", conf.WorkerCount)
	if err != nil {
		return err
	}
	err = router.Run(nil)
	return err
}
Пример #3
0
func ConnectToEventStream(conf Config) error {
	convoy, err := volume.NewConvoyClient(conf.Socket)
	log.Infof("Socket file: %v", conf.Socket)
	if err != nil {
		return err
	}

	vdh := volumeRemoveHandler{
		convoyClient: convoy,
	}
	nh := noopHandler{}
	ph := PingHandler{}

	eventHandlers := map[string]revents.EventHandler{
		"storage.volume.activate":   nh.Handler,
		"storage.volume.deactivate": nh.Handler,
		"storage.volume.remove":     vdh.Handler,
		"ping":                      ph.Handler,
	}

	router, err := revents.NewEventRouter("", 0, conf.CattleURL, conf.CattleAccessKey, conf.CattleSecretKey, nil, eventHandlers, "", conf.WorkerCount)
	if err != nil {
		return err
	}
	err = router.StartWithoutCreate(nil)
	return err
}
Пример #4
0
func main() {
	log.WithFields(log.Fields{
		"gitcommit": GITCOMMIT,
	}).Info("Starting rancher-compose-executor")

	eventHandlers := map[string]events.EventHandler{
		"environment.create": handlers.CreateEnvironment,
		"ping":               handlers.PingNoOp,
	}

	apiUrl := os.Getenv("CATTLE_URL")
	accessKey := os.Getenv("CATTLE_ACCESS_KEY")
	secretKey := os.Getenv("CATTLE_SECRET_KEY")

	router, err := events.NewEventRouter("rancher-compose-executor", 2000, apiUrl, accessKey, secretKey, nil, eventHandlers, "environment", 10)
	if err != nil {
		log.WithFields(log.Fields{
			"error": err,
		}).Error("Unable to create event router")
	} else {
		err := router.Start(nil)
		if err != nil {
			log.WithFields(log.Fields{
				"error": err,
			}).Error("Unable to start event router")
		}
	}
	log.Info("Exiting rancher-compose-executor")
}
Пример #5
0
func main() {
	logger := logrus.WithFields(logrus.Fields{
		"gitcommit": GITCOMMIT,
	})

	logger.Info("Starting rancher-compose-executor")

	eventHandlers := map[string]events.EventHandler{
		"environment.create": handlers.CreateEnvironment,
		"ping": func(event *events.Event, apiClient *client.RancherClient) error {
			return nil
		},
	}

	router, err := events.NewEventRouter("rancher-compose-executor", 2000,
		os.Getenv("CATTLE_URL"),
		os.Getenv("CATTLE_ACCESS_KEY"),
		os.Getenv("CATTLE_SECRET_KEY"),
		nil, eventHandlers, "environment", 10)
	if err != nil {
		logrus.WithField("error", err).Fatal("Unable to create event router")
	}

	if err := router.Start(nil); err != nil {
		logrus.WithField("error", err).Fatal("Unable to start event router")
	}

	logger.Info("Exiting rancher-compose-executor")
}
Пример #6
0
func Main() {
	logger := logrus.WithFields(logrus.Fields{
		"version": version.VERSION,
	})

	logger.Info("Starting rancher-compose-executor")

	eventHandlers := map[string]events.EventHandler{
		"environment.create":        handlers.WithLock(handlers.CreateEnvironment),
		"environment.upgrade":       handlers.WithLock(handlers.UpgradeEnvironment),
		"environment.finishupgrade": handlers.WithLock(handlers.FinishUpgradeEnvironment),
		"environment.rollback":      handlers.WithLock(handlers.RollbackEnvironment),
		"ping": func(event *events.Event, apiClient *client.RancherClient) error {
			return nil
		},
	}

	router, err := events.NewEventRouter("rancher-compose-executor", 2000,
		os.Getenv("CATTLE_URL"),
		os.Getenv("CATTLE_ACCESS_KEY"),
		os.Getenv("CATTLE_SECRET_KEY"),
		nil, eventHandlers, "environment", 10)
	if err != nil {
		logrus.WithField("error", err).Fatal("Unable to create event router")
	}

	if err := router.Start(nil); err != nil {
		logrus.WithField("error", err).Fatal("Unable to start event router")
	}

	logger.Info("Exiting rancher-compose-executor")
}
Пример #7
0
func ConnectToEventStream(conf config.Config) error {

	kClient := kubernetesclient.NewClient(conf.KubernetesURL, false)

	eventHandlers := map[string]revents.EventHandler{
		"compute.instance.providelabels": eventhandlers.NewProvideLablesHandler(kClient).Handler,
		"config.update":                  eventhandlers.NewPingHandler().Handler,
		"ping":                           eventhandlers.NewPingHandler().Handler,
	}

	router, err := revents.NewEventRouter("", 0, conf.CattleURL, conf.CattleAccessKey, conf.CattleSecretKey, nil, eventHandlers, "", conf.WorkerCount)
	if err != nil {
		return err
	}
	err = router.StartWithoutCreate(nil)
	return err
}