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


Golang Project.GetDefaultParent方法代码示例

本文整理汇总了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, ":"))
}
开发者ID:hkumarmk,项目名称:contrail-go-api,代码行数:27,代码来源:network.go

示例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
}
开发者ID:hkumarmk,项目名称:contrail-go-api,代码行数:19,代码来源:project.go

示例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)
}
开发者ID:hkumarmk,项目名称:contrail-go-api,代码行数:22,代码来源:project.go


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