Exemplo n.º 1
0
func join(c *cli.Context) {
	var clusterName string

	if !c.Args().Present() {
		log.Fatalln("Error: missing cluster name")
	} else {
		clusterName = c.Args().First()
	}
	ipAddress := c.String("address")
	port := c.String("port")
	etcdAddress := c.String("etcdserver")
	nodeName := c.String("name")

	// infrastructure
	initializeNetwork(ipAddress, port)
	initializeDiscovery("etcd", etcdAddress)
	// Configuration
	initializeAgent(clusterName)
	initializeServices(clusterName)
	initializePolicy(clusterName)
	initializeAnalytics(clusterName)
	// Core agent services
	initializeStorage()
	initializeMetricSerivice()
	initializeContainerEngine()
	// Resources
	initializeResources()
	initializeNode(nodeName, clusterName)
	// Join Cluster
	registerToCluster(clusterName)
	agent.StartMonitoring()
	defer api.StartServer(port)

	fmt.Printf("Joined cluster %s.\nWaiting for commands...\n", clusterName)
}
Exemplo n.º 2
0
func create(c *cli.Context) {
	var clusterName string
	if !c.Args().Present() {
		log.Fatalln("Error: missing cluster name")
	} else {
		clusterName = c.Args().First()
	}
	// Get etcd address
	etcdAddress := c.String("etcdserver")

	// Initialize etcd client
	discovery.New("etcd", etcdAddress)

	// Generate cluster
	id, err := utils.GenerateUUID()
	if err != nil {
		log.WithField("err", err).Fatalln("Error generating cluster UUID")
	}
	cluster.RegisterCluster(clusterName, id)
	// Print cluster UUID for join
	fmt.Println(clusterName + ":" + id)
}