Merge pull request #1235 in YUNIONIO/onecloud from ~QUXUAN/onecloud:hotfix/qx-openstack-create-error to release/2.7.0

* commit '13f36146fa7656422d3edbe5c66911a30a3987d6':
  避免openstack创建机器失败后长时间等待
This commit is contained in:
邱剑
2019-03-13 21:37:32 +08:00
11 changed files with 68 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package openstack
import (
"context"
"errors"
"fmt"
"time"
@@ -69,6 +70,12 @@ type VolumesAttached struct {
DeleteOnTermination bool
}
type SFault struct {
Message string
Code int
Details string
}
type SInstance struct {
host *SHost
@@ -115,6 +122,7 @@ type SInstance struct {
TrustedImageCertificates []string
Updated time.Time
UserID string
Fault SFault
}
func (region *SRegion) GetSecurityGroupsByInstance(instanceId string) ([]SecurityGroup, error) {
@@ -629,3 +637,10 @@ func (region *SRegion) RenewInstances(instanceId []string, bc billing.SBillingCy
func (instance *SInstance) GetProjectId() string {
return instance.TenantID
}
func (self *SInstance) GetError() error {
if self.Status == INSTANCE_STATUS_ERROR && len(self.Fault.Message) > 0 {
return errors.New(self.Fault.Message)
}
return nil
}