Esempio n. 1
0
func NewTopology(path string) (*Topology, error) {
	td, err := descriptions.NewTopologyDescription(path)
	if err != nil {
		return nil, err
	}
	mcluster, err := machine.NewCluster(td.GetMachineGlobalOptions())
	if err != nil {
		return nil, err
	}
	clusterOpts := td.GetClusterOptions()
	driver := clusterOpts.String("driver")
	if driver == "" {
		return nil, fmt.Errorf("container cluster driver option missed.")
	}

	m, err := getMasterMachine(clusterOpts, mcluster, td)
	if err != nil {
		return nil, err
	}

	ccluster, err := cluster.NewCluster(driver, clusterOpts, m)
	if err != nil {
		return nil, err
	}

	t := &Topology{
		machineCluster:   mcluster,
		containerCluster: ccluster,
		description:      td,
	}
	ccluster.RegisterEventHandler(TopologyEventsHandler, t)
	return t, nil
}
Esempio n. 2
0
func getMachineCluster() *machine.Cluster {
	opts := make(map[string]string)
	opts["debug"] = "true"
	opts["engine-insecure-registry"] = "registry.intra.weibo.com"
	opts["engine-storage-driver"] = "aufs"
	// options["native-ssh"] = "true"
	cluster, err := machine.NewCluster(&options.Options{Values: opts})
	if err != nil {
		fmt.Printf("Failed to create machine cluster:%s\n", err.Error())
		os.Exit(0)
	}
	return cluster
}