Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NCPVPC Connection config, Build script, and Full-Test files #620

Merged
merged 3 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
RESTSERVER=localhost

# Cloud Driver Info
curl -X POST http://$RESTSERVER:1024/spider/driver -H 'Content-Type: application/json' -d '{"DriverName":"ncpvpc-driver01","ProviderName":"NCPVPC", "DriverLibFileName":"ncpvpc-driver-v1.0.so"}'

# Cloud Credential Info
curl -X POST http://$RESTSERVER:1024/spider/credential -H 'Content-Type: application/json' -d '{"CredentialName":"ncpvpc-credential01","ProviderName":"NCPVPC", "KeyValueInfoList": [{"Key":"ClientId", "Value":"XXXXXXXXXXXXXXXXXX"}, {"Key":"ClientSecret", "Value":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]}'

# Cloud Region & Zone Info
curl -X POST http://$RESTSERVER:1024/spider/region -H 'Content-Type: application/json' -d '{"RegionName":"ncpvpc-korea1","ProviderName":"NCPVPC", "KeyValueInfoList": [{"Key":"Region", "Value":"KR"}, {"Key":"Zone", "Value":"KR-1"}]}'

curl -X POST http://$RESTSERVER:1024/spider/region -H 'Content-Type: application/json' -d '{"RegionName":"ncpvpc-korea2","ProviderName":"NCPVPC", "KeyValueInfoList": [{"Key":"Region", "Value":"KR"}, {"Key":"Zone", "Value":"KR-2"}]}'

curl -X POST http://$RESTSERVER:1024/spider/region -H 'Content-Type: application/json' -d '{"RegionName":"ncpvpc-singapore4","ProviderName":"NCPVPC", "KeyValueInfoList": [{"Key":"Region", "Value":"SGN"}, {"Key":"Zone", "Value":"SGN-4"}]}'

curl -X POST http://$RESTSERVER:1024/spider/region -H 'Content-Type: application/json' -d '{"RegionName":"ncpvpc-singapore5","ProviderName":"NCPVPC", "KeyValueInfoList": [{"Key":"Region", "Value":"SGN"}, {"Key":"Zone", "Value":"SGN-5"}]}'

# Cloud Connection Config Info
curl -X POST http://$RESTSERVER:1024/spider/connectionconfig -H 'Content-Type: application/json' -d '{"ConfigName":"ncpvpc-korea1-config","ProviderName":"NCPVPC", "DriverName":"ncpvpc-driver01", "CredentialName":"ncpvpc-credential01", "RegionName":"ncpvpc-korea1"}'

curl -X POST http://$RESTSERVER:1024/spider/connectionconfig -H 'Content-Type: application/json' -d '{"ConfigName":"ncpvpc-korea2-config","ProviderName":"NCPVPC", "DriverName":"ncpvpc-driver01", "CredentialName":"ncpvpc-credential01", "RegionName":"ncpvpc-korea2"}'

curl -X POST http://$RESTSERVER:1024/spider/connectionconfig -H 'Content-Type: application/json' -d '{"ConfigName":"ncpvpc-singapore4-config","ProviderName":"NCPVPC", "DriverName":"ncpvpc-driver01", "CredentialName":"ncpvpc-credential01", "RegionName":"ncpvpc-singapore4"}'

curl -X POST http://$RESTSERVER:1024/spider/connectionconfig -H 'Content-Type: application/json' -d '{"ConfigName":"ncpvpc-singapore5-config","ProviderName":"NCPVPC", "DriverName":"ncpvpc-driver01", "CredentialName":"ncpvpc-credential01", "RegionName":"ncpvpc-singapore5"}'
14 changes: 14 additions & 0 deletions api-runtime/rest-runtime/test/full-test/14.ncpvpc-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export CONN_CONFIG=ncpvpc-korea1-config
#export CONN_CONFIG=ncpvpc-korea2-config
#export CONN_CONFIG=ncpvpc-singapore4-config
#export CONN_CONFIG=ncpvpc-singapore5-config

# Ubuntu 18.04 image(for Korea1)
export IMAGE_NAME=SW.VSVR.OS.LNX64.UBNTU.SVR1804.B050
# singapore4-config도 지원

# vCPU: 4, Mem: 8192MB
export SPEC_NAME=SVR.VSVR.HICPU.C004.M008.NET.SSD.B050.G002
# singapore4-config도 지원

./ncpvpc-full_test.sh
212 changes: 212 additions & 0 deletions api-runtime/rest-runtime/test/full-test/ncpvpc-full_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
echo "#### Full Test Process - Start ###"

