Exemple #1
0
func readContainerTransact(view db.Database, dir directory) {
	minion, err := view.MinionSelf()
	worker := err == nil && minion.Role == db.Worker

	for _, container := range view.SelectFromContainer(nil) {
		container.IP = ""
		var labels []string
		if children, ok := dir[container.DockerID]; ok {
			json.Unmarshal([]byte(children["Labels"]), &labels)

			container.IP = children["IP"]
			ip := net.ParseIP(container.IP).To4()
			if ip != nil {
				container.Mac = fmt.Sprintf("02:00:%02x:%02x:%02x:%02x",
					ip[0], ip[1], ip[2], ip[3])
			}
		}

		if worker {
			// Masters get their labels from the policy, workers from the
			// etcd store.
			container.Labels = labels
		}

		view.Commit(container)
	}
}
Exemple #2
0
func checkSupervisorInit(view db.Database) bool {
	self, err := view.MinionSelf()
	return err == nil && self.SupervisorInit
}