示例#1
0
文件: join.go 项目: elleFlorio/gru
func initializeNetwork(address string, port string) {
	err := network.InitializeNetwork(address, port)
	if err != nil {
		log.WithField("err", err).Fatalln("Error initializing the network")
	}
	log.WithField(network.Config().IpAddress+":"+network.Config().Port, "ok").Infoln("Network initialized")
}
示例#2
0
文件: node.go 项目: elleFlorio/gru
func CreateNode(name string, resources *res.Resource) {
	node_UUID, err := utils.GenerateUUID()
	if err != nil {
		log.WithField("err", err).Errorln("Error generating node UUID")
	}
	node_address := "http://" + network.Config().IpAddress + ":" + network.Config().Port
	config := cfg.NodeConfig{node_UUID, name, node_address, "", ""}
	nodeRes := cfg.NodeResources{
		TotalCpus:   resources.CPU.Total,
		TotalMemory: resources.Memory.Total,
	}
	node := cfg.Node{
		Configuration: config,
		Active:        false,
		Resources:     nodeRes,
	}
	cfg.SetNode(node)
}
示例#3
0
文件: join.go 项目: elleFlorio/gru
func getDaemonUrl() string {
	url := cfg.GetAgentDocker().DaemonUrl
	if url == "default" {
		return "unix:///var/run/docker.sock"
	}

	ipPort := strings.Split(url, ":")
	if len(ipPort) < 2 {
		log.WithField("err", "Wrong daemon url").Fatalln("Error initializing container engine")
	}

	var daemonUrl string
	if ipPort[0] == "local" {
		daemonUrl = "http://" + network.Config().IpAddress + ":" + ipPort[1]
	} else {
		daemonUrl = "http://" + ipPort[0] + ":" + ipPort[1]
	}

	return daemonUrl
}
示例#4
0
func SaveInstanceAddress(id string, port string) {
	hostIp := net.Config().IpAddress
	address := hostIp + ":" + port
	addressMap[id] = address
}