Пример #1
0
func (s *S) TestCluster(c *check.C) {
	var p FakeOneProvisioner
	cs, err := buildClusterStorage()
	c.Assert(err, check.IsNil)
	cluster, err := cluster.New(cs, cluster.Node{Address: "127.0.0.1:6767"})
	c.Assert(err, check.IsNil)
	p.cluster = cluster
	c.Assert(p.Cluster(), check.Equals, cluster)
}
Пример #2
0
func newFakeOneProvisioner(servers ...string) (*fakeOneProvisioner, error) {
	var err error
	p := fakeOneProvisioner{
		storage: &cluster.MapStorage{},
	}
	nodes := make([]cluster.Node, len(servers))
	for i, server := range servers {
		nodes[i] = cluster.Node{Address: server}
	}
	p.cluster, err = cluster.New(p.storage, nodes...)
	if err != nil {
		return nil, err
	}
	return &p, nil
}
Пример #3
0
func NewFakeOneProvisioner(servers ...string) (*FakeOneProvisioner, error) {
	var err error
	p := FakeOneProvisioner{
		storage:         &cluster.MapStorage{},
		preparedErrors:  make(chan error, 10),
		preparedResults: make(chan []machine.Machine, 10),
		machines:        make(map[string][]machine.Machine),
	}
	nodes := make([]cluster.Node, len(servers))
	for i, server := range servers {
		nodes[i] = cluster.Node{Address: server}
	}
	p.cluster, err = cluster.New(p.storage, nodes...)
	if err != nil {
		return nil, err
	}
	return &p, nil
}
Пример #4
0
func (p *oneProvisioner) initOneCluster(m map[string]string) error {
	var err error
	if p.storage == nil {
		p.storage, err = buildClusterStorage()
		if err != nil {
			return err
		}
	}
	p.defaultImage = m[api.IMAGE]
	var nodes []cluster.Node = []cluster.Node{cluster.Node{
		Address:  m[api.ENDPOINT],
		Metadata: m,
	},
	}
	//register nodes using the map.
	p.cluster, err = cluster.New(p.storage, nodes...)
	if err != nil {
		return err
	}
	return nil
}