func (s *DeployHelperSuite) SetUpSuite(c *C) {
	crypto.Init()
	dns.Provider = FakeDNSProvider(true)
	zkTestServer = zookeeper.NewZkTestServer()
	c.Assert(zkTestServer.Init(), IsNil)
	datamodel.Zk = zkTestServer.Zk
}
示例#2
0
func (m *ManagerServer) Run(bldr builder.Builder) {
	smtpCC := []string{}
	builder.DefaultBuilder = bldr

	if m.Config.SMTPCC != "" {
		smtpCC = strings.Split(m.Config.SMTPCC, ",")
	}

	smtp.Init(m.Config.SMTPAddr, m.Config.SMTPFrom, smtpCC)
	if err := crypto.Init(); err != nil {
		panic(fmt.Sprintf("Error initializing crypto: %s", err.Error()))
	}
	log.Println("Fate rarely calls upon us at a moment of our choosing.")
	log.Println("                                                       -- Manager\n")
	ldap.Init(m.Config.LdapHost, m.Config.LdapPort, m.Config.LdapBaseDomain)
	Host = m.Config.Host
	Region = m.Config.Region
	Zone = m.Config.Zone
	AvailableZones = strings.Split(m.Config.AvailableZones, ",")
	log.Printf("Initializing Manager [%s] [%s] [%s]", Region, Zone, Host)
	datamodel.Init(m.Config.ZookeeperUri)
	datamodel.MinRouterPort = m.Config.MinRouterPort
	datamodel.MaxRouterPort = m.Config.MaxRouterPort
	resultDuration, err := time.ParseDuration(m.Config.ResultDuration)
	if err != nil {
		panic(fmt.Sprintf("Could not parse Result Duration: %s", err.Error()))
	}
	handleError(rpc.Init(m.Config.RpcAddr, m.Config.SupervisorPort, m.Config.CPUSharesIncrement,
		m.Config.MemoryLimitIncrement, resultDuration))
	handleError(api.Init(m.Config.ApiAddr))
	err = m.LDAPInit()
	if err != nil {
		log.Fatalln(err)
	}
	maintenanceCheckInterval, err := time.ParseDuration(m.Config.MaintenanceCheckInterval)
	if err != nil {
		log.Fatalln(err)
	}
	superUserCheckInterval, err := time.ParseDuration(m.Config.SuperUserOnlyCheckInterval)
	if err != nil {
		log.Fatalln(err)
	}
	MaintenanceChecker(m.Config.MaintenanceFile, maintenanceCheckInterval)
	rpc.SuperUserOnlyChecker(m.Config.SuperUserOnlyFile, superUserCheckInterval)
	go signalListener()
	go rpc.Listen()
	api.Listen()
}
示例#3
0
func (ih *Supervisor) Run() {
	ih.parser.Parse()
	log.Println("You feelin' lucky, punk?")
	log.Println("                          -- Supervisor\n")
	crypto.Init()
	overlayConfig()
	Region = config.Region
	Zone = config.Zone
	Price = config.Price
	log.Printf("Initializing Atlantis Supervisor [%s] [%s]", Region, Zone)
	handleError(containers.Init(config.RegistryHost, config.SaveDir, config.NumContainers, config.NumSecondary,
		config.MinPort, config.CPUShares, config.MemoryLimit, config.EnableNetsec))
	handleError(rpc.Init(config.RpcAddr))
	maintenanceCheckInterval, err := time.ParseDuration(config.MaintenanceCheckInterval)
	if err != nil {
		log.Fatalln(err)
	}
	go healthz.Run(8080)
	go signalListener()
	MaintenanceChecker(config.MaintenanceFile, maintenanceCheckInterval)
	rpc.Listen()
}
示例#4
0
func (s *DatamodelSuite) TestApp(c *C) {
	crypto.Init()
	Zk.RecursiveDelete(helper.GetBaseAppPath())
	Zk.RecursiveDelete(helper.GetBaseEnvPath())
	Env("prod").Save()
	Env("staging").Save()
	apps, err := ListRegisteredApps()
	c.Assert(err, Not(IsNil)) // the path doesn't exist. this is an error
	c.Assert(len(apps), Equals, 0)
	app1, err := GetApp(app)
	c.Assert(err, Not(IsNil))
	app1, err = CreateOrUpdateApp(true, true, "app1", "", "", "*****@*****.**")
	c.Assert(err, IsNil)
	c.Assert(app1.NonAtlantis, Equals, true)
	c.Assert(app1.Internal, Equals, true)
	c.Assert(app1.Name, Equals, "app1")
	c.Assert(app1.Repo, Equals, "")
	c.Assert(app1.Root, Equals, "")
	c.Assert(app1.Email, Equals, "*****@*****.**")
	app2, err := CreateOrUpdateApp(false, true, "app2", repo, root, "*****@*****.**")
	c.Assert(err, IsNil)
	c.Assert(app2.NonAtlantis, Equals, false)
	c.Assert(app2.Internal, Equals, true)
	c.Assert(app2.Name, Equals, "app2")
	c.Assert(app2.Repo, Equals, repo)
	c.Assert(app2.Root, Equals, root)
	c.Assert(app2.Email, Equals, "*****@*****.**")

	// verify ListRegisteredApps
	apps, err = ListRegisteredApps()
	c.Assert(err, IsNil)
	c.Assert(len(apps), Equals, 2)

	// attempt to set env/app data
	c.Assert(app1.AddDependerEnvData(&types.DependerEnvData{
		Name:          "prod",
		SecurityGroup: map[string][]uint16{"1.1.1.1": []uint16{1111}, "1.1.1.2": []uint16{1111}},
		DataMap: map[string]interface{}{
			"dep1": "prodvalue1",
		},
	}), IsNil)
	c.Assert(app1.AddDependerAppData(&types.DependerAppData{
		Name: "app2",
		DependerEnvData: map[string]*types.DependerEnvData{
			"prod": &types.DependerEnvData{
				Name: "prod",
				DataMap: map[string]interface{}{
					"dep2": "prodvalue2",
				},
			},
		},
	}), IsNil)
	c.Assert(app1.AddDependerEnvDataForDependerApp("app2", &types.DependerEnvData{
		Name:          "staging",
		SecurityGroup: map[string][]uint16{"1.1.2.1": []uint16{1121}, "1.1.2.2": []uint16{1121}},
		DataMap: map[string]interface{}{
			"dep1": "stagingvalue1",
		},
	}), IsNil)

	// ensure data is encrypted
	app1, err = GetApp("app1")
	c.Assert(err, IsNil)
	c.Assert(app1.NonAtlantis, Equals, true)
	c.Assert(app1.Internal, Equals, true)
	c.Assert(app1.Name, Equals, "app1")
	c.Assert(app1.Repo, Equals, "")
	c.Assert(app1.Root, Equals, "")
	c.Assert(app1.Email, Equals, "*****@*****.**")
	c.Assert(app1.GetDependerEnvData("somethingthatdoesntexist", false), IsNil)
	prodEnvData := app1.GetDependerEnvData("prod", false)
	c.Assert(prodEnvData, Not(IsNil))
	c.Assert(prodEnvData.EncryptedData, Not(Equals), "")
	c.Assert(prodEnvData.DataMap, IsNil)
	appData := app1.GetDependerAppData("app2", false)
	c.Assert(appData, Not(IsNil))
	for _, envData := range appData.DependerEnvData {
		c.Assert(envData.EncryptedData, Not(Equals), "")
		c.Assert(envData.DataMap, IsNil)
	}
	prodEnvData = app1.GetDependerEnvDataForDependerApp("app2", "staging", false)
	c.Assert(prodEnvData, Not(IsNil))
	c.Assert(prodEnvData.EncryptedData, Not(Equals), "")
	c.Assert(prodEnvData.DataMap, IsNil)

	// check that data is decrypted
	app1, err = GetApp("app1")
	c.Assert(err, IsNil)
	c.Assert(app1.NonAtlantis, Equals, true)
	c.Assert(app1.Internal, Equals, true)
	c.Assert(app1.Name, Equals, "app1")
	c.Assert(app1.Repo, Equals, "")
	c.Assert(app1.Root, Equals, "")
	c.Assert(app1.Email, Equals, "*****@*****.**")
	c.Assert(app1.GetDependerEnvData("somethingthatdoesntexist", true), IsNil)
	prodEnvData = app1.GetDependerEnvData("prod", true)
	c.Assert(prodEnvData, Not(IsNil))
	c.Assert(prodEnvData.DataMap, Not(IsNil))
	appData = app1.GetDependerAppData("app2", true)
	c.Assert(appData, Not(IsNil))
	for _, envData := range appData.DependerEnvData {
		c.Assert(envData.DataMap, Not(IsNil))
	}
	prodEnvData = app1.GetDependerEnvDataForDependerApp("app2", "staging", true)
	c.Assert(prodEnvData, Not(IsNil))
	c.Assert(prodEnvData.DataMap, Not(IsNil))
}