Ejemplo n.º 1
0
// SetSubnet sets the subnet used for virtual addresses
func (reg *VIFRegistry) SetSubnet(subnet string) error {
	if err := validation.IsSubnet16(subnet); err != nil {
		return err
	}
	reg.subnet = subnet
	glog.Infof("vif subnet is: %s", reg.subnet)
	return nil
}
Ejemplo n.º 2
0
// cmdInit starts the server if no subcommands are called
func (c *ServicedCli) cmdInit(ctx *cli.Context) error {
	options := api.Options{
		DockerRegistry:       ctx.GlobalString("docker-registry"),
		NFSClient:            ctx.GlobalString("nfs-client"),
		Endpoint:             ctx.GlobalString("endpoint"),
		StaticIPs:            ctx.GlobalStringSlice("static-ip"),
		UIPort:               ctx.GlobalString("uiport"),
		RPCPort:              fmt.Sprintf("%d", ctx.GlobalInt("listen")),
		Listen:               fmt.Sprintf(":%d", ctx.GlobalInt("listen")),
		DockerDNS:            ctx.GlobalStringSlice("docker-dns"),
		Master:               ctx.GlobalBool("master"),
		Agent:                ctx.GlobalBool("agent"),
		MuxPort:              ctx.GlobalInt("mux"),
		TLS:                  true,
		VarPath:              ctx.GlobalString("var"),
		KeyPEMFile:           ctx.GlobalString("keyfile"),
		CertPEMFile:          ctx.GlobalString("certfile"),
		Zookeepers:           ctx.GlobalStringSlice("zk"),
		RemoteZookeepers:     ctx.GlobalStringSlice("remote-zk"),
		Mount:                ctx.GlobalStringSlice("mount"),
		FSType:               ctx.GlobalString("fstype"),
		HostAliases:          ctx.GlobalStringSlice("alias"),
		ESStartupTimeout:     ctx.GlobalInt("es-startup-timeout"),
		ReportStats:          ctx.GlobalBool("report-stats"),
		HostStats:            ctx.GlobalString("host-stats"),
		StatsPeriod:          ctx.GlobalInt("stats-period"),
		MCUsername:           ctx.GlobalString("mc-username"),
		MCPasswd:             ctx.GlobalString("mc-password"),
		Verbosity:            ctx.GlobalInt("v"),
		CPUProfile:           ctx.GlobalString("cpuprofile"),
		MaxContainerAge:      ctx.GlobalInt("max-container-age"),
		MaxDFSTimeout:        ctx.GlobalInt("max-dfs-timeout"),
		VirtualAddressSubnet: ctx.GlobalString("virtual-address-subnet"),
		MasterPoolID:         ctx.GlobalString("master-pool-id"),
		OutboundIP:           ctx.GlobalString("outbound"),
		LogstashES:           ctx.GlobalString("logstash-es"),
		LogstashMaxDays:      ctx.GlobalInt("logstash-max-days"),
		LogstashMaxSize:      ctx.GlobalInt("logstash-max-size"),
		DebugPort:            ctx.GlobalInt("debug-port"),
		AdminGroup:           ctx.GlobalString("admin-group"),
		MaxRPCClients:        ctx.GlobalInt("max-rpc-clients"),
		RPCDialTimeout:       ctx.GlobalInt("rpc-dial-timeout"),
		SnapshotTTL:          ctx.GlobalInt("snapshot-ttl"),
	}
	if os.Getenv("SERVICED_MASTER") == "1" {
		options.Master = true
	}
	if os.Getenv("SERVICED_AGENT") == "1" {
		options.Agent = true
	}

	if err := validation.IsSubnet16(options.VirtualAddressSubnet); err != nil {
		fmt.Fprintf(os.Stderr, "error validating virtual-address-subnet: %s\n", err)
		return fmt.Errorf("error validating virtual-address-subnet: %s", err)
	}

	api.LoadOptions(options)

	// Set logging options
	if err := setLogging(ctx); err != nil {
		fmt.Println(err)
	}

	if err := setIsvcsEnv(ctx); err != nil {
		fmt.Println(err)
		return err
	}

	if options.Master {
		fmt.Println("This master has been configured to be in pool: " + options.MasterPoolID)
	}

	// Start server mode
	if (options.Master || options.Agent) && len(ctx.Args()) == 0 {
		rpcutils.RPC_CLIENT_SIZE = options.MaxRPCClients
		c.driver.StartServer()
		return fmt.Errorf("running server mode")
	}

	return nil
}