Esempio n. 1
0
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")
}
Esempio n. 2
0
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)
}
Esempio n. 3
0
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
}
Esempio n. 4
0
func SaveInstanceAddress(id string, port string) {
	hostIp := net.Config().IpAddress
	address := hostIp + ":" + port
	addressMap[id] = address
}