Skip to content

Commit 24ce416

Browse files
authored
Merge pull request #645 from jschoiRR/mold-main#2025
[Mold ] 컴퓨트 오퍼링, 네트워크 오퍼링 생성시 네트워크 속도 필수값 설정 및 기본값 10000 으로 세팅
2 parents 771ad5e + e8d8219 commit 24ce416

File tree

5 files changed

+52
-17
lines changed

5 files changed

+52
-17
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.cloud.hypervisor.kvm.storage;
1818

1919
import java.io.File;
20+
import java.io.FileWriter;
21+
import java.io.IOException;
2022
import java.util.List;
2123
import java.util.Map;
2224

@@ -362,6 +364,7 @@ public String createHeartBeatCommand(HAStoragePool primaryStoragePool, String ho
362364
cmd.add("-c");
363365
}
364366
} else if (primaryStoragePool.getPool().getType() == StoragePoolType.RBD) {
367+
createRBDSecretKeyFileIfNoExist(primaryStoragePool.getPoolUUID(), "/var/lib/libvirt/images/", primaryStoragePool.getPoolAuthSecret());
365368
cmd.add("-i", primaryStoragePool.getPoolSourceHost());
366369
cmd.add("-p", primaryStoragePool.getPoolMountSourcePath());
367370
cmd.add("-n", primaryStoragePool.getPoolAuthUserName());
@@ -613,6 +616,7 @@ public Boolean vmActivityCheck(HAStoragePool pool, HostTO host, Duration activit
613616
cmd.add("-t", String.valueOf(String.valueOf(System.currentTimeMillis() / 1000)));
614617
cmd.add("-d", String.valueOf(duration));
615618
} else if (pool.getPool().getType() == StoragePoolType.RBD) {
619+
cmd.add("-i", pool.getPoolSourceHost());
616620
cmd.add("-p", pool.getPoolMountSourcePath());
617621
cmd.add("-n", pool.getPoolAuthUserName());
618622
cmd.add("-s", pool.getPoolAuthSecret());
@@ -704,4 +708,21 @@ public Boolean vmActivityCheck(HAStoragePool pool, HostTO host, Duration activit
704708
return true;
705709
}
706710
}
711+
712+
public void createRBDSecretKeyFileIfNoExist(String uuid, String localPath, String skey) {
713+
File file = new File(localPath + File.separator + uuid);
714+
try {
715+
// 파일이 존재하지 않을 때만 생성
716+
if (!file.exists()) {
717+
boolean isCreated = file.createNewFile();
718+
if (isCreated) {
719+
// 파일 생성 후 내용 작성
720+
FileWriter writer = new FileWriter(file);
721+
writer.write(skey);
722+
writer.close();
723+
}
724+
}
725+
} catch (IOException e) {}
726+
}
727+
707728
}

scripts/vm/hypervisor/kvm/kvmheartbeat_rbd.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ interval=0
3939
rflag=0
4040
cflag=0
4141
UUIDList=
42+
skeyPath="/var/lib/libvirt/images/"
4243

4344
while getopts 'p:n:s:h:i:t:u:r:c' OPTION
4445
do
@@ -81,38 +82,38 @@ if [ -z "$PoolName" ]; then
8182
fi
8283

8384
# rados object touch action for vol list
84-
res=$(rbd -p $PoolName ls --id $PoolAuthUserName | grep MOLD-AC)
85+
res=$(rbd -p $PoolName ls --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret | grep MOLD-AC)
8586
if [ $? -gt 0 ]; then
86-
rbd -p $PoolName create --size 1 --id $PoolAuthUserName MOLD-AC
87+
rbd -p $PoolName create --size 1 --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret MOLD-AC
8788
fi
8889

8990
timestamp=$(date +%s)
9091

