예제 #1
0
func (p *dockerProvisioner) Shell(opts provision.ShellOptions) error {
	var (
		c   *container.Container
		err error
	)
	c, err = p.GetContainerByBox(opts.Box)

	if err != nil {
		return err
	}
	return c.Shell(p, opts.Conn, opts.Conn, opts.Conn, container.Pty{Width: opts.Width, Height: opts.Height, Term: opts.Term})
}
예제 #2
0
func (s *S) newContainer(opts *newContainerOpts, p *dockerProvisioner) (*container.Container, error) {
	container := container.Container{
		Id:       "id",
		PublicIp: "10.10.10.10",
		HostPort: "3333",
		HostAddr: "127.0.0.1",
	}
	if p == nil {
		p = s.p
	}
	image := "github.com/megamsys/vertice/python:latest"
	var customData map[string]interface{}
	if opts != nil {
		if opts.Image != "" {
			image = opts.Image
		}
		container.Status = opts.Status
		container.BoxName = opts.BoxName
		if opts.Provisioner != nil {
			p = opts.Provisioner
		}
	}
	err := s.newFakeImage(p, image, customData)
	if err != nil {
		return nil, err
	}
	if container.BoxName == "" {
		container.BoxName = "container"
	}
	port := "9999"
	if err != nil {
		return nil, err
	}
	ports := map[docker.Port]struct{}{
		docker.Port(port + "/tcp"): {},
	}
	config := docker.Config{
		Image:        image,
		Cmd:          []string{"ps"},
		ExposedPorts: ports,
	}
	_, c, err := p.Cluster().CreateContainer(docker.CreateContainerOptions{Config: &config})
	if err != nil {
		return nil, err
	}
	container.Id = c.ID
	container.Image = image
	imageId := "testimageid"

	err = s.newFakeImage(p, imageId, nil)
	if err != nil {
		return nil, err
	}
	return &container, nil
}
예제 #3
0
func (s *S) TestContainerGetAddress(c *check.C) {
	container := container.Container{Id: "id123", HostAddr: "10.10.10.10", HostPort: "49153"}
	address := container.Address()
	expected := "http://10.10.10.10:49153"
	c.Assert(address.String(), check.Equals, expected)
}
예제 #4
0
		if rollback != nil {
			for c := range toRollback {
				rollback(c)
			}
		}
		return err
	}

	return nil
}

var updateStatusInRiak = action.Action{
	Name: "update-status-riak",
	Forward: func(ctx action.FWContext) (action.Result, error) {
		args := ctx.Params[0].(runContainerActionsArgs)
		var cont container.Container

		if ctx.Previous != nil {
			cont = ctx.Previous.(container.Container)
		} else {
			ncont, _ := args.provisioner.GetContainerByBox(args.box)
			cont = *ncont
			cont.Image = args.imageId
		}

		if err := cont.SetStatus(args.containerStatus); err != nil {
			return nil, err
		}
		return cont, nil
	},
	Backward: func(ctx action.BWContext) {