diff --git a/pkg/compute/hostdrivers/kvm.go b/pkg/compute/hostdrivers/kvm.go index 331efad8ee..051927af2b 100644 --- a/pkg/compute/hostdrivers/kvm.go +++ b/pkg/compute/hostdrivers/kvm.go @@ -218,7 +218,7 @@ func (self *SKVMHostDriver) RequestAllocateDiskOnStorage(ctx context.Context, ho content.Set("snapshot_out_of_chain", jsonutils.NewBool(snapshot.OutOfChain)) } else if options.Options.SnapshotCreateDiskProtocol == "fuse" { content.Set("snapshot_url", jsonutils.NewString(fmt.Sprintf("%s/snapshots/%s/%s", - snapshotHost.GetFetchUrl(), snapshot.DiskId, snapshot.Id))) + snapshotHost.GetFetchUrl(true), snapshot.DiskId, snapshot.Id))) } content.Set("protocol", jsonutils.NewString(options.Options.SnapshotCreateDiskProtocol)) } diff --git a/pkg/compute/models/disks.go b/pkg/compute/models/disks.go index d3d40b6959..960b1ecc90 100644 --- a/pkg/compute/models/disks.go +++ b/pkg/compute/models/disks.go @@ -920,7 +920,7 @@ func (self *SDisk) GetPathAtHost(host *SHost) string { func (self *SDisk) GetFetchUrl() string { storage := self.GetStorage() host := storage.GetMasterHost() - return fmt.Sprintf("%s/disks/%s", host.GetFetchUrl(), self.Id) + return fmt.Sprintf("%s/disks/%s", host.GetFetchUrl(true), self.Id) } func (self *SDisk) GetFsFormat() string { diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index e88425858d..9839dc9a16 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -738,11 +738,16 @@ func (self *SHost) PerformUpdateStorage( return nil, nil } -func (self *SHost) GetFetchUrl() string { +func (self *SHost) GetFetchUrl(disableHttps bool) string { managerUrl, err := url.Parse(self.ManagerUri) if err != nil { log.Errorf("GetFetchUrl fail to parse url: %s", err) } + + if disableHttps { + managerUrl.Scheme = "http" + } + portStr := managerUrl.Port() var port int if len(portStr) > 0 { diff --git a/pkg/hostimage/host_image_service.go b/pkg/hostimage/host_image_service.go index 2ef920b5c3..17ee338787 100644 --- a/pkg/hostimage/host_image_service.go +++ b/pkg/hostimage/host_image_service.go @@ -30,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" - "yunion.io/x/onecloud/pkg/cloudcommon" app_common "yunion.io/x/onecloud/pkg/cloudcommon/app" "yunion.io/x/onecloud/pkg/cloudcommon/consts" common_options "yunion.io/x/onecloud/pkg/cloudcommon/options" @@ -39,7 +38,7 @@ import ( ) type SHostImageOptions struct { - cloudcommon.Options + common_options.CommonOptions LocalImagePath []string `help:"Local Image Paths"` SnapshotDirSuffix string `help:"Snapshot dir name equal diskId concat snapshot dir suffix" default:"_snap"` } @@ -48,14 +47,15 @@ var HostImageOptions SHostImageOptions func StartService() { consts.SetServiceType("host-image") - common_options.ParseOptions(&HostImageOptions, &HostImageOptions.Options, os.Args, "host.conf") + common_options.ParseOptions(&HostImageOptions, os.Args, "host.conf", "host-image") + HostImageOptions.EnableSsl = false HostImageOptions.Port += 40000 - app_common.InitAuth(&HostImageOptions.Options, func() { + app_common.InitAuth(&HostImageOptions.CommonOptions, func() { log.Infof("Auth complete!!") }) - app := app_common.InitApp(&HostImageOptions.Options) + app := app_common.InitApp(&HostImageOptions.CommonOptions, false) initHandlers(app, "") - app_common.ServeForever(app, &HostImageOptions.Options) + app_common.ServeForever(app, &HostImageOptions.CommonOptions) } func initHandlers(app *appsrv.Application, prefix string) {