sleep 1
echo "####################################################################"
echo "## Full Test Scripts for CB-Spider IID Working Version - 2020.04.22."
echo "## 0. VM Image: List"
echo "## 0. VM Spec: List"
echo "## 1. VPC: Create -> List -> Get"
echo "## 2. SecurityGroup: Create -> List -> Get"
echo "## 3. KeyPair: Create -> List -> Get"
echo "## 4. VM: StartVM -> List -> Get -> ListStatus -> GetStatus -> Suspend -> Resume -> Reboot"
echo "## ---------------------------------"
echo "## 4. VM: Terminate(Delete)"
echo "## 3. KeyPair: Delete"
echo "## 2. SecurityGroup: Delete"
echo "## 1. VPC: Delete"
echo "####################################################################"

sleep 2

echo "## 0. VM Image: List"
curl -sX GET http://localhost:1024/spider/vmimage -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 5

echo "## 0. VM Image: Get"
curl -sX GET http://localhost:1024/spider/vmimage/${IMAGE_NAME} -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 5

echo "## 0. VM Spec: List"
curl -sX GET http://localhost:1024/spider/vmspec -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 5

echo "## 0. VM Spec: Get"
curl -sX GET http://localhost:1024/spider/vmspec/${SPEC_NAME} -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp
echo "#-----------------------------"

sleep 5

echo "####################################################################"
echo "## 1. VPC: Create -> List -> Get"
echo "####################################################################"
sleep 1
echo "## 1. VPC: Create"
curl -sX POST http://localhost:1024/spider/vpc -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "Name": "ncp-vpc-01", "IPv4_CIDR": "172.16.0.0/16", "SubnetInfoList": [ { "Name": "ncp-subnet-01", "IPv4_CIDR": "172.16.0.0/24"}, { "Name": "ncp-subnet-02", "IPv4_CIDR": "172.16.1.0/24"} ] } }' |json_pp

sleep 5
echo "## 1. VPC: List"
curl -sX GET http://localhost:1024/spider/vpc -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 5
echo "## 1. VPC: Get"
curl -sX GET http://localhost:1024/spider/vpc/ncp-vpc-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp
echo "#-----------------------------"

echo "####################################################################"
echo "## 2. SecurityGroup: Create -> List -> Get"
echo "####################################################################"

sleep 1
echo "## 2. SecurityGroup: Create"
curl -sX POST http://localhost:1024/spider/securitygroup -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "Name": "ncp-sg-01", "VPCName": "ncp-vpc-01", "SecurityRules": [ {"FromPort": "22", "ToPort" : "22", "IPProtocol" : "tcp", "Direction" : "inbound", "CIDR": "0.0.0.0/0"} ] } }' |json_pp

sleep 5

curl -sX POST http://localhost:1024/spider/securitygroup -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "Name": "ncp-sg-02", "VPCName": "ncp-vpc-01", "SecurityRules": [ {"FromPort": "1", "ToPort" : "65535", "IPProtocol" : "tcp", "Direction" : "inbound", "CIDR": "0.0.0.0/0"}, {"FromPort": "-1", "ToPort" : "-1", "IPProtocol" : "udp", "Direction" : "inbound", "CIDR": "0.0.0.0/0"}, {"FromPort": "-1", "ToPort" : "-1", "IPProtocol" : "icmp", "Direction" : "inbound", "CIDR": "0.0.0.0/0"} ] } }' |json_pp

sleep 5

curl -sX POST http://localhost:1024/spider/securitygroup -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "Name": "ncp-sg-03", "VPCName": "ncp-vpc-01", "SecurityRules": [ {"FromPort": "22", "ToPort" : "22", "IPProtocol" : "tcp", "Direction" : "inbound", "CIDR": "0.0.0.0/0"}, {"FromPort": "1024", "ToPort" : "1024", "IPProtocol" : "tcp", "Direction" : "inbound", "CIDR": "0.0.0.0/0"}, {"FromPort": "8080", "ToPort" : "8080", "IPProtocol" : "tcp", "Direction" : "inbound", "CIDR": "0.0.0.0/0"} ] } }' |json_pp

sleep 5
echo "## 2. SecurityGroup: AddRules"
curl -sX POST http://localhost:1024/spider/securitygroup/ncp-sg-01/rules -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "RuleInfoList" : [ {"Direction": "inbound", "IPProtocol": "TCP", "FromPort": "7080", "ToPort": "8080"}, {"Direction": "outbound", "IPProtocol": "TCP", "FromPort": "500", "ToPort": "500"} ]} }' |json_pp

