fix(region): format and check existing path

Signed-off-by: wanyaoqi <d3lx.yq@gmail.com>
This commit is contained in:
wanyaoqi
2022-09-08 20:22:11 +08:00
parent 5b8d97c8f3
commit 494e13d68a
+8
View File
@@ -19,6 +19,7 @@ import (
"database/sql"
"fmt"
"path"
"path/filepath"
"strings"
"time"
@@ -1884,6 +1885,13 @@ func parseDiskInfo(ctx context.Context, userCred mcclient.TokenCredential, info
}
}
}
if info.ExistingPath != "" {
info.ExistingPath = strings.TrimSpace(info.ExistingPath)
_, err := filepath.Rel("/", info.ExistingPath)
if err != nil {
return nil, errors.Wrap(err, "invaild existing path")
}
}
// XXX: do not set default disk size here, set it by each hypervisor driver
// if len(diskConfig.ImageId) > 0 && diskConfig.SizeMb == 0 {
// diskConfig.SizeMb = options.Options.DefaultDiskSize // MB