Ejemplo n.º 1
0
func main() {

	defer func() {
		if r := recover(); r != nil {
			fmt.Println(r)
			os.Exit(1)
		}
	}()

	utils.LogInfo("\nDeploying Agent Server...")

	var ln string
	var e error
	rd := bufio.NewReader(os.Stdin)

	for {
		ln, e = rd.ReadString('\n')
		println(ln)
		if e != nil {
			panic(e)
		} else if strings.ContainsAny(ln, "AGENT_KUBER_API") {
			break
		}
	}

	if !strings.ContainsAny(ln, "AGENT_KUBER_API") {
		panic("Missing Key, AGENT_KUBER_API. Cannot proceed.")
	}

	kv := strings.Split(ln, "=")
	utils.SetKey("AGENT_KUBER_API", kv[1])

	pk, puk, _ := utils.CreateSSHKey()

	c := deploy.CenturyLink{
		PublicSSHKey:   puk,
		APIUsername:    os.Getenv("USERNAME"),
		APIPassword:    os.Getenv("PASSWORD"),
		GroupID:        os.Getenv("GROUP_ID"),
		CPU:            1,
		MemoryGB:       1,
		TCPOpenPorts:   []int{3001},
		ServerName:     "AGENT",
		ServerTemplate: "UBUNTU-14-64-TEMPLATE",
	}

	utils.LogInfo("\nWaiting for server creation...")
	s, e := c.DeployVM()

	if e != nil {
		panic(e)
	}

	utils.SetKey("AGENT_PRIVATE_KEY", base64.StdEncoding.EncodeToString([]byte(pk)))
	utils.SetKey("AGENT_PUBLIC_IP", s.PublicIP)

	utils.LogInfo("\nAgent server deployment complete!!")
}
Ejemplo n.º 2
0
func main() {

	defer func() {
		if r := recover(); r != nil {
			fmt.Println(r)
			os.Exit(1)
		}
	}()

	mIP := ""
	mPrIP := ""
	mPK := ""
	var miIP []string

	c, _ := strconv.Atoi(os.Getenv("MINION_COUNT"))

	if c == 0 {
		panic("\nPlease make sure you have at least one minion in the cluster.")
	}

	params := provision.Params{MinionCount: c}

	cp := provision.New("centurylink")
	s, e := cp.ProvisionCluster(params)

	if e != nil {
		panic(e.Error())
	}

	for _, v := range s {
		if v.PrivateSSHKey == "" {
			miIP = append(miIP, v.PrivateIP)
		} else {
			mIP = v.PublicIP
			mPK = v.PrivateSSHKey
			mPrIP = v.PrivateIP
		}
	}

	utils.SetKey("MASTER_PUBLIC_IP", mIP)
	utils.SetKey("MASTER_PRIVATE_IP", mPrIP)
	utils.SetKey("MASTER_PRIVATE_KEY", base64.StdEncoding.EncodeToString([]byte(mPK)))
	utils.SetKey("MINION_IPS", strings.Join(miIP, ","))
}