9192
if [ -n "$UUIDList" ]; then
9293
for uuid in $(echo $UUIDList | sed 's/,/ /g'); do
93-
objId=$(rbd -p $PoolName info $uuid --id $PoolAuthUserName | grep 'id:')
94+
objId=$(rbd -p $PoolName info $uuid --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret | grep 'id:')
9495
objId=${objId#*id: }
9596
res=$(timeout 3s bash -c "rados -p $PoolName touch rbd_object_map.$objId")
9697
if [ $? -eq 0 ]; then
9798
# 정상적인 touch 상태면 image meta에 key: uuid / value : timestamp 입력
98-
rbd -p $PoolName --id $PoolAuthUserName image-meta set MOLD-AC $uuid $HostIP:$timestamp
99+
rbd -p $PoolName --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret image-meta set MOLD-AC $uuid $HostIP:$timestamp
99100
else
100101
# 정상적으로 touch 상태가 아니면 image meta에 key : uuid 삭제
101-
rbd -p $PoolName --id $PoolAuthUserName image-meta rm MOLD-AC $uuid
102+
rbd -p $PoolName --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret image-meta rm MOLD-AC $uuid
102103
fi
103104
done
104105
fi
105106

106107
#write the heart beat log
107108
write_hbLog() {
108109
Timestamp=$(date +%s)
109-
obj=$(rbd -p $PoolName ls --id $PoolAuthUserName | grep MOLD-HB)
110+
obj=$(rbd -p $PoolName ls --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret | grep MOLD-HB)
110111

111112
if [ $? -gt 0 ]; then
112-
rbd -p $PoolName create --size 1 --id $PoolAuthUserName MOLD-HB
113+
rbd -p $PoolName create --size 1 --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret MOLD-HB
113114
fi
114115

115-
obj=$(rbd -p $PoolName --id $PoolAuthUserName image-meta set MOLD-HB $HostIP $Timestamp)
116+
obj=$(rbd -p $PoolName --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret image-meta set MOLD-HB $HostIP $Timestamp)
116117
if [ $? -gt 0 ]; then
117118
printf "Failed to create rbd file and set image-meta"
118119
return 2
@@ -123,7 +124,7 @@ write_hbLog() {
123124
#check the heart beat log
124125
check_hbLog() {
125126
now=$(date +%s)
126-
getHbTime=$(rbd -p $PoolName --id $PoolAuthUserName image-meta get MOLD-HB $HostIP)
127+
getHbTime=$(rbd -p $PoolName --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret image-meta get MOLD-HB $HostIP)
127128
if [ $? -gt 0 ] || [ -z "$getHbTime" ]; then
128129
return 1
129130
fi

scripts/vm/hypervisor/kvm/kvmvmactivity_rbd.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ PoolName=
3131
PoolAuthUserName=
3232
PoolAuthSecret=
3333
HostIP=
34+
SourceHostIP=
3435
UUIDList=
3536
interval=0
37+
skeyPath="/var/lib/libvirt/images/"
3638

37-
while getopts 'p:n:s:h:u:t:' OPTION
39+
while getopts 'p:n:s:h:i:u:t:' OPTION
3840
do
3941
case $OPTION in
4042
p)
@@ -49,6 +51,9 @@ do
4951
h)
5052
HostIP="$OPTARG"
5153
;;
54+
i)
55+
SourceHostIP="$OPTARG"
56+
;;
5257
u)
5358
UUIDList="$OPTARG"
5459
;;
@@ -72,7 +77,7 @@ fi
7277
# First check: heartbeat filei
7378

7479
now=$(date +%s)
75-
getHbTime=$(rbd -p $PoolName --id $PoolAuthUserName image-meta get MOLD-HB $HostIP)
80+
getHbTime=$(rbd -p $PoolName --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret image-meta get MOLD-HB $HostIP)
7681

7782
if [ $? -eq 0 ]; then
7883
diff=$(expr $now - $getHbTime)
@@ -89,12 +94,12 @@ fi
8994

9095
# Second check: disk activity check
9196
for uuid in $(echo $UUIDList | sed 's/,/ /g'); do
92-
acTime=$(rbd -p $PoolName --id $PoolAuthUserName image-meta get MOLD-AC $uuid > /dev/null 2>&1)
97+
acTime=$(rbd -p $PoolName --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret image-meta get MOLD-AC $uuid > /dev/null 2>&1)
9398
if [ $? -gt 0 ]; then
9499
echo "### [HOST STATE : DEAD] Unable to confirm normal activity of volume image list => Considered host down in [PoolType : RBD] ### "
95100
exit 0
96101
else
97-
acTime=$(rbd -p $PoolName --id $PoolAuthUserName image-meta get MOLD-AC $uuid)
102+
acTime=$(rbd -p $PoolName --id $PoolAuthUserName -m $SourceHostIP -K $skeyPath$PoolAuthSecret image-meta get MOLD-AC $uuid)
98103
if [ -z "$acTime" ]; then
99104
echo "### [HOST STATE : DEAD] Unable to confirm normal activity of volume image list => Considered host down in [PoolType : RBD] ### "
100105
exit 0

ui/src/views/offering/AddComputeOffering.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,8 @@ export default {
748748
diskofferingstrictness: this.diskofferingstrictness,
749749
encryptdisk: this.encryptdisk,
750750
kvdoenable: false,
751-
shareable: false
751+
shareable: false,
752+
networkrate: 10000
752753
})
753754
this.rules = reactive({
754755
name: [{ required: true, message: this.$t('message.error.required.input') }],
@@ -780,7 +781,10 @@ export default {
780781
{ required: true, message: this.$t('message.error.required.input') },
781782
this.naturalNumberRule
782783
],
783-
networkrate: [this.naturalNumberRule],
784+
networkrate: [
785+
{ required: true, message: this.$t('message.error.required.input') },
786+
this.naturalNumberRule
787+
],
784788
rootdisksize: [this.naturalNumberRule],
785789
diskbytesreadrate: [this.naturalNumberRule],
786790
diskbyteswriterate: [this.naturalNumberRule],

ui/src/views/offering/AddNetworkOffering.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,15 @@ export default {
681681
egressdefaultpolicy: 'deny',
682682
ispublic: this.isPublic,
683683
nsxsupportlb: true,
684-
routingmode: 'static'
684+
routingmode: 'static',
685+
networkrate: '10000'
685686
})
686687
this.rules = reactive({
687688
name: [{ required: true, message: this.$t('message.error.name') }],
688-
networkrate: [{ type: 'number', validator: this.validateNumber }],
689+
networkrate: [
690+
{ type: 'number', validator: this.validateNumber },
691+
{ required: true, message: this.$t('message.error.required.input') }
692+
],
689693
serviceofferingid: [{ required: true, message: this.$t('message.error.select') }],
690694
domainid: [{ type: 'array', required: true, message: this.$t('message.error.select') }],
691695
zoneid: [{

0 commit comments

Comments
 (0)