fix server create

This commit is contained in:
wanyaoqi
2018-08-11 18:34:21 +08:00
parent 4b28c2a201
commit 9474752c05
6 changed files with 62 additions and 12 deletions
+5 -2
View File
@@ -593,6 +593,7 @@ type SDiskConfig struct {
Cache string //
Mountpoint string //
Backend string // stroageType
Medium string
ImageProperties map[string]string
}
@@ -608,9 +609,9 @@ func parseDiskInfo(ctx context.Context, userCred mcclient.TokenCredential, info
return &diskConfig, nil
}
// default backend
// default backend and medium type
diskConfig.Backend = STORAGE_LOCAL
// diskConfig.Medium = DISK_TYPE_HYBRID
diskConfig.Medium = DISK_TYPE_HYBRID
diskStr, err := info.GetString()
if err != nil {
@@ -629,6 +630,8 @@ func parseDiskInfo(ctx context.Context, userCred mcclient.TokenCredential, info
diskConfig.Driver = p
} else if utils.IsInStringArray(p, osprofile.DISK_CACHE_MODES) {
diskConfig.Cache = p
} else if utils.IsInStringArray(p, DISK_TYPES) {
diskConfig.Medium = p
} else if p[0] == '/' {
diskConfig.Mountpoint = p
} else if p == "autoextend" {
+2 -2
View File
@@ -27,11 +27,11 @@ func (self *DiskCreateTask) OnInit(ctx context.Context, obj db.IStandaloneModel,
self.SetStage("on_storage_cache_image_complete", nil)
storagecache.StartImageCacheTask(ctx, self.UserCred, imageId, false, self.GetTaskId())
} else {
self.OnStorageCacheImageComplete(ctx, disk)
self.OnStorageCacheImageComplete(ctx, disk, nil)
}
}
func (self *DiskCreateTask) OnStorageCacheImageComplete(ctx context.Context, disk *models.SDisk) {
func (self *DiskCreateTask) OnStorageCacheImageComplete(ctx context.Context, disk *models.SDisk, data jsonutils.JSONObject) {
rebuild, _ := self.GetParams().Bool("rebuild")
snapshot, _ := self.GetParams().GetString("snapshot")
if rebuild {
+11
View File
@@ -53,6 +53,10 @@ func NewClient(authUrl string, timeout int, debug bool, insecure bool) *Client {
return &client
}
func (this *Client) SetDebug(debug bool) {
this.debug = debug
}
func (this *Client) AuthVersion() string {
pos := strings.LastIndexByte(this.authUrl, '/')
if pos > 0 {
@@ -62,6 +66,13 @@ func (this *Client) AuthVersion() string {
}
}
func (this *Client) NewAuthTokenCredential() TokenCredential {
if this.AuthVersion() == "v3" {
return &TokenCredentialV3{}
}
return &TokenCredentialV2{}
}
func getDefaultHeader(header http.Header, token string) http.Header {
if len(token) > 0 {
if header == nil {
+4
View File
@@ -63,6 +63,10 @@ func SplitVersionedURL(url string) (string, string) {
return base
}*/
func (this *ClientSession) GetClient() *Client {
return this.client
}
func (this *ClientSession) GetServiceURL(service, endpointType string) (string, error) {
if len(this.endpointType) > 0 {
// session specific endpoint type should override the input endpointType, which is supplied by manager