當前位置: 首頁>>代碼示例>>Golang>>正文


Golang provision.Box類代碼示例

本文整理匯總了Golang中github.com/megamsys/vertice/provision.Box的典型用法代碼示例。如果您正苦於以下問題:Golang Box類的具體用法?Golang Box怎麽用?Golang Box使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Box類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getRouterForBox

func getRouterForBox(box *provision.Box) (router.Router, error) {
	routerName, err := box.GetRouter()
	if err != nil {
		return nil, err
	}
	return router.Get(routerName)
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:7,代碼來源:provisioner.go

示例2: deployPipeline

func (p *dockerProvisioner) deployPipeline(box *provision.Box, imageId string, w io.Writer) (string, error) {
	fmt.Fprintf(w, "\n--- deploy box (%s, image:%s)\n", box.GetFullName(), imageId)

	actions := []*action.Action{
		&updateStatusInRiak,
		&createContainer,
		&startContainer,
		&updateStatusInRiak,
		&setNetworkInfo,
		&followLogsAndCommit,
	}

	pipeline := action.NewPipeline(actions...)

	args := runContainerActionsArgs{
		box:             box,
		imageId:         imageId,
		writer:          w,
		isDeploy:        true,
		buildingImage:   imageId,
		containerStatus: provision.StatusLaunching,
		provisioner:     p,
	}
	err := pipeline.Execute(args)
	if err != nil {
		fmt.Fprintf(w, "deploy pipeline for box (%s)\n --> %s", box.GetFullName(), err)
		return "", err
	}
	return imageId, nil
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:30,代碼來源:provisioner.go

示例3: UnsetCName

func (p *oneProvisioner) UnsetCName(box *provision.Box, cname string) error {
	r, err := getRouterForBox(box)
	if err != nil {
		return err
	}
	return r.UnsetCName(cname, box.GetFullName())
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:7,代碼來源:provisioner.go

示例4: Stop

func (p *oneProvisioner) Stop(box *provision.Box, process string, w io.Writer) error {
	fmt.Fprintf(w, "\n--- stoping box (%s)\n", box.GetFullName())
	args := runMachineActionsArgs{
		box:           box,
		writer:        w,
		isDeploy:      false,
		machineStatus: provision.StatusStopping,
		provisioner:   p,
	}
	actions := []*action.Action{
		&updateStatusInRiak,
		&stopMachine,
		&updateStatusInRiak,
	}

	pipeline := action.NewPipeline(actions...)

	err := pipeline.Execute(args)
	if err != nil {
		fmt.Fprintf(w, "--- stoping box (%s)\n --> %s", box.GetFullName(), err)
		return err
	}

	return nil
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:25,代碼來源:provisioner.go

示例5: Destroy

func (p *oneProvisioner) Destroy(box *provision.Box, w io.Writer) error {
	fmt.Fprintf(w, "\n--- destroying box (%s)\n", box.GetFullName())
	args := runMachineActionsArgs{
		box:           box,
		writer:        w,
		isDeploy:      false,
		machineStatus: provision.StatusDestroying,
		provisioner:   p,
	}

	actions := []*action.Action{
		&updateStatusInRiak,
		&destroyOldMachine,
		&destroyOldRoute,
	}

	pipeline := action.NewPipeline(actions...)

	err := pipeline.Execute(args)
	if err != nil {
		fmt.Fprintf(w, "--- destroying box (%s)\n --> %s", box.GetFullName(), err)
		return err
	}
	err = doneNotify(box, w, alerts.DESTROYED)
	return nil
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:26,代碼來源:provisioner.go

示例6: ImageDeploy

func (p *dockerProvisioner) ImageDeploy(box *provision.Box, imageId string, w io.Writer) (string, error) {
	isValid, err := isValidBoxImage(box.GetFullName(), imageId)
	if err != nil {
		return "", err
	}
	if !isValid {
		return "", fmt.Errorf("invalid image for box %s: %s", box.GetFullName(), imageId)
	}
	return p.deployPipeline(box, imageId, w)
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:10,代碼來源:provisioner.go

示例7: GetContainerByBox

//this is essentially converting box to a container.
func (p *dockerProvisioner) GetContainerByBox(box *provision.Box) (*container.Container, error) {
	return &container.Container{
		BoxId:    box.Id,
		CartonId: box.CartonId,
		Name:     box.Name,
		BoxName:  box.GetFullName(),
		Level:    box.Level,
		Status:   box.Status,
	}, nil

}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:12,代碼來源:repository.go

示例8: Addr

func (*dockerProvisioner) Addr(box *provision.Box) (string, error) {
	r, err := getRouterForBox(box)
	if err != nil {
		log.Errorf("Failed to get router: %s", err)
		return "", err
	}
	addr, err := r.Addr(box.GetFullName())
	if err != nil {
		log.Errorf("Failed to obtain box %s address: %s", box.GetFullName(), err)
		return "", err
	}
	return addr, nil
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:13,代碼來源:provisioner.go

示例9: doneNotify

func doneNotify(box *provision.Box, w io.Writer, evtAction alerts.EventAction) error {
	fmt.Fprintf(w, "\n--- done %s box \n", box.GetFullName())
	mi := make(map[string]string)
	mi[alerts.VERTNAME] = box.GetFullName()
	mi[alerts.VERTTYPE] = box.Tosca
	newEvent := events.NewMulti(
		[]*events.Event{
			&events.Event{
				AccountsId:  box.AccountsId,
				EventAction: evtAction,
				EventType:   events.EventUser,
				EventData:   events.EventData{M: mi},
				Timestamp:   time.Now().Local(),
			},
		})
	return newEvent.Write()
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:17,代碼來源:provisioner.go

示例10: Start

func (p *dockerProvisioner) Start(box *provision.Box, process string, w io.Writer) error {
	containers, err := p.listContainersByBox(box)
	if err != nil {
		fmt.Fprintf(w, "Failed to list box containers (%s)\n --> %s", box.GetFullName(), err)
	}
	return runInContainers(containers, func(c *container.Container, _ chan *container.Container) error {
		err := c.Start(&container.StartArgs{
			Provisioner: p,
			Box:         box,
		})
		if err != nil {
			return err
		}
		c.SetStatus(provision.StatusStarting)
		if info, err := c.NetworkInfo(p); err == nil {
			p.fixContainer(c, info)
		}
		return nil
	}, nil, true)
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:20,代碼來源:provisioner.go

示例11: SetBoxStatus

func (p *dockerProvisioner) SetBoxStatus(box *provision.Box, w io.Writer, status provision.Status) error {
	fmt.Fprintf(w, "\n---- status %s box %s ----\n", box.GetFullName(), status.String())
	actions := []*action.Action{
		&updateStatusInRiak,
	}
	pipeline := action.NewPipeline(actions...)

	args := runContainerActionsArgs{
		box:             box,
		writer:          w,
		containerStatus: status,
		provisioner:     p,
	}

	err := pipeline.Execute(args)
	if err != nil {
		log.Errorf("error on execute status pipeline for box %s - %s", box.GetFullName(), err)
		return err
	}
	return nil
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:21,代碼來源:provisioner.go

示例12: SetState

func (p *oneProvisioner) SetState(box *provision.Box, w io.Writer, changeto provision.Status) error {
	fmt.Fprintf(w, "\n--- stateto %s\n", box.GetFullName())
	args := runMachineActionsArgs{
		box:           box,
		writer:        w,
		machineStatus: changeto,
		provisioner:   p,
	}

	actions := []*action.Action{
		&changeStateofMachine,
		&addNewRoute,
	}

	pipeline := action.NewPipeline(actions...)

	err := pipeline.Execute(args)
	if err != nil {
		return err
	}
	err = doneNotify(box, w, alerts.LAUNCHED)
	return err
}
開發者ID:vijaykanthm28,項目名稱:vertice,代碼行數:23,代碼來源:provisioner.go


注:本文中的github.com/megamsys/vertice/provision.Box類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。