本文整理匯總了Golang中github.com/contiv/netplugin/netmaster/mastercfg.CfgEndpointState.NetID方法的典型用法代碼示例。如果您正苦於以下問題:Golang CfgEndpointState.NetID方法的具體用法?Golang CfgEndpointState.NetID怎麽用?Golang CfgEndpointState.NetID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/contiv/netplugin/netmaster/mastercfg.CfgEndpointState
的用法示例。
在下文中一共展示了CfgEndpointState.NetID方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestOvsDriverCreateEndpointStatefulStateMismatch
func TestOvsDriverCreateEndpointStatefulStateMismatch(t *testing.T) {
driver := initOvsDriver(t)
defer func() { driver.Deinit() }()
id := createEpIDStatefulMismatch
// create network
err := driver.CreateNetwork(testOvsNwID)
if err != nil {
t.Fatalf("network creation failed. Error: %s", err)
}
defer func() { driver.DeleteNetwork(testOvsNwID, "", "", testPktTag, testExtPktTag, testGateway, testTenant) }()
// create second network
err = driver.CreateNetwork(testOvsNwIDStateful)
if err != nil {
t.Fatalf("network creation failed. Error: %s", err)
}
defer func() {
driver.DeleteNetwork(testOvsNwIDStateful, "", "", testPktTagStateful, testExtPktTag, testGateway, testTenant)
}()
// create endpoint
err = driver.CreateEndpoint(id)
if err != nil {
t.Fatalf("endpoint creation failed. Error: %s", err)
}
cfgEp := mastercfg.CfgEndpointState{}
cfgEp.StateDriver = driver.oper.StateDriver
err = cfgEp.Read(id)
if err != nil {
t.Fatalf("failed to read ep config. Error: %s", err)
}
cfgEp.NetID = testOvsNwIDStateful
err = cfgEp.Write()
if err != nil {
t.Fatalf("failed to write ep config. Error: %s", err)
}
err = driver.CreateEndpoint(id)
if err != nil {
t.Fatalf("stateful endpoint creation failed. Error: %s", err)
}
defer func() { driver.DeleteEndpoint(id) }()
output, err := exec.Command("ovs-vsctl", "list", "Port").CombinedOutput()
expectedPortName := fmt.Sprintf("port%d", driver.oper.CurrPortNum)
if err != nil || !strings.Contains(string(output), expectedPortName) {
t.Fatalf("port lookup failed. Error: %s expected port: %s Output: %s",
err, expectedPortName, output)
}
output, err = exec.Command("ovs-vsctl", "list", "Interface").CombinedOutput()
if err != nil || !strings.Contains(string(output), expectedPortName) {
t.Fatalf("interface lookup failed. Error: %s expected port: %s Output: %s",
err, expectedPortName, output)
}
}