add ucloud import
This commit is contained in:
parent
f72da4b7f7
commit
61f9d3a9fe
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/hashicorp/packer/template/interpolate"
|
||||
"github.com/hashicorp/packer/version"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/uaccount"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/ufile"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/uhost"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/unet"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/vpc"
|
||||
|
@ -42,10 +43,11 @@ func (c *AccessConfig) Client() (*UCloudClient, error) {
|
|||
cred.PrivateKey = c.PrivateKey
|
||||
|
||||
c.client = &UCloudClient{}
|
||||
c.client.uhostconn = uhost.NewClient(&cfg, &cred)
|
||||
c.client.unetconn = unet.NewClient(&cfg, &cred)
|
||||
c.client.vpcconn = vpc.NewClient(&cfg, &cred)
|
||||
c.client.uaccountconn = uaccount.NewClient(&cfg, &cred)
|
||||
c.client.UHostConn = uhost.NewClient(&cfg, &cred)
|
||||
c.client.UNetConn = unet.NewClient(&cfg, &cred)
|
||||
c.client.VPCConn = vpc.NewClient(&cfg, &cred)
|
||||
c.client.UAccountConn = uaccount.NewClient(&cfg, &cred)
|
||||
c.client.UFileConn = ufile.NewClient(&cfg, &cred)
|
||||
|
||||
return c.client, nil
|
||||
}
|
||||
|
@ -137,7 +139,7 @@ func (c *AccessConfig) ValidateZone(region, zone string) error {
|
|||
|
||||
func (c *AccessConfig) getSupportedProjectIds() ([]string, error) {
|
||||
client, err := c.Client()
|
||||
conn := client.uaccountconn
|
||||
conn := client.UAccountConn
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -150,7 +152,7 @@ func (c *AccessConfig) getSupportedProjectIds() ([]string, error) {
|
|||
|
||||
validProjectIds := make([]string, len(resp.ProjectSet))
|
||||
for _, val := range resp.ProjectSet {
|
||||
if !isStringIn(val.ProjectId, validProjectIds) {
|
||||
if !IsStringIn(val.ProjectId, validProjectIds) {
|
||||
validProjectIds = append(validProjectIds, val.ProjectId)
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +162,7 @@ func (c *AccessConfig) getSupportedProjectIds() ([]string, error) {
|
|||
|
||||
func (c *AccessConfig) getSupportedRegions() ([]string, error) {
|
||||
client, err := c.Client()
|
||||
conn := client.uaccountconn
|
||||
conn := client.UAccountConn
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -173,7 +175,7 @@ func (c *AccessConfig) getSupportedRegions() ([]string, error) {
|
|||
|
||||
validRegions := make([]string, len(resp.Regions))
|
||||
for _, val := range resp.Regions {
|
||||
if !isStringIn(val.Region, validRegions) {
|
||||
if !IsStringIn(val.Region, validRegions) {
|
||||
validRegions = append(validRegions, val.Region)
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +185,7 @@ func (c *AccessConfig) getSupportedRegions() ([]string, error) {
|
|||
|
||||
func (c *AccessConfig) getSupportedZones(region string) ([]string, error) {
|
||||
client, err := c.Client()
|
||||
conn := client.uaccountconn
|
||||
conn := client.UAccountConn
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -196,7 +198,7 @@ func (c *AccessConfig) getSupportedZones(region string) ([]string, error) {
|
|||
|
||||
validZones := make([]string, len(resp.Regions))
|
||||
for _, val := range resp.Regions {
|
||||
if val.Region == region && !isStringIn(val.Zone, validZones) {
|
||||
if val.Region == region && !IsStringIn(val.Zone, validZones) {
|
||||
validZones = append(validZones, val.Zone)
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"os"
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
type Artifact struct {
|
||||
UCloudImages *imageInfoSet
|
||||
UCloudImages *ImageInfoSet
|
||||
|
||||
BuilderIdValue string
|
||||
|
||||
|
@ -56,7 +56,7 @@ func (a *Artifact) State(name string) interface{} {
|
|||
}
|
||||
|
||||
func (a *Artifact) Destroy() error {
|
||||
conn := a.Client.uhostconn
|
||||
conn := a.Client.UHostConn
|
||||
errors := make([]error, 0)
|
||||
|
||||
for _, v := range a.UCloudImages.GetAll() {
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/packer/packer"
|
||||
|
@ -13,14 +13,14 @@ func TestArtifact_Impl(t *testing.T) {
|
|||
func TestArtifactId(t *testing.T) {
|
||||
expected := `project1:region1:foo,project2:region2:bar`
|
||||
|
||||
images := newImageInfoSet(nil)
|
||||
images.Set(imageInfo{
|
||||
images := NewImageInfoSet(nil)
|
||||
images.Set(ImageInfo{
|
||||
Region: "region1",
|
||||
ProjectId: "project1",
|
||||
ImageId: "foo",
|
||||
})
|
||||
|
||||
images.Set(imageInfo{
|
||||
images.Set(ImageInfo{
|
||||
Region: "region2",
|
||||
ProjectId: "project2",
|
||||
ImageId: "bar",
|
||||
|
@ -37,14 +37,14 @@ func TestArtifactId(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestArtifactState_atlasMetadata(t *testing.T) {
|
||||
images := newImageInfoSet(nil)
|
||||
images.Set(imageInfo{
|
||||
images := NewImageInfoSet(nil)
|
||||
images.Set(ImageInfo{
|
||||
Region: "region1",
|
||||
ProjectId: "project1",
|
||||
ImageId: "foo",
|
||||
})
|
||||
|
||||
images.Set(imageInfo{
|
||||
images.Set(ImageInfo{
|
||||
Region: "region2",
|
||||
ProjectId: "project2",
|
||||
ImageId: "bar",
|
|
@ -1,7 +1,8 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/services/uaccount"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/ufile"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/uhost"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/unet"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/vpc"
|
||||
|
@ -10,17 +11,18 @@ import (
|
|||
)
|
||||
|
||||
type UCloudClient struct {
|
||||
uhostconn *uhost.UHostClient
|
||||
unetconn *unet.UNetClient
|
||||
vpcconn *vpc.VPCClient
|
||||
uaccountconn *uaccount.UAccountClient
|
||||
UHostConn *uhost.UHostClient
|
||||
UNetConn *unet.UNetClient
|
||||
VPCConn *vpc.VPCClient
|
||||
UAccountConn *uaccount.UAccountClient
|
||||
UFileConn *ufile.UFileClient
|
||||
}
|
||||
|
||||
func (c *UCloudClient) describeFirewallById(sgId string) (*unet.FirewallDataSet, error) {
|
||||
func (c *UCloudClient) DescribeFirewallById(sgId string) (*unet.FirewallDataSet, error) {
|
||||
if sgId == "" {
|
||||
return nil, newNotFoundError("security group", sgId)
|
||||
return nil, NewNotFoundError("security group", sgId)
|
||||
}
|
||||
conn := c.unetconn
|
||||
conn := c.UNetConn
|
||||
|
||||
req := conn.NewDescribeFirewallRequest()
|
||||
req.FWId = ucloud.String(sgId)
|
||||
|
@ -29,23 +31,23 @@ func (c *UCloudClient) describeFirewallById(sgId string) (*unet.FirewallDataSet,
|
|||
|
||||
if err != nil {
|
||||
if uErr, ok := err.(uerr.Error); ok && uErr.Code() == 54002 {
|
||||
return nil, newNotFoundError("security group", sgId)
|
||||
return nil, NewNotFoundError("security group", sgId)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(resp.DataSet) < 1 {
|
||||
return nil, newNotFoundError("security group", sgId)
|
||||
return nil, NewNotFoundError("security group", sgId)
|
||||
}
|
||||
|
||||
return &resp.DataSet[0], nil
|
||||
}
|
||||
|
||||
func (c *UCloudClient) describeSubnetById(subnetId string) (*vpc.VPCSubnetInfoSet, error) {
|
||||
func (c *UCloudClient) DescribeSubnetById(subnetId string) (*vpc.VPCSubnetInfoSet, error) {
|
||||
if subnetId == "" {
|
||||
return nil, newNotFoundError("Subnet", subnetId)
|
||||
return nil, NewNotFoundError("Subnet", subnetId)
|
||||
}
|
||||
conn := c.vpcconn
|
||||
conn := c.VPCConn
|
||||
|
||||
req := conn.NewDescribeSubnetRequest()
|
||||
req.SubnetIds = []string{subnetId}
|
||||
|
@ -56,17 +58,17 @@ func (c *UCloudClient) describeSubnetById(subnetId string) (*vpc.VPCSubnetInfoSe
|
|||
}
|
||||
|
||||
if resp == nil || len(resp.DataSet) < 1 {
|
||||
return nil, newNotFoundError("Subnet", subnetId)
|
||||
return nil, NewNotFoundError("Subnet", subnetId)
|
||||
}
|
||||
|
||||
return &resp.DataSet[0], nil
|
||||
}
|
||||
|
||||
func (c *UCloudClient) describeVPCById(vpcId string) (*vpc.VPCInfo, error) {
|
||||
func (c *UCloudClient) DescribeVPCById(vpcId string) (*vpc.VPCInfo, error) {
|
||||
if vpcId == "" {
|
||||
return nil, newNotFoundError("VPC", vpcId)
|
||||
return nil, NewNotFoundError("VPC", vpcId)
|
||||
}
|
||||
conn := c.vpcconn
|
||||
conn := c.VPCConn
|
||||
|
||||
req := conn.NewDescribeVPCRequest()
|
||||
req.VPCIds = []string{vpcId}
|
||||
|
@ -77,7 +79,7 @@ func (c *UCloudClient) describeVPCById(vpcId string) (*vpc.VPCInfo, error) {
|
|||
}
|
||||
|
||||
if resp == nil || len(resp.DataSet) < 1 {
|
||||
return nil, newNotFoundError("VPC", vpcId)
|
||||
return nil, NewNotFoundError("VPC", vpcId)
|
||||
}
|
||||
|
||||
return &resp.DataSet[0], nil
|
||||
|
@ -85,31 +87,31 @@ func (c *UCloudClient) describeVPCById(vpcId string) (*vpc.VPCInfo, error) {
|
|||
|
||||
func (c *UCloudClient) DescribeImageById(imageId string) (*uhost.UHostImageSet, error) {
|
||||
if imageId == "" {
|
||||
return nil, newNotFoundError("image", imageId)
|
||||
return nil, NewNotFoundError("image", imageId)
|
||||
}
|
||||
req := c.uhostconn.NewDescribeImageRequest()
|
||||
req := c.UHostConn.NewDescribeImageRequest()
|
||||
req.ImageId = ucloud.String(imageId)
|
||||
|
||||
resp, err := c.uhostconn.DescribeImage(req)
|
||||
resp, err := c.UHostConn.DescribeImage(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(resp.ImageSet) < 1 {
|
||||
return nil, newNotFoundError("image", imageId)
|
||||
return nil, NewNotFoundError("image", imageId)
|
||||
}
|
||||
|
||||
return &resp.ImageSet[0], nil
|
||||
}
|
||||
|
||||
func (c *UCloudClient) describeUHostById(uhostId string) (*uhost.UHostInstanceSet, error) {
|
||||
func (c *UCloudClient) DescribeUHostById(uhostId string) (*uhost.UHostInstanceSet, error) {
|
||||
if uhostId == "" {
|
||||
return nil, newNotFoundError("instance", uhostId)
|
||||
return nil, NewNotFoundError("instance", uhostId)
|
||||
}
|
||||
req := c.uhostconn.NewDescribeUHostInstanceRequest()
|
||||
req := c.UHostConn.NewDescribeUHostInstanceRequest()
|
||||
req.UHostIds = []string{uhostId}
|
||||
|
||||
resp, err := c.uhostconn.DescribeUHostInstance(req)
|
||||
resp, err := c.UHostConn.DescribeUHostInstance(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -120,19 +122,19 @@ func (c *UCloudClient) describeUHostById(uhostId string) (*uhost.UHostInstanceSe
|
|||
return &resp.UHostSet[0], nil
|
||||
}
|
||||
|
||||
func (c *UCloudClient) describeImageByInfo(projectId, regionId, imageId string) (*uhost.UHostImageSet, error) {
|
||||
req := c.uhostconn.NewDescribeImageRequest()
|
||||
func (c *UCloudClient) DescribeImageByInfo(projectId, regionId, imageId string) (*uhost.UHostImageSet, error) {
|
||||
req := c.UHostConn.NewDescribeImageRequest()
|
||||
req.ProjectId = ucloud.String(projectId)
|
||||
req.ImageId = ucloud.String(imageId)
|
||||
req.Region = ucloud.String(regionId)
|
||||
|
||||
resp, err := c.uhostconn.DescribeImage(req)
|
||||
resp, err := c.UHostConn.DescribeImage(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(resp.ImageSet) < 1 {
|
||||
return nil, newNotFoundError("image", imageId)
|
||||
return nil, NewNotFoundError("image", imageId)
|
||||
}
|
||||
|
||||
return &resp.ImageSet[0], nil
|
|
@ -0,0 +1,25 @@
|
|||
package common
|
||||
|
||||
const (
|
||||
// DefaultPasswordStr, DefaultPasswordNum and DefaultPasswordSpe are used to general default value of root password of UHost instance
|
||||
DefaultPasswordNum = "012346789"
|
||||
DefaultPasswordStr = "abcdefghijklmnopqrstuvwxyz"
|
||||
DefaultPasswordSpe = "-_"
|
||||
)
|
||||
|
||||
const (
|
||||
OsTypeWindows = "Windows"
|
||||
SecurityGroupNonWeb = "recommend non web"
|
||||
InstanceStateRunning = "Running"
|
||||
InstanceStateStopped = "Stopped"
|
||||
BootDiskStateNormal = "Normal"
|
||||
ImageStateAvailable = "Available"
|
||||
ImageStateUnavailable = "Unavailable"
|
||||
IpTypePrivate = "Private"
|
||||
)
|
||||
|
||||
var BootDiskTypeMap = NewStringConverter(map[string]string{
|
||||
"cloud_ssd": "CLOUD_SSD",
|
||||
"local_normal": "LOCAL_NORMAL",
|
||||
"local_ssd": "LOCAL_SSD",
|
||||
})
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -28,33 +28,33 @@ func (e *NotCompleteError) Error() string {
|
|||
return e.message
|
||||
}
|
||||
|
||||
func newNotFoundError(product, id string) error {
|
||||
func NewNotFoundError(product, id string) error {
|
||||
return &NotFoundError{fmt.Sprintf("the %s %s is not found", product, id)}
|
||||
}
|
||||
|
||||
func newExpectedStateError(product, id string) error {
|
||||
func NewExpectedStateError(product, id string) error {
|
||||
return &ExpectedStateError{fmt.Sprintf("the %s %s not be expected state", product, id)}
|
||||
}
|
||||
|
||||
func newNotCompleteError(product string) error {
|
||||
func NewNotCompleteError(product string) error {
|
||||
return &NotCompleteError{fmt.Sprintf("%s is not completed", product)}
|
||||
}
|
||||
|
||||
func isNotFoundError(err error) bool {
|
||||
func IsNotFoundError(err error) bool {
|
||||
if _, ok := err.(*NotFoundError); ok {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isExpectedStateError(err error) bool {
|
||||
func IsExpectedStateError(err error) bool {
|
||||
if _, ok := err.(*ExpectedStateError); ok {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isNotCompleteError(err error) bool {
|
||||
func IsNotCompleteError(err error) bool {
|
||||
if _, ok := err.(*NotCompleteError); ok {
|
||||
return true
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
//go:generate mapstructure-to-hcl2 -type ImageDestination
|
||||
|
||||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -39,7 +39,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
|
||||
if c.InstanceType == "" {
|
||||
errs = append(errs, fmt.Errorf("%q must be set", "instance_type"))
|
||||
} else if _, err := parseInstanceType(c.InstanceType); err != nil {
|
||||
} else if _, err := ParseInstanceType(c.InstanceType); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
|
||||
if c.BootDiskType == "" {
|
||||
c.BootDiskType = "cloud_ssd"
|
||||
} else if err := checkStringIn(c.BootDiskType,
|
||||
} else if err := CheckStringIn(c.BootDiskType,
|
||||
[]string{"local_normal", "local_ssd", "cloud_ssd"}); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -0,0 +1,31 @@
|
|||
package common
|
||||
|
||||
type stringConverter struct {
|
||||
c map[string]string
|
||||
r map[string]string
|
||||
}
|
||||
|
||||
func NewStringConverter(input map[string]string) stringConverter {
|
||||
reversed := make(map[string]string)
|
||||
for k, v := range input {
|
||||
reversed[v] = k
|
||||
}
|
||||
return stringConverter{
|
||||
c: input,
|
||||
r: reversed,
|
||||
}
|
||||
}
|
||||
|
||||
func (c stringConverter) Convert(src string) string {
|
||||
if dst, ok := c.c[src]; ok {
|
||||
return dst
|
||||
}
|
||||
return src
|
||||
}
|
||||
|
||||
func (c stringConverter) UnConvert(dst string) string {
|
||||
if src, ok := c.r[dst]; ok {
|
||||
return src
|
||||
}
|
||||
return dst
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -7,14 +7,14 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
type instanceType struct {
|
||||
type InstanceType struct {
|
||||
CPU int
|
||||
Memory int
|
||||
HostType string
|
||||
HostScaleType string
|
||||
}
|
||||
|
||||
func parseInstanceType(s string) (*instanceType, error) {
|
||||
func ParseInstanceType(s string) (*InstanceType, error) {
|
||||
split := strings.Split(s, "-")
|
||||
if len(split) < 3 {
|
||||
return nil, fmt.Errorf("instance type is invalid, got %q", s)
|
||||
|
@ -26,7 +26,7 @@ func parseInstanceType(s string) (*instanceType, error) {
|
|||
|
||||
return parseInstanceTypeByNormal(split...)
|
||||
}
|
||||
func (i *instanceType) String() string {
|
||||
func (i *InstanceType) String() string {
|
||||
if i.Iscustomized() {
|
||||
return fmt.Sprintf("%s-%s-%v-%v", i.HostType, i.HostScaleType, i.CPU, i.Memory)
|
||||
} else {
|
||||
|
@ -34,7 +34,7 @@ func (i *instanceType) String() string {
|
|||
}
|
||||
}
|
||||
|
||||
func (i *instanceType) Iscustomized() bool {
|
||||
func (i *InstanceType) Iscustomized() bool {
|
||||
return i.HostScaleType == "customized"
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,13 @@ var instanceTypeScaleMap = map[string]int{
|
|||
|
||||
var availableHostTypes = []string{"n"}
|
||||
|
||||
func parseInstanceTypeByCustomize(splited ...string) (*instanceType, error) {
|
||||
func parseInstanceTypeByCustomize(splited ...string) (*InstanceType, error) {
|
||||
if len(splited) != 4 {
|
||||
return nil, fmt.Errorf("instance type is invalid, expected like n-customize-1-2")
|
||||
}
|
||||
|
||||
hostType := splited[0]
|
||||
err := checkStringIn(hostType, availableHostTypes)
|
||||
err := CheckStringIn(hostType, availableHostTypes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func parseInstanceTypeByCustomize(splited ...string) (*instanceType, error) {
|
|||
return nil, fmt.Errorf("expected the number of memory must be divisible by 2 without a remainder (except single memory), got %d", memory)
|
||||
}
|
||||
|
||||
t := &instanceType{}
|
||||
t := &InstanceType{}
|
||||
t.HostType = hostType
|
||||
t.HostScaleType = hostScaleType
|
||||
t.CPU = cpu
|
||||
|
@ -105,13 +105,13 @@ func parseInstanceTypeByCustomize(splited ...string) (*instanceType, error) {
|
|||
|
||||
var availableOutstandingCpu = []int{4, 8, 16, 32, 64}
|
||||
|
||||
func parseInstanceTypeByNormal(split ...string) (*instanceType, error) {
|
||||
func parseInstanceTypeByNormal(split ...string) (*InstanceType, error) {
|
||||
if len(split) != 3 {
|
||||
return nil, fmt.Errorf("instance type is invalid, expected like n-standard-1")
|
||||
}
|
||||
|
||||
hostType := split[0]
|
||||
err := checkStringIn(hostType, []string{"n", "o"})
|
||||
err := CheckStringIn(hostType, []string{"n", "o"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func parseInstanceTypeByNormal(split ...string) (*instanceType, error) {
|
|||
}
|
||||
|
||||
if hostType == "o" {
|
||||
if err := checkIntIn(cpu, availableOutstandingCpu); err != nil {
|
||||
if err := CheckIntIn(cpu, availableOutstandingCpu); err != nil {
|
||||
return nil, fmt.Errorf("expected cpu of outstanding instancetype %q", err)
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ func parseInstanceTypeByNormal(split ...string) (*instanceType, error) {
|
|||
|
||||
memory := cpu * scale
|
||||
|
||||
t := &instanceType{}
|
||||
t := &InstanceType{}
|
||||
t.HostType = hostType
|
||||
t.HostScaleType = hostScaleType
|
||||
t.CPU = cpu
|
||||
|
@ -159,46 +159,46 @@ func parseInstanceTypeByNormal(split ...string) (*instanceType, error) {
|
|||
}
|
||||
}
|
||||
|
||||
type imageInfo struct {
|
||||
type ImageInfo struct {
|
||||
ImageId string
|
||||
ProjectId string
|
||||
Region string
|
||||
}
|
||||
|
||||
func (i *imageInfo) Id() string {
|
||||
func (i *ImageInfo) Id() string {
|
||||
return fmt.Sprintf("%s:%s", i.ProjectId, i.Region)
|
||||
}
|
||||
|
||||
type imageInfoSet struct {
|
||||
m map[string]imageInfo
|
||||
type ImageInfoSet struct {
|
||||
m map[string]ImageInfo
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
func newImageInfoSet(vL []imageInfo) *imageInfoSet {
|
||||
s := imageInfoSet{}
|
||||
func NewImageInfoSet(vL []ImageInfo) *ImageInfoSet {
|
||||
s := ImageInfoSet{}
|
||||
for _, v := range vL {
|
||||
s.Set(v)
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (i *imageInfoSet) init() {
|
||||
i.m = make(map[string]imageInfo)
|
||||
func (i *ImageInfoSet) init() {
|
||||
i.m = make(map[string]ImageInfo)
|
||||
}
|
||||
|
||||
func (i *imageInfoSet) Set(img imageInfo) {
|
||||
func (i *ImageInfoSet) Set(img ImageInfo) {
|
||||
i.once.Do(i.init)
|
||||
|
||||
i.m[img.Id()] = img
|
||||
}
|
||||
|
||||
func (i *imageInfoSet) Remove(id string) {
|
||||
func (i *ImageInfoSet) Remove(id string) {
|
||||
i.once.Do(i.init)
|
||||
|
||||
delete(i.m, id)
|
||||
}
|
||||
|
||||
func (i *imageInfoSet) Get(projectId, region string) *imageInfo {
|
||||
func (i *ImageInfoSet) Get(projectId, region string) *ImageInfo {
|
||||
k := fmt.Sprintf("%s:%s", projectId, region)
|
||||
if v, ok := i.m[k]; ok {
|
||||
return &v
|
||||
|
@ -206,8 +206,8 @@ func (i *imageInfoSet) Get(projectId, region string) *imageInfo {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (i *imageInfoSet) GetAll() []imageInfo {
|
||||
var vL []imageInfo
|
||||
func (i *ImageInfoSet) GetAll() []ImageInfo {
|
||||
var vL []ImageInfo
|
||||
for _, img := range i.m {
|
||||
vL = append(vL, img)
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
@ -12,14 +12,14 @@ func Test_parseInstanceType(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *instanceType
|
||||
want *InstanceType
|
||||
wantErr bool
|
||||
}{
|
||||
{"ok_highcpu", args{"n-highcpu-1"}, &instanceType{1, 1024, "n", "highcpu"}, false},
|
||||
{"ok_basic", args{"n-basic-1"}, &instanceType{1, 2048, "n", "basic"}, false},
|
||||
{"ok_standard", args{"n-standard-1"}, &instanceType{1, 4096, "n", "standard"}, false},
|
||||
{"ok_highmem", args{"n-highmem-1"}, &instanceType{1, 8192, "n", "highmem"}, false},
|
||||
{"ok_customized", args{"n-customized-1-12"}, &instanceType{1, 12288, "n", "customized"}, false},
|
||||
{"ok_highcpu", args{"n-highcpu-1"}, &InstanceType{1, 1024, "n", "highcpu"}, false},
|
||||
{"ok_basic", args{"n-basic-1"}, &InstanceType{1, 2048, "n", "basic"}, false},
|
||||
{"ok_standard", args{"n-standard-1"}, &InstanceType{1, 4096, "n", "standard"}, false},
|
||||
{"ok_highmem", args{"n-highmem-1"}, &InstanceType{1, 8192, "n", "highmem"}, false},
|
||||
{"ok_customized", args{"n-customized-1-12"}, &InstanceType{1, 12288, "n", "customized"}, false},
|
||||
|
||||
{"err_customized", args{"n-customized-1-5"}, nil, true},
|
||||
{"err_type", args{"nx-highcpu-1"}, nil, true},
|
||||
|
@ -33,9 +33,9 @@ func Test_parseInstanceType(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := parseInstanceType(tt.args.s)
|
||||
got, err := ParseInstanceType(tt.args.s)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("parseInstanceType() arg %s got %#v error = %v, wantErr %v", tt.args.s, got, err, tt.wantErr)
|
||||
t.Errorf("ParseInstanceType() arg %s got %#v error = %v, wantErr %v", tt.args.s, got, err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ func Test_parseInstanceType(t *testing.T) {
|
|||
!(tt.want.Memory == got.Memory) ||
|
||||
!(tt.want.HostType == got.HostType) ||
|
||||
!(tt.want.HostScaleType == got.HostScaleType) {
|
||||
t.Errorf("parseInstanceType() = %v, want %v", got, tt.want)
|
||||
t.Errorf("ParseInstanceType() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package uhost
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -8,7 +8,7 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
func checkStringIn(val string, available []string) error {
|
||||
func CheckStringIn(val string, available []string) error {
|
||||
for _, choice := range available {
|
||||
if val == choice {
|
||||
return nil
|
||||
|
@ -18,7 +18,7 @@ func checkStringIn(val string, available []string) error {
|
|||
return fmt.Errorf("should be one of %q, got %q", strings.Join(available, ","), val)
|
||||
}
|
||||
|
||||
func checkIntIn(val int, available []int) error {
|
||||
func CheckIntIn(val int, available []int) error {
|
||||
for _, choice := range available {
|
||||
if val == choice {
|
||||
return nil
|
||||
|
@ -28,7 +28,7 @@ func checkIntIn(val int, available []int) error {
|
|||
return fmt.Errorf("should be one of %v, got %d", available, val)
|
||||
}
|
||||
|
||||
func isStringIn(val string, available []string) bool {
|
||||
func IsStringIn(val string, available []string) bool {
|
||||
for _, choice := range available {
|
||||
if val == choice {
|
||||
return true
|
||||
|
@ -46,7 +46,7 @@ func SSHHost(usePrivateIp bool) func(multistep.StateBag) (string, error) {
|
|||
var privateIp, publicIp string
|
||||
|
||||
for _, v := range instance.IPSet {
|
||||
if v.Type == ipTypePrivate {
|
||||
if v.Type == IpTypePrivate {
|
||||
privateIp = v.IP
|
||||
} else {
|
||||
publicIp = v.IP
|
||||
|
@ -61,7 +61,7 @@ func SSHHost(usePrivateIp bool) func(multistep.StateBag) (string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func halt(state multistep.StateBag, err error, prefix string) multistep.StepAction {
|
||||
func Halt(state multistep.StateBag, err error, prefix string) multistep.StepAction {
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
if prefix != "" {
|
|
@ -7,6 +7,7 @@ package uhost
|
|||
import (
|
||||
"context"
|
||||
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/helper/communicator"
|
||||
"github.com/hashicorp/packer/helper/config"
|
||||
|
@ -20,9 +21,9 @@ const BuilderId = "ucloud.uhost"
|
|||
|
||||
type Config struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
AccessConfig `mapstructure:",squash"`
|
||||
ImageConfig `mapstructure:",squash"`
|
||||
RunConfig `mapstructure:",squash"`
|
||||
ucloudcommon.AccessConfig `mapstructure:",squash"`
|
||||
ucloudcommon.ImageConfig `mapstructure:",squash"`
|
||||
ucloudcommon.RunConfig `mapstructure:",squash"`
|
||||
|
||||
ctx interpolate.Context
|
||||
}
|
||||
|
@ -111,7 +112,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
|||
},
|
||||
&communicator.StepConnect{
|
||||
Config: &b.config.RunConfig.Comm,
|
||||
Host: SSHHost(
|
||||
Host: ucloudcommon.SSHHost(
|
||||
b.config.UseSSHPrivateIp),
|
||||
SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(),
|
||||
},
|
||||
|
@ -140,8 +141,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
|||
}
|
||||
|
||||
// Build the artifact and return it
|
||||
artifact := &Artifact{
|
||||
UCloudImages: state.Get("ucloud_images").(*imageInfoSet),
|
||||
artifact := &ucloudcommon.Artifact{
|
||||
UCloudImages: state.Get("ucloud_images").(*ucloudcommon.ImageInfoSet),
|
||||
BuilderIdValue: BuilderId,
|
||||
Client: client,
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package uhost
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
|
@ -20,7 +21,7 @@ func TestBuilderAcc_validateRegion(t *testing.T) {
|
|||
|
||||
testAccPreCheck(t)
|
||||
|
||||
access := &AccessConfig{Region: "cn-bj2"}
|
||||
access := &ucloudcommon.AccessConfig{Region: "cn-bj2"}
|
||||
err := access.Config()
|
||||
if err != nil {
|
||||
t.Fatalf("Error on initing UCloud AccessConfig, %s", err)
|
||||
|
@ -94,8 +95,8 @@ func TestBuilderAcc_regionCopy(t *testing.T) {
|
|||
Template: testBuilderAccRegionCopy(projectId),
|
||||
Check: checkRegionCopy(
|
||||
projectId,
|
||||
[]ImageDestination{
|
||||
{projectId, "cn-sh2", "packer-test-regionCopy-sh", "test"},
|
||||
[]ucloudcommon.ImageDestination{
|
||||
{ProjectId: projectId, Region: "cn-sh2", Name: "packer-test-regionCopy-sh", Description: "test"},
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
@ -121,21 +122,21 @@ func testBuilderAccRegionCopy(projectId string) string {
|
|||
}`, projectId)
|
||||
}
|
||||
|
||||
func checkRegionCopy(projectId string, imageDst []ImageDestination) builderT.TestCheckFunc {
|
||||
func checkRegionCopy(projectId string, imageDst []ucloudcommon.ImageDestination) builderT.TestCheckFunc {
|
||||
return func(artifacts []packer.Artifact) error {
|
||||
if len(artifacts) > 1 {
|
||||
return fmt.Errorf("more than 1 artifact")
|
||||
}
|
||||
|
||||
artifactSet := artifacts[0]
|
||||
artifact, ok := artifactSet.(*Artifact)
|
||||
artifact, ok := artifactSet.(*ucloudcommon.Artifact)
|
||||
if !ok {
|
||||
return fmt.Errorf("unknown artifact: %#v", artifactSet)
|
||||
}
|
||||
|
||||
destSet := newImageInfoSet(nil)
|
||||
destSet := ucloudcommon.NewImageInfoSet(nil)
|
||||
for _, dest := range imageDst {
|
||||
destSet.Set(imageInfo{
|
||||
destSet.Set(ucloudcommon.ImageInfo{
|
||||
Region: dest.Region,
|
||||
ProjectId: dest.ProjectId,
|
||||
})
|
||||
|
@ -163,9 +164,9 @@ func checkRegionCopy(projectId string, imageDst []ImageDestination) builderT.Tes
|
|||
if r.ProjectId == projectId && r.Region == "cn-bj2" {
|
||||
continue
|
||||
}
|
||||
imageSet, err := client.describeImageByInfo(r.ProjectId, r.Region, r.ImageId)
|
||||
imageSet, err := client.DescribeImageByInfo(r.ProjectId, r.Region, r.ImageId)
|
||||
if err != nil {
|
||||
if isNotFoundError(err) {
|
||||
if ucloudcommon.IsNotFoundError(err) {
|
||||
return fmt.Errorf("image %s in artifacts can not be found", r.ImageId)
|
||||
}
|
||||
return err
|
||||
|
@ -205,8 +206,8 @@ func TestUCloudClientBaseUrlConfigurable(t *testing.T) {
|
|||
assert.Equal(t, url, client.vpcconn.Client.GetConfig().BaseUrl, "vpc conn's base url not configurable")
|
||||
}
|
||||
|
||||
func testUCloudClient() (*UCloudClient, error) {
|
||||
access := &AccessConfig{Region: "cn-bj2"}
|
||||
func testUCloudClient() (*ucloudcommon.UCloudClient, error) {
|
||||
access := &ucloudcommon.AccessConfig{Region: "cn-bj2"}
|
||||
err := access.Config()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package uhost
|
||||
|
||||
import (
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
@ -120,7 +121,7 @@ func TestBuilderPrepare_ImageDestinations(t *testing.T) {
|
|||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(b.config.ImageDestinations, []ImageDestination{
|
||||
if !reflect.DeepEqual(b.config.ImageDestinations, []ucloudcommon.ImageDestination{
|
||||
{
|
||||
ProjectId: "project1",
|
||||
Region: "region1",
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package uhost
|
||||
|
||||
const (
|
||||
// defaultPasswordStr, defaultPasswordNum and defaultPasswordSpe are used to general default value of root password of UHost instance
|
||||
defaultPasswordNum = "012346789"
|
||||
defaultPasswordStr = "abcdefghijklmnopqrstuvwxyz"
|
||||
defaultPasswordSpe = "-_"
|
||||
)
|
||||
|
||||
const (
|
||||
osTypeWindows = "Windows"
|
||||
securityGroupNonWeb = "recommend non web"
|
||||
instanceStateRunning = "Running"
|
||||
instanceStateStopped = "Stopped"
|
||||
bootDiskStateNormal = "Normal"
|
||||
imageStateAvailable = "Available"
|
||||
ipTypePrivate = "Private"
|
||||
)
|
||||
|
||||
var bootDiskTypeMap = map[string]string{
|
||||
"cloud_ssd": "CLOUD_SSD",
|
||||
"local_normal": "LOCAL_NORMAL",
|
||||
"local_ssd": "LOCAL_SSD",
|
||||
}
|
|
@ -3,6 +3,7 @@ package uhost
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
)
|
||||
|
@ -13,20 +14,20 @@ type stepCheckSourceImageId struct {
|
|||
|
||||
func (s *stepCheckSourceImageId) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
|
||||
ui.Say("Querying source image id...")
|
||||
|
||||
imageSet, err := client.DescribeImageById(s.SourceUHostImageId)
|
||||
if err != nil {
|
||||
if isNotFoundError(err) {
|
||||
return halt(state, err, "")
|
||||
if ucloudcommon.IsNotFoundError(err) {
|
||||
return ucloudcommon.Halt(state, err, "")
|
||||
}
|
||||
return halt(state, err, fmt.Sprintf("Error on querying specified source_image_id %q", s.SourceUHostImageId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on querying specified source_image_id %q", s.SourceUHostImageId))
|
||||
}
|
||||
|
||||
if imageSet.OsType == osTypeWindows {
|
||||
return halt(state, err, "The ucloud-uhost builder does not support Windows images yet")
|
||||
if imageSet.OsType == ucloudcommon.OsTypeWindows {
|
||||
return ucloudcommon.Halt(state, err, "The ucloud-uhost builder does not support Windows images yet")
|
||||
}
|
||||
|
||||
state.Put("source_image", imageSet)
|
||||
|
|
|
@ -3,6 +3,7 @@ package uhost
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud"
|
||||
|
@ -13,19 +14,19 @@ type stepConfigSecurityGroup struct {
|
|||
}
|
||||
|
||||
func (s *stepConfigSecurityGroup) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
conn := client.unetconn
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
conn := client.UNetConn
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
if len(s.SecurityGroupId) != 0 {
|
||||
ui.Say(fmt.Sprintf("Trying to use specified security group %q...", s.SecurityGroupId))
|
||||
securityGroupSet, err := client.describeFirewallById(s.SecurityGroupId)
|
||||
securityGroupSet, err := client.DescribeFirewallById(s.SecurityGroupId)
|
||||
if err != nil {
|
||||
if isNotFoundError(err) {
|
||||
if ucloudcommon.IsNotFoundError(err) {
|
||||
err = fmt.Errorf("the specified security group %q does not exist", s.SecurityGroupId)
|
||||
return halt(state, err, "")
|
||||
return ucloudcommon.Halt(state, err, "")
|
||||
}
|
||||
return halt(state, err, fmt.Sprintf("Error on querying specified security group %q", s.SecurityGroupId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on querying specified security group %q", s.SecurityGroupId))
|
||||
}
|
||||
|
||||
state.Put("security_group_id", securityGroupSet.FWId)
|
||||
|
@ -44,7 +45,7 @@ func (s *stepConfigSecurityGroup) Run(ctx context.Context, state multistep.State
|
|||
|
||||
resp, err := conn.DescribeFirewall(req)
|
||||
if err != nil {
|
||||
return halt(state, err, "Error on querying default security group")
|
||||
return ucloudcommon.Halt(state, err, "Error on querying default security group")
|
||||
}
|
||||
|
||||
if resp == nil || len(resp.DataSet) < 1 {
|
||||
|
@ -52,7 +53,7 @@ func (s *stepConfigSecurityGroup) Run(ctx context.Context, state multistep.State
|
|||
}
|
||||
|
||||
for _, item := range resp.DataSet {
|
||||
if item.Type == securityGroupNonWeb {
|
||||
if item.Type == ucloudcommon.SecurityGroupNonWeb {
|
||||
securityGroupId = item.FWId
|
||||
break
|
||||
}
|
||||
|
@ -66,7 +67,7 @@ func (s *stepConfigSecurityGroup) Run(ctx context.Context, state multistep.State
|
|||
}
|
||||
|
||||
if securityGroupId == "" {
|
||||
return halt(state, fmt.Errorf("the default security group does not exist"), "")
|
||||
return ucloudcommon.Halt(state, fmt.Errorf("the default security group does not exist"), "")
|
||||
}
|
||||
|
||||
state.Put("security_group_id", securityGroupId)
|
||||
|
|
|
@ -3,6 +3,7 @@ package uhost
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
)
|
||||
|
@ -12,18 +13,18 @@ type stepConfigSubnet struct {
|
|||
}
|
||||
|
||||
func (s *stepConfigSubnet) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
if len(s.SubnetId) != 0 {
|
||||
ui.Say(fmt.Sprintf("Trying to use specified subnet %q...", s.SubnetId))
|
||||
subnetSet, err := client.describeSubnetById(s.SubnetId)
|
||||
subnetSet, err := client.DescribeSubnetById(s.SubnetId)
|
||||
if err != nil {
|
||||
if isNotFoundError(err) {
|
||||
if ucloudcommon.IsNotFoundError(err) {
|
||||
err = fmt.Errorf("the specified subnet %q does not exist", s.SubnetId)
|
||||
return halt(state, err, "")
|
||||
return ucloudcommon.Halt(state, err, "")
|
||||
}
|
||||
return halt(state, err, fmt.Sprintf("Error on querying specified subnet %q", s.SubnetId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on querying specified subnet %q", s.SubnetId))
|
||||
}
|
||||
|
||||
state.Put("subnet_id", subnetSet.SubnetId)
|
||||
|
|
|
@ -3,6 +3,7 @@ package uhost
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
|
@ -13,19 +14,19 @@ type stepConfigVPC struct {
|
|||
}
|
||||
|
||||
func (s *stepConfigVPC) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
if len(s.VPCId) != 0 {
|
||||
ui.Say(fmt.Sprintf("Trying to use specified vpc %q...", s.VPCId))
|
||||
|
||||
vpcSet, err := client.describeVPCById(s.VPCId)
|
||||
vpcSet, err := client.DescribeVPCById(s.VPCId)
|
||||
if err != nil {
|
||||
if isNotFoundError(err) {
|
||||
if ucloudcommon.IsNotFoundError(err) {
|
||||
err = fmt.Errorf("the specified vpc %q does not exist", s.VPCId)
|
||||
return halt(state, err, "")
|
||||
return ucloudcommon.Halt(state, err, "")
|
||||
}
|
||||
return halt(state, err, fmt.Sprintf("Error on querying specified vpc %q", s.VPCId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on querying specified vpc %q", s.VPCId))
|
||||
}
|
||||
|
||||
state.Put("vpc_id", vpcSet.VPCId)
|
||||
|
|
|
@ -3,6 +3,7 @@ package uhost
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/common/retry"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -13,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
type stepCopyUCloudImage struct {
|
||||
ImageDestinations []ImageDestination
|
||||
ImageDestinations []ucloudcommon.ImageDestination
|
||||
RegionId string
|
||||
ProjectId string
|
||||
}
|
||||
|
@ -23,13 +24,13 @@ func (s *stepCopyUCloudImage) Run(ctx context.Context, state multistep.StateBag)
|
|||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
conn := client.uhostconn
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
conn := client.UHostConn
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
srcImageId := state.Get("image_id").(string)
|
||||
artifactImages := state.Get("ucloud_images").(*imageInfoSet)
|
||||
expectedImages := newImageInfoSet(nil)
|
||||
artifactImages := state.Get("ucloud_images").(*ucloudcommon.ImageInfoSet)
|
||||
expectedImages := ucloudcommon.NewImageInfoSet(nil)
|
||||
ui.Say(fmt.Sprintf("Copying images from %q...", srcImageId))
|
||||
for _, v := range s.ImageDestinations {
|
||||
if v.ProjectId == s.ProjectId && v.Region == s.RegionId {
|
||||
|
@ -45,10 +46,10 @@ func (s *stepCopyUCloudImage) Run(ctx context.Context, state multistep.StateBag)
|
|||
|
||||
resp, err := conn.CopyCustomImage(req)
|
||||
if err != nil {
|
||||
return halt(state, err, fmt.Sprintf("Error on copying image %q to %s:%s", srcImageId, v.ProjectId, v.Region))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on copying image %q to %s:%s", srcImageId, v.ProjectId, v.Region))
|
||||
}
|
||||
|
||||
image := imageInfo{
|
||||
image := ucloudcommon.ImageInfo{
|
||||
Region: v.Region,
|
||||
ProjectId: v.ProjectId,
|
||||
ImageId: resp.TargetImageId,
|
||||
|
@ -63,23 +64,23 @@ func (s *stepCopyUCloudImage) Run(ctx context.Context, state multistep.StateBag)
|
|||
|
||||
err := retry.Config{
|
||||
Tries: 200,
|
||||
ShouldRetry: func(err error) bool { return isNotCompleteError(err) },
|
||||
ShouldRetry: func(err error) bool { return ucloudcommon.IsNotCompleteError(err) },
|
||||
RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 12 * time.Second, Multiplier: 2}).Linear,
|
||||
}.Run(ctx, func(ctx context.Context) error {
|
||||
for _, v := range expectedImages.GetAll() {
|
||||
imageSet, err := client.describeImageByInfo(v.ProjectId, v.Region, v.ImageId)
|
||||
imageSet, err := client.DescribeImageByInfo(v.ProjectId, v.Region, v.ImageId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading %s:%s:%s failed, %s", v.ProjectId, v.Region, v.ImageId, err)
|
||||
}
|
||||
|
||||
if imageSet.State == imageStateAvailable {
|
||||
if imageSet.State == ucloudcommon.ImageStateAvailable {
|
||||
expectedImages.Remove(v.Id())
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if len(expectedImages.GetAll()) != 0 {
|
||||
return newNotCompleteError("copying image")
|
||||
return ucloudcommon.NewNotCompleteError("copying image")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -91,7 +92,7 @@ func (s *stepCopyUCloudImage) Run(ctx context.Context, state multistep.StateBag)
|
|||
s = append(s, fmt.Sprintf("%s:%s:%s", v.ProjectId, v.Region, v.ImageId))
|
||||
}
|
||||
|
||||
return halt(state, err, fmt.Sprintf("Error on waiting for copying images %q to become available", strings.Join(s, ",")))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on waiting for copying images %q to become available", strings.Join(s, ",")))
|
||||
}
|
||||
|
||||
ui.Message(fmt.Sprintf("Copying image complete"))
|
||||
|
@ -107,7 +108,7 @@ func (s *stepCopyUCloudImage) Cleanup(state multistep.StateBag) {
|
|||
}
|
||||
|
||||
srcImageId := state.Get("image_id").(string)
|
||||
ucloudImages := state.Get("ucloud_images").(*imageInfoSet)
|
||||
ucloudImages := state.Get("ucloud_images").(*ucloudcommon.ImageInfoSet)
|
||||
imageInfos := ucloudImages.GetAll()
|
||||
if len(imageInfos) == 0 {
|
||||
return
|
||||
|
@ -116,8 +117,8 @@ func (s *stepCopyUCloudImage) Cleanup(state multistep.StateBag) {
|
|||
}
|
||||
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
conn := client.uhostconn
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
conn := client.UHostConn
|
||||
ui.Say(fmt.Sprintf("Deleting copied image because of cancellation or error..."))
|
||||
|
||||
for _, v := range imageInfos {
|
||||
|
|
|
@ -3,6 +3,7 @@ package uhost
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/common/retry"
|
||||
"time"
|
||||
|
||||
|
@ -17,8 +18,8 @@ type stepCreateImage struct {
|
|||
}
|
||||
|
||||
func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
conn := client.uhostconn
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
conn := client.UHostConn
|
||||
instance := state.Get("instance").(*uhost.UHostInstanceSet)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
config := state.Get("config").(*Config)
|
||||
|
@ -32,14 +33,14 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
|
|||
|
||||
resp, err := conn.CreateCustomImage(req)
|
||||
if err != nil {
|
||||
return halt(state, err, "Error on creating image")
|
||||
return ucloudcommon.Halt(state, err, "Error on creating image")
|
||||
}
|
||||
ui.Message(fmt.Sprintf("Waiting for the created image %q to become available...", resp.ImageId))
|
||||
|
||||
err = retry.Config{
|
||||
Tries: 200,
|
||||
ShouldRetry: func(err error) bool {
|
||||
return isExpectedStateError(err)
|
||||
return ucloudcommon.IsExpectedStateError(err)
|
||||
},
|
||||
RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 12 * time.Second, Multiplier: 2}).Linear,
|
||||
}.Run(ctx, func(ctx context.Context) error {
|
||||
|
@ -47,26 +48,26 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if inst == nil || inst.State != imageStateAvailable {
|
||||
return newExpectedStateError("image", resp.ImageId)
|
||||
if inst == nil || inst.State != ucloudcommon.ImageStateAvailable {
|
||||
return ucloudcommon.NewExpectedStateError("image", resp.ImageId)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return halt(state, err, fmt.Sprintf("Error on waiting for image %q to become available", resp.ImageId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on waiting for image %q to become available", resp.ImageId))
|
||||
}
|
||||
|
||||
imageSet, err := client.DescribeImageById(resp.ImageId)
|
||||
if err != nil {
|
||||
return halt(state, err, fmt.Sprintf("Error on reading image when creating %q", resp.ImageId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on reading image when creating %q", resp.ImageId))
|
||||
}
|
||||
|
||||
s.image = imageSet
|
||||
state.Put("image_id", imageSet.ImageId)
|
||||
|
||||
images := []imageInfo{
|
||||
images := []ucloudcommon.ImageInfo{
|
||||
{
|
||||
ImageId: imageSet.ImageId,
|
||||
ProjectId: config.ProjectId,
|
||||
|
@ -74,7 +75,7 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
|
|||
},
|
||||
}
|
||||
|
||||
state.Put("ucloud_images", newImageInfoSet(images))
|
||||
state.Put("ucloud_images", ucloudcommon.NewImageInfoSet(images))
|
||||
ui.Message(fmt.Sprintf("Creating image %q complete", imageSet.ImageId))
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
@ -89,8 +90,8 @@ func (s *stepCreateImage) Cleanup(state multistep.StateBag) {
|
|||
return
|
||||
}
|
||||
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
conn := client.uhostconn
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
conn := client.UHostConn
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
ui.Say("Deleting image because of cancellation or error...")
|
||||
|
|
|
@ -3,6 +3,7 @@ package uhost
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/common/retry"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
|
@ -26,25 +27,25 @@ type stepCreateInstance struct {
|
|||
}
|
||||
|
||||
func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
conn := client.uhostconn
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
conn := client.UHostConn
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
ui.Say("Creating Instance...")
|
||||
resp, err := conn.CreateUHostInstance(s.buildCreateInstanceRequest(state))
|
||||
if err != nil {
|
||||
return halt(state, err, "Error on creating instance")
|
||||
return ucloudcommon.Halt(state, err, "Error on creating instance")
|
||||
}
|
||||
instanceId := resp.UHostIds[0]
|
||||
|
||||
err = retry.Config{
|
||||
Tries: 20,
|
||||
ShouldRetry: func(err error) bool {
|
||||
return isExpectedStateError(err)
|
||||
return ucloudcommon.IsExpectedStateError(err)
|
||||
},
|
||||
RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 6 * time.Second, Multiplier: 2}).Linear,
|
||||
}.Run(ctx, func(ctx context.Context) error {
|
||||
inst, err := client.describeUHostById(instanceId)
|
||||
inst, err := client.DescribeUHostById(instanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -57,27 +58,27 @@ func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
|
|||
return fmt.Errorf("install failed")
|
||||
}
|
||||
|
||||
if inst == nil || inst.State != instanceStateRunning {
|
||||
return newExpectedStateError("instance", instanceId)
|
||||
if inst == nil || inst.State != ucloudcommon.InstanceStateRunning {
|
||||
return ucloudcommon.NewExpectedStateError("instance", instanceId)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return halt(state, err, fmt.Sprintf("Error on waiting for instance %q to become available", instanceId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on waiting for instance %q to become available", instanceId))
|
||||
}
|
||||
|
||||
ui.Message(fmt.Sprintf("Creating instance %q complete", instanceId))
|
||||
instance, err := client.describeUHostById(instanceId)
|
||||
instance, err := client.DescribeUHostById(instanceId)
|
||||
if err != nil {
|
||||
return halt(state, err, fmt.Sprintf("Error on reading instance when creating %q", instanceId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on reading instance when creating %q", instanceId))
|
||||
}
|
||||
|
||||
s.instanceId = instanceId
|
||||
state.Put("instance", instance)
|
||||
|
||||
if instance.BootDiskState != bootDiskStateNormal {
|
||||
if instance.BootDiskState != ucloudcommon.BootDiskStateNormal {
|
||||
ui.Say("Waiting for boot disk of instance initialized")
|
||||
if s.BootDiskType == "local_normal" || s.BootDiskType == "local_ssd" {
|
||||
ui.Message(fmt.Sprintf("Warning: It takes around 10 mins for boot disk initialization when `boot_disk_type` is %q", s.BootDiskType))
|
||||
|
@ -86,23 +87,23 @@ func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
|
|||
err = retry.Config{
|
||||
Tries: 200,
|
||||
ShouldRetry: func(err error) bool {
|
||||
return isExpectedStateError(err)
|
||||
return ucloudcommon.IsExpectedStateError(err)
|
||||
},
|
||||
RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 12 * time.Second, Multiplier: 2}).Linear,
|
||||
}.Run(ctx, func(ctx context.Context) error {
|
||||
inst, err := client.describeUHostById(instanceId)
|
||||
inst, err := client.DescribeUHostById(instanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if inst.BootDiskState != bootDiskStateNormal {
|
||||
return newExpectedStateError("boot_disk of instance", instanceId)
|
||||
if inst.BootDiskState != ucloudcommon.BootDiskStateNormal {
|
||||
return ucloudcommon.NewExpectedStateError("boot_disk of instance", instanceId)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return halt(state, err, fmt.Sprintf("Error on waiting for boot disk of instance %q initialized", instanceId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on waiting for boot disk of instance %q initialized", instanceId))
|
||||
}
|
||||
|
||||
ui.Message(fmt.Sprintf("Waiting for boot disk of instance %q initialized complete", instanceId))
|
||||
|
@ -127,12 +128,12 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) {
|
|||
ui.Say("Deleting instance...")
|
||||
}
|
||||
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
conn := client.uhostconn
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
conn := client.UHostConn
|
||||
|
||||
instance, err := client.describeUHostById(s.instanceId)
|
||||
instance, err := client.DescribeUHostById(s.instanceId)
|
||||
if err != nil {
|
||||
if isNotFoundError(err) {
|
||||
if ucloudcommon.IsNotFoundError(err) {
|
||||
return
|
||||
}
|
||||
ui.Error(fmt.Sprintf("Error on reading instance when deleting %q, %s",
|
||||
|
@ -140,7 +141,7 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) {
|
|||
return
|
||||
}
|
||||
|
||||
if instance.State != instanceStateStopped {
|
||||
if instance.State != ucloudcommon.InstanceStateStopped {
|
||||
stopReq := conn.NewStopUHostInstanceRequest()
|
||||
stopReq.UHostId = ucloud.String(s.instanceId)
|
||||
if _, err = conn.StopUHostInstance(stopReq); err != nil {
|
||||
|
@ -152,17 +153,17 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) {
|
|||
err = retry.Config{
|
||||
Tries: 30,
|
||||
ShouldRetry: func(err error) bool {
|
||||
return isExpectedStateError(err)
|
||||
return ucloudcommon.IsExpectedStateError(err)
|
||||
},
|
||||
RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 6 * time.Second, Multiplier: 2}).Linear,
|
||||
}.Run(ctx, func(ctx context.Context) error {
|
||||
instance, err := client.describeUHostById(s.instanceId)
|
||||
instance, err := client.DescribeUHostById(s.instanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if instance.State != instanceStateStopped {
|
||||
return newExpectedStateError("instance", s.instanceId)
|
||||
if instance.State != ucloudcommon.InstanceStateStopped {
|
||||
return ucloudcommon.NewExpectedStateError("instance", s.instanceId)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -188,10 +189,10 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) {
|
|||
|
||||
err = retry.Config{
|
||||
Tries: 30,
|
||||
ShouldRetry: func(err error) bool { return !isNotFoundError(err) },
|
||||
ShouldRetry: func(err error) bool { return !ucloudcommon.IsNotFoundError(err) },
|
||||
RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 6 * time.Second, Multiplier: 2}).Linear,
|
||||
}.Run(ctx, func(ctx context.Context) error {
|
||||
_, err := client.describeUHostById(s.instanceId)
|
||||
_, err := client.DescribeUHostById(s.instanceId)
|
||||
return err
|
||||
})
|
||||
|
||||
|
@ -205,8 +206,8 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) {
|
|||
}
|
||||
|
||||
func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag) *uhost.CreateUHostInstanceRequest {
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
conn := client.uhostconn
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
conn := client.UHostConn
|
||||
srcImage := state.Get("source_image").(*uhost.UHostImageSet)
|
||||
config := state.Get("config").(*Config)
|
||||
connectConfig := &config.RunConfig.Comm
|
||||
|
@ -218,16 +219,16 @@ func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag
|
|||
|
||||
if password == "" {
|
||||
password = fmt.Sprintf("%s%s%s",
|
||||
s.randStringFromCharSet(5, defaultPasswordStr),
|
||||
s.randStringFromCharSet(1, defaultPasswordSpe),
|
||||
s.randStringFromCharSet(5, defaultPasswordNum))
|
||||
s.randStringFromCharSet(5, ucloudcommon.DefaultPasswordStr),
|
||||
s.randStringFromCharSet(1, ucloudcommon.DefaultPasswordSpe),
|
||||
s.randStringFromCharSet(5, ucloudcommon.DefaultPasswordNum))
|
||||
if srcImage.OsType == "Linux" {
|
||||
connectConfig.SSHPassword = password
|
||||
}
|
||||
}
|
||||
|
||||
req := conn.NewCreateUHostInstanceRequest()
|
||||
t, _ := parseInstanceType(s.InstanceType)
|
||||
t, _ := ucloudcommon.ParseInstanceType(s.InstanceType)
|
||||
|
||||
req.CPU = ucloud.Int(t.CPU)
|
||||
req.Memory = ucloud.Int(t.Memory)
|
||||
|
@ -238,6 +239,13 @@ func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag
|
|||
req.ChargeType = ucloud.String("Dynamic")
|
||||
req.Password = ucloud.String(password)
|
||||
|
||||
req.MachineType = ucloud.String("N")
|
||||
req.MinimalCpuPlatform = ucloud.String("Intel/Auto")
|
||||
if t.HostType == "o" {
|
||||
req.MachineType = ucloud.String("O")
|
||||
req.MinimalCpuPlatform = ucloud.String("Intel/Cascadelake")
|
||||
}
|
||||
|
||||
if v, ok := state.GetOk("security_group_id"); ok {
|
||||
req.SecurityGroupId = ucloud.String(v.(string))
|
||||
}
|
||||
|
@ -253,14 +261,14 @@ func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag
|
|||
bootDisk := uhost.UHostDisk{}
|
||||
bootDisk.IsBoot = ucloud.String("true")
|
||||
bootDisk.Size = ucloud.Int(srcImage.ImageSize)
|
||||
bootDisk.Type = ucloud.String(bootDiskTypeMap[s.BootDiskType])
|
||||
bootDisk.Type = ucloud.String(ucloudcommon.BootDiskTypeMap.Convert(s.BootDiskType))
|
||||
|
||||
req.Disks = append(req.Disks, bootDisk)
|
||||
|
||||
if !s.UsePrivateIp {
|
||||
operatorName := ucloud.String("International")
|
||||
if strings.HasPrefix(s.Region, "cn-") {
|
||||
operatorName = ucloud.String("Bgp")
|
||||
operatorName = ucloud.String("BGP")
|
||||
}
|
||||
networkInterface := uhost.CreateUHostInstanceParamNetworkInterface{
|
||||
EIP: &uhost.CreateUHostInstanceParamNetworkInterfaceEIP{
|
||||
|
|
|
@ -2,6 +2,7 @@ package uhost
|
|||
|
||||
import (
|
||||
"context"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
)
|
||||
|
@ -10,20 +11,20 @@ type stepPreValidate struct {
|
|||
ProjectId string
|
||||
Region string
|
||||
Zone string
|
||||
ImageDestinations []ImageDestination
|
||||
ImageDestinations []ucloudcommon.ImageDestination
|
||||
}
|
||||
|
||||
func (s *stepPreValidate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
if err := s.validateProjectIds(state); err != nil {
|
||||
return halt(state, err, "")
|
||||
return ucloudcommon.Halt(state, err, "")
|
||||
}
|
||||
|
||||
if err := s.validateRegions(state); err != nil {
|
||||
return halt(state, err, "")
|
||||
return ucloudcommon.Halt(state, err, "")
|
||||
}
|
||||
|
||||
if err := s.validateZones(state); err != nil {
|
||||
return halt(state, err, "")
|
||||
return ucloudcommon.Halt(state, err, "")
|
||||
}
|
||||
|
||||
return multistep.ActionContinue
|
||||
|
|
|
@ -3,6 +3,7 @@ package uhost
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/common/retry"
|
||||
"time"
|
||||
|
||||
|
@ -16,17 +17,17 @@ type stepStopInstance struct {
|
|||
}
|
||||
|
||||
func (s *stepStopInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
client := state.Get("client").(*UCloudClient)
|
||||
conn := client.uhostconn
|
||||
client := state.Get("client").(*ucloudcommon.UCloudClient)
|
||||
conn := client.UHostConn
|
||||
instance := state.Get("instance").(*uhost.UHostInstanceSet)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
instance, err := client.describeUHostById(instance.UHostId)
|
||||
instance, err := client.DescribeUHostById(instance.UHostId)
|
||||
if err != nil {
|
||||
return halt(state, err, fmt.Sprintf("Error on reading instance when stopping %q", instance.UHostId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on reading instance when stopping %q", instance.UHostId))
|
||||
}
|
||||
|
||||
if instance.State != instanceStateStopped {
|
||||
if instance.State != ucloudcommon.InstanceStateStopped {
|
||||
stopReq := conn.NewStopUHostInstanceRequest()
|
||||
stopReq.UHostId = ucloud.String(instance.UHostId)
|
||||
ui.Say(fmt.Sprintf("Stopping instance %q", instance.UHostId))
|
||||
|
@ -44,30 +45,30 @@ func (s *stepStopInstance) Run(ctx context.Context, state multistep.StateBag) mu
|
|||
})
|
||||
|
||||
if err != nil {
|
||||
return halt(state, err, fmt.Sprintf("Error on stopping instance %q", instance.UHostId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on stopping instance %q", instance.UHostId))
|
||||
}
|
||||
|
||||
err = retry.Config{
|
||||
Tries: 20,
|
||||
ShouldRetry: func(err error) bool {
|
||||
return isExpectedStateError(err)
|
||||
return ucloudcommon.IsExpectedStateError(err)
|
||||
},
|
||||
RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 6 * time.Second, Multiplier: 2}).Linear,
|
||||
}.Run(ctx, func(ctx context.Context) error {
|
||||
instance, err := client.describeUHostById(instance.UHostId)
|
||||
instance, err := client.DescribeUHostById(instance.UHostId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if instance.State != instanceStateStopped {
|
||||
return newExpectedStateError("instance", instance.UHostId)
|
||||
if instance.State != ucloudcommon.InstanceStateStopped {
|
||||
return ucloudcommon.NewExpectedStateError("instance", instance.UHostId)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return halt(state, err, fmt.Sprintf("Error on waiting for stopping instance when stopping %q", instance.UHostId))
|
||||
return ucloudcommon.Halt(state, err, fmt.Sprintf("Error on waiting for stopping instance when stopping %q", instance.UHostId))
|
||||
}
|
||||
|
||||
ui.Message(fmt.Sprintf("Stopping instance %q complete", instance.UHostId))
|
||||
|
|
|
@ -75,6 +75,7 @@ import (
|
|||
googlecomputeimportpostprocessor "github.com/hashicorp/packer/post-processor/googlecompute-import"
|
||||
manifestpostprocessor "github.com/hashicorp/packer/post-processor/manifest"
|
||||
shelllocalpostprocessor "github.com/hashicorp/packer/post-processor/shell-local"
|
||||
ucloudimportpostprocessor "github.com/hashicorp/packer/post-processor/ucloud-import"
|
||||
vagrantpostprocessor "github.com/hashicorp/packer/post-processor/vagrant"
|
||||
vagrantcloudpostprocessor "github.com/hashicorp/packer/post-processor/vagrant-cloud"
|
||||
vspherepostprocessor "github.com/hashicorp/packer/post-processor/vsphere"
|
||||
|
@ -174,6 +175,7 @@ var Provisioners = map[string]packer.Provisioner{
|
|||
|
||||
var PostProcessors = map[string]packer.PostProcessor{
|
||||
"alicloud-import": new(alicloudimportpostprocessor.PostProcessor),
|
||||
"ucloud-import": new(ucloudimportpostprocessor.PostProcessor),
|
||||
"amazon-import": new(amazonimportpostprocessor.PostProcessor),
|
||||
"artifice": new(artificepostprocessor.PostProcessor),
|
||||
"checksum": new(checksumpostprocessor.PostProcessor),
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
"ucloud_private_key": "{{env `UCLOUD_PRIVATE_KEY`}}",
|
||||
"ucloud_project_id": "{{env `UCLOUD_PROJECT_ID`}}"
|
||||
},
|
||||
|
||||
"builders": [{
|
||||
"builders": [
|
||||
{
|
||||
"type": "ucloud-uhost",
|
||||
"public_key": "{{user `ucloud_public_key`}}",
|
||||
"private_key": "{{user `ucloud_private_key`}}",
|
||||
|
@ -16,18 +16,23 @@
|
|||
"source_image_id": "uimage-f1chxn",
|
||||
"ssh_username": "root",
|
||||
"image_name": "packer-test-basic-bj",
|
||||
"image_copy_to_mappings": [{
|
||||
"image_copy_to_mappings": [
|
||||
{
|
||||
"project_id": "{{user `ucloud_project_id`}}",
|
||||
"region": "cn-sh2",
|
||||
"description": "test",
|
||||
"name": "packer-test-basic-sh"
|
||||
}]
|
||||
}],
|
||||
"provisioners": [{
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "shell",
|
||||
"inline": [
|
||||
"yum install -y nginx"
|
||||
]
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
install
|
||||
cdrom
|
||||
lang en_US.UTF-8
|
||||
keyboard us
|
||||
network --bootproto=dhcp
|
||||
rootpw vagrant
|
||||
firewall --disabled
|
||||
selinux --permissive
|
||||
timezone UTC
|
||||
unsupported_hardware
|
||||
bootloader --location=mbr
|
||||
text
|
||||
skipx
|
||||
zerombr
|
||||
clearpart --all
|
||||
autopart
|
||||
auth --enableshadow --passalgo=sha512
|
||||
firstboot --disabled
|
||||
reboot
|
||||
user --name=vagrant --password=vagrant
|
||||
|
||||
%packages --nobase --ignoremissing
|
||||
# vagrant needs this to copy initial files via scp
|
||||
openssh-clients
|
||||
sudo
|
||||
kernel-headers
|
||||
kernel-devel
|
||||
gcc
|
||||
make
|
||||
perl
|
||||
wget
|
||||
nfs-utils
|
||||
-fprintd-pam
|
||||
-intltool
|
||||
%end
|
||||
|
||||
%post
|
||||
# Force to set SELinux to a permissive mode
|
||||
sed -i -e 's/\(^SELINUX=\).*$/\1permissive/' /etc/selinux/config
|
||||
# sudo
|
||||
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
|
||||
%end
|
|
@ -0,0 +1,61 @@
|
|||
{"variables": {
|
||||
"build_timestamp": "{{isotime \"20060102150405\"}}",
|
||||
"cpus": "1",
|
||||
"disk_size": "4096",
|
||||
"git_revision": "__unknown_git_revision__",
|
||||
"headless": "",
|
||||
"http_proxy": "{{env `http_proxy`}}",
|
||||
"https_proxy": "{{env `https_proxy`}}",
|
||||
"iso_checksum": "7002b56184180591a8fa08c2fe0c7338",
|
||||
"iso_checksum_type": "md5",
|
||||
"iso_name": "CentOS-7-x86_64-Minimal-1908.iso",
|
||||
"ks_path": "centos-6.8/ks.cfg",
|
||||
"memory": "512",
|
||||
"metadata": "floppy/dummy_metadata.json",
|
||||
"mirror": "https://mirrors.sjtug.sjtu.edu.cn/centos",
|
||||
"mirror_directory": "7.7.1908/isos/x86_64",
|
||||
"no_proxy": "{{env `no_proxy`}}",
|
||||
"template": "centos-7.7-x86_64",
|
||||
"version": "2.1.TIMESTAMP"
|
||||
},
|
||||
"builders":[
|
||||
{
|
||||
"type": "qemu",
|
||||
"boot_command": [
|
||||
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `ks_path`}}<enter><wait>"
|
||||
],
|
||||
"boot_wait": "10s",
|
||||
"disk_size": "{{user `disk_size`}}",
|
||||
"headless": "{{ user `headless` }}",
|
||||
"http_directory": "http",
|
||||
"iso_checksum": "{{user `iso_checksum`}}",
|
||||
"iso_checksum_type": "{{user `iso_checksum_type`}}",
|
||||
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
|
||||
"output_directory": "packer-{{user `template`}}-qemu",
|
||||
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/halt -h -p",
|
||||
"ssh_password": "vagrant",
|
||||
"ssh_port": 22,
|
||||
"ssh_username": "root",
|
||||
"ssh_timeout": "10000s",
|
||||
"vm_name": "{{ user `template` }}.raw",
|
||||
"net_device": "virtio-net",
|
||||
"disk_interface": "virtio",
|
||||
"format": "raw",
|
||||
"use_default_display": "false",
|
||||
"qemuargs": [
|
||||
["-display", "cocoa"]
|
||||
]
|
||||
}
|
||||
],
|
||||
"post-processors":[
|
||||
{
|
||||
"type":"ucloud-import",
|
||||
"ufile_bucket_name": "packer",
|
||||
"image_name": "packer_import",
|
||||
"image_os_type": "CentOS",
|
||||
"image_os_name": "CentOS 6.8 64位",
|
||||
"format": "raw",
|
||||
"region":"cn-bj2"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
{"variables": {
|
||||
"build_timestamp": "{{isotime \"20060102150405\"}}",
|
||||
"cpus": "1",
|
||||
"disk_size": "4096",
|
||||
"git_revision": "__unknown_git_revision__",
|
||||
"headless": "",
|
||||
"http_proxy": "{{env `http_proxy`}}",
|
||||
"https_proxy": "{{env `https_proxy`}}",
|
||||
"iso_checksum": "7002b56184180591a8fa08c2fe0c7338",
|
||||
"iso_checksum_type": "md5",
|
||||
"iso_name": "CentOS-7-x86_64-Minimal-1908.iso",
|
||||
"ks_path": "centos-6.8/ks.cfg",
|
||||
"memory": "512",
|
||||
"metadata": "floppy/dummy_metadata.json",
|
||||
"mirror": "http://mirrors.aliyun.com/centos",
|
||||
"mirror_directory": "7/isos/x86_64",
|
||||
"no_proxy": "{{env `no_proxy`}}",
|
||||
"template": "centos-7-x86_64",
|
||||
"version": "2.1.TIMESTAMP"
|
||||
},
|
||||
"builders":[
|
||||
{
|
||||
"type": "qemu",
|
||||
"boot_command": [
|
||||
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `ks_path`}}<enter><wait>"
|
||||
],
|
||||
"boot_wait": "10s",
|
||||
"disk_size": "{{user `disk_size`}}",
|
||||
"headless": "{{ user `headless` }}",
|
||||
"http_directory": "http",
|
||||
"iso_checksum": "{{user `iso_checksum`}}",
|
||||
"iso_checksum_type": "{{user `iso_checksum_type`}}",
|
||||
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
|
||||
"output_directory": "packer-{{user `template`}}-qemu",
|
||||
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/halt -h -p",
|
||||
"ssh_password": "vagrant",
|
||||
"ssh_port": 22,
|
||||
"ssh_username": "root",
|
||||
"ssh_timeout": "10000s",
|
||||
"vm_name": "{{ user `template` }}.raw",
|
||||
"net_device": "virtio-net",
|
||||
"disk_interface": "virtio",
|
||||
"format": "raw",
|
||||
"use_default_display": "false",
|
||||
"qemuargs": [
|
||||
["-display", "cocoa"]
|
||||
]
|
||||
}
|
||||
],
|
||||
"post-processors":[
|
||||
{
|
||||
"type":"ucloud-import",
|
||||
"ufile_bucket_name": "packer",
|
||||
"image_name": "packer_import",
|
||||
"image_os_type": "CentOS",
|
||||
"image_os_name": "CentOS 7.0 64位",
|
||||
"format": "raw",
|
||||
"region":"cn-bj2",
|
||||
"project_id": "org-xp2ucn"
|
||||
}
|
||||
]
|
||||
}
|
5
go.mod
5
go.mod
|
@ -133,8 +133,9 @@ require (
|
|||
github.com/stretchr/testify v1.4.0
|
||||
github.com/temoto/robotstxt v1.1.1 // indirect
|
||||
github.com/tencentcloud/tencentcloud-sdk-go v3.0.94+incompatible
|
||||
github.com/ucloud/ucloud-sdk-go v0.8.7
|
||||
github.com/ugorji/go v0.0.0-20151218193438-646ae4a518c1
|
||||
github.com/ucloud/ucloud-sdk-go v0.11.1
|
||||
github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190730023212-866b183392c4
|
||||
github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5
|
||||
github.com/ulikunitz/xz v0.5.5
|
||||
github.com/vmware/govmomi v0.0.0-20170707011325-c2105a174311
|
||||
github.com/xanzy/go-cloudstack v0.0.0-20190526095453-42f262b63ed0
|
||||
|
|
65
go.sum
65
go.sum
|
@ -33,7 +33,6 @@ github.com/Telmate/proxmox-api-go v0.0.0-20191015171801-b0c2796b9fcf h1:rVT2xsBm
|
|||
github.com/Telmate/proxmox-api-go v0.0.0-20191015171801-b0c2796b9fcf/go.mod h1:OGWyIMJ87/k/GCz8CGiWB2HOXsOVDM6Lpe/nFPkC4IQ=
|
||||
github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af h1:DBNMBMuMiWYu0b+8KMJuWmfCkcxl09JwdlqwDZZ6U14=
|
||||
github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw=
|
||||
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
|
||||
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e h1:/8wOj52pewmIX/8d5eVO3t7Rr3astkBI/ruyg4WNqRo=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e/go.mod h1:T9M45xf79ahXVelWoOBmH0y4aC1t5kXO5BxwyakgIGA=
|
||||
|
@ -134,8 +133,6 @@ github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJA
|
|||
github.com/gocolly/colly v1.2.0 h1:qRz9YAn8FIH0qzgNUw+HT9UN7wm1oF9OBAilwEWpyrI=
|
||||
github.com/gocolly/colly v1.2.0/go.mod h1:Hof5T3ZswNVsOHYmba1u03W65HDWgpV5HifSuueE0EA=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4=
|
||||
|
@ -146,19 +143,15 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
|
|||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
|
@ -199,7 +192,6 @@ github.com/hashicorp/go-getter v1.3.1-0.20190906090232-a0f878cb75da h1:HAasZmyRr
|
|||
github.com/hashicorp/go-getter v1.3.1-0.20190906090232-a0f878cb75da/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
|
@ -217,12 +209,10 @@ github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdv
|
|||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0=
|
||||
github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
|
@ -260,7 +250,6 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV
|
|||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE=
|
||||
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 h1:PJPDf8OUfOK1bb/NeTKd4f1QXZItOX389VN3B6qC8ro=
|
||||
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
|
||||
github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o=
|
||||
github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak=
|
||||
|
@ -283,7 +272,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/linode/linodego v0.7.1 h1:4WZmMpSA2NRwlPZcc0+4Gyn7rr99Evk9bnr0B3gXRKE=
|
||||
github.com/linode/linodego v0.7.1/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY=
|
||||
|
@ -291,12 +279,10 @@ github.com/masterzen/azure-sdk-for-go v0.0.0-20161014135628-ee4f0065d00c h1:FMUO
|
|||
github.com/masterzen/azure-sdk-for-go v0.0.0-20161014135628-ee4f0065d00c/go.mod h1:mf8fjOu33zCqxUjuiU3I8S1lJMyEAlH+0F2+M5xl3hE=
|
||||
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 h1:2ZKn+w/BJeL43sCxI2jhPLRv73oVVOjEKZjKkflyqxg=
|
||||
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc=
|
||||
github.com/masterzen/winrm v0.0.0-20180224160350-7e40f93ae939 h1:cRFHA33ER97Xy5jmjS519OXCS/yE3AT3zdbQAg0Z53g=
|
||||
github.com/masterzen/winrm v0.0.0-20180224160350-7e40f93ae939/go.mod h1:CfZSN7zwz5gJiFhZJz49Uzk7mEBHIceWmbFmYx7Hf7E=
|
||||
github.com/masterzen/winrm v0.0.0-20190223112901-5e5c9a7fe54b h1:/1RFh2SLCJ+tEnT73+Fh5R2AO89sQqs8ba7o+hx1G0Y=
|
||||
github.com/masterzen/winrm v0.0.0-20190223112901-5e5c9a7fe54b/go.mod h1:wr1VqkwW0AB5JS0QLy5GpVMS9E3VtRoSYXUYyVk46KY=
|
||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
|
@ -309,13 +295,11 @@ github.com/mitchellh/cli v1.0.0 h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y=
|
|||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-fs v0.0.0-20180402234041-7b48fa161ea7 h1:PXPMDtfqV+rZJshQHOiwUFqlqErXaAcuWy+/ZmyRfNc=
|
||||
github.com/mitchellh/go-fs v0.0.0-20180402234041-7b48fa161ea7/go.mod h1:g7SZj7ABpStq3tM4zqHiVEG5un/DZ1+qJJKO7qx1EvU=
|
||||
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed h1:FI2NIv6fpef6BQl2u3IZX/Cj20tfypRF4yd+uaHOMtI=
|
||||
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed/go.mod h1:3rdaFaCv4AyBgu5ALFM0+tSuHrBh6v692nyQe3ikrq0=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
|
||||
|
@ -359,7 +343,6 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5
|
|||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
@ -367,7 +350,6 @@ github.com/pkg/sftp v0.0.0-20160118190721-e84cc8c755ca h1:k8gsErq3rkcbAyCnpOycQs
|
|||
github.com/pkg/sftp v0.0.0-20160118190721-e84cc8c755ca/go.mod h1:NxmoDg/QLVWluQDUYG7XBZTLUpKeFa8e3aMf1BfjyHk=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/profitbricks/profitbricks-sdk-go v4.0.2+incompatible h1:ZoVHH6voxW9Onzo6z2yLtocVoN6mBocyDoqoyAMHokE=
|
||||
github.com/profitbricks/profitbricks-sdk-go v4.0.2+incompatible/go.mod h1:T3/WrziK7fYH3C8ilAFAHe99R452/IzIG3YYkqaOFeQ=
|
||||
|
@ -390,7 +372,6 @@ github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAri
|
|||
github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=
|
||||
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
|
||||
github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME=
|
||||
github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
|
@ -402,9 +383,7 @@ github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
|
|||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
|
@ -412,10 +391,19 @@ github.com/temoto/robotstxt v1.1.1 h1:Gh8RCs8ouX3hRSxxK7B1mO5RFByQ4CmJZDwgom++Ja
|
|||
github.com/temoto/robotstxt v1.1.1/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go v3.0.94+incompatible h1:G8i7dPMK1RCpbQz+VpfFp679vmVna38NI8tz5xsybXI=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go v3.0.94+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
|
||||
<<<<<<< HEAD
|
||||
github.com/ucloud/ucloud-sdk-go v0.8.7 h1:BmXOb5RivI0Uu4oZRpjI6SQ9/y7n/H9wxTGR1txIE8o=
|
||||
github.com/ucloud/ucloud-sdk-go v0.8.7/go.mod h1:lM6fpI8y6iwACtlbHUav823/uKPdXsNBlnBpRF2fj3c=
|
||||
github.com/ugorji/go v0.0.0-20151218193438-646ae4a518c1 h1:U6ufy3mLDgg9RYupntOvAF7xCmNNquyKaYaaVHo1Nnk=
|
||||
github.com/ugorji/go v0.0.0-20151218193438-646ae4a518c1/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
|
||||
=======
|
||||
github.com/ucloud/ucloud-sdk-go v0.11.1 h1:rnyoqM3oJ1c3vX0IqDF4JPgVBYgPGiAxrQ6mv2woNDg=
|
||||
github.com/ucloud/ucloud-sdk-go v0.11.1/go.mod h1:lM6fpI8y6iwACtlbHUav823/uKPdXsNBlnBpRF2fj3c=
|
||||
github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190730023212-866b183392c4 h1:KYfTP8NJHDb1ETR4KC3cnCKgXzugY/1UhO4EecPTuIQ=
|
||||
github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190730023212-866b183392c4/go.mod h1:R5FMQxkQ+QK/9Vz+jfnJP4rZIktYrRcWmuAnbOSkROI=
|
||||
github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5 h1:cMjKdf4PxEBN9K5HaD9UMW8gkTbM0kMzkTa9SJe0WNQ=
|
||||
github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
|
||||
>>>>>>> add ucloud import
|
||||
github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok=
|
||||
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
|
||||
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
|
@ -429,7 +417,6 @@ github.com/yandex-cloud/go-sdk v0.0.0-20190916101744-c781afa45829 h1:2FGwbx03GpP
|
|||
github.com/yandex-cloud/go-sdk v0.0.0-20190916101744-c781afa45829/go.mod h1:Eml0jFLU4VVHgIN8zPHMuNwZXVzUMILyO6lQZSfz854=
|
||||
github.com/zclconf/go-cty v1.1.0 h1:uJwc9HiBOCpoKIObTQaLR+tsEXx1HBHnOsOOpcdhZgw=
|
||||
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
||||
go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
|
@ -437,13 +424,15 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
|||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3 h1:KYQXGkl6vs02hK7pK4eIbw0NpNPedieTSTEiJ//bwGs=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
<<<<<<< HEAD
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
=======
|
||||
golang.org/x/crypto v0.0.0-20190222235706-ffb98f73852f/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
>>>>>>> add ucloud import
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 h1:58fnuSXlxZmFdJyvtTFVmVhcMLU6v5fEb/ok4wyqtNU=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
|
@ -461,13 +450,10 @@ golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73r
|
|||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc h1:a3CU5tJYVj92DY2LaA1kUkrsqD5/3mLDhx2NcNqyW+0=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd h1:HuTn7WObtcDo9uEEU7rEqL0jYthdXAmZ6PP+meazmaU=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
|
@ -476,28 +462,22 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR
|
|||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5 h1:x6r4Jo0KNzOOzYd8lbcRsqjuqEASK6ob3auvWYM4/8U=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -506,15 +486,17 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
<<<<<<< HEAD
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
=======
|
||||
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa h1:KIDDMLT1O0Nr7TSxp8xM5tJcdn8tgyAONntO829og1M=
|
||||
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
>>>>>>> add ucloud import
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
@ -524,27 +506,23 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
|
|||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138 h1:H3uGjxCR/6Ds0Mjgyp7LMK81+LvmbvWWEnJhzk1Pi9E=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0 h1:Dh6fw+p6FyRl5x/FvNswO1ji0lIGzm3KP8Y9VkS9PTE=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
google.golang.org/api v0.4.0 h1:KKgc1aqhV8wDPbDzlDtpvyjZFY3vjz85FP7p4wcQUyI=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.9.0 h1:jbyannxz0XFD3zdjgrSUsaJbgpH4eTrkdhRChkHPfO8=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19 h1:Lj2SnHtxkRGJDqnGaSjo+CCdIieEnwVazbOXILwQemk=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
|
@ -553,11 +531,9 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98
|
|||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1 h1:j6XxA85m/6txkUCHvzlV5f+HBNl/1r5cZ2A/3IEFOO8=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
@ -576,7 +552,6 @@ gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
|||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -0,0 +1,349 @@
|
|||
package ucloudimport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
|
||||
"github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/common/retry"
|
||||
"github.com/hashicorp/packer/helper/config"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/hashicorp/packer/template/interpolate"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/ufile"
|
||||
"github.com/ucloud/ucloud-sdk-go/services/uhost"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud"
|
||||
ufsdk "github.com/ufilesdk-dev/ufile-gosdk"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
BuilderId = "packer.post-processor.ucloud-import"
|
||||
RAWFileFormat = "raw"
|
||||
VHDFileFormat = "vhd"
|
||||
VMDKFileFormat = "vmdk"
|
||||
QCOW2FileFormat = "qcow2"
|
||||
)
|
||||
|
||||
var regionForFileMap = ucloudcommon.NewStringConverter(map[string]string{
|
||||
"cn-bj2": "cn-bj",
|
||||
"cn-bj1": "cn-bj",
|
||||
})
|
||||
|
||||
var imageFormatMap = ucloudcommon.NewStringConverter(map[string]string{
|
||||
"raw": "RAW",
|
||||
"vhd": "VHD",
|
||||
"vmdk": "VMDK",
|
||||
})
|
||||
|
||||
// Configuration of this post processor
|
||||
type Config struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
ucloudcommon.AccessConfig `mapstructure:",squash"`
|
||||
|
||||
// Variables specific to this post processor
|
||||
UFileBucket string `mapstructure:"ufile_bucket_name"`
|
||||
UFileKey string `mapstructure:"ufile_key_name"`
|
||||
SkipClean bool `mapstructure:"skip_clean"`
|
||||
ImageName string `mapstructure:"image_name"`
|
||||
ImageDescription string `mapstructure:"image_description"`
|
||||
OSType string `mapstructure:"image_os_type"`
|
||||
OSName string `mapstructure:"image_os_name"`
|
||||
Format string `mapstructure:"format"`
|
||||
|
||||
ctx interpolate.Context
|
||||
}
|
||||
|
||||
type PostProcessor struct {
|
||||
config Config
|
||||
}
|
||||
|
||||
// Entry point for configuration parsing when we've defined
|
||||
func (p *PostProcessor) Configure(raws ...interface{}) error {
|
||||
err := config.Decode(&p.config, &config.DecodeOpts{
|
||||
Interpolate: true,
|
||||
InterpolateContext: &p.config.ctx,
|
||||
InterpolateFilter: &interpolate.RenderFilter{
|
||||
Exclude: []string{
|
||||
"ufile_key_name",
|
||||
},
|
||||
},
|
||||
}, raws...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set defaults
|
||||
if p.config.UFileKey == "" {
|
||||
//fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID()[:8])
|
||||
p.config.UFileKey = "packer-import-{{timestamp}}." + p.config.Format
|
||||
}
|
||||
|
||||
errs := new(packer.MultiError)
|
||||
|
||||
// Check and render ufile_key_name
|
||||
if err = interpolate.Validate(p.config.UFileKey, &p.config.ctx); err != nil {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, fmt.Errorf("Error parsing ufile_key_name template: %s", err))
|
||||
}
|
||||
|
||||
// Check we have ucloud access variables defined somewhere
|
||||
errs = packer.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...)
|
||||
|
||||
// define all our required parameters
|
||||
templates := map[string]*string{
|
||||
"ufile_bucket_name": &p.config.UFileBucket,
|
||||
"image_name": &p.config.ImageName,
|
||||
"image_os_type": &p.config.OSName,
|
||||
"image_os_name": &p.config.OSType,
|
||||
}
|
||||
// Check out required params are defined
|
||||
for key, ptr := range templates {
|
||||
if *ptr == "" {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, fmt.Errorf("%s must be set", key))
|
||||
}
|
||||
}
|
||||
|
||||
switch p.config.Format {
|
||||
case VHDFileFormat, RAWFileFormat, VMDKFileFormat, QCOW2FileFormat:
|
||||
default:
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, fmt.Errorf("invalid format '%s'. Only 'raw', 'vhd', 'vmdk', or 'qcow2' are allowed", p.config.Format))
|
||||
}
|
||||
|
||||
// Anything which flagged return back up the stack
|
||||
if len(errs.Errors) > 0 {
|
||||
return errs
|
||||
}
|
||||
|
||||
packer.LogSecretFilter.Set(p.config.PublicKey, p.config.PrivateKey)
|
||||
log.Println(p.config)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, bool, error) {
|
||||
var err error
|
||||
|
||||
client, err := p.config.Client()
|
||||
if err != nil {
|
||||
return nil, false, false, err
|
||||
}
|
||||
uhostconn := client.UHostConn
|
||||
ufileconn := client.UFileConn
|
||||
|
||||
// Render this key since we didn't in the configure phase
|
||||
p.config.UFileKey, err = interpolate.Render(p.config.UFileKey, &p.config.ctx)
|
||||
if err != nil {
|
||||
return nil, false, false, fmt.Errorf("Error rendering ufile_key_name template: %s", err)
|
||||
}
|
||||
|
||||
log.Printf("Rendered ufile_key_name as %s", p.config.UFileKey)
|
||||
|
||||
log.Println("Looking for image in artifact")
|
||||
// Locate the files output from the builder
|
||||
var source string
|
||||
for _, path := range artifact.Files() {
|
||||
if strings.HasSuffix(path, "."+p.config.Format) {
|
||||
source = path
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Hope we found something useful
|
||||
if source == "" {
|
||||
return nil, false, false, fmt.Errorf("No %s image file found in artifact from builder", p.config.Format)
|
||||
}
|
||||
|
||||
region := regionForFileMap.Convert(p.config.Region)
|
||||
projectId := p.config.ProjectId
|
||||
keyName := p.config.UFileKey
|
||||
bucketName := p.config.UFileBucket
|
||||
|
||||
config := &ufsdk.Config{
|
||||
PublicKey: p.config.PublicKey,
|
||||
PrivateKey: p.config.PrivateKey,
|
||||
BucketName: bucketName,
|
||||
FileHost: fmt.Sprintf(region + ".ufileos.com"),
|
||||
BucketHost: "api.ucloud.cn",
|
||||
}
|
||||
if err != nil {
|
||||
return nil, false, false, fmt.Errorf("Load config error %s", err)
|
||||
}
|
||||
|
||||
if err := queryOrCreateBucket(ufileconn, config, region, projectId); err != nil {
|
||||
return nil, false, false, fmt.Errorf("Query or create bucket error %s", err)
|
||||
}
|
||||
|
||||
bucketUrl := fmt.Sprintf("http://" + bucketName + "." + region + ".ufileos.com")
|
||||
ui.Say(fmt.Sprintf("Waiting for uploading file %s to %s/%s...", source, bucketUrl, p.config.UFileKey))
|
||||
|
||||
privateUrl, err := uploadFile(config, keyName, source, projectId)
|
||||
if err != nil {
|
||||
return nil, false, false, fmt.Errorf("Upload file error %s", err)
|
||||
}
|
||||
|
||||
ui.Say(fmt.Sprintf("Image file %s has been uploaded to UFile %s", source, privateUrl))
|
||||
|
||||
importImageRequest := p.buildImportImageRequest(uhostconn, privateUrl)
|
||||
importImageResponse, err := uhostconn.ImportCustomImage(importImageRequest)
|
||||
if err != nil {
|
||||
return nil, false, false, fmt.Errorf("Failed to import from %s/%s: %s", bucketUrl, p.config.UFileKey, err)
|
||||
}
|
||||
|
||||
imageId := importImageResponse.ImageId
|
||||
|
||||
ui.Say(fmt.Sprintf("Waiting for importing %s/%s to ucloud...", bucketUrl, p.config.UFileKey))
|
||||
|
||||
err = retry.Config{
|
||||
Tries: 30,
|
||||
ShouldRetry: func(err error) bool {
|
||||
return ucloudcommon.IsExpectedStateError(err)
|
||||
},
|
||||
RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 6 * time.Second, Multiplier: 2}).Linear,
|
||||
}.Run(ctx, func(ctx context.Context) error {
|
||||
image, err := client.DescribeImageById(imageId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if image.State == ucloudcommon.ImageStateUnavailable {
|
||||
return fmt.Errorf("Unavailable importing image %s", imageId)
|
||||
}
|
||||
|
||||
if image.State != ucloudcommon.ImageStateAvailable {
|
||||
return ucloudcommon.NewExpectedStateError("image", imageId)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, false, false, fmt.Errorf("Error on waiting for importing image %q, %s",
|
||||
imageId, err.Error())
|
||||
}
|
||||
|
||||
// Add the reported UCloud image ID to the artifact list
|
||||
ui.Say(fmt.Sprintf("Importing created ucloud image ID %s in region %s Finished.", imageId, p.config.Region))
|
||||
images := []ucloudcommon.ImageInfo{
|
||||
{
|
||||
ImageId: imageId,
|
||||
ProjectId: p.config.ProjectId,
|
||||
Region: p.config.Region,
|
||||
},
|
||||
}
|
||||
|
||||
artifact = &ucloudcommon.Artifact{
|
||||
UCloudImages: ucloudcommon.NewImageInfoSet(images),
|
||||
BuilderIdValue: BuilderId,
|
||||
Client: client,
|
||||
}
|
||||
|
||||
if !p.config.SkipClean {
|
||||
ui.Message(fmt.Sprintf("Deleting import source %s/%s/%s", bucketUrl, p.config.UFileBucket, p.config.UFileKey))
|
||||
if err = deleteFile(config, p.config.UFileKey); err != nil {
|
||||
return nil, false, false, fmt.Errorf("Failed to delete %s/%s/%s: %s", bucketUrl, p.config.UFileBucket, p.config.UFileKey, err)
|
||||
}
|
||||
}
|
||||
|
||||
return artifact, false, false, nil
|
||||
}
|
||||
|
||||
func (p *PostProcessor) buildImportImageRequest(conn *uhost.UHostClient, privateUrl string) *uhost.ImportCustomImageRequest {
|
||||
req := conn.NewImportCustomImageRequest()
|
||||
req.ImageName = ucloud.String(p.config.ImageName)
|
||||
req.ImageDescription = ucloud.String(p.config.ImageDescription)
|
||||
req.UFileUrl = ucloud.String(privateUrl)
|
||||
req.OsType = ucloud.String(p.config.OSType)
|
||||
req.OsName = ucloud.String(p.config.OSName)
|
||||
req.Format = ucloud.String(imageFormatMap.Convert(p.config.Format))
|
||||
req.Auth = ucloud.Bool(true)
|
||||
return req
|
||||
}
|
||||
|
||||
func queryOrCreateBucket(conn *ufile.UFileClient, config *ufsdk.Config, region, projectId string) error {
|
||||
var limit = 100
|
||||
var offset int
|
||||
var bucketList []ufile.UFileBucketSet
|
||||
for {
|
||||
req := conn.NewDescribeBucketRequest()
|
||||
req.Limit = ucloud.Int(limit)
|
||||
req.Offset = ucloud.Int(offset)
|
||||
resp, err := conn.DescribeBucket(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error on reading bucket list, %s", err)
|
||||
}
|
||||
|
||||
if resp == nil || len(resp.DataSet) < 1 {
|
||||
break
|
||||
}
|
||||
|
||||
bucketList = append(bucketList, resp.DataSet...)
|
||||
|
||||
if len(resp.DataSet) < limit {
|
||||
break
|
||||
}
|
||||
|
||||
offset = offset + limit
|
||||
}
|
||||
|
||||
var bucketNames []string
|
||||
for _, v := range bucketList {
|
||||
bucketNames = append(bucketNames, v.BucketName)
|
||||
}
|
||||
|
||||
if !ucloudcommon.IsStringIn(config.BucketName, bucketNames) {
|
||||
req := conn.NewCreateBucketRequest()
|
||||
req.BucketName = ucloud.String(config.BucketName)
|
||||
req.Type = ucloud.String("private")
|
||||
|
||||
_, err := conn.CreateBucket(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error on creating bucket %s, %s", config.BucketName, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func uploadFile(config *ufsdk.Config, keyName, filePath, projectId string) (string, error) {
|
||||
reqFile, err := ufsdk.NewFileRequest(config, nil)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("NewFileErr:%s", err)
|
||||
}
|
||||
|
||||
err = reqFile.AsyncMPut(filePath, keyName, "")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("AsyncMPutErr:%s, Response:%s", err, reqFile.DumpResponse(true))
|
||||
}
|
||||
|
||||
reqBucket, err := ufsdk.NewBucketRequest(config, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
bucketList, err := reqBucket.DescribeBucket(config.BucketName, 0, 1, projectId)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
if bucketList.DataSet[0].Type == "private" {
|
||||
return reqFile.GetPrivateURL(keyName, 24*60*60), nil
|
||||
}
|
||||
|
||||
return reqBucket.GetPublicURL(keyName), nil
|
||||
}
|
||||
|
||||
func deleteFile(config *ufsdk.Config, keyName string) error {
|
||||
req, err := ufsdk.NewFileRequest(config, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error on new deleting file, %s", err)
|
||||
}
|
||||
req.DeleteFile(keyName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error on deleting file, %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -57,7 +57,10 @@ func ValueAtPath(v interface{}, path string) (interface{}, error) {
|
|||
}
|
||||
|
||||
if rv.Kind() == reflect.Struct {
|
||||
itemV := rv.FieldByName(components[0])
|
||||
itemV := rv.FieldByNameFunc(func(s string) bool {
|
||||
return strings.ToLower(s) == strings.ToLower(components[0])
|
||||
})
|
||||
|
||||
if !itemV.IsValid() {
|
||||
return nil, errors.Errorf("path %s is invalid for struct", path)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package uaccount
|
||||
|
||||
import (
|
||||
|
@ -12,7 +14,8 @@ type UAccountClient struct {
|
|||
|
||||
// NewClient will return a instance of UAccountClient
|
||||
func NewClient(config *ucloud.Config, credential *auth.Credential) *UAccountClient {
|
||||
client := ucloud.NewClient(config, credential)
|
||||
meta := ucloud.ClientMeta{Product: "UAccount"}
|
||||
client := ucloud.NewClientWithMeta(config, credential, meta)
|
||||
return &UAccountClient{
|
||||
client,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
|
||||
)
|
||||
|
||||
// UFileClient is the client of UFile
|
||||
type UFileClient struct {
|
||||
*ucloud.Client
|
||||
}
|
||||
|
||||
// NewClient will return a instance of UFileClient
|
||||
func NewClient(config *ucloud.Config, credential *auth.Credential) *UFileClient {
|
||||
client := ucloud.NewClient(config, credential)
|
||||
return &UFileClient{
|
||||
client,
|
||||
}
|
||||
}
|
63
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/create_bucket.go
generated
vendored
Normal file
63
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/create_bucket.go
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// CreateBucketRequest is request schema for CreateBucket action
|
||||
type CreateBucketRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// 待创建Bucket的名称,具有全局唯一性
|
||||
BucketName *string `required:"true"`
|
||||
|
||||
// Bucket访问类型,public或private; 默认为private
|
||||
Type *string `required:"false"`
|
||||
}
|
||||
|
||||
// CreateBucketResponse is response schema for CreateBucket action
|
||||
type CreateBucketResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 已创建Bucket的ID
|
||||
BucketId string
|
||||
|
||||
// 已创建Bucket的名称
|
||||
BucketName string
|
||||
}
|
||||
|
||||
// NewCreateBucketRequest will create request of CreateBucket action.
|
||||
func (c *UFileClient) NewCreateBucketRequest() *CreateBucketRequest {
|
||||
req := &CreateBucketRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(false)
|
||||
return req
|
||||
}
|
||||
|
||||
// CreateBucket - 创建Bucket
|
||||
func (c *UFileClient) CreateBucket(req *CreateBucketRequest) (*CreateBucketResponse, error) {
|
||||
var err error
|
||||
var res CreateBucketResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("CreateBucket", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
69
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/create_ufile_token.go
generated
vendored
Normal file
69
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/create_ufile_token.go
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// CreateUFileTokenRequest is request schema for CreateUFileToken action
|
||||
type CreateUFileTokenRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"true"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"false"`
|
||||
|
||||
// 令牌允许操作的bucket,默认*表示全部
|
||||
AllowedBuckets []string `required:"false"`
|
||||
|
||||
// 令牌允许执行的操作,[ TOKEN_ALLOW_NONE , TOKEN_ALLOW_READ , TOKEN_ALLOW_WRITE , TOKEN_ALLOW_DELETE , TOKEN_ALLOW_LIST, TOKEN_ALLOW_IOP , TOKEN_ALLOW_DP ]。默认TOKEN_ALLOW_NONE
|
||||
AllowedOps []string `required:"false"`
|
||||
|
||||
// 令牌允许操作的key前缀,默认*表示全部
|
||||
AllowedPrefixes []string `required:"false"`
|
||||
|
||||
// 令牌的超时时间点(时间戳),默认一天;注意:过期时间不能超过 4102416000
|
||||
ExpireTime *int `required:"false"`
|
||||
|
||||
// 令牌名称
|
||||
TokenName *string `required:"true"`
|
||||
}
|
||||
|
||||
// CreateUFileTokenResponse is response schema for CreateUFileToken action
|
||||
type CreateUFileTokenResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 创建令牌的token_id
|
||||
TokenId string
|
||||
}
|
||||
|
||||
// NewCreateUFileTokenRequest will create request of CreateUFileToken action.
|
||||
func (c *UFileClient) NewCreateUFileTokenRequest() *CreateUFileTokenRequest {
|
||||
req := &CreateUFileTokenRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(false)
|
||||
return req
|
||||
}
|
||||
|
||||
// CreateUFileToken - 创建ufile令牌
|
||||
func (c *UFileClient) CreateUFileToken(req *CreateUFileTokenRequest) (*CreateUFileTokenResponse, error) {
|
||||
var err error
|
||||
var res CreateUFileTokenResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("CreateUFileToken", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
60
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/delete_bucket.go
generated
vendored
Normal file
60
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/delete_bucket.go
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DeleteBucketRequest is request schema for DeleteBucket action
|
||||
type DeleteBucketRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// 待删除Bucket的名称
|
||||
BucketName *string `required:"true"`
|
||||
}
|
||||
|
||||
// DeleteBucketResponse is response schema for DeleteBucket action
|
||||
type DeleteBucketResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// Bucket的ID
|
||||
BucketId string
|
||||
|
||||
// Bucket的名称
|
||||
BucketName string
|
||||
}
|
||||
|
||||
// NewDeleteBucketRequest will create request of DeleteBucket action.
|
||||
func (c *UFileClient) NewDeleteBucketRequest() *DeleteBucketRequest {
|
||||
req := &DeleteBucketRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DeleteBucket - 删除Bucket
|
||||
func (c *UFileClient) DeleteBucket(req *DeleteBucketRequest) (*DeleteBucketResponse, error) {
|
||||
var err error
|
||||
var res DeleteBucketResponse
|
||||
|
||||
reqCopier := *req
|
||||
// In order to ignore the parameters about Region
|
||||
reqCopier.Region = ucloud.String("")
|
||||
|
||||
err = c.Client.InvokeAction("DeleteBucket", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
54
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/delete_ufile_token.go
generated
vendored
Normal file
54
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/delete_ufile_token.go
generated
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DeleteUFileTokenRequest is request schema for DeleteUFileToken action
|
||||
type DeleteUFileTokenRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"true"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// 令牌ID
|
||||
TokenId *string `required:"true"`
|
||||
}
|
||||
|
||||
// DeleteUFileTokenResponse is response schema for DeleteUFileToken action
|
||||
type DeleteUFileTokenResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewDeleteUFileTokenRequest will create request of DeleteUFileToken action.
|
||||
func (c *UFileClient) NewDeleteUFileTokenRequest() *DeleteUFileTokenRequest {
|
||||
req := &DeleteUFileTokenRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DeleteUFileToken - 删除令牌
|
||||
func (c *UFileClient) DeleteUFileToken(req *DeleteUFileTokenRequest) (*DeleteUFileTokenResponse, error) {
|
||||
var err error
|
||||
var res DeleteUFileTokenResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("DeleteUFileToken", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
64
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/describe_bucket.go
generated
vendored
Normal file
64
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/describe_bucket.go
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DescribeBucketRequest is request schema for DescribeBucket action
|
||||
type DescribeBucketRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// 待获取Bucket的名称,若不提供,则获取所有Bucket
|
||||
BucketName *string `required:"false"`
|
||||
|
||||
// 获取所有Bucket列表的限制数目,默认为20
|
||||
Limit *int `required:"false"`
|
||||
|
||||
// 获取所有Bucket列表的偏移数目,默认为0
|
||||
Offset *int `required:"false"`
|
||||
}
|
||||
|
||||
// DescribeBucketResponse is response schema for DescribeBucket action
|
||||
type DescribeBucketResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// Bucket的描述信息 参数见 UFileBucketSet
|
||||
DataSet []UFileBucketSet
|
||||
}
|
||||
|
||||
// NewDescribeBucketRequest will create request of DescribeBucket action.
|
||||
func (c *UFileClient) NewDescribeBucketRequest() *DescribeBucketRequest {
|
||||
req := &DescribeBucketRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DescribeBucket - 获取Bucket的描述信息
|
||||
func (c *UFileClient) DescribeBucket(req *DescribeBucketRequest) (*DescribeBucketResponse, error) {
|
||||
var err error
|
||||
var res DescribeBucketResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
// In order to ignore the parameters about Region
|
||||
reqCopier.Region = ucloud.String("")
|
||||
|
||||
err = c.Client.InvokeAction("DescribeBucket", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
66
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/describe_ufile_token.go
generated
vendored
Normal file
66
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/describe_ufile_token.go
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DescribeUFileTokenRequest is request schema for DescribeUFileToken action
|
||||
type DescribeUFileTokenRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"true"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"false"`
|
||||
|
||||
// 0表示显示部分token信息;不传递和其他情况表示显示全部token信息
|
||||
Display *int `required:"false"`
|
||||
|
||||
// 令牌ID,只返回指定ID信息,否则拉取所有令牌
|
||||
TokenId *string `required:"false"`
|
||||
}
|
||||
|
||||
// DescribeUFileTokenResponse is response schema for DescribeUFileToken action
|
||||
type DescribeUFileTokenResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 操作名称
|
||||
Action string
|
||||
|
||||
// 令牌描述信息
|
||||
DataSet []UFileTokenSet
|
||||
|
||||
// 返回码
|
||||
RetCode int
|
||||
}
|
||||
|
||||
// NewDescribeUFileTokenRequest will create request of DescribeUFileToken action.
|
||||
func (c *UFileClient) NewDescribeUFileTokenRequest() *DescribeUFileTokenRequest {
|
||||
req := &DescribeUFileTokenRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DescribeUFileToken - 获取令牌信息
|
||||
func (c *UFileClient) DescribeUFileToken(req *DescribeUFileTokenRequest) (*DescribeUFileTokenResponse, error) {
|
||||
var err error
|
||||
var res DescribeUFileTokenResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("DescribeUFileToken", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
/*
|
||||
Package ufile include resources of ucloud ufile product
|
||||
|
||||
See also
|
||||
|
||||
- API: https://docs.ucloud.cn/api/ufile-api/index
|
||||
- Product: https://www.ucloud.cn/site/product/ufile.html
|
||||
|
||||
for detail.
|
||||
*/
|
||||
package ufile
|
45
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/types_ufile_bucket_set.go
generated
vendored
Normal file
45
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/types_ufile_bucket_set.go
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
/*
|
||||
UFileBucketSet - DescribeBucket
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type UFileBucketSet struct {
|
||||
|
||||
// Bucket所属业务, general或vod或udb general: 普通业务; vod: 视频云业务; udb: 云数据库业务
|
||||
Biz string
|
||||
|
||||
// Bucket的ID
|
||||
BucketId string
|
||||
|
||||
// Bucket名称
|
||||
BucketName string
|
||||
|
||||
// 与Bucket关联的CND加速域名的ID列表
|
||||
CdnDomainId []string
|
||||
|
||||
// Bucket的创建时间
|
||||
CreateTime int
|
||||
|
||||
// Bucket的域名集合 参数见 UFileDomainSet
|
||||
Domain UFileDomainSet
|
||||
|
||||
// 是否存在自定义域名。0不存在,1存在,2错误
|
||||
HasUserDomain int
|
||||
|
||||
// Bucket的修改时间
|
||||
ModifyTime int
|
||||
|
||||
// Bucket所属地域
|
||||
Region string
|
||||
|
||||
// 所属业务组
|
||||
Tag string
|
||||
|
||||
// Bucket访问类型
|
||||
Type string
|
||||
}
|
24
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/types_ufile_domain_set.go
generated
vendored
Normal file
24
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/types_ufile_domain_set.go
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
/*
|
||||
UFileDomainSet - DescribeBucket
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type UFileDomainSet struct {
|
||||
|
||||
// UCDN加速域名
|
||||
Cdn []string
|
||||
|
||||
// 用户自定义CDN加速域名
|
||||
CustomCdn []string
|
||||
|
||||
// 用户自定义源站域名
|
||||
CustomSrc []string
|
||||
|
||||
// 源站域名
|
||||
Src []string
|
||||
}
|
45
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/types_ufile_token_set.go
generated
vendored
Normal file
45
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/types_ufile_token_set.go
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
/*
|
||||
UFileTokenSet - ufile令牌集合
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type UFileTokenSet struct {
|
||||
|
||||
// 令牌允许操作的bucket
|
||||
AllowedBuckets []string
|
||||
|
||||
// 令牌允许执行的操作,[ TOKEN_ALLOW_NONE , TOKEN_ALLOW_READ , TOKEN_ALLOW_WRITE , TOKEN_ALLOW_DELETE , TOKEN_ALLOW_LIST, TOKEN_ALLOW_IOP , TOKEN_ALLOW_DP ]
|
||||
AllowedOps []string
|
||||
|
||||
// 令牌允许操作的key前缀
|
||||
AllowedPrefixes []string
|
||||
|
||||
// 创建时间
|
||||
CreateTime int
|
||||
|
||||
// 令牌的超时时间点
|
||||
ExpireTime int
|
||||
|
||||
// 修改时间
|
||||
ModifyTime int
|
||||
|
||||
// 令牌私钥
|
||||
PrivateKey string
|
||||
|
||||
// 令牌公钥
|
||||
PublicKey string
|
||||
|
||||
// 所属地区
|
||||
Region string
|
||||
|
||||
// 令牌ID
|
||||
TokenId string
|
||||
|
||||
// 令牌名称
|
||||
TokenName string
|
||||
}
|
62
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/update_bucket.go
generated
vendored
Normal file
62
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/update_bucket.go
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// UpdateBucketRequest is request schema for UpdateBucket action
|
||||
type UpdateBucketRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"true"`
|
||||
|
||||
// 待修改Bucket的名称
|
||||
BucketName *string `required:"true"`
|
||||
|
||||
// Bucket访问类型;public或private
|
||||
Type *string `required:"true"`
|
||||
}
|
||||
|
||||
// UpdateBucketResponse is response schema for UpdateBucket action
|
||||
type UpdateBucketResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// Bucket的ID
|
||||
BucketId string
|
||||
|
||||
// Bucket的名称
|
||||
BucketName string
|
||||
}
|
||||
|
||||
// NewUpdateBucketRequest will create request of UpdateBucket action.
|
||||
func (c *UFileClient) NewUpdateBucketRequest() *UpdateBucketRequest {
|
||||
req := &UpdateBucketRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// UpdateBucket - 更改Bucket的属性
|
||||
func (c *UFileClient) UpdateBucket(req *UpdateBucketRequest) (*UpdateBucketResponse, error) {
|
||||
var err error
|
||||
var res UpdateBucketResponse
|
||||
|
||||
reqCopier := *req
|
||||
reqCopier.Region = ucloud.String("")
|
||||
|
||||
err = c.Client.InvokeAction("UpdateBucket", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
69
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/update_ufile_token.go
generated
vendored
Normal file
69
vendor/github.com/ucloud/ucloud-sdk-go/services/ufile/update_ufile_token.go
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package ufile
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// UpdateUFileTokenRequest is request schema for UpdateUFileToken action
|
||||
type UpdateUFileTokenRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"true"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"false"`
|
||||
|
||||
// 令牌允许操作的bucket
|
||||
AllowedBuckets []string `required:"false"`
|
||||
|
||||
// 令牌允许执行的操作,[ TOKEN_ALLOW_NONE , TOKEN_ALLOW_READ , TOKEN_ALLOW_WRITE , TOKEN_ALLOW_DELETE , TOKEN_ALLOW_LIST, TOKEN_ALLOW_IOP , TOKEN_ALLOW_DP ]
|
||||
AllowedOps []string `required:"false"`
|
||||
|
||||
// 令牌允许操作的key前缀
|
||||
AllowedPrefixes []string `required:"false"`
|
||||
|
||||
// 令牌的超时时间点(时间戳);注意:过期时间不能超过 4102416000
|
||||
ExpireTime *int `required:"false"`
|
||||
|
||||
// 令牌ID
|
||||
TokenId *string `required:"true"`
|
||||
|
||||
// 令牌名称
|
||||
TokenName *string `required:"false"`
|
||||
}
|
||||
|
||||
// UpdateUFileTokenResponse is response schema for UpdateUFileToken action
|
||||
type UpdateUFileTokenResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewUpdateUFileTokenRequest will create request of UpdateUFileToken action.
|
||||
func (c *UFileClient) NewUpdateUFileTokenRequest() *UpdateUFileTokenRequest {
|
||||
req := &UpdateUFileTokenRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// UpdateUFileToken - 更新令牌的操作权限,可操作key的前缀,可操作bucket和令牌超时时间点
|
||||
func (c *UFileClient) UpdateUFileToken(req *UpdateUFileTokenRequest) (*UpdateUFileTokenResponse, error) {
|
||||
var err error
|
||||
var res UpdateUFileTokenResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("UpdateUFileToken", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package uhost
|
||||
|
||||
import (
|
||||
|
@ -12,7 +14,8 @@ type UHostClient struct {
|
|||
|
||||
// NewClient will return a instance of UHostClient
|
||||
func NewClient(config *ucloud.Config, credential *auth.Credential) *UHostClient {
|
||||
client := ucloud.NewClient(config, credential)
|
||||
meta := ucloud.ClientMeta{Product: "UHost"}
|
||||
client := ucloud.NewClientWithMeta(config, credential, meta)
|
||||
return &UHostClient{
|
||||
client,
|
||||
}
|
||||
|
|
59
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_isolation_group.go
generated
vendored
Normal file
59
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/create_isolation_group.go
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
|
||||
//go:generate ucloud-gen-go-api UHost CreateIsolationGroup
|
||||
|
||||
package uhost
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// CreateIsolationGroupRequest is request schema for CreateIsolationGroup action
|
||||
type CreateIsolationGroupRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// [公共参数] 项目id
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// 硬件隔离组名称。请遵照[[api:uhost-api:specification|字段规范]]设定隔离组名称。
|
||||
GroupName *string `required:"true"`
|
||||
|
||||
// 备注。请遵照[[api:uhost-api:specification|字段规范]]设定隔离组备注。
|
||||
Remark *string `required:"false"`
|
||||
}
|
||||
|
||||
// CreateIsolationGroupResponse is response schema for CreateIsolationGroup action
|
||||
type CreateIsolationGroupResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 硬件隔离组id
|
||||
GroupId string
|
||||
}
|
||||
|
||||
// NewCreateIsolationGroupRequest will create request of CreateIsolationGroup action.
|
||||
func (c *UHostClient) NewCreateIsolationGroupRequest() *CreateIsolationGroupRequest {
|
||||
req := &CreateIsolationGroupRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(false)
|
||||
return req
|
||||
}
|
||||
|
||||
// CreateIsolationGroup - 创建硬件隔离组,组内机器严格隔离在不同宿主机上。
|
||||
func (c *UHostClient) CreateIsolationGroup(req *CreateIsolationGroupRequest) (*CreateIsolationGroupResponse, error) {
|
||||
var err error
|
||||
var res CreateIsolationGroupResponse
|
||||
|
||||
err = c.Client.InvokeAction("CreateIsolationGroup", req, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
|
@ -90,6 +90,9 @@ type CreateUHostInstanceRequest struct {
|
|||
// 防火墙Id,默认:Web推荐防火墙。如何查询SecurityGroupId请参见 [DescribeSecurityGroup](../unet-api/describe_security_group.html)
|
||||
SecurityGroupId *string `required:"false"`
|
||||
|
||||
// 硬件隔离组id。可通过DescribeIsolationGroup获取。
|
||||
IsolationGroup *string `required:"false"`
|
||||
|
||||
// 【暂不支持】cloudinit方式下,用户初始化脚本
|
||||
UserDataScript *string `required:"false"`
|
||||
|
||||
|
@ -111,6 +114,12 @@ type CreateUHostInstanceRequest struct {
|
|||
// 最低cpu平台,枚举值["Intel/Auto", "Intel/LvyBridge", "Intel/Haswell", "Intel/Broadwell", "Intel/Skylake", "Intel/Cascadelake"(只有O型云主机可选)]
|
||||
MinimalCpuPlatform *string `required:"false"`
|
||||
|
||||
// 【批量创建主机时必填】最大创建主机数量,取值范围是[1,100];
|
||||
MaxCount *int `required:"false"`
|
||||
|
||||
// GPU类型,枚举值["K80", "P40", "V100"],MachineType为G时必填
|
||||
GpuType *string `required:"false"`
|
||||
|
||||
// NetworkInterface
|
||||
NetworkInterface []CreateUHostInstanceParamNetworkInterface
|
||||
}
|
||||
|
|
56
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/delete_isolation_group.go
generated
vendored
Normal file
56
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/delete_isolation_group.go
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
|
||||
//go:generate ucloud-gen-go-api UHost DeleteIsolationGroup
|
||||
|
||||
package uhost
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DeleteIsolationGroupRequest is request schema for DeleteIsolationGroup action
|
||||
type DeleteIsolationGroupRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// [公共参数] 项目id
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// 硬件隔离组id
|
||||
GroupId *string `required:"true"`
|
||||
}
|
||||
|
||||
// DeleteIsolationGroupResponse is response schema for DeleteIsolationGroup action
|
||||
type DeleteIsolationGroupResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 硬件隔离组id
|
||||
GroupId string
|
||||
}
|
||||
|
||||
// NewDeleteIsolationGroupRequest will create request of DeleteIsolationGroup action.
|
||||
func (c *UHostClient) NewDeleteIsolationGroupRequest() *DeleteIsolationGroupRequest {
|
||||
req := &DeleteIsolationGroupRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DeleteIsolationGroup - 删除硬件隔离组。
|
||||
func (c *UHostClient) DeleteIsolationGroup(req *DeleteIsolationGroupRequest) (*DeleteIsolationGroupResponse, error) {
|
||||
var err error
|
||||
var res DeleteIsolationGroupResponse
|
||||
|
||||
err = c.Client.InvokeAction("DeleteIsolationGroup", req, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
62
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_isolation_group.go
generated
vendored
Normal file
62
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/describe_isolation_group.go
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
|
||||
//go:generate ucloud-gen-go-api UHost DescribeIsolationGroup
|
||||
|
||||
package uhost
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DescribeIsolationGroupRequest is request schema for DescribeIsolationGroup action
|
||||
type DescribeIsolationGroupRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// [公共参数] 项目id
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// 待查的硬件隔离组id
|
||||
GroupId *string `required:"false"`
|
||||
|
||||
// 列表起始位置偏移量,默认为0
|
||||
Offset *int `required:"false"`
|
||||
|
||||
// 返回数据长度,默认为20,最大100
|
||||
Limit *int `required:"false"`
|
||||
}
|
||||
|
||||
// DescribeIsolationGroupResponse is response schema for DescribeIsolationGroup action
|
||||
type DescribeIsolationGroupResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 硬件隔离组集合。参见数据结构IsolationGroup。
|
||||
IsolationGroupSet []IsolationGroup
|
||||
}
|
||||
|
||||
// NewDescribeIsolationGroupRequest will create request of DescribeIsolationGroup action.
|
||||
func (c *UHostClient) NewDescribeIsolationGroupRequest() *DescribeIsolationGroupRequest {
|
||||
req := &DescribeIsolationGroupRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DescribeIsolationGroup - 查询硬件隔离组列表。
|
||||
func (c *UHostClient) DescribeIsolationGroup(req *DescribeIsolationGroupRequest) (*DescribeIsolationGroupResponse, error) {
|
||||
var err error
|
||||
var res DescribeIsolationGroupResponse
|
||||
|
||||
err = c.Client.InvokeAction("DescribeIsolationGroup", req, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
62
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/leave_isolation_group.go
generated
vendored
Normal file
62
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/leave_isolation_group.go
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
|
||||
//go:generate ucloud-gen-go-api UHost LeaveIsolationGroup
|
||||
|
||||
package uhost
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// LeaveIsolationGroupRequest is request schema for LeaveIsolationGroup action
|
||||
type LeaveIsolationGroupRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// [公共参数] 可用区信息
|
||||
// Zone *string `required:"false"`
|
||||
|
||||
// [公共参数] 项目id
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// 硬件隔离组id
|
||||
GroupId *string `required:"true"`
|
||||
|
||||
// 主机id
|
||||
UHostId *string `required:"true"`
|
||||
}
|
||||
|
||||
// LeaveIsolationGroupResponse is response schema for LeaveIsolationGroup action
|
||||
type LeaveIsolationGroupResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 主机id
|
||||
UHostId string
|
||||
}
|
||||
|
||||
// NewLeaveIsolationGroupRequest will create request of LeaveIsolationGroup action.
|
||||
func (c *UHostClient) NewLeaveIsolationGroupRequest() *LeaveIsolationGroupRequest {
|
||||
req := &LeaveIsolationGroupRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// LeaveIsolationGroup - 移除硬件隔离组中的主机
|
||||
func (c *UHostClient) LeaveIsolationGroup(req *LeaveIsolationGroupRequest) (*LeaveIsolationGroupResponse, error) {
|
||||
var err error
|
||||
var res LeaveIsolationGroupResponse
|
||||
|
||||
err = c.Client.InvokeAction("LeaveIsolationGroup", req, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
22
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_isolation_group.go
generated
vendored
Normal file
22
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_isolation_group.go
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
package uhost
|
||||
|
||||
/*
|
||||
IsolationGroup - 硬件隔离组信息
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn for detail.
|
||||
*/
|
||||
type IsolationGroup struct {
|
||||
|
||||
// 硬件隔离组名称
|
||||
GroupName string
|
||||
|
||||
// 硬件隔离组id
|
||||
GroupId string
|
||||
|
||||
// 每个可用区中的机器数量。参见数据结构SpreadInfo。
|
||||
SpreadInfoSet []SpreadInfo
|
||||
|
||||
// 备注
|
||||
Remark string
|
||||
}
|
16
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_spread_info.go
generated
vendored
Normal file
16
vendor/github.com/ucloud/ucloud-sdk-go/services/uhost/types_spread_info.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
package uhost
|
||||
|
||||
/*
|
||||
SpreadInfo - 每个可用区中硬件隔离组信息
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn for detail.
|
||||
*/
|
||||
type SpreadInfo struct {
|
||||
|
||||
// 可用区信息
|
||||
Zone string
|
||||
|
||||
// 可用区中硬件隔离组中云主机的数量,不超过7。
|
||||
UHostCount int
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package unet
|
||||
|
||||
import (
|
||||
|
@ -12,7 +14,8 @@ type UNetClient struct {
|
|||
|
||||
// NewClient will return a instance of UNetClient
|
||||
func NewClient(config *ucloud.Config, credential *auth.Credential) *UNetClient {
|
||||
client := ucloud.NewClient(config, credential)
|
||||
meta := ucloud.ClientMeta{Product: "UNet"}
|
||||
client := ucloud.NewClientWithMeta(config, credential, meta)
|
||||
return &UNetClient{
|
||||
client,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
|
||||
//go:generate ucloud-gen-go-api UNet DescribeVIP
|
||||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package unet
|
||||
|
||||
|
@ -12,17 +11,17 @@ import (
|
|||
type DescribeVIPRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"true"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// [公共参数] 可用区。参见 [可用区列表](../summary/regionlist.html)
|
||||
// Zone *string `required:"false"`
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// vpc的id,指定SubnetId时必填
|
||||
VPCId *string `required:"false"`
|
||||
// 业务组
|
||||
BusinessId *string `required:"false"`
|
||||
|
||||
// 子网id,不指定则获取VPCId下的所有vip
|
||||
SubnetId *string `required:"false"`
|
||||
|
@ -30,22 +29,25 @@ type DescribeVIPRequest struct {
|
|||
// 业务组名称, 默认为 Default
|
||||
Tag *string `required:"false"`
|
||||
|
||||
// 业务组
|
||||
BusinessId *string `required:"false"`
|
||||
// VIP ID
|
||||
VIPId *string `required:"false"`
|
||||
|
||||
// vpc的id,指定SubnetId时必填
|
||||
VPCId *string `required:"false"`
|
||||
}
|
||||
|
||||
// DescribeVIPResponse is response schema for DescribeVIP action
|
||||
type DescribeVIPResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 内网VIP详情,请见VIPDetailSet
|
||||
VIPSet []VIPDetailSet
|
||||
|
||||
// 内网VIP地址列表
|
||||
DataSet []string
|
||||
|
||||
// vip数量
|
||||
TotalCount int
|
||||
|
||||
// 内网VIP详情,请见VIPDetailSet
|
||||
VIPSet []VIPDetailSet
|
||||
}
|
||||
|
||||
// NewDescribeVIPRequest will create request of DescribeVIP action.
|
||||
|
@ -65,7 +67,9 @@ func (c *UNetClient) DescribeVIP(req *DescribeVIPRequest) (*DescribeVIPResponse,
|
|||
var err error
|
||||
var res DescribeVIPResponse
|
||||
|
||||
err = c.Client.InvokeAction("DescribeVIP", req, &res)
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("DescribeVIP", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
|
|
@ -1,34 +1,42 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package unet
|
||||
|
||||
/*
|
||||
VIPDetailSet - VIPDetailSet
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn for detail.
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type VIPDetailSet struct {
|
||||
|
||||
// 地域
|
||||
Zone string
|
||||
|
||||
// 虚拟ip id
|
||||
VIPId string
|
||||
|
||||
// 创建时间
|
||||
CreateTime int
|
||||
|
||||
// VIP名称
|
||||
Name string
|
||||
|
||||
// 真实主机ip
|
||||
RealIp string
|
||||
|
||||
// 虚拟ip
|
||||
VIP string
|
||||
// VIP备注
|
||||
Remark string
|
||||
|
||||
// 子网id
|
||||
SubnetId string
|
||||
|
||||
// VIP所属业务组
|
||||
Tag string
|
||||
|
||||
// 虚拟ip
|
||||
VIP string
|
||||
|
||||
// 虚拟ip id
|
||||
VIPId string
|
||||
|
||||
// VPC id
|
||||
VPCId string
|
||||
|
||||
// Virtual IP 名称
|
||||
Name string
|
||||
// 地域
|
||||
Zone string
|
||||
}
|
63
vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_vip_attribute.go
generated
vendored
Normal file
63
vendor/github.com/ucloud/ucloud-sdk-go/services/unet/update_vip_attribute.go
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package unet
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// UpdateVIPAttributeRequest is request schema for UpdateVIPAttribute action
|
||||
type UpdateVIPAttributeRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目ID。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"true"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// 内网VIP的名称
|
||||
Name *string `required:"false"`
|
||||
|
||||
// 内网VIP的备注
|
||||
Remark *string `required:"false"`
|
||||
|
||||
// 内网VIP所属的业务组
|
||||
Tag *string `required:"false"`
|
||||
|
||||
// 内网VIP的资源Id
|
||||
VIPId *string `required:"true"`
|
||||
}
|
||||
|
||||
// UpdateVIPAttributeResponse is response schema for UpdateVIPAttribute action
|
||||
type UpdateVIPAttributeResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewUpdateVIPAttributeRequest will create request of UpdateVIPAttribute action.
|
||||
func (c *UNetClient) NewUpdateVIPAttributeRequest() *UpdateVIPAttributeRequest {
|
||||
req := &UpdateVIPAttributeRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// UpdateVIPAttribute - 更新VIP信息
|
||||
func (c *UNetClient) UpdateVIPAttribute(req *UpdateVIPAttributeRequest) (*UpdateVIPAttributeResponse, error) {
|
||||
var err error
|
||||
var res UpdateVIPAttributeResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("UpdateVIPAttribute", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/add_white_list_resource.go
generated
vendored
Normal file
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/add_white_list_resource.go
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// AddWhiteListResourceRequest is request schema for AddWhiteListResource action
|
||||
type AddWhiteListResourceRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
|
||||
// 可添加白名单的资源Id
|
||||
ResourceIds []string `required:"true"`
|
||||
}
|
||||
|
||||
// AddWhiteListResourceResponse is response schema for AddWhiteListResource action
|
||||
type AddWhiteListResourceResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewAddWhiteListResourceRequest will create request of AddWhiteListResource action.
|
||||
func (c *VPCClient) NewAddWhiteListResourceRequest() *AddWhiteListResourceRequest {
|
||||
req := &AddWhiteListResourceRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(false)
|
||||
return req
|
||||
}
|
||||
|
||||
// AddWhiteListResource - 添加NAT网关白名单
|
||||
func (c *VPCClient) AddWhiteListResource(req *AddWhiteListResourceRequest) (*AddWhiteListResourceResponse, error) {
|
||||
var err error
|
||||
var res AddWhiteListResourceResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("AddWhiteListResource", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
|
@ -5,14 +7,15 @@ import (
|
|||
"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
|
||||
)
|
||||
|
||||
// VPCClient is the client of VPC2.0
|
||||
// VPCClient is the client of VPC
|
||||
type VPCClient struct {
|
||||
*ucloud.Client
|
||||
}
|
||||
|
||||
// NewClient will return a instance of VPCClient
|
||||
func NewClient(config *ucloud.Config, credential *auth.Credential) *VPCClient {
|
||||
client := ucloud.NewClient(config, credential)
|
||||
meta := ucloud.ClientMeta{Product: "VPC2.0"}
|
||||
client := ucloud.NewClientWithMeta(config, credential, meta)
|
||||
return &VPCClient{
|
||||
client,
|
||||
}
|
||||
|
|
78
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_natgw.go
generated
vendored
Normal file
78
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_natgw.go
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// CreateNATGWRequest is request schema for CreateNATGW action
|
||||
type CreateNATGWRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关绑定的EIPId
|
||||
EIPIds []string `required:"true"`
|
||||
|
||||
// NAT网关绑定的防火墙Id
|
||||
FirewallId *string `required:"true"`
|
||||
|
||||
// 白名单开关标记。0表示关闭,1表示开启。默认为0
|
||||
IfOpen *int `required:"false"`
|
||||
|
||||
// NAT网关名称
|
||||
NATGWName *string `required:"true"`
|
||||
|
||||
// 备注。默认为空
|
||||
Remark *string `required:"false"`
|
||||
|
||||
// NAT网关绑定的子网Id
|
||||
SubnetworkIds []string `required:"true"`
|
||||
|
||||
// 业务组。默认为空
|
||||
Tag *string `required:"false"`
|
||||
|
||||
// NAT网关所属的VPC Id。默认为Default VPC Id
|
||||
VPCId *string `required:"false"`
|
||||
}
|
||||
|
||||
// CreateNATGWResponse is response schema for CreateNATGW action
|
||||
type CreateNATGWResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 申请到的NATGateWay Id
|
||||
NATGWId string
|
||||
}
|
||||
|
||||
// NewCreateNATGWRequest will create request of CreateNATGW action.
|
||||
func (c *VPCClient) NewCreateNATGWRequest() *CreateNATGWRequest {
|
||||
req := &CreateNATGWRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(false)
|
||||
return req
|
||||
}
|
||||
|
||||
// CreateNATGW - 创建NAT网关
|
||||
func (c *VPCClient) CreateNATGW(req *CreateNATGWRequest) (*CreateNATGWResponse, error) {
|
||||
var err error
|
||||
var res CreateNATGWResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("CreateNATGW", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
75
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_natgw_policy.go
generated
vendored
Normal file
75
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/create_natgw_policy.go
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// CreateNATGWPolicyRequest is request schema for CreateNATGWPolicy action
|
||||
type CreateNATGWPolicyRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// 目标IP。填写对应的目标IP地址
|
||||
DstIP *string `required:"true"`
|
||||
|
||||
// 目标端口。可填写固定端口,也可填写端口范围。支持的端口范围为1-65535
|
||||
DstPort *string `required:"true"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
|
||||
// 转发策略名称。默认为空
|
||||
PolicyName *string `required:"false"`
|
||||
|
||||
// 协议类型。枚举值为:TCP、UDP
|
||||
Protocol *string `required:"true"`
|
||||
|
||||
// 源IP。填写对应的EIP Id
|
||||
SrcEIPId *string `required:"true"`
|
||||
|
||||
// 源端口。可填写固定端口,也可填写端口范围。支持的端口范围为1-65535
|
||||
SrcPort *string `required:"true"`
|
||||
}
|
||||
|
||||
// CreateNATGWPolicyResponse is response schema for CreateNATGWPolicy action
|
||||
type CreateNATGWPolicyResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 创建时分配的策略Id
|
||||
PolicyId string
|
||||
}
|
||||
|
||||
// NewCreateNATGWPolicyRequest will create request of CreateNATGWPolicy action.
|
||||
func (c *VPCClient) NewCreateNATGWPolicyRequest() *CreateNATGWPolicyRequest {
|
||||
req := &CreateNATGWPolicyRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(false)
|
||||
return req
|
||||
}
|
||||
|
||||
// CreateNATGWPolicy - 添加NAT网关端口转发规则
|
||||
func (c *VPCClient) CreateNATGWPolicy(req *CreateNATGWPolicyRequest) (*CreateNATGWPolicyResponse, error) {
|
||||
var err error
|
||||
var res CreateNATGWPolicyResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("CreateNATGWPolicy", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_natgw.go
generated
vendored
Normal file
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_natgw.go
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DeleteNATGWRequest is request schema for DeleteNATGW action
|
||||
type DeleteNATGWRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
|
||||
// 是否释放绑定的EIP。true:解绑并释放;false:只解绑不释放。默认为false
|
||||
ReleaseEip *bool `required:"false"`
|
||||
}
|
||||
|
||||
// DeleteNATGWResponse is response schema for DeleteNATGW action
|
||||
type DeleteNATGWResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewDeleteNATGWRequest will create request of DeleteNATGW action.
|
||||
func (c *VPCClient) NewDeleteNATGWRequest() *DeleteNATGWRequest {
|
||||
req := &DeleteNATGWRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DeleteNATGW - 删除NAT网关
|
||||
func (c *VPCClient) DeleteNATGW(req *DeleteNATGWRequest) (*DeleteNATGWResponse, error) {
|
||||
var err error
|
||||
var res DeleteNATGWResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("DeleteNATGW", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_natgw_policy.go
generated
vendored
Normal file
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_natgw_policy.go
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DeleteNATGWPolicyRequest is request schema for DeleteNATGWPolicy action
|
||||
type DeleteNATGWPolicyRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
|
||||
// 端口转发规则Id
|
||||
PolicyId *string `required:"true"`
|
||||
}
|
||||
|
||||
// DeleteNATGWPolicyResponse is response schema for DeleteNATGWPolicy action
|
||||
type DeleteNATGWPolicyResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewDeleteNATGWPolicyRequest will create request of DeleteNATGWPolicy action.
|
||||
func (c *VPCClient) NewDeleteNATGWPolicyRequest() *DeleteNATGWPolicyRequest {
|
||||
req := &DeleteNATGWPolicyRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DeleteNATGWPolicy - 删除NAT网关端口转发规则
|
||||
func (c *VPCClient) DeleteNATGWPolicy(req *DeleteNATGWPolicyRequest) (*DeleteNATGWPolicyResponse, error) {
|
||||
var err error
|
||||
var res DeleteNATGWPolicyResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("DeleteNATGWPolicy", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_white_list_resource.go
generated
vendored
Normal file
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/delete_white_list_resource.go
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DeleteWhiteListResourceRequest is request schema for DeleteWhiteListResource action
|
||||
type DeleteWhiteListResourceRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
|
||||
// 删除白名单的资源Id
|
||||
ResourceIds []string `required:"true"`
|
||||
}
|
||||
|
||||
// DeleteWhiteListResourceResponse is response schema for DeleteWhiteListResource action
|
||||
type DeleteWhiteListResourceResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewDeleteWhiteListResourceRequest will create request of DeleteWhiteListResource action.
|
||||
func (c *VPCClient) NewDeleteWhiteListResourceRequest() *DeleteWhiteListResourceRequest {
|
||||
req := &DeleteWhiteListResourceRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DeleteWhiteListResource - 删除NAT网关白名单列表
|
||||
func (c *VPCClient) DeleteWhiteListResource(req *DeleteWhiteListResourceRequest) (*DeleteWhiteListResourceResponse, error) {
|
||||
var err error
|
||||
var res DeleteWhiteListResourceResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("DeleteWhiteListResource", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
66
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_natgw.go
generated
vendored
Normal file
66
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_natgw.go
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DescribeNATGWRequest is request schema for DescribeNATGW action
|
||||
type DescribeNATGWRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// 数据分页值。默认为20
|
||||
Limit *int `required:"false"`
|
||||
|
||||
// NAT网关Id。默认为该项目下所有NAT网关
|
||||
NATGWIds []string `required:"false"`
|
||||
|
||||
// 数据偏移量。默认为0
|
||||
Offset *int `required:"false"`
|
||||
}
|
||||
|
||||
// DescribeNATGWResponse is response schema for DescribeNATGW action
|
||||
type DescribeNATGWResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 查到的NATGW信息列表
|
||||
DataSet []NatGatewayDataSet
|
||||
|
||||
// 满足条件的实例的总数
|
||||
TotalCount int
|
||||
}
|
||||
|
||||
// NewDescribeNATGWRequest will create request of DescribeNATGW action.
|
||||
func (c *VPCClient) NewDescribeNATGWRequest() *DescribeNATGWRequest {
|
||||
req := &DescribeNATGWRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DescribeNATGW - 获取NAT网关信息
|
||||
func (c *VPCClient) DescribeNATGW(req *DescribeNATGWRequest) (*DescribeNATGWResponse, error) {
|
||||
var err error
|
||||
var res DescribeNATGWResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("DescribeNATGW", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
66
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_natgw_policy.go
generated
vendored
Normal file
66
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_natgw_policy.go
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DescribeNATGWPolicyRequest is request schema for DescribeNATGWPolicy action
|
||||
type DescribeNATGWPolicyRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// 返回数据长度,默认为10000
|
||||
Limit *int `required:"false"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
|
||||
// 列表起始位置偏移量,默认为0
|
||||
Offset *int `required:"false"`
|
||||
}
|
||||
|
||||
// DescribeNATGWPolicyResponse is response schema for DescribeNATGWPolicy action
|
||||
type DescribeNATGWPolicyResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 查到的NATGW 转发策略的详细信息
|
||||
DataSet []NATGWPolicyDataSet
|
||||
|
||||
// 满足条件的转发策略总数
|
||||
TotalCount int
|
||||
}
|
||||
|
||||
// NewDescribeNATGWPolicyRequest will create request of DescribeNATGWPolicy action.
|
||||
func (c *VPCClient) NewDescribeNATGWPolicyRequest() *DescribeNATGWPolicyRequest {
|
||||
req := &DescribeNATGWPolicyRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DescribeNATGWPolicy - 展示NAT网关端口转发规则
|
||||
func (c *VPCClient) DescribeNATGWPolicy(req *DescribeNATGWPolicyRequest) (*DescribeNATGWPolicyResponse, error) {
|
||||
var err error
|
||||
var res DescribeNATGWPolicyResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("DescribeNATGWPolicy", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
60
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_white_list_resource.go
generated
vendored
Normal file
60
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/describe_white_list_resource.go
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// DescribeWhiteListResourceRequest is request schema for DescribeWhiteListResource action
|
||||
type DescribeWhiteListResourceRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目id
|
||||
// ProjectId *string `required:"true"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关的Id
|
||||
NATGWIds []string `required:"true"`
|
||||
}
|
||||
|
||||
// DescribeWhiteListResourceResponse is response schema for DescribeWhiteListResource action
|
||||
type DescribeWhiteListResourceResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 白名单资源的详细信息,详见DescribeResourceWhiteListDataSet
|
||||
DataSet []NatGWWhitelistDataSet
|
||||
|
||||
// 上述DataSet总数量
|
||||
TotalCount int
|
||||
}
|
||||
|
||||
// NewDescribeWhiteListResourceRequest will create request of DescribeWhiteListResource action.
|
||||
func (c *VPCClient) NewDescribeWhiteListResourceRequest() *DescribeWhiteListResourceRequest {
|
||||
req := &DescribeWhiteListResourceRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// DescribeWhiteListResource - 展示NAT网关白名单资源列表
|
||||
func (c *VPCClient) DescribeWhiteListResource(req *DescribeWhiteListResourceRequest) (*DescribeWhiteListResourceResponse, error) {
|
||||
var err error
|
||||
var res DescribeWhiteListResourceResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("DescribeWhiteListResource", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/enable_white_list.go
generated
vendored
Normal file
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/enable_white_list.go
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// EnableWhiteListRequest is request schema for EnableWhiteList action
|
||||
type EnableWhiteListRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// 白名单开关标记。0:关闭;1:开启。默认为0
|
||||
IfOpen *int `required:"true"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
}
|
||||
|
||||
// EnableWhiteListResponse is response schema for EnableWhiteList action
|
||||
type EnableWhiteListResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewEnableWhiteListRequest will create request of EnableWhiteList action.
|
||||
func (c *VPCClient) NewEnableWhiteListRequest() *EnableWhiteListRequest {
|
||||
req := &EnableWhiteListRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// EnableWhiteList - 修改NAT网关白名单开关
|
||||
func (c *VPCClient) EnableWhiteList(req *EnableWhiteListRequest) (*EnableWhiteListResponse, error) {
|
||||
var err error
|
||||
var res EnableWhiteListResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("EnableWhiteList", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
63
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/get_available_resource_for_policy.go
generated
vendored
Normal file
63
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/get_available_resource_for_policy.go
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// GetAvailableResourceForPolicyRequest is request schema for GetAvailableResourceForPolicy action
|
||||
type GetAvailableResourceForPolicyRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// 返回数据长度,默认为10000
|
||||
Limit *int `required:"false"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
|
||||
// 列表起始位置偏移量,默认为0
|
||||
Offset *int `required:"false"`
|
||||
}
|
||||
|
||||
// GetAvailableResourceForPolicyResponse is response schema for GetAvailableResourceForPolicy action
|
||||
type GetAvailableResourceForPolicyResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 支持资源类型的信息
|
||||
DataSet []GetAvailableResourceForPolicyDataSet
|
||||
}
|
||||
|
||||
// NewGetAvailableResourceForPolicyRequest will create request of GetAvailableResourceForPolicy action.
|
||||
func (c *VPCClient) NewGetAvailableResourceForPolicyRequest() *GetAvailableResourceForPolicyRequest {
|
||||
req := &GetAvailableResourceForPolicyRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// GetAvailableResourceForPolicy - 获取NAT网关可配置端口转发规则的资源信息
|
||||
func (c *VPCClient) GetAvailableResourceForPolicy(req *GetAvailableResourceForPolicyRequest) (*GetAvailableResourceForPolicyResponse, error) {
|
||||
var err error
|
||||
var res GetAvailableResourceForPolicyResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("GetAvailableResourceForPolicy", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
60
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/get_available_resource_for_white_list.go
generated
vendored
Normal file
60
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/get_available_resource_for_white_list.go
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// GetAvailableResourceForWhiteListRequest is request schema for GetAvailableResourceForWhiteList action
|
||||
type GetAvailableResourceForWhiteListRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
}
|
||||
|
||||
// GetAvailableResourceForWhiteListResponse is response schema for GetAvailableResourceForWhiteList action
|
||||
type GetAvailableResourceForWhiteListResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 返回白名单列表的详细信息
|
||||
DataSet []GetAvailableResourceForWhiteListDataSet
|
||||
|
||||
// 白名单资源列表的总的个数
|
||||
TotalCount int
|
||||
}
|
||||
|
||||
// NewGetAvailableResourceForWhiteListRequest will create request of GetAvailableResourceForWhiteList action.
|
||||
func (c *VPCClient) NewGetAvailableResourceForWhiteListRequest() *GetAvailableResourceForWhiteListRequest {
|
||||
req := &GetAvailableResourceForWhiteListRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// GetAvailableResourceForWhiteList - 获取NAT网关可添加白名单的资源
|
||||
func (c *VPCClient) GetAvailableResourceForWhiteList(req *GetAvailableResourceForWhiteListRequest) (*GetAvailableResourceForWhiteListResponse, error) {
|
||||
var err error
|
||||
var res GetAvailableResourceForWhiteListResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("GetAvailableResourceForWhiteList", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/list_subnet_for_natgw.go
generated
vendored
Normal file
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/list_subnet_for_natgw.go
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// ListSubnetForNATGWRequest is request schema for ListSubnetForNATGW action
|
||||
type ListSubnetForNATGWRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关所属VPC Id。默认值为Default VPC Id
|
||||
VPCId *string `required:"false"`
|
||||
}
|
||||
|
||||
// ListSubnetForNATGWResponse is response schema for ListSubnetForNATGW action
|
||||
type ListSubnetForNATGWResponse struct {
|
||||
response.CommonBase
|
||||
|
||||
// 具体参数请见NatgwSubnetDataSet
|
||||
DataSet []NatgwSubnetDataSet
|
||||
}
|
||||
|
||||
// NewListSubnetForNATGWRequest will create request of ListSubnetForNATGW action.
|
||||
func (c *VPCClient) NewListSubnetForNATGWRequest() *ListSubnetForNATGWRequest {
|
||||
req := &ListSubnetForNATGWRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// ListSubnetForNATGW - 展示NAT网关可绑定的子网列表
|
||||
func (c *VPCClient) ListSubnetForNATGW(req *ListSubnetForNATGWRequest) (*ListSubnetForNATGWResponse, error) {
|
||||
var err error
|
||||
var res ListSubnetForNATGWResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("ListSubnetForNATGW", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
60
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/set_gw_default_export.go
generated
vendored
Normal file
60
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/set_gw_default_export.go
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// SetGwDefaultExportRequest is request schema for SetGwDefaultExport action
|
||||
type SetGwDefaultExportRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关绑定的EIP Id。ExportIp和ExportEipId必填一个
|
||||
ExportEipId *string `required:"false"`
|
||||
|
||||
// NAT网关绑定的EIP。ExportIp和ExportEipId必填一个
|
||||
ExportIp *string `required:"false"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
}
|
||||
|
||||
// SetGwDefaultExportResponse is response schema for SetGwDefaultExport action
|
||||
type SetGwDefaultExportResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewSetGwDefaultExportRequest will create request of SetGwDefaultExport action.
|
||||
func (c *VPCClient) NewSetGwDefaultExportRequest() *SetGwDefaultExportRequest {
|
||||
req := &SetGwDefaultExportRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// SetGwDefaultExport - 设置NAT网关的默认出口
|
||||
func (c *VPCClient) SetGwDefaultExport(req *SetGwDefaultExportRequest) (*SetGwDefaultExportResponse, error) {
|
||||
var err error
|
||||
var res SetGwDefaultExportResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("SetGwDefaultExport", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
39
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_describe_white_list_resource_object_ip_info.go
generated
vendored
Normal file
39
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_describe_white_list_resource_object_ip_info.go
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
DescribeWhiteListResourceObjectIPInfo - DescribeWhiteListResource
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type DescribeWhiteListResourceObjectIPInfo struct {
|
||||
|
||||
// natgw字符串
|
||||
GwType string
|
||||
|
||||
// 白名单资源的内网IP
|
||||
PrivateIP string
|
||||
|
||||
// 白名单资源Id信息
|
||||
ResourceId string
|
||||
|
||||
// 白名单资源名称
|
||||
ResourceName string
|
||||
|
||||
// 白名单资源类型
|
||||
ResourceType string
|
||||
|
||||
// 资源绑定的虚拟网卡的实例ID
|
||||
SubResourceId string
|
||||
|
||||
// 资源绑定的虚拟网卡的实例名称
|
||||
SubResourceName string
|
||||
|
||||
// 资源绑定的虚拟网卡的类型
|
||||
SubResourceType string
|
||||
|
||||
// 白名单资源所属VPCId
|
||||
VPCId string
|
||||
}
|
21
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_get_available_resource_for_policy_data_set.go
generated
vendored
Normal file
21
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_get_available_resource_for_policy_data_set.go
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
GetAvailableResourceForPolicyDataSet - GetAvailableResourceForPolicy
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type GetAvailableResourceForPolicyDataSet struct {
|
||||
|
||||
// 资源对应的内网Ip
|
||||
PrivateIP string
|
||||
|
||||
// 资源的Id
|
||||
ResourceId string
|
||||
|
||||
// 资源类型。"uhost":云主机; "upm",物理云主机; "hadoophost":hadoop节点; "fortresshost":堡垒机: "udockhost",容器
|
||||
ResourceType string
|
||||
}
|
39
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_get_available_resource_for_white_list_data_set.go
generated
vendored
Normal file
39
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_get_available_resource_for_white_list_data_set.go
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
GetAvailableResourceForWhiteListDataSet - GetAvailableResourceForWhiteList
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type GetAvailableResourceForWhiteListDataSet struct {
|
||||
|
||||
// 资源的内网Ip
|
||||
PrivateIP string
|
||||
|
||||
// 资源类型Id
|
||||
ResourceId string
|
||||
|
||||
// 资源名称
|
||||
ResourceName string
|
||||
|
||||
// 资源类型。"uhost":云主机; "upm",物理云主机; "hadoophost":hadoop节点; "fortresshost":堡垒机: "udockhost",容器
|
||||
ResourceType string
|
||||
|
||||
// 资源绑定的虚拟网卡的实例ID
|
||||
SubResouceId string
|
||||
|
||||
// 资源绑定的虚拟网卡的实例类型
|
||||
SubResouceType string
|
||||
|
||||
// 资源绑定的虚拟网卡的实例名称
|
||||
SubResourceName string
|
||||
|
||||
// 资源所属子网Id
|
||||
SubnetworkId string
|
||||
|
||||
// 资源所属VPCId
|
||||
VPCId string
|
||||
}
|
45
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gateway_data_set.go
generated
vendored
Normal file
45
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gateway_data_set.go
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
NatGatewayDataSet - natgw的信息
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type NatGatewayDataSet struct {
|
||||
|
||||
// natgw创建时间
|
||||
CreateTime int
|
||||
|
||||
// 绑定的防火墙Id
|
||||
FirewallId string
|
||||
|
||||
// 绑定的EIP 信息
|
||||
IPSet []NatGatewayIPSet
|
||||
|
||||
// natgw id
|
||||
NATGWId string
|
||||
|
||||
// natgw名称
|
||||
NATGWName string
|
||||
|
||||
// 转发策略Id
|
||||
PolicyId []string
|
||||
|
||||
// 备注
|
||||
Remark string
|
||||
|
||||
// 子网 Id
|
||||
SubnetSet []NatGatewaySubnetSet
|
||||
|
||||
// 业务组
|
||||
Tag string
|
||||
|
||||
// 所属VPC Id
|
||||
VPCId string
|
||||
|
||||
// 所属VPC 信息
|
||||
VPCInfo string
|
||||
}
|
27
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gateway_ip_set.go
generated
vendored
Normal file
27
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gateway_ip_set.go
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
NatGatewayIPSet - IPSet信息
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type NatGatewayIPSet struct {
|
||||
|
||||
// 带宽
|
||||
Bandwidth int
|
||||
|
||||
// EIP带宽类型
|
||||
BandwidthType string
|
||||
|
||||
// 外网IP的 EIPId
|
||||
EIPId string
|
||||
|
||||
// 外网IP信息
|
||||
IPResInfo []NatGWIPResInfo
|
||||
|
||||
// 权重为100的为出口
|
||||
Weight int
|
||||
}
|
21
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gateway_subnet_set.go
generated
vendored
Normal file
21
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gateway_subnet_set.go
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
NatGatewaySubnetSet - natgw里面的子网信息
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type NatGatewaySubnetSet struct {
|
||||
|
||||
// 子网网段
|
||||
Subnet string
|
||||
|
||||
// 子网名字
|
||||
SubnetName string
|
||||
|
||||
// 子网id
|
||||
SubnetworkId string
|
||||
}
|
18
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gw_ip_res_info.go
generated
vendored
Normal file
18
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gw_ip_res_info.go
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
NatGWIPResInfo - IP信息
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type NatGWIPResInfo struct {
|
||||
|
||||
// 外网IP
|
||||
EIP string
|
||||
|
||||
// IP的运营商信息
|
||||
OperatorName string
|
||||
}
|
21
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gw_whitelist_data_set.go
generated
vendored
Normal file
21
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_nat_gw_whitelist_data_set.go
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
NatGWWhitelistDataSet - nat网关白名单数据
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type NatGWWhitelistDataSet struct {
|
||||
|
||||
// 白名单开关标记
|
||||
IfOpen int
|
||||
|
||||
// NATGateWay Id
|
||||
NATGWId string
|
||||
|
||||
// 白名单详情
|
||||
ObjectIPInfo []DescribeWhiteListResourceObjectIPInfo
|
||||
}
|
39
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_natgw_policy_data_set.go
generated
vendored
Normal file
39
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_natgw_policy_data_set.go
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
NATGWPolicyDataSet - DescribeNATGWPolicy
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type NATGWPolicyDataSet struct {
|
||||
|
||||
// 目的地址
|
||||
DstIP string
|
||||
|
||||
// 目的端口
|
||||
DstPort string
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId string
|
||||
|
||||
// 转发策略Id
|
||||
PolicyId string
|
||||
|
||||
// 转发策略名称
|
||||
PolicyName string
|
||||
|
||||
// 协议类型
|
||||
Protocol string
|
||||
|
||||
// 端口转发前端EIP
|
||||
SrcEIP string
|
||||
|
||||
// 端口转发前端EIP Id
|
||||
SrcEIPId string
|
||||
|
||||
// 源端口
|
||||
SrcPort string
|
||||
}
|
27
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_natgw_subnet_data_set.go
generated
vendored
Normal file
27
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/types_natgw_subnet_data_set.go
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
/*
|
||||
NatgwSubnetDataSet - natgw可以绑定的子网
|
||||
|
||||
this model is auto created by ucloud code generater for open api,
|
||||
you can also see https://docs.ucloud.cn/api for detail.
|
||||
*/
|
||||
type NatgwSubnetDataSet struct {
|
||||
|
||||
// 是否绑定NATGW
|
||||
HasNATGW bool
|
||||
|
||||
// 掩码
|
||||
Netmask string
|
||||
|
||||
// 子网网段
|
||||
Subnet string
|
||||
|
||||
// 子网id
|
||||
SubnetId string
|
||||
|
||||
// 子网名字
|
||||
SubnetName string
|
||||
}
|
75
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_natgw_policy.go
generated
vendored
Normal file
75
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_natgw_policy.go
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// UpdateNATGWPolicyRequest is request schema for UpdateNATGWPolicy action
|
||||
type UpdateNATGWPolicyRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// 目标IP。填写对饮的目标IP地址
|
||||
DstIP *string `required:"true"`
|
||||
|
||||
// 目标端口。可填写固定端口,也可填写端口范围。支持的端口范围为1-65535
|
||||
DstPort *string `required:"true"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
|
||||
// 转发策略Id
|
||||
PolicyId *string `required:"true"`
|
||||
|
||||
// 转发策略名称。默认为空
|
||||
PolicyName *string `required:"false"`
|
||||
|
||||
// 协议类型。枚举值为:TCP 、 UDP
|
||||
Protocol *string `required:"true"`
|
||||
|
||||
// 源IP。填写对应的EIP Id
|
||||
SrcEIPId *string `required:"true"`
|
||||
|
||||
// 源端口。可填写固定端口,也可填写端口范围。支持的端口范围为1-6553
|
||||
SrcPort *string `required:"true"`
|
||||
}
|
||||
|
||||
// UpdateNATGWPolicyResponse is response schema for UpdateNATGWPolicy action
|
||||
type UpdateNATGWPolicyResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewUpdateNATGWPolicyRequest will create request of UpdateNATGWPolicy action.
|
||||
func (c *VPCClient) NewUpdateNATGWPolicyRequest() *UpdateNATGWPolicyRequest {
|
||||
req := &UpdateNATGWPolicyRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// UpdateNATGWPolicy - 更新NAT网关端口转发规则
|
||||
func (c *VPCClient) UpdateNATGWPolicy(req *UpdateNATGWPolicyRequest) (*UpdateNATGWPolicyResponse, error) {
|
||||
var err error
|
||||
var res UpdateNATGWPolicyResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("UpdateNATGWPolicy", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_natgw_subnet.go
generated
vendored
Normal file
57
vendor/github.com/ucloud/ucloud-sdk-go/services/vpc/update_natgw_subnet.go
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Code is generated by ucloud-model, DO NOT EDIT IT.
|
||||
|
||||
package vpc
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
// UpdateNATGWSubnetRequest is request schema for UpdateNATGWSubnet action
|
||||
type UpdateNATGWSubnetRequest struct {
|
||||
request.CommonBase
|
||||
|
||||
// [公共参数] 项目Id。不填写为默认项目,子帐号必须填写。 请参考[GetProjectList接口](../summary/get_project_list.html)
|
||||
// ProjectId *string `required:"false"`
|
||||
|
||||
// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
|
||||
// Region *string `required:"true"`
|
||||
|
||||
// NAT网关Id
|
||||
NATGWId *string `required:"true"`
|
||||
|
||||
// NAT网关绑定的子网Id
|
||||
SubnetworkIds []string `required:"true"`
|
||||
}
|
||||
|
||||
// UpdateNATGWSubnetResponse is response schema for UpdateNATGWSubnet action
|
||||
type UpdateNATGWSubnetResponse struct {
|
||||
response.CommonBase
|
||||
}
|
||||
|
||||
// NewUpdateNATGWSubnetRequest will create request of UpdateNATGWSubnet action.
|
||||
func (c *VPCClient) NewUpdateNATGWSubnetRequest() *UpdateNATGWSubnetRequest {
|
||||
req := &UpdateNATGWSubnetRequest{}
|
||||
|
||||
// setup request with client config
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
// setup retryable with default retry policy (retry for non-create action and common error)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
// UpdateNATGWSubnet - 更新NAT网关绑定的子网
|
||||
func (c *VPCClient) UpdateNATGWSubnet(req *UpdateNATGWSubnetRequest) (*UpdateNATGWSubnetResponse, error) {
|
||||
var err error
|
||||
var res UpdateNATGWSubnetResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("UpdateNATGWSubnet", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
|
@ -9,7 +9,6 @@ import (
|
|||
"io"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Credential is the information of credential keys
|
||||
|
@ -25,32 +24,44 @@ func NewCredential() Credential {
|
|||
|
||||
// CreateSign will encode query string to credential signature.
|
||||
func (c *Credential) CreateSign(query string) string {
|
||||
// replace "=" "&"
|
||||
str := strings.Replace(query, "&", "", -1)
|
||||
str = strings.Replace(str, "=", "", -1)
|
||||
|
||||
// crypto by SHA1
|
||||
strUnescaped, _ := url.QueryUnescape(str)
|
||||
h := sha1.New()
|
||||
s := strUnescaped + c.PrivateKey
|
||||
io.WriteString(h, s)
|
||||
bs := h.Sum(nil)
|
||||
result := hex.EncodeToString(bs)
|
||||
|
||||
return result
|
||||
urlValues, err := url.ParseQuery(query)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
urlValues.Set("PublicKey", c.PublicKey)
|
||||
return c.verifyAc(urlValues)
|
||||
}
|
||||
|
||||
// BuildCredentialedQuery will build query string with signature query param.
|
||||
func (c *Credential) BuildCredentialedQuery(query map[string]string) string {
|
||||
var queryList []string
|
||||
for k, v := range query {
|
||||
queryList = append(queryList, k+"="+url.QueryEscape(v))
|
||||
func (c *Credential) BuildCredentialedQuery(params map[string]string) string {
|
||||
urlValues := url.Values{}
|
||||
for k, v := range params {
|
||||
urlValues.Set(k, v)
|
||||
}
|
||||
urlValues.Set("PublicKey", c.PublicKey)
|
||||
urlValues.Set("Signature", c.verifyAc(urlValues))
|
||||
return urlValues.Encode()
|
||||
}
|
||||
queryList = append(queryList, "PublicKey="+url.QueryEscape(c.PublicKey))
|
||||
sort.Strings(queryList)
|
||||
queryString := strings.Join(queryList, "&")
|
||||
|
||||
sign := c.CreateSign(queryString)
|
||||
queryString = queryString + "&Signature=" + sign
|
||||
return queryString
|
||||
func (c *Credential) verifyAc(urlValues url.Values) string {
|
||||
// sort keys
|
||||
var keys []string
|
||||
for k := range urlValues {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
signQuery := ""
|
||||
for _, k := range keys {
|
||||
signQuery += k + urlValues.Get(k)
|
||||
}
|
||||
signQuery += c.PrivateKey
|
||||
return encodeSha1(signQuery)
|
||||
}
|
||||
|
||||
func encodeSha1(s string) string {
|
||||
h := sha1.New()
|
||||
_, _ = io.WriteString(h, s)
|
||||
bs := h.Sum(nil)
|
||||
return hex.EncodeToString(bs)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@ import (
|
|||
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
|
||||
)
|
||||
|
||||
type ClientMeta struct {
|
||||
Product string
|
||||
}
|
||||
|
||||
// Client 客户端
|
||||
type Client struct {
|
||||
// configurations
|
||||
|
@ -31,6 +35,9 @@ type Client struct {
|
|||
httpRequestHandlers []HttpRequestHandler
|
||||
responseHandlers []ResponseHandler
|
||||
httpResponseHandlers []HttpResponseHandler
|
||||
|
||||
// client information injection
|
||||
meta ClientMeta
|
||||
}
|
||||
|
||||
// NewClient will create an client of ucloud sdk
|
||||
|
@ -38,6 +45,7 @@ func NewClient(config *Config, credential *auth.Credential) *Client {
|
|||
client := Client{
|
||||
credential: credential,
|
||||
config: config,
|
||||
meta: ClientMeta{},
|
||||
}
|
||||
|
||||
client.requestHandlers = append(client.requestHandlers, defaultRequestHandlers...)
|
||||
|
@ -51,6 +59,12 @@ func NewClient(config *Config, credential *auth.Credential) *Client {
|
|||
return &client
|
||||
}
|
||||
|
||||
func NewClientWithMeta(config *Config, credential *auth.Credential, meta ClientMeta) *Client {
|
||||
client := NewClient(config, credential)
|
||||
client.meta = meta
|
||||
return client
|
||||
}
|
||||
|
||||
// SetHttpClient will setup a http client
|
||||
func (c *Client) SetHttpClient(httpClient http.Client) error {
|
||||
c.httpClient = httpClient
|
||||
|
@ -67,6 +81,11 @@ func (c *Client) GetConfig() *Config {
|
|||
return c.config
|
||||
}
|
||||
|
||||
// GetMeta will return the meta data of client.
|
||||
func (c *Client) GetMeta() ClientMeta {
|
||||
return c.meta
|
||||
}
|
||||
|
||||
// SetLogger will set the logger of client
|
||||
func (c *Client) SetLogger(logger log.Logger) {
|
||||
c.logger = logger
|
||||
|
@ -131,6 +150,9 @@ func (c *Client) InvokeActionWithPatcher(action string, req request.Common, resp
|
|||
}
|
||||
|
||||
err = c.unmarshalHTTPResponse(body, resp)
|
||||
|
||||
uuid := httpResp.GetHeaders().Get(headerKeyRequestUUID)
|
||||
resp.SetRequestUUID(uuid)
|
||||
}
|
||||
|
||||
// use response middle to build and convert response when response has been created.
|
||||
|
|
|
@ -4,8 +4,14 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/log"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/version"
|
||||
)
|
||||
|
||||
// Version is the version of sdk
|
||||
const Version = version.Version
|
||||
|
||||
const headerKeyRequestUUID = "X-UCLOUD-REQUEST-UUID"
|
||||
|
||||
// Config is the config of ucloud sdk, use for setting up client
|
||||
type Config struct {
|
||||
// Region is the region of backend service
|
||||
|
|
|
@ -59,7 +59,6 @@ type CommonBase struct {
|
|||
retryCount int
|
||||
timeout time.Duration
|
||||
requestTime time.Time
|
||||
requestUUID string
|
||||
}
|
||||
|
||||
// SetRetryCount will set retry count of request
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// ToBase64Query will encode a wrapped string as base64 wrapped string
|
||||
func ToBase64Query(s *string) *string {
|
||||
return String(base64.StdEncoding.EncodeToString([]byte(StringValue(s))))
|
||||
}
|
||||
|
||||
// ToQueryMap will convert a request to string map
|
||||
func ToQueryMap(req Common) (map[string]string, error) {
|
||||
v := reflect.ValueOf(req)
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// String will return a pointer to string
|
||||
func String(val string) *string {
|
||||
return &val
|
||||
}
|
||||
|
||||
// StringValue will return a string from string pointer
|
||||
func StringValue(ptr *string) string {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Int will return a pointer to int
|
||||
func Int(val int) *int {
|
||||
return &val
|
||||
}
|
||||
|
||||
// IntValue will return a int from int pointer
|
||||
func IntValue(ptr *int) int {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Bool will return a pointer to bool
|
||||
func Bool(val bool) *bool {
|
||||
return &val
|
||||
}
|
||||
|
||||
// BoolValue will return a bool from bool pointer
|
||||
func BoolValue(ptr *bool) bool {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Float64 will return a pointer to float64
|
||||
func Float64(val float64) *float64 {
|
||||
return &val
|
||||
}
|
||||
|
||||
// Float64Value will return a float64 from float64 pointer
|
||||
func Float64Value(ptr *float64) float64 {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return 0.0
|
||||
}
|
||||
|
||||
// TimeDuration will return a pointer to time.Duration
|
||||
func TimeDuration(val time.Duration) *time.Duration {
|
||||
return &val
|
||||
}
|
||||
|
||||
// TimeDurationValue will return a time.Duration from a time.Duration pointer
|
||||
func TimeDurationValue(ptr *time.Duration) time.Duration {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return 0
|
||||
}
|
|
@ -16,6 +16,9 @@ type Common interface {
|
|||
|
||||
GetRequest() request.Common
|
||||
SetRequest(request.Common)
|
||||
|
||||
SetRequestUUID(string)
|
||||
GetRequestUUID() string
|
||||
}
|
||||
|
||||
// CommonBase has common attribute and method,
|
||||
|
@ -25,6 +28,8 @@ type CommonBase struct {
|
|||
RetCode int
|
||||
Message string
|
||||
|
||||
requestUUID string
|
||||
|
||||
request request.Common
|
||||
}
|
||||
|
||||
|
@ -53,3 +58,13 @@ func (c *CommonBase) GetRequest() request.Common {
|
|||
func (c *CommonBase) SetRequest(req request.Common) {
|
||||
c.request = req
|
||||
}
|
||||
|
||||
// SetRequestUUID will set uuid of request
|
||||
func (c *CommonBase) SetRequestUUID(uuid string) {
|
||||
c.requestUUID = uuid
|
||||
}
|
||||
|
||||
// GetRequestUUID will get uuid of request
|
||||
func (c *CommonBase) GetRequestUUID() string {
|
||||
return c.requestUUID
|
||||
}
|
||||
|
|
|
@ -1,75 +1,18 @@
|
|||
package ucloud
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/version"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
|
||||
)
|
||||
|
||||
// Version is the version of sdk
|
||||
const Version = version.Version
|
||||
|
||||
// String will return a pointer to string
|
||||
func String(val string) *string {
|
||||
return &val
|
||||
}
|
||||
|
||||
// StringValue will return a string from string pointer
|
||||
func StringValue(ptr *string) string {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Int will return a pointer to int
|
||||
func Int(val int) *int {
|
||||
return &val
|
||||
}
|
||||
|
||||
// IntValue will return a int from int pointer
|
||||
func IntValue(ptr *int) int {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Bool will return a pointer to bool
|
||||
func Bool(val bool) *bool {
|
||||
return &val
|
||||
}
|
||||
|
||||
// BoolValue will return a bool from bool pointer
|
||||
func BoolValue(ptr *bool) bool {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Float64 will return a pointer to float64
|
||||
func Float64(val float64) *float64 {
|
||||
return &val
|
||||
}
|
||||
|
||||
// Float64Value will return a float64 from float64 pointer
|
||||
func Float64Value(ptr *float64) float64 {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return 0.0
|
||||
}
|
||||
|
||||
// TimeDuration will return a pointer to time.Duration
|
||||
func TimeDuration(val time.Duration) *time.Duration {
|
||||
return &val
|
||||
}
|
||||
|
||||
// TimeDurationValue will return a time.Duration from a time.Duration pointer
|
||||
func TimeDurationValue(ptr *time.Duration) time.Duration {
|
||||
if ptr != nil {
|
||||
return *ptr
|
||||
}
|
||||
return 0
|
||||
}
|
||||
var (
|
||||
String = request.String
|
||||
StringValue = request.StringValue
|
||||
Int = request.Int
|
||||
IntValue = request.IntValue
|
||||
Bool = request.Bool
|
||||
BoolValue = request.BoolValue
|
||||
Float64 = request.Float64
|
||||
Float64Value = request.Float64Value
|
||||
TimeDuration = request.TimeDuration
|
||||
TimeDurationValue = request.TimeDurationValue
|
||||
)
|
||||
|
|
|
@ -4,4 +4,4 @@ Package version is the version of sdk
|
|||
package version
|
||||
|
||||
// Version see also semantic version: https://semver.org/
|
||||
const Version = "0.8.7"
|
||||
const Version = "0.11.1"
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
example/config.json
|
||||
example/*.txt
|
||||
*.exe
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue