本文整理匯總了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)
}
示例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
}
示例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())
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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()
}
示例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)
}
示例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
}
示例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
}