Automatic merge from release/2.6.0 -> release/2.7.0

* commit 'a504ede86f3ce4d587bdf23e9445a5bbe9cc94b1':
  huawei add more region location info
  huawei disk delete bugfix
  eip short desc add ip_addr & guest delete fix
This commit is contained in:
邱剑
2019-03-05 20:20:59 +08:00
5 changed files with 23 additions and 4 deletions
+1
View File
@@ -178,6 +178,7 @@ func (self *SElasticip) GetShortDesc(ctx context.Context) *jsonutils.JSONDict {
desc.Add(jsonutils.NewInt(int64(self.Bandwidth)), "bandwidth")
desc.Add(jsonutils.NewString(self.Mode), "mode")
desc.Add(jsonutils.NewString(self.IpAddr), "ip_addr")
// region := self.GetRegion()
// if len(region.ExternalId) > 0 {
+8 -2
View File
@@ -292,11 +292,17 @@ func (self *SDisk) GetAccessPath() string {
}
func (self *SDisk) Delete(ctx context.Context) error {
if _, err := self.storage.zone.region.GetDisk(self.GetId()); err == cloudprovider.ErrNotFound {
if disk, err := self.storage.zone.region.GetDisk(self.GetId()); err == cloudprovider.ErrNotFound {
log.Errorf("Failed to find disk %s when delete", self.GetId())
return nil
} else if disk.Status != "deleting" {
err := self.storage.zone.region.DeleteDisk(self.GetId())
if err != nil {
return err
}
}
return self.storage.zone.region.DeleteDisk(self.GetId())
return cloudprovider.WaitDeleted(self, 10*time.Second, 120*time.Second)
}
func (self *SDisk) CreateISnapshot(ctx context.Context, name string, desc string) (cloudprovider.ICloudSnapshot, error) {
+2 -2
View File
@@ -244,7 +244,7 @@ func (self *SHost) _createVM(name string, imgId string, sysDisk cloudprovider.SD
vmId, err := self.zone.region.CreateInstance(name, imgId, instanceType, networkId, secgroupId, secgroup.VpcID, self.zone.GetId(), desc, disks, ipAddr, keypair, passwd, userData, bc)
if err != nil {
log.Errorf("Failed for %s: %s", instanceType, err)
return "", fmt.Errorf("Failed to create specification %s.%s", instanceType, err.Error())
return "", fmt.Errorf("create %s failed:%s", instanceType, ErrMessage(err))
} else {
return vmId, nil
}
@@ -271,5 +271,5 @@ func (self *SHost) _createVM(name string, imgId string, sysDisk cloudprovider.SD
}
}
return "", fmt.Errorf("Failed to create, %s", err.Error())
return "", fmt.Errorf("create failed: %s", ErrMessage(err))
}
+3
View File
@@ -8,10 +8,13 @@ import "yunion.io/x/onecloud/pkg/cloudprovider"
var LatitudeAndLongitude = map[string]cloudprovider.SGeographicInfo{
"cn-east-2": {Latitude: 31.210344, Longitude: 121.455364, City: "Shanghai", CountryCode: "CN"},
"cn-north-1": {Latitude: 39.997743, Longitude: 116.304542, City: "Beijing", CountryCode: "CN"},
"cn-north-4": {Latitude: 39.997743, Longitude: 116.304542, City: "Beijing", CountryCode: "CN"},
"cn-south-1": {Latitude: 23.12911, Longitude: 113.264385, City: "Guangzhou", CountryCode: "CN"},
"cn-south-2": {Latitude: 23.12911, Longitude: 113.264385, City: "Guangzhou", CountryCode: "CN"},
"ap-southeast-1": {Latitude: 22.396428, Longitude: 114.109497, City: "Hongkong", CountryCode: "CN"},
"ap-southeast-2": {Latitude: 13.7563309, Longitude: 100.5017651, City: "Bangkok", CountryCode: "TH"},
"ap-southeast-3": {Latitude: 1.360386, Longitude: 103.821195, City: "Singapore", CountryCode: "SG"},
"eu-west-0": {Latitude: 48.856614, Longitude: 2.3522219, City: "Paris", CountryCode: "FR"},
"cn-northeast-1": {Latitude: 38.91400300000001, Longitude: 121.614682, City: "Shanghai", CountryCode: "CN"},
"cn-southwest-2": {Latitude: 26.6470035286, Longitude: 106.6302113880, City: "Guiyang", CountryCode: "CN"},
}
+9
View File
@@ -181,3 +181,12 @@ func DoDeleteWithSpec(deleteFunc deleteFunc2, ctx manager.IManagerContext, id st
_, err := deleteFunc(ctx, id, spec, queries, params, "")
return err
}
func ErrMessage(err error) string {
switch v := err.(type) {
case *httputils.JSONClientError:
return fmt.Sprintf("%d(%s):%s", v.Code, v.Class, v.Details)
default:
return err.Error()
}
}