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


Golang Project.GetUuid方法代碼示例

本文整理匯總了Golang中github.com/Juniper/contrail-go-api/types.Project.GetUuid方法的典型用法代碼示例。如果您正苦於以下問題:Golang Project.GetUuid方法的具體用法?Golang Project.GetUuid怎麽用?Golang Project.GetUuid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/Juniper/contrail-go-api/types.Project的用法示例。


在下文中一共展示了Project.GetUuid方法的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: CreateProject

// TODO: Create default security-group.
func CreateProject(client *contrail.Client, name string, createIpam bool) (
	string, error) {
	project := new(types.Project)
	project.SetName(name)
	err := client.Create(project)
	if err != nil {
		return "", err
	}
	if createIpam {
		ipam := new(types.NetworkIpam)
		ipam.SetParent(project)
		ipam.SetName("default-network-ipam")
		err = client.Create(ipam)
		if err != nil {
			client.Delete(project)
			return "", err
		}
	}
	return project.GetUuid(), nil
}
開發者ID:hkumarmk,項目名稱:contrail-go-api,代碼行數:21,代碼來源:project.go


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