Example #1
0
func main() {

	hostsvc := uhost.New(&ucloud.Config{
		Credentials: &auth.KeyPair{
			PublicKey:  "[email protected]",
			PrivateKey: "46f09bb9fab4f12dfc160dae12273d5332b5debe",
		},
		Region:    "cn-north-01",
		ProjectID: "",
	})

	describeParams := uhost.DescribeUHostInstanceParams{
		Region: "cn-north-03",
		Limit:  10,
		Offset: 0,
	}

	response, err := hostsvc.DescribeUHostInstance(&describeParams)
	if err != nil {
		fmt.Println(err)
	}
	utils.DumpVal(response)

	//	createUhostParams := uhost.CreateUHostInstanceParams{
	//
	//		Region: "cn-north-03",
	//		ImageId: "uimage-j4fbrn",
	//		LoginMode: "Password",
	//		Password: "******",
	//		CPU: 1,
	//		Memory:2048,
	//		Quantity:1,
	//		Quantity:1,
	//		Count: 1,
	//	}
	//
	//
	//	response, err := hostsvc.CreateUHostInstance(&createUhostParams)
	//	if err != nil {
	//		fmt.Println(err)
	//	}
	//
	//	utils.DumpVal(response)
	//
	//
	//	// describeimage
	//	imageparams := uhost.DescribeImageParams{
	//		Region: "cn-north-03",
	//	}
	//
	//
	//	imageresp, err := hostsvc.DescribeImage(&imageparams)
	//	if err != nil {
	//		fmt.Println(err)
	//	}
	//
	//	utils.DumpVal(imageresp)
}
Example #2
0
func (d *Driver) getUHostService() *uhost.UHost {

	if hostsvc != nil {
		return hostsvc
	}
	hostsvc = uhost.New(d.newConfig())

	return hostsvc
}