mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): vendor update for aws image import (#19305)
This commit is contained in:
@@ -88,12 +88,12 @@ require (
|
||||
k8s.io/client-go v0.19.3
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240118084313-ab18e956a30a
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240119080520-50ad1dee76b9
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19
|
||||
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
|
||||
yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900
|
||||
yunion.io/x/pkg v1.0.1-0.20240114161232-64f11f704be8
|
||||
yunion.io/x/pkg v1.0.1-0.20240119022847-0486a12fcaf2
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
|
||||
yunion.io/x/sqlchemy v1.1.3-0.20240103021517-2be4fb49bd3b
|
||||
yunion.io/x/structarg v0.0.0-20231017124457-df4d5009457c
|
||||
|
||||
@@ -1201,8 +1201,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240118084313-ab18e956a30a h1:jUi02jzul/YZLlYryaULlfnvH6T/BQkws2Jh8npP0l0=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240118084313-ab18e956a30a/go.mod h1:aj1gR9PPb6eqqKOwvANe26CoZFY8ydmXy0fuvgKYXH0=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240119080520-50ad1dee76b9 h1:uADncTCFcv36z3QfZ41bBaLZKjUHlCWoo95LM4jLp9g=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240119080520-50ad1dee76b9/go.mod h1:aj1gR9PPb6eqqKOwvANe26CoZFY8ydmXy0fuvgKYXH0=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
@@ -1216,8 +1216,8 @@ yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900 h1:Hu/4ERvoWaN6aiFs4h4/yvVB
|
||||
yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900/go.mod h1:0vLkNEhlmA64HViPBAnSTUMrx5QP1CLsxXmxDKQ80tc=
|
||||
yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v1.0.1-0.20240114161232-64f11f704be8 h1:+zOGiKwsEOfnxBOqDHBTl4SqSvCHIrC5gsF5dMgtnrs=
|
||||
yunion.io/x/pkg v1.0.1-0.20240114161232-64f11f704be8/go.mod h1:ksCJVQ+DwKrJ5QBEoU8pzrDFfDaZVAFH/iJ6yQCYxJk=
|
||||
yunion.io/x/pkg v1.0.1-0.20240119022847-0486a12fcaf2 h1:RojIOrbdwjnmZhXooQCytIHebyxsHP/3G0CW/ErGhbE=
|
||||
yunion.io/x/pkg v1.0.1-0.20240119022847-0486a12fcaf2/go.mod h1:ksCJVQ+DwKrJ5QBEoU8pzrDFfDaZVAFH/iJ6yQCYxJk=
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo=
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo=
|
||||
yunion.io/x/sqlchemy v1.1.3-0.20240103021517-2be4fb49bd3b h1:W87Fe3H4wVm2CIrsVXNuypnO3yV7nhkiWozd2lDruKM=
|
||||
|
||||
Vendored
+2
-2
@@ -1465,7 +1465,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
||||
# sigs.k8s.io/yaml v1.2.0
|
||||
## explicit; go 1.12
|
||||
sigs.k8s.io/yaml
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240118084313-ab18e956a30a
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240119080520-50ad1dee76b9
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
@@ -1560,7 +1560,7 @@ yunion.io/x/log/hooks
|
||||
yunion.io/x/ovsdb/cli_util
|
||||
yunion.io/x/ovsdb/schema/ovn_nb
|
||||
yunion.io/x/ovsdb/types
|
||||
# yunion.io/x/pkg v1.0.1-0.20240114161232-64f11f704be8
|
||||
# yunion.io/x/pkg v1.0.1-0.20240119022847-0486a12fcaf2
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/pkg/appctx
|
||||
yunion.io/x/pkg/errors
|
||||
|
||||
+26
-18
@@ -132,9 +132,10 @@ func (self *ImageImportTask) Refresh() error {
|
||||
return jsonutils.Update(self, task)
|
||||
}
|
||||
|
||||
func (self *SRegion) GetImportImageTask(id string) (*ImageImportTask, error) {
|
||||
params := map[string]string{
|
||||
"ImportTaskId.1": id,
|
||||
func (self *SRegion) GetImportImageTasks(ids []string) ([]ImageImportTask, error) {
|
||||
params := map[string]string{}
|
||||
for i, id := range ids {
|
||||
params[fmt.Sprintf("ImportTaskId.%d", i+1)] = id
|
||||
}
|
||||
ret := struct {
|
||||
ImportImageTaskSet []ImageImportTask `xml:"importImageTaskSet>item"`
|
||||
@@ -143,10 +144,17 @@ func (self *SRegion) GetImportImageTask(id string) (*ImageImportTask, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "DescribeImportImageTasks")
|
||||
}
|
||||
return ret.ImportImageTaskSet, nil
|
||||
}
|
||||
|
||||
for i := range ret.ImportImageTaskSet {
|
||||
if ret.ImportImageTaskSet[i].TaskId == id {
|
||||
return &ret.ImportImageTaskSet[i], nil
|
||||
func (self *SRegion) GetImportImageTask(id string) (*ImageImportTask, error) {
|
||||
tasks, err := self.GetImportImageTasks([]string{id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range tasks {
|
||||
if tasks[i].TaskId == id {
|
||||
return &tasks[i], nil
|
||||
}
|
||||
}
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
|
||||
@@ -305,18 +313,18 @@ func (self *SImage) GetIStoragecache() cloudprovider.ICloudStoragecache {
|
||||
|
||||
func (self *SRegion) ImportImage(name string, osArch string, osType string, osDist string, diskFormat string, bucket string, key string) (*ImageImportTask, error) {
|
||||
params := map[string]string{
|
||||
"Architecture": osArch,
|
||||
"Hypervisor": "xen",
|
||||
"Platform": osType,
|
||||
"RoleName": "vmimport",
|
||||
"TagSpecification": "",
|
||||
"TagSpecification.1.Tag.1.Key": "Name",
|
||||
"TagSpecification.1.Tag.1.Value": name,
|
||||
"Description": fmt.Sprintf("vmimport %s - %s", name, osDist),
|
||||
"DiskContainer.1.Format": strings.ToUpper(diskFormat),
|
||||
"DiskContainer.1.DeviceName": "/dev/sda",
|
||||
"DiskContainer.1.Url": fmt.Sprintf("https://%s.%s/%s", bucket, self.getS3Endpoint(), key),
|
||||
"LicenseType": "BYOL",
|
||||
"Architecture": osArch,
|
||||
"Hypervisor": "xen",
|
||||
"Platform": osType,
|
||||
"RoleName": "vmimport",
|
||||
"TagSpecification.1.ResourceType": "import-image-task",
|
||||
"TagSpecification.1.Tag.1.Key": "Name",
|
||||
"TagSpecification.1.Tag.1.Value": name,
|
||||
"Description": fmt.Sprintf("vmimport %s - %s", name, osDist),
|
||||
"DiskContainer.1.Format": strings.ToUpper(diskFormat),
|
||||
"DiskContainer.1.DeviceName": "/dev/sda",
|
||||
"DiskContainer.1.Url": fmt.Sprintf("s3://%s/%s", bucket, key),
|
||||
"LicenseType": "BYOL",
|
||||
}
|
||||
ret := &ImageImportTask{region: self}
|
||||
err := self.ec2Request("ImportImage", params, ret)
|
||||
|
||||
+2
-5
@@ -167,14 +167,13 @@ func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider
|
||||
}
|
||||
|
||||
task, err := self.region.ImportImage(imageName, image.OsArch, image.OsType, image.OsDistribution, string(qemuimgfmt.VMDK), bucketName, image.ImageId)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("ImportImage error %s %s %s", image.ImageId, bucketName, err)
|
||||
return "", err
|
||||
return "", errors.Wrapf(err, "ImportImage")
|
||||
}
|
||||
|
||||
err = cloudprovider.Wait(2*time.Minute, 4*time.Hour, func() (bool, error) {
|
||||
status := task.GetStatus()
|
||||
log.Debugf("task %s status: %s", task.TaskId, status)
|
||||
if status == ImageImportStatusDeleted {
|
||||
return false, errors.Wrap(errors.ErrInvalidStatus, "SStoragecache.ImageImportStatusDeleted")
|
||||
}
|
||||
@@ -189,8 +188,6 @@ func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider
|
||||
return "", errors.Wrap(err, "SStoragecache.Wait")
|
||||
}
|
||||
|
||||
// add name tag
|
||||
//self.region.addTags(task.ImageId, "Name", image.ImageId)
|
||||
if callback != nil {
|
||||
callback(100)
|
||||
}
|
||||
|
||||
+4
@@ -744,6 +744,10 @@ func (self *SRegion) GetInstance(instanceId string) (*SInstance, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 华为云删除的实例依然可以查到
|
||||
if ret.Status == "DELETED" {
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "aleady deleted")
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
||||
+9
-2
@@ -546,8 +546,15 @@ func TransSQLAchemyURL(pySQLSrc string) (dialect, ret string, err error) {
|
||||
return dialect, pySQLSrc, nil
|
||||
}
|
||||
|
||||
r := regexp.MustCompile(`[/@:]+`)
|
||||
strs := r.Split(pySQLSrc, -1)
|
||||
lastAtIndex := strings.LastIndex(pySQLSrc, "@")
|
||||
firstPart := pySQLSrc[:lastAtIndex]
|
||||
secondPart := pySQLSrc[lastAtIndex+1:]
|
||||
|
||||
r := regexp.MustCompile(`[/:]+`)
|
||||
firstPartArr := r.Split(firstPart, -1)
|
||||
secondPartArr := r.Split(secondPart, -1)
|
||||
|
||||
strs := append(firstPartArr, secondPartArr...)
|
||||
if len(strs) != 6 {
|
||||
err = fmt.Errorf("Incorrect mysql connection url: %s", pySQLSrc)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user