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


Golang executor.Context類代碼示例

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


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

示例1: Execute

func (cv CreateVeth) Execute(context executor.Context) error {
	err := context.LinkFactory().CreateVeth(cv.Name, cv.PeerName, cv.MTU)
	if err != nil {
		return fmt.Errorf("create veth: %s", err)
	}
	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:7,代碼來源:create_veth.go

示例2: Execute

func (cv CreateDummy) Execute(context executor.Context) error {
	err := context.LinkFactory().CreateDummy(cv.Name)
	if err != nil {
		return fmt.Errorf("create dummy: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:8,代碼來源:create_dummy.go

示例3: Execute

func (cb CreateBridge) Execute(context executor.Context) error {
	err := context.LinkFactory().CreateBridge(cb.Name)
	if err != nil {
		return fmt.Errorf("create bridge: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:8,代碼來源:create_bridge.go

示例4: Execute

func (c DeleteLink) Execute(context executor.Context) error {
	err := context.LinkFactory().DeleteLinkByName(c.LinkName)
	if err != nil {
		return fmt.Errorf("delete link: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:8,代碼來源:delete_link.go

示例5: Execute

func (slm SetLinkMaster) Execute(context executor.Context) error {
	err := context.LinkFactory().SetMaster(slm.Slave, slm.Master)
	if err != nil {
		return fmt.Errorf("set link master: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:8,代碼來源:set_link_master.go

示例6: Execute

func (s SetLinkUp) Execute(context executor.Context) error {
	err := context.LinkFactory().SetUp(s.LinkName)
	if err != nil {
		return fmt.Errorf("set link up: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:8,代碼來源:set_link_up.go

示例7: Execute

func (aa AddAddress) Execute(context executor.Context) error {
	err := context.AddressManager().AddAddress(aa.InterfaceName, &aa.Address)
	if err != nil {
		return fmt.Errorf("add address: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:8,代碼來源:add_address.go

示例8: Execute

func (ad AddRoute) Execute(context executor.Context) error {
	err := context.RouteManager().AddRoute(ad.Interface, &ad.Destination, ad.Gateway)
	if err != nil {
		return fmt.Errorf("add route: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:8,代碼來源:add_route.go

示例9: Execute

func (cv CreateVxlan) Execute(context executor.Context) error {
	err := context.LinkFactory().CreateVxlan(cv.Name, cv.VNI)
	if err != nil {
		return fmt.Errorf("create vxlan: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:8,代碼來源:create_vxlan.go

示例10: Execute

func (cmd *GetHardwareAddress) Execute(context executor.Context) error {
	hwAddr, err := context.LinkFactory().HardwareAddress(cmd.LinkName)
	if err != nil {
		return fmt.Errorf("get hardware address: %s", err)
	}

	cmd.Result = hwAddr

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:10,代碼來源:get_hardware_address.go

示例11: Execute

func (cn CreateSandbox) Execute(context executor.Context) error {
	logger := context.Logger().WithData(lager.Data{"sandbox-name": cn.Name})
	logger.Info("create-sandbox")
	defer logger.Info("create-sandbox-complete")

	_, err := context.SandboxRepository().Create(cn.Name)
	if err != nil {
		return fmt.Errorf("create sandbox: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:12,代碼來源:create_sandbox.go

示例12: Execute

func (s MoveLink) Execute(context executor.Context) error {
	sbox, err := context.SandboxRepository().Get(s.SandboxName)
	if err != nil {
		return fmt.Errorf("get sandbox: %s", err)
	}

	err = context.LinkFactory().SetNamespace(s.Name, sbox.Namespace().Fd())
	if err != nil {
		return fmt.Errorf("move link: %s", err)
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:13,代碼來源:move_link.go

示例13: Execute

func (sm StartMonitor) Execute(context executor.Context) error {
	ns, err := context.SandboxNamespaceRepository().Get(sm.SandboxName)
	if err != nil {
		return fmt.Errorf("getting sandbox namespace: %s", err)
	}

	return sm.HostNamespace.Execute(func(_ *os.File) error {
		err = sm.Watcher.StartMonitor(ns, sm.VxlanLinkName)
		if err != nil {
			return fmt.Errorf("watcher start monitor: %s", err)
		}
		return nil
	})
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:14,代碼來源:start_monitor.go

示例14: Execute

func (c CleanupSandbox) Execute(context executor.Context) error {
	logger := context.Logger().Session("cleanup-sandbox", lager.Data{"sandbox-name": c.SandboxName})
	logger.Info("start")
	defer logger.Info("complete")

	sandboxRepo := context.SandboxRepository()
	sbox, err := sandboxRepo.Get(c.SandboxName)
	if err != nil {
		if err == sandbox.NotFoundError {
			return nil
		}

		logger.Error("get-sandbox-failed", err)
		return fmt.Errorf("get sandbox: %s", err)
	}

	// TODO: move into sandbox
	sbox.Lock()
	defer sbox.Unlock()

	vethLinkCount, err := sbox.VethDeviceCount()
	if err != nil {
		return fmt.Errorf("counting veth devices: %s", err)
	}

	logger.Info("veth-links-remaining", lager.Data{"count": vethLinkCount})

	if vethLinkCount == 0 {
		err = sbox.Namespace().Execute(func(*os.File) error {
			err := context.LinkFactory().DeleteLinkByName(c.VxlanDeviceName)
			if err != nil {
				if context.LinkFactory().Exists(c.VxlanDeviceName) {
					return fmt.Errorf("destroying vxlan %s: %s", c.VxlanDeviceName, err)
				}
			}
			return nil
		})
		if err != nil {
			return fmt.Errorf("in namespace %s: %s", c.SandboxName, err)
		}

		err = sandboxRepo.Destroy(c.SandboxName)
		switch err {
		case nil:
		case sandbox.AlreadyDestroyedError:
		case sandbox.NotFoundError:
		default:
			return fmt.Errorf("sandbox destroy: %s", err)
		}
	}

	return nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:53,代碼來源:cleanup_sandbox.go

示例15: Satisfied

func (l LinkExists) Satisfied(context executor.Context) (bool, error) {
	return context.LinkFactory().Exists(l.Name), nil
}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:3,代碼來源:link_exists.go


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