sleep 5
echo "## 2. SecurityGroup: AddRules"
curl -sX POST http://localhost:1024/spider/securitygroup/ncp-sg-01/rules -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "RuleInfoList" : [ {"Direction": "inbound", "IPProtocol": "ALL", "FromPort": "-1", "ToPort": "-1"}, {"Direction": "outbound", "IPProtocol": "ALL", "FromPort": "-1", "ToPort": "-1"} ]} }' |json_pp

sleep 5

echo "## 2. SecurityGroup: RemoveRules"
curl -sX DELETE http://localhost:1024/spider/securitygroup/ncp-sg-01/rules -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "RuleInfoList" : [ {"Direction": "inbound", "IPProtocol": "TCP", "FromPort": "7080", "ToPort": "8080"}, {"Direction": "outbound", "IPProtocol": "TCP", "FromPort": "500", "ToPort": "500"} ]} }' |json_pp

sleep 5

echo "## 2. SecurityGroup: RemoveRules"
curl -sX DELETE http://localhost:1024/spider/securitygroup/ncp-sg-01/rules -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "RuleInfoList" : [ {"Direction": "inbound", "IPProtocol": "ALL", "FromPort": "-1", "ToPort": "-1"}, {"Direction": "outbound", "IPProtocol": "ALL", "FromPort": "-1", "ToPort": "-1"} ]} }' |json_pp

sleep 5

echo "## 2. SecurityGroup: List"
curl -sX GET http://localhost:1024/spider/securitygroup -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 3
echo "## 2. SecurityGroup: Get"

curl -sX GET http://localhost:1024/spider/securitygroup/ncp-sg-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

curl -sX GET http://localhost:1024/spider/securitygroup/ncp-sg-02 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

curl -sX GET http://localhost:1024/spider/securitygroup/ncp-sg-03 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp
echo "#-----------------------------"

echo "####################################################################"
echo "## 3. KeyPair: Create -> List -> Get"
echo "####################################################################"

sleep 1
echo "## 3. KeyPair: Create"
curl -sX POST http://localhost:1024/spider/keypair -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "Name": "ncp-key-01" } }' |json_pp

sleep 5
echo "## 3. KeyPair: List"
curl -sX GET http://localhost:1024/spider/keypair -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 5
echo "## 3. KeyPair: Get"
curl -sX GET http://localhost:1024/spider/keypair/ncp-key-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp
echo "#-----------------------------"

echo "####################################################################"
echo "## 4. VM: StartVM -> List -> Get -> ListStatus -> GetStatus -> Suspend -> Resume -> Reboot"
echo "####################################################################"

sleep 1
echo "## 4. VM: StartVM"
curl -sX POST http://localhost:1024/spider/vm -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "Name": "ncp-vm-01", "ImageName": "'${IMAGE_NAME}'", "VPCName": "ncp-vpc-01", "SubnetName": "ncp-subnet-01", "SecurityGroupNames": [ "ncp-sg-01", "ncp-sg-02" ], "VMSpecName": "'${SPEC_NAME}'", "KeyPairName": "ncp-key-01"} }' |json_pp

echo "============== sleep 50sec after start VM"

sleep 50

echo "## 4. VM: List"
curl -sX GET http://localhost:1024/spider/vm -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

echo "============== sleep 5sec after List VM"
sleep 5
echo "## 4. VM: Get"
curl -sX GET http://localhost:1024/spider/vm/ncp-vm-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

echo "============== sleep 10sec after Get VM"
sleep 10
echo "## 4. VM: ListStatus"
curl -sX GET http://localhost:1024/spider/vmstatus -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

echo "============== sleep 2sec after List VM Status"
sleep 2
echo "## 4. VM: GetStatus"
curl -sX GET http://localhost:1024/spider/vmstatus/ncp-vm-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

echo "============== sleep 5sec after Get VM Status"
sleep 5
echo "## 4. VM: Suspend"
curl -sX GET http://localhost:1024/spider/controlvm/ncp-vm-01?action=suspend -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

echo "============== sleep 40sec after suspend VM"
sleep 40
echo "## 4. VM: Resume"
curl -sX GET http://localhost:1024/spider/controlvm/ncp-vm-01?action=resume -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

echo "============== sleep 100sec after resume VM"
sleep 100
echo "## 4. VM: Reboot"
curl -sX GET http://localhost:1024/spider/controlvm/ncp-vm-01?action=reboot -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

