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