Пример #1
0
// Init initializes the master daemon
func (d *MasterDaemon) Init() {
	// set cluster mode
	err := master.SetClusterMode(d.ClusterMode)
	if err != nil {
		log.Fatalf("Failed to set cluster-mode. Error: %s", err)
	}

	// save dns flag
	err = master.SetDNSEnabled(d.DNSEnabled)
	if err != nil {
		log.Fatalf("Failed to set dns-enable. Error: %s", err)
	}

	// initialize state driver
	d.stateDriver, err = initStateDriver(d.ClusterStore)
	if err != nil {
		log.Fatalf("Failed to init state-store. Error: %s", err)
	}

	// Initialize resource manager
	d.resmgr, err = resources.NewStateResourceManager(d.stateDriver)
	if err != nil {
		log.Fatalf("Failed to init resource manager. Error: %s", err)
	}

	// Create an objdb client
	d.objdbClient, err = objdb.NewClient(d.ClusterStore)
	if err != nil {
		log.Fatalf("Error connecting to state store: %v. Err: %v", d.ClusterStore, err)
	}
}
Пример #2
0
// Init initializes the master daemon
func (d *MasterDaemon) Init() {
	// set cluster mode
	err := master.SetClusterMode(d.ClusterMode)
	if err != nil {
		log.Fatalf("Failed to set cluster-mode. Error: %s", err)
	}

	// save dns flag
	err = master.SetDNSEnabled(d.DNSEnabled)
	if err != nil {
		log.Fatalf("Failed to set dns-enable. Error: %s", err)
	}

	// initialize state driver
	d.stateDriver, err = initStateDriver(d.ClusterStore)
	if err != nil {
		log.Fatalf("Failed to init state-store. Error: %s", err)
	}

	// Initialize resource manager
	d.resmgr, err = resources.NewStateResourceManager(d.stateDriver)
	if err != nil {
		log.Fatalf("Failed to init resource manager. Error: %s", err)
	}
}
Пример #3
0
func (d *daemon) execOpts() {
	if err := d.parseOpts(); err != nil {
		log.Fatalf("Failed to parse cli options. Error: %s", err)
	}

	if d.opts.help {
		fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]...\n", os.Args[0])
		flagSet.PrintDefaults()
		os.Exit(0)
	}

	if d.opts.debug {
		log.SetLevel(log.DebugLevel)
	}

	if err := master.SetClusterMode(d.opts.clusterMode); err != nil {
		log.Fatalf("Failed to set cluster-mode. Error: %s", err)
	}

	sd, err := initStateDriver(&d.opts)
	if err != nil {
		log.Fatalf("Failed to init state-store. Error: %s", err)
	}

	if _, err = resources.NewStateResourceManager(sd); err != nil {
		log.Fatalf("Failed to init resource manager. Error: %s", err)
	}

	d.stateDriver = sd
}
Пример #4
0
func execOpts(opts *cliOpts) core.StateDriver {

	if opts.help {
		fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]...\n", os.Args[0])
		flagSet.PrintDefaults()
		os.Exit(0)
	}

	if opts.version {
		fmt.Printf(version.String())
		os.Exit(0)
	}

	log.SetFormatter(&log.TextFormatter{FullTimestamp: true, TimestampFormat: time.StampNano})

	if opts.debug {
		log.SetLevel(log.DebugLevel)
	}

	if err := master.SetClusterMode(opts.clusterMode); err != nil {
		log.Fatalf("Failed to set cluster-mode. Error: %s", err)
	}

	if err := master.SetDNSEnabled(opts.dnsEnabled); err != nil {
		log.Fatalf("Failed to set dns-enable. Error: %s", err)
	}

	sd, err := initStateDriver(opts)
	if err != nil {
		log.Fatalf("Failed to init state-store. Error: %s", err)
	}

	if _, err = resources.NewStateResourceManager(sd); err != nil {
		log.Fatalf("Failed to init resource manager. Error: %s", err)
	}

	return sd
}