echo "============== sleep 70sec after reboot VM"
sleep 70
echo "#-----------------------------"

echo "####################################################################"
echo "####################################################################"
echo "####################################################################"

echo "####################################################################"
echo "## 4. VM: Terminate(Delete) "
echo "####################################################################"
curl -sX DELETE http://localhost:1024/spider/vm/ncp-vm-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

echo "============== sleep 40sec after terminate VM"
sleep 40

echo "####################################################################"
echo "## 3. KeyPair: Delete"
echo "####################################################################"
curl -sX DELETE http://localhost:1024/spider/keypair/ncp-key-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 5

echo "####################################################################"
echo "## 2. SecurityGroup: Delete"
echo "####################################################################"
curl -sX DELETE http://localhost:1024/spider/securitygroup/ncp-sg-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 1

curl -sX DELETE http://localhost:1024/spider/securitygroup/ncp-sg-02 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 1

curl -sX DELETE http://localhost:1024/spider/securitygroup/ncp-sg-03 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

sleep 5

echo "####################################################################"
echo "## 1. VPC: Delete"
echo "####################################################################"
curl -sX DELETE http://localhost:1024/spider/vpc/ncp-vpc-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' |json_pp

echo "#### Full Test Process - Finished ###"
6 changes: 4 additions & 2 deletions cloud-driver-libs/cloudos_meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ NCP:
region: Region / Zone
credential: ClientId / ClientSecret
# idmaxlength: VPC / Subnet / SecurityGroup / KeyPair / VM
idmaxlength: 0 / 0 / 0 / 30 / 30
idmaxlength: 0 / 0 / 0 / 30 / 30

NCPVPC:
region: Region / Zone
credential: ClientId / ClientSecret
# idmaxlength: VPC / Subnet / SecurityGroup / KeyPair / VM
idmaxlength: 30 / 30 / 30 / 30 / 30

KTCLOUD:
region: Region / Zone
Expand All @@ -86,7 +88,7 @@ NHNCLOUD:
credential: IdentityEndpoint / Username / Password / DomainName / TenantId
rootdisktype: General_HDD / General_SSD
# idmaxlength: VPC / Subnet / SecurityGroup / KeyPair / VM
idmaxlength: 0 / 0 / 255 / 255 / 255
idmaxlength: 0 / 0 / 255 / 255 / 255

#--- PoC

Expand Down
39 changes: 39 additions & 0 deletions utils/driver-build-docker/2.build/ncpvpc-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Build Scripts to build drivers with plugin mode.
# The driver repos can be other repos.
# cf) https://github.com/cloud-barista/cb-spider/issues/343
#
# The CB-Spider is a sub-Framework of the Cloud-Barista Multi-Cloud Project.
# The CB-Spider Mission is to connect all the clouds with a single interface.
#
# * Cloud-Barista: https://github.com/cloud-barista
#
# by CB-Spider Team, 2022.01.

# You have to run in driver build container.
echo "\$HOME" path is $HOME
echo "\$CBSPIDER_ROOT" path is $CBSPIDER_ROOT

echo "# cd" $CBSPIDER_ROOT
cd $CBSPIDER_ROOT

echo "# go get -v github.com/NaverCloudPlatform/ncloud-sdk-go-v2@v1.4.4"
go get -v github.com/NaverCloudPlatform/ncloud-sdk-go-v2@v1.4.4

cd $HOME

echo "# git clone https://github.com/cloud-barista/ncpvpc.git" $HOME"/ncpvpc;"
git clone https://github.com/cloud-barista/ncpvpc.git $HOME/ncpvpc;

ln -s $HOME/ncpvpc/ncpvpc $CBSPIDER_ROOT/cloud-control-manager/cloud-driver/drivers;
ln -s $HOME/ncpvpc/ncpvpc-plugin $CBSPIDER_ROOT/cloud-control-manager/cloud-driver/drivers;

echo "# cd "$CBSPIDER_ROOT"/cloud-control-manager/cloud-driver/drivers/ncpvpc-plugin;"
cd $CBSPIDER_ROOT/cloud-control-manager/cloud-driver/drivers/ncpvpc-plugin;

echo "# ./build_driver_lib.sh"
./build_driver_lib.sh

rm $CBSPIDER_ROOT/cloud-control-manager/cloud-driver/drivers/ncpvpc;
rm $CBSPIDER_ROOT/cloud-control-manager/cloud-driver/drivers/ncpvpc-plugin;