本文整理汇总了Golang中github.com/Juniper/contrail-go-api/types.VirtualNetwork.GetVirtualMachineInterfaceBackRefs方法的典型用法代码示例。如果您正苦于以下问题:Golang VirtualNetwork.GetVirtualMachineInterfaceBackRefs方法的具体用法?Golang VirtualNetwork.GetVirtualMachineInterfaceBackRefs怎么用?Golang VirtualNetwork.GetVirtualMachineInterfaceBackRefs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Juniper/contrail-go-api/types.VirtualNetwork
的用法示例。
在下文中一共展示了VirtualNetwork.GetVirtualMachineInterfaceBackRefs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestReadModifiedRefs
func TestReadModifiedRefs(t *testing.T) {
client := new(ApiClient)
client.Init()
project := new(types.Project)
project.SetFQName("domain", []string{"default-domain", "p1"})
assert.NoError(t, client.Create(project))
net := new(types.VirtualNetwork)
net.SetFQName("project", []string{"default-domain", "p1", "n1"})
assert.NoError(t, client.Create(net))
vmi1 := new(types.VirtualMachineInterface)
vmi1.SetFQName("project", []string{"default-domain", "p1", "port1"})
vmi1.AddVirtualNetwork(net)
assert.NoError(t, client.Create(vmi1))
vmi2 := new(types.VirtualMachineInterface)
vmi2.SetFQName("project", []string{"default-domain", "p1", "port2"})
vmi2.AddVirtualNetwork(net)
assert.NoError(t, client.Create(vmi2))
refs, err := net.GetVirtualMachineInterfaceBackRefs()
assert.NoError(t, err)
assert.Len(t, refs, 2)
assert.NoError(t, client.Delete(vmi1))
refs, err = net.GetVirtualMachineInterfaceBackRefs()
assert.NoError(t, err)
assert.Len(t, refs, 1)
}
示例2: TestReadBackRefs
func TestReadBackRefs(t *testing.T) {
client := new(ApiClient)
client.Init()
project := new(types.Project)
project.SetFQName("domain", []string{"default-domain", "p1"})
assert.NoError(t, client.Create(project))
net := new(types.VirtualNetwork)
net.SetFQName("project", []string{"default-domain", "p1", "n1"})
props := new(types.VirtualNetworkType)
props.ForwardingMode = "turbo"
net.SetVirtualNetworkProperties(props)
assert.NoError(t, client.Create(net))
vmi1 := new(types.VirtualMachineInterface)
vmi1.SetFQName("project", []string{"default-domain", "p1", "port1"})
vmi1.AddVirtualNetwork(net)
assert.NoError(t, client.Create(vmi1))
vmi2 := new(types.VirtualMachineInterface)
vmi2.SetFQName("project", []string{"default-domain", "p1", "port2"})
vmi2.AddVirtualNetwork(net)
assert.NoError(t, client.Create(vmi2))
refs, err := net.GetVirtualMachineInterfaceBackRefs()
assert.NoError(t, err)
assert.Len(t, refs, 2)
idList := make([]string, len(refs))
for i, ref := range refs {
idList[i] = ref.Uuid
}
assert.Contains(t, idList, vmi1.GetUuid())
assert.Contains(t, idList, vmi2.GetUuid())
rProps := net.GetVirtualNetworkProperties()
assert.Equal(t, "turbo", rProps.ForwardingMode)
}