Skip to content

Commit

Permalink
Support domestic CSPs testing (NHN, KT requires register feature)
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-github-robot authored Jun 7, 2024
2 parents 75dcd1b + 1ec2fee commit 0b123a9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.21.6

require (
github.com/cloud-barista/cb-store v0.8.0
github.com/cloud-barista/mc-terrarium v0.0.7
github.com/fsnotify/fsnotify v1.7.0
github.com/go-playground/validator/v10 v10.17.0
github.com/go-resty/resty/v2 v2.11.0
Expand All @@ -30,7 +31,6 @@ require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/cloud-barista/cb-log v0.8.0 // indirect
github.com/cloud-barista/mc-terrarium v0.0.7 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand Down
11 changes: 1 addition & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ github.com/cloud-barista/cb-log v0.8.0 h1:ArWCs1EgpoD3ZnBgcC4cAw5ufI/JHmFKfJswlv
github.com/cloud-barista/cb-log v0.8.0/go.mod h1:nGgfTFMPwl1MpCO3FBjexUkNdOYA0BNJoyM9Pd0lMms=
github.com/cloud-barista/cb-store v0.8.0 h1:0K47YEf+K3wx18D+m0XirlDbdTz229XxsTXw6WACjRA=
github.com/cloud-barista/cb-store v0.8.0/go.mod h1:6NuA5TdeVRExd59ULXv6LEhm4EE0ODn9L820g4VqApo=
github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516022714-7bafe50e1df5 h1:4/OX/AF2/f4vtA4JrmAQKtjTDvZP0dcJjoChLNXAhUk=
github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516022714-7bafe50e1df5/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI=
github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516045927-43023b6a0e18 h1:tsBHD7Gh+Q0jpZ3NCh4jDM+ozlxFCfpMc2gto+G6tZQ=
github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516045927-43023b6a0e18/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI=
github.com/cloud-barista/mc-terrarium v0.0.6 h1:6HKwnzJ1i3xRiFeboJhMMzTq/qvTt11adIBkmJrSV04=
github.com/cloud-barista/mc-terrarium v0.0.6/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI=
github.com/cloud-barista/mc-terrarium v0.0.7-0.20240605063928-b1786b261c06 h1:zAovyT3dYd77t2PkP2IsayYNQ3emxUyldDfmVBvRw6Y=
github.com/cloud-barista/mc-terrarium v0.0.7-0.20240605063928-b1786b261c06/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI=
github.com/cloud-barista/mc-terrarium v0.0.7 h1:rXBbAxZyOuwWx77xekrBylGVj9ZIOmHyYcPZkykpCag=
github.com/cloud-barista/mc-terrarium v0.0.7/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
Expand Down Expand Up @@ -295,8 +287,7 @@ github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
Expand Down
11 changes: 8 additions & 3 deletions src/core/mcis/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -1698,20 +1698,25 @@ func CreateVm(nsId string, mcisId string, vmInfoData *TbVmInfo, option string) e
// Try lookup customImage
requestBody.ReqInfo.ImageName, err = common.GetCspResourceId(nsId, common.StrCustomImage, vmInfoData.ImageId)
if requestBody.ReqInfo.ImageName == "" || err != nil {
log.Warn().Msgf("Not found the Image: %s in nsId: %s, find it from SystemCommonNs", vmInfoData.ImageId, nsId)
log.Warn().Msgf("Not found %s from CustomImage in ns: %s, find it from UserImage", vmInfoData.ImageId, nsId)
errAgg := err.Error()
// If customImage doesn't exist, then try lookup image
requestBody.ReqInfo.ImageName, err = common.GetCspResourceId(nsId, common.StrImage, vmInfoData.ImageId)
if requestBody.ReqInfo.ImageName == "" || err != nil {
log.Warn().Msgf("Not found %s from UserImage in ns: %s, find CommonImage from SystemCommonNs", vmInfoData.ImageId, nsId)
errAgg += err.Error()
// If cannot find the resource, use common resource
requestBody.ReqInfo.ImageName, err = common.GetCspResourceId(common.SystemCommonNs, common.StrImage, vmInfoData.ImageId)
if requestBody.ReqInfo.ImageName == "" || err != nil {
errAgg += err.Error()
err = fmt.Errorf(errAgg)
log.Error().Err(err).Msg("")
log.Error().Err(err).Msgf("Not found %s both from ns %s and SystemCommonNs", vmInfoData.ImageId, nsId)
return err
} else {
log.Info().Msgf("Use the CommonImage: %s in SystemCommonNs", requestBody.ReqInfo.ImageName)
}
} else {
log.Info().Msgf("Use the UserImage: %s in ns: %s", requestBody.ReqInfo.ImageName, nsId)
}
} else {
customImageFlag = true
Expand Down Expand Up @@ -1807,7 +1812,7 @@ func CreateVm(nsId string, mcisId string, vmInfoData *TbVmInfo, option string) e
)

if err != nil {
log.Error().Err(err).Msg("")
log.Error().Err(err).Msg("Spider returned an error")
return err
}

Expand Down
15 changes: 14 additions & 1 deletion src/testclient/scripts/8.mcis/add-subgroup-to-mcis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
else
RootDiskSize="${DISK_SIZE[$INDEX,$REGION]}"
fi


# Get a Subnet from the vNet (10.25.10.1/24 condition is only for KT cloud vpc)
echo "- Get vNet ${CONN_CONFIG[$INDEX,$REGION]}-${POSTFIX} to designate a Subnet"
VNETINFO=$(curl -H "${AUTH}" -sX GET http://$TumblebugServer/tumblebug/ns/$NSID/resources/vNet/${CONN_CONFIG[$INDEX,$REGION]}-${POSTFIX})
SUBNETARRAY=$(jq -r '.subnetInfoList' <<<"$VNETINFO")
echo "$SUBNETARRAY"
SUBNETID=$(jq -r '.subnetInfoList[] | select(.IPv4_CIDR == "10.25.10.1/24") | .Id' <<<"$VNETINFO")
if [ -z "$SUBNETID" ]; then
SUBNETID=$(jq -r '.subnetInfoList[0].Id' <<<"$VNETINFO")
fi
echo "Designated Subnet ID (for testing only): $SUBNETID"


curl -H "${AUTH}" -sX POST http://$TumblebugServer/tumblebug/ns/$NSID/mcis/$MCISID/vm -H 'Content-Type: application/json' -d \
'{
Expand All @@ -35,7 +48,7 @@
"'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'"
],
"vNetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
"subnetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
"subnetId": "'${SUBNETID}'",
"description": "description",
"vmUserPassword": "",
"rootDiskType": "'${RootDiskType}'",
Expand Down
14 changes: 13 additions & 1 deletion src/testclient/scripts/8.mcis/create-mcis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ else
RootDiskSize="${DISK_SIZE[$INDEX,$REGION]}"
fi

# Get a Subnet from the vNet
echo "- Get vNet ${CONN_CONFIG[$INDEX,$REGION]}-${POSTFIX} to designate a Subnet"
VNETINFO=$(curl -H "${AUTH}" -sX GET http://$TumblebugServer/tumblebug/ns/$NSID/resources/vNet/${CONN_CONFIG[$INDEX,$REGION]}-${POSTFIX})
SUBNETARRAY=$(jq -r '.subnetInfoList' <<<"$VNETINFO")
echo "$SUBNETARRAY"
SUBNETID=$(jq -r '.subnetInfoList[] | select(.IPv4_CIDR == "10.25.10.1/24") | .Id' <<<"$VNETINFO")
if [ -z "$SUBNETID" ]; then
SUBNETID=$(jq -r '.subnetInfoList[0].Id' <<<"$VNETINFO")
fi
echo "Designated Subnet ID (for testing only): $SUBNETID"


curl -H "${AUTH}" -sX POST http://$TumblebugServer/tumblebug/ns/$NSID/mcis -H 'Content-Type: application/json' -d \
'{
"name": "'${MCISID}'",
Expand All @@ -43,7 +55,7 @@ curl -H "${AUTH}" -sX POST http://$TumblebugServer/tumblebug/ns/$NSID/mcis -H 'C
"'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'"
],
"vNetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
"subnetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
"subnetId": "'${SUBNETID}'",
"description": "description",
"vmUserPassword": "",
"rootDiskType": "'${RootDiskType}'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function clean_sequence() {

fi

#if ! [ "${CSP}" == "nhncloud" ]; then
if ! [ "${CSP}" == "nhncloud" ]; then
echo '## 3. vNet: Delete'
OUTPUT=$(../3.vNet/delete-vNet.sh -c $CSP -r $REGION -n $POSTFIX -f $TestSetFile)
echo "${OUTPUT}"
Expand Down Expand Up @@ -99,7 +99,7 @@ function clean_sequence() {
done

fi
#fi
fi

#../2.configureTumblebug/delete-ns.sh $CSP $REGION $POSTFIX

Expand Down

0 comments on commit 0b123a9

Please sign in to comment.