diff --git a/pkg/appsrv/handlerinfo.go b/pkg/appsrv/handlerinfo.go index 6a7234ca65..048a4124cd 100644 --- a/pkg/appsrv/handlerinfo.go +++ b/pkg/appsrv/handlerinfo.go @@ -110,4 +110,4 @@ func (hi *SHandlerInfo) GetAppParams(params map[string]string, path []string) *S appParams.Params = params appParams.Path = path return &appParams -} \ No newline at end of file +} diff --git a/pkg/compute/hostdrivers/esxi.go b/pkg/compute/hostdrivers/esxi.go index d7d1158007..05bbb9e9ef 100644 --- a/pkg/compute/hostdrivers/esxi.go +++ b/pkg/compute/hostdrivers/esxi.go @@ -9,6 +9,7 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/util/httputils" + "github.com/golang-plus/errors" ) type SESXiHostDriver struct { @@ -62,6 +63,12 @@ func (self *SESXiHostDriver) CheckAndSetCacheImage(ctx context.Context, host *mo content.Format = cacheImage.GetFormat() storage := host.GetStorageByFilePath(storageCache.Path) + if storage == nil { + msg := fmt.Sprintf("fail to find storage for storageCache %s", storageCache.Path) + log.Errorf(msg) + return errors.New(msg) + } + accessInfo, err := host.GetCloudaccount().GetVCenterAccessInfo(storage.ExternalId) if err != nil { return err diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index 9fa926df40..d9107bdbfe 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" + "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modules" "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/appsrv" ) const ( diff --git a/pkg/compute/tasks/cloud_account_sync_task.go b/pkg/compute/tasks/cloud_account_sync_task.go index cf5dfe6591..0ffcf2ef83 100644 --- a/pkg/compute/tasks/cloud_account_sync_task.go +++ b/pkg/compute/tasks/cloud_account_sync_task.go @@ -91,6 +91,7 @@ func (self *CloudAccountSyncInfoTask) OnCloudaccountSyncComplete(ctx context.Con err := skus.SyncSkusByProviderIds([]string{cloudprovider.Provider}) return nil, err }) + return } } self.SetStageComplete(ctx, nil) diff --git a/pkg/util/esxi/storage.go b/pkg/util/esxi/storage.go index 34c786b937..58d61e6a71 100644 --- a/pkg/util/esxi/storage.go +++ b/pkg/util/esxi/storage.go @@ -1,12 +1,8 @@ package esxi import ( - "github.com/vmware/govmomi/vim25/mo" - "context" "fmt" - "github.com/vmware/govmomi/object" - "github.com/vmware/govmomi/vim25/types" "io" "io/ioutil" "net/http" @@ -16,8 +12,14 @@ import ( "strconv" "strings" "time" + + "github.com/vmware/govmomi/object" + "github.com/vmware/govmomi/vim25/types" + "github.com/vmware/govmomi/vim25/mo" + "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/util/vmdkutils" @@ -330,8 +332,14 @@ func (self *SDatastore) GetManagerId() string { return self.manager.providerId } +const dsPrefix = "ds://" + func (self *SDatastore) GetUrl() string { - return self.getDatastore().Info.GetDatastoreInfo().Url + url := self.getDatastore().Info.GetDatastoreInfo().Url + if strings.HasPrefix(url, dsPrefix) { + url = url[len(dsPrefix):] + } + return url } func (self *SDatastore) GetMountPoint() string {