mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #725 from wanyaoqi/bugfix/wyq-fix-host-image
bugfix: fix host image service, disable https
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user