当前位置: 首页>>代码示例>>Golang>>正文


Golang VirtualNetwork.SetUuid方法代码示例

本文整理汇总了Golang中github.com/Juniper/contrail-go-api/types.VirtualNetwork.SetUuid方法的典型用法代码示例。如果您正苦于以下问题:Golang VirtualNetwork.SetUuid方法的具体用法?Golang VirtualNetwork.SetUuid怎么用?Golang VirtualNetwork.SetUuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/Juniper/contrail-go-api/types.VirtualNetwork的用法示例。


在下文中一共展示了VirtualNetwork.SetUuid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestChildrenRefs

func TestChildrenRefs(t *testing.T) {
	db := NewInMemDatabase()
	project := new(types.Project)
	project.SetUuid(uuid.New())
	project.SetName("p1")
	assert.NoError(t, db.Put(project, nil, GetReferenceList(project)))

	net := new(types.VirtualNetwork)
	net.SetUuid(uuid.New())
	net.SetFQName("project", []string{"p1", "n1"})
	assert.NoError(t, db.Put(net, project, UIDList{}))

	vmi1 := new(types.VirtualMachineInterface)
	vmi1.SetUuid(uuid.New())
	vmi1.SetName("port1")
	vmi1.AddVirtualNetwork(net)
	assert.NoError(t, db.Put(vmi1, project, GetReferenceList(vmi1)))

	vmi2 := new(types.VirtualMachineInterface)
	vmi2.SetUuid(uuid.New())
	vmi2.SetName("port2")
	vmi2.AddVirtualNetwork(net)
	assert.NoError(t, db.Put(vmi2, project, GetReferenceList(vmi2)))

	result, err := db.GetChildren(parseUID(project.GetUuid()), "virtual_network")
	assert.NoError(t, err)
	assert.Len(t, result, 1)

	result, err = db.GetChildren(parseUID(project.GetUuid()), "virtual_machine_interface")
	assert.NoError(t, err)
	assert.Len(t, result, 2)
	assert.Contains(t, result, parseUID(vmi1.GetUuid()))
	assert.Contains(t, result, parseUID(vmi2.GetUuid()))

	assert.Error(t, db.Delete(project))

	assert.NoError(t, db.Delete(vmi1))
	assert.Error(t, db.Delete(net))
	assert.NoError(t, db.Delete(vmi2))

	assert.NoError(t, db.Delete(net))
	assert.NoError(t, db.Delete(project))
}
开发者ID:netturpin,项目名称:contrail-go-api,代码行数:43,代码来源:database_test.go

示例2: TestReference

func TestReference(t *testing.T) {
	db := NewInMemDatabase()

	ipam := new(types.NetworkIpam)
	ipam.SetUuid(uuid.New())
	ipam.SetFQName("project", strings.Split("default-domain:p1:ipam", ":"))
	assert.NoError(t, db.Put(ipam, nil, UIDList{}))

	net := new(types.VirtualNetwork)
	net.SetUuid(uuid.New())
	net.SetFQName("project", strings.Split("default-domain:p1:network", ":"))
	subnets := types.VnSubnetsType{}
	subnets.AddIpamSubnets(
		&types.IpamSubnetType{
			Subnet: &types.SubnetType{"10.0.0.0", 8}})

	net.AddNetworkIpam(ipam, subnets)
	refs := GetReferenceList(net)
	assert.NoError(t, db.Put(net, nil, refs))

	result, err := db.GetBackReferences(parseUID(ipam.GetUuid()), "virtual_network")
	assert.NoError(t, err)
	assert.Contains(t, result, parseUID(net.GetUuid()))
}
开发者ID:netturpin,项目名称:contrail-go-api,代码行数:24,代码来源:database_test.go


注:本文中的github.com/Juniper/contrail-go-api/types.VirtualNetwork.SetUuid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。