本文整理匯總了Golang中github.com/Juniper/contrail-go-api/types.Project.GetDefaultParent方法的典型用法代碼示例。如果您正苦於以下問題:Golang Project.GetDefaultParent方法的具體用法?Golang Project.GetDefaultParent怎麽用?Golang Project.GetDefaultParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Juniper/contrail-go-api/types.Project
的用法示例。
在下文中一共展示了Project.GetDefaultParent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getNetworkUuidByName
func getNetworkUuidByName(
client *contrail.Client, project_name, project_id, name string) (
string, error) {
var fqn []string
if len(project_id) > 0 {
uuid := strings.ToLower(project_id)
if !config.IsUuid(uuid) {
fmt.Fprintf(os.Stderr,
"Invalid project-id value: %s\n", uuid)
os.Exit(2)
}
obj, err := client.FindByUuid("project", project_id)
if err != nil {
fmt.Fprint(os.Stderr, err)
os.Exit(2)
}
fqn = obj.GetFQName()
} else {
fqn = strings.Split(project_name, ":")
if len(fqn) == 1 {
obj := new(types.Project)
fqn = append(obj.GetDefaultParent(), project_name)
}
}
fqn = append(fqn, name)
return client.UuidByName("virtual-network", strings.Join(fqn, ":"))
}
示例2: GetProjectFQN
func GetProjectFQN(
client *contrail.Client, projectName string, projectId string) (
[]string, error) {
if len(projectId) > 0 {
uuid := strings.ToLower(projectId)
if !IsUuid(uuid) {
return nil,
fmt.Errorf("Invalid uuid value: %s\n", uuid)
}
return client.FQNameByUuid(uuid)
}
if strings.ContainsRune(projectName, ':') {
return strings.Split(projectName, ":"), nil
}
obj := new(types.Project)
return append(obj.GetDefaultParent(), projectName), nil
}
示例3: GetProjectId
func GetProjectId(
client *contrail.Client, project_name string, project_id string) (
string, error) {
if len(project_id) > 0 {
uuid := strings.ToLower(project_id)
if !IsUuid(uuid) {
return "",
fmt.Errorf("Invalid uuid value: %s\n", uuid)
}
return uuid, nil
}
var name string
if strings.ContainsRune(project_name, ':') {
name = project_name
} else {
obj := new(types.Project)
fqn := append(obj.GetDefaultParent(), project_name)
name = strings.Join(fqn, `:`)
}
return client.UuidByName("project", name)
}