Merge pull request #716 from Zexi/hotfix/baremetal-ipmi-disksize

fix baremetal disk config auto extend not work and ipmi_info not record
This commit is contained in:
yunion-ci-robot
2019-05-05 19:03:14 +08:00
committed by GitHub
6 changed files with 13 additions and 4 deletions
+4
View File
@@ -465,6 +465,7 @@ func init() {
MAC string `help:"Default MAC address of baremetal"`
Rack string `help:"Rack number of baremetal"`
Slots string `help:"Slots number of baremetal"`
IpmiUser string `help:"IPMI user name"`
IpmiPasswd string `help:"IPMI user password"`
IpmiAddr string `help:"IPMI IP address"`
}
@@ -479,6 +480,9 @@ func init() {
if len(args.Slots) > 0 {
params.Add(jsonutils.NewString(args.Slots), "slots")
}
if len(args.IpmiUser) > 0 {
params.Add(jsonutils.NewString(args.IpmiUser), "ipmi_username")
}
if len(args.IpmiPasswd) > 0 {
params.Add(jsonutils.NewString(args.IpmiPasswd), "ipmi_password")
}
+2
View File
@@ -51,4 +51,6 @@ const (
DISK_TYPE_VOLUME = "volume"
DISK_BACKING_IMAGE = "image"
DISK_SIZE_AUTOEXTEND = -1
)
+1 -1
View File
@@ -1245,7 +1245,7 @@ func fillDiskConfigByImage(ctx context.Context, userCred mcclient.TokenCredentia
// }
// diskConfig.ImageDiskFormat = image.DiskFormat
CachedimageManager.ImageAddRefCount(image.Id)
if diskConfig.SizeMb < image.MinDiskMB {
if diskConfig.SizeMb != api.DISK_SIZE_AUTOEXTEND && diskConfig.SizeMb < image.MinDiskMB {
diskConfig.SizeMb = image.MinDiskMB // MB
}
}
+1 -1
View File
@@ -964,7 +964,7 @@ func (manager *SGuestManager) ValidateCreateData(ctx context.Context, userCred m
}
}
sysMinDiskMB := GetDriver(hypervisor).GetMinimalSysDiskSizeGb() * 1024
if rootDiskConfig.SizeMb < sysMinDiskMB {
if rootDiskConfig.SizeMb != api.DISK_SIZE_AUTOEXTEND && rootDiskConfig.SizeMb < sysMinDiskMB {
rootDiskConfig.SizeMb = sysMinDiskMB
}
}
-1
View File
@@ -2597,7 +2597,6 @@ func fetchIpmiInfo(data *jsonutils.JSONDict, hostId string) (*jsonutils.JSONDict
if strings.HasPrefix(key, IPMI_KEY_PERFIX) {
value, _ := data.GetString(key)
subkey := key[len(IPMI_KEY_PERFIX):]
data.Remove(key)
if subkey == "password" && len(hostId) > 0 {
value, err = utils.EncryptAESBase64(hostId, value)
if err != nil {
+5 -1
View File
@@ -100,7 +100,7 @@ func parseHosts(data string) ([]jsonutils.JSONObject, string) {
}
fields := strings.Split(host, ",")
if len(fields) != 4 {
if len(fields) != 5 {
msg += fmt.Sprintf("第%d行: %s (格式不正确)\n", i, host)
continue
}
@@ -129,6 +129,10 @@ func parseHosts(data string) ([]jsonutils.JSONObject, string) {
params.Add(jsonutils.NewString(fields[3]), "ipmi_password")
}
if len(fields[4]) > 0 {
params.Add(jsonutils.NewString(fields[4]), "ipmi_username")
}
ret = append(ret, params)
}