• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang anchnet-go.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/caicloud/anchnet-go.Client的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: execAddSecurityGroupRule

func execAddSecurityGroupRule(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 2 {
		fmt.Fprintln(os.Stderr, "Rule name and security group ID required")
		os.Exit(1)
	}

	priority := getFlagInt(cmd, "priority")
	direction := getFlagInt(cmd, "direction")
	action := getFlagString(cmd, "action")
	protocol := getFlagString(cmd, "protocol")
	value1 := getFlagString(cmd, "value1")
	value2 := getFlagString(cmd, "value2")
	value3 := getFlagString(cmd, "value3")

	request := anchnet.AddSecurityGroupRulesRequest{
		SecurityGroupID: args[1],
		SecurityGroupRules: []anchnet.AddSecurityGroupRule{
			{
				SecurityGroupRuleName: args[0],
				Action:                anchnet.SecurityGroupRuleAction(action),
				Direction:             anchnet.SecurityGroupRuleDirection(direction),
				Protocol:              anchnet.SecurityGroupRuleProtocol(protocol),
				Priority:              priority,
				Value1:                value1,
				Value2:                value2,
				Value3:                value3,
			},
		},
	}
	var response anchnet.AddSecurityGroupRulesResponse
	sendResult(&response, out, "AddSecurityGroup", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:32,代码来源:security_group_cli.go


示例2: execCreateUserProject

func execCreateUserProject(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "Login ID required, i.e. username")
		os.Exit(1)
	}

	sex := getFlagString(cmd, "sex")
	mobile := getFlagString(cmd, "mobile")
	passwd := getFlagString(cmd, "passwd")

	// use {userid}@caicloud.io as loginid which is supposed to be unique.
	loginID := args[0] + "@caicloud.io"

	request := anchnet.CreateUserProjectRequest{
		LoginID:     loginID,
		Sex:         sex,
		ProjectName: args[0],
		Email:       loginID,
		ContactName: args[0],
		Mobile:      mobile,
		LoginPasswd: passwd,
	}
	var response anchnet.CreateUserProjectResponse
	sendResult(&response, out, "CreateUserProject", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:25,代码来源:user_project_cli.go


示例3: execWaitJob

func execWaitJob(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "Job id required")
		os.Exit(1)
	}

	count := getFlagInt(cmd, "count")
	status := getFlagString(cmd, "status")
	interval := getFlagInt(cmd, "interval")
	exitOnFail := getFlagBool(cmd, "exit_on_fail")

	for i := 0; i < count; i++ {
		request := anchnet.DescribeJobsRequest{
			JobIDs: []string{args[0]},
		}
		var response anchnet.DescribeJobsResponse
		err := client.SendRequest(request, &response)
		if err == nil && len(response.ItemSet) == 1 {
			// Return if there is no error and status matches.
			if string(response.ItemSet[0].Status) == status {
				return
			}
			// Return if there is no error, and status is failed + user wants early return.
			if response.ItemSet[0].Status == anchnet.JobStatusFailed && exitOnFail {
				fmt.Fprintf(os.Stderr, "Job %v failed", args[0])
				os.Exit(1)
			}
		}
		time.Sleep(time.Duration(interval) * time.Second)
	}
	fmt.Fprintf(os.Stderr, "Time out waiting for job %v", args[0])
	os.Exit(1)
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:33,代码来源:job_cli.go


示例4: execCreateLoadBalancer

func execCreateLoadBalancer(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 2 {
		fmt.Fprintln(os.Stderr, "Load balancer name and public ips required")
		os.Exit(1)
	}

	lb_type := getFlagInt(cmd, "type")

	refs := strings.Split(args[1], ",")
	ips := make([]anchnet.CreateLoadBalancerIP, len(refs))
	for i, ip := range refs {
		ips[i].RefID = ip
	}

	request := anchnet.CreateLoadBalancerRequest{
		Product: anchnet.CreateLoadBalancerProduct{
			Loadbalancer: anchnet.CreateLoadBalancerLB{
				Name: args[0],
				Type: anchnet.LoadBalancerType(lb_type),
			},
			Eips: ips,
		},
	}
	var response anchnet.CreateLoadBalancerResponse
	sendResult(&response, out, "CreateLoadBalancer", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:26,代码来源:lb_cli.go


示例5: execDeleteSecurityGroups

func execDeleteSecurityGroups(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 1 {
		fmt.Fprintln(os.Stderr, "Security group IDs required")
		os.Exit(1)
	}

	request := anchnet.DeleteSecurityGroupsRequest{
		SecurityGroupIDs: strings.Split(args[0], ","),
	}
	var response anchnet.DeleteSecurityGroupsResponse
	sendResult(&response, out, "DeleteSecurityGroups", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:12,代码来源:security_group_cli.go


示例6: execTerminateInstances

func execTerminateInstances(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "Instance IDs required")
		os.Exit(1)
	}

	request := anchnet.TerminateInstancesRequest{
		InstanceIDs: strings.Split(args[0], ","),
	}
	var response anchnet.TerminateInstancesResponse
	sendResult(&response, out, "TerminateInstance", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:12,代码来源:instance_cli.go


示例7: execDescribeVxnets

func execDescribeVxnets(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "Vxnet IDs required")
		os.Exit(1)
	}

	request := anchnet.DescribeVxnetsRequest{
		VxnetIDs: strings.Split(args[0], ","),
	}
	var response anchnet.DescribeVxnetsResponse
	sendResult(&response, out, "DescribeVxnet", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:12,代码来源:vxnet_cli.go


示例8: execReleaseEips

func execReleaseEips(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "EIP IDs required")
		os.Exit(1)
	}

	request := anchnet.ReleaseEipsRequest{
		EipIDs: strings.Split(args[0], ","),
	}
	var response anchnet.ReleaseEipsResponse
	sendResult(&response, out, "ReleaseEips", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:12,代码来源:eip_cli.go


示例9: execDescribeJob

func execDescribeJob(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "Job id required")
		os.Exit(1)
	}

	request := anchnet.DescribeJobsRequest{
		JobIDs: []string{args[0]},
	}
	var response anchnet.DescribeJobsResponse
	sendResult(&response, out, "DescribeJob", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:12,代码来源:job_cli.go


示例10: execApplySecurityGroup

func execApplySecurityGroup(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 2 {
		fmt.Fprintln(os.Stderr, "Security group id and instance ids required")
		os.Exit(1)
	}

	request := anchnet.ApplySecurityGroupRequest{
		SecurityGroupID: args[0],
		InstanceIDs:     strings.Split(args[1], ","),
	}
	var response anchnet.ApplySecurityGroupResponse
	sendResult(&response, out, "ApplySecurityGroup", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:13,代码来源:security_group_cli.go


示例11: execJoinVxnet

func execJoinVxnet(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 2 {
		fmt.Fprintln(os.Stderr, "Vxnet and instances IDs required")
		os.Exit(1)
	}

	request := anchnet.JoinVxnetRequest{
		VxnetID:     args[0],
		InstanceIDs: strings.Split(args[1], ","),
	}
	var response anchnet.JoinVxnetResponse
	sendResult(&response, out, "JobVxnet", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:13,代码来源:vxnet_cli.go


示例12: execRevokeImageFromUsers

func execRevokeImageFromUsers(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 2 {
		fmt.Fprintln(os.Stderr, "Image id and user ids required")
		os.Exit(1)
	}

	request := anchnet.RevokeImageFromUsersRequest{
		ImageIDs: []string{args[0]},
		UserIDs:  strings.Split(args[1], ","),
	}
	var response anchnet.RevokeImageFromUsersResponse
	sendResult(&response, out, "RevokeImageToUsers", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:13,代码来源:image_cli.go


示例13: execCaptureInstance

func execCaptureInstance(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 2 {
		fmt.Fprintln(os.Stderr, "Image name and instance id required")
		os.Exit(1)
	}

	request := anchnet.CaptureInstanceRequest{
		ImageName: args[0],
		Instance:  args[1],
	}
	var response anchnet.CaptureInstanceResponse
	sendResult(&response, out, "CaptureInstance", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:13,代码来源:image_cli.go


示例14: execDescribeProjects

func execDescribeProjects(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "projectid required, e.g. pro-xxxxx")
		os.Exit(1)
	}

	request := anchnet.DescribeProjectsRequest{
		Projects: args[0],
	}

	var response anchnet.DescribeProjectsResponse
	sendResult(&response, out, "DescribeProjects", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:13,代码来源:user_project_cli.go


示例15: execSearchSecurityGroup

func execSearchSecurityGroup(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 1 {
		fmt.Fprintln(os.Stderr, "Security group name required")
		os.Exit(1)
	}

	request := anchnet.DescribeSecurityGroupsRequest{
		SearchWord: args[0],
		Verbose:    1,
	}
	var response anchnet.DescribeSecurityGroupsResponse
	sendResult(&response, out, "SearchSecurityGroup", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:13,代码来源:security_group_cli.go


示例16: execCreateVxnet

func execCreateVxnet(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "Vxnet name required")
		os.Exit(1)
	}

	request := anchnet.CreateVxnetsRequest{
		VxnetName: args[0],
		VxnetType: anchnet.VxnetTypePriv,
		Count:     1,
	}
	var response anchnet.CreateVxnetsResponse
	sendResult(&response, out, "CreateVxnet", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:14,代码来源:vxnet_cli.go


示例17: execSearchUserProject

func execSearchUserProject(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "Login ID required, i.e. username")
		os.Exit(1)
	}

	loginID := args[0] + "@caicloud.io"

	request := anchnet.DescribeProjectsRequest{
		SearchWord: loginID,
	}

	var response anchnet.DescribeProjectsResponse
	sendResult(&response, out, "SearchUserProject", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:15,代码来源:user_project_cli.go


示例18: execDeleteLoadBalancer

func execDeleteLoadBalancer(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 2 {
		fmt.Fprintln(os.Stderr, "Load balancer ids and public ips required")
		os.Exit(1)
	}

	lbs := strings.Split(args[0], ",")
	ips := strings.Split(args[1], ",")

	request := anchnet.DeleteLoadBalancersRequest{
		LoadbalancerIDs: lbs,
		EipIDs:          ips,
	}
	var response anchnet.DeleteLoadBalancersResponse
	sendResult(&response, out, "DeleteLoadBalancer", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:16,代码来源:lb_cli.go


示例19: execSearchLoadBalancer

func execSearchLoadBalancer(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, "LoadBalancer name required")
		os.Exit(1)
	}

	var lb_status []anchnet.LoadBalancerStatus
	for _, status := range strings.Split(getFlagString(cmd, "status"), ",") {
		lb_status = append(lb_status, anchnet.LoadBalancerStatus(status))
	}

	request := anchnet.DescribeLoadBalancersRequest{
		SearchWord: args[0],
		Status:     lb_status,
		Verbose:    1,
	}
	var response anchnet.DescribeLoadBalancersResponse
	sendResult(&response, out, "SearchLoadBalancer", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:19,代码来源:lb_cli.go


示例20: execCreateSecurityGroup

func execCreateSecurityGroup(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
	if len(args) != 1 {
		fmt.Fprintln(os.Stderr, "Security group name required")
		os.Exit(1)
	}

	// Assume number matches.
	rulename := strings.Split(getFlagString(cmd, "rulename"), ",")
	priority := strings.Split(getFlagString(cmd, "priority"), ",")
	direction := strings.Split(getFlagString(cmd, "direction"), ",")
	action := strings.Split(getFlagString(cmd, "action"), ",")
	protocol := strings.Split(getFlagString(cmd, "protocol"), ",")
	value1 := strings.Split(getFlagString(cmd, "value1"), ",")
	value2 := strings.Split(getFlagString(cmd, "value2"), ",")

	var rules []anchnet.CreateSecurityGroupRule
	for i := range rulename {
		d, _ := strconv.Atoi(direction[i])
		p, _ := strconv.Atoi(priority[i])
		rule := anchnet.CreateSecurityGroupRule{
			SecurityGroupRuleName: rulename[i],
			Action:                anchnet.SecurityGroupRuleAction(action[i]),
			Direction:             anchnet.SecurityGroupRuleDirection(d),
			Protocol:              anchnet.SecurityGroupRuleProtocol(protocol[i]),
			Priority:              p,
			Value1:                value1[i],
			Value2:                value2[i],
		}
		rules = append(rules, rule)
	}

	request := anchnet.CreateSecurityGroupRequest{
		SecurityGroupName:  args[0],
		SecurityGroupRules: rules,
	}
	var response anchnet.CreateSecurityGroupResponse
	sendResult(&response, out, "CreateSecurityGroup", response.Code, client.SendRequest(request, &response))
}
开发者ID:caicloud,项目名称:anchnet-go-sdk,代码行数:38,代码来源:security_group_cli.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang assert.New函数代码示例发布时间:2022-05-24
下一篇:
Golang webc.Context类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap