From 75bf52ab23f410445710ddc7b30b64f112b8bbce Mon Sep 17 00:00:00 2001 From: Itohan Date: Tue, 21 Apr 2020 18:03:13 -0700 Subject: Script to test DCM API Issue-ID: MULTICLOUD-996 Signed-off-by: Itohan Ukponmwan Change-Id: I18b75693beeaa5d5fe64e91087ddaa911a553a5f --- src/dcm/test/dcm_call_api.sh | 147 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100755 src/dcm/test/dcm_call_api.sh (limited to 'src') diff --git a/src/dcm/test/dcm_call_api.sh b/src/dcm/test/dcm_call_api.sh new file mode 100755 index 00000000..3bf27524 --- /dev/null +++ b/src/dcm/test/dcm_call_api.sh @@ -0,0 +1,147 @@ +# /* +# * Copyright 2020 Intel Corporation, Inc +# * +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ + + +project="test-project" +description="test-description" +logical_cloud_name="lc1" +logical_cloud_url="http://localhost:9015/v2/projects/${project}/logical-clouds" +quota_name="quota-1" +quota_url="${logical_cloud_url}/${logical_cloud_name}/cluster-quotas" +cluster_url="${logical_cloud_url}/${logical_cloud_name}/cluster-references" + + +logical_cloud_data="$(cat << EOF +{ + "metadata" : { + "name": "${logical_cloud_name}", + "description": "${test-description}", + "userData1":"", + "userData2":"" + }, + "spec" : { + "namespace" : "ns-1", + "user" : { + "user-name" : "user-1", + "type" : "certificate", + "user-permissions" : [ + { "permission-name" : "permission-1", + "apiGroups" : ["stable.example.com"], + "resources" : ["secrets", "pods"], + "verbs" : ["get", "watch", "list", "create"] + } + ] + } + } +} +EOF +)" + +cluster_1_data="$(cat << EOF +{ + "metadata" : { + "name": "lc-cl-1", + "description": "${test-description}", + "userData1":"", + "userData2":"" + }, + + "spec" : { + "cluster-provider": "cp-1", + "cluster-name": "c1", + "loadbalancer-ip" : "0.0.0.0" + } +} +EOF +)" + +cluster_2_data="$(cat << EOF +{ + "metadata" : { + "name": "lc-cl-2", + "description": "${test-description}", + "userData1":"", + "userData2":"" + }, + + "spec" : { + "cluster-provider": "cp-1", + "cluster-name": "c2", + "loadbalancer-ip" : "0.0.0.1" + } +} +EOF +)" + +quota_data="$(cat << EOF +{ + "metadata" : { + "name" : "${quota_name}", + "description": "${test-description}" + }, + "spec" : { + "limits.cpu": "400", + "limits.memory": "1000Gi", + "requests.cpu": "300", + "requests.memory": "900Gi", + "requests.storage" : "500Gi", + "requests.ephemeral-storage": "", + "limits.ephemeral-storage": "", + "persistentvolumeclaims" : " ", + "pods": "500", + "configmaps" : "", + "replicationcontrollers": "", + "resourcequotas" : "", + "services": "", + "services.loadbalancers" : "", + "services.nodeports" : "", + "secrets" : "", + "count/replicationcontrollers" : "", + "count/deployments.apps" : "", + "count/replicasets.apps" : "", + "count/statefulsets.apps" : "", + "count/jobs.batch" : "", + "count/cronjobs.batch" : "", + "count/deployments.extensions" : "" + } +} +EOF +)" + + +# Create logical cloud +printf "\n\nCreating logical cloud data\n\n" +curl -d "${logical_cloud_data}" -X POST ${logical_cloud_url} + +# Associate two clusters with the logical cloud +printf "\n\nAdding two clusters to logical cloud\n\n" +curl -d "${cluster_1_data}" -X POST ${cluster_url} +curl -d "${cluster_2_data}" -X POST ${cluster_url} + +# Add resource quota for the logical cloud +printf "\n\nAdding resource quota for the logical cloud\n\n" +curl -d "${quota_data}" -X POST ${quota_url} + + +# Get logical cloud data +printf "\n\nGetting logical cloud\n\n" +curl -X GET "${logical_cloud_url}/${logical_cloud_name}" + +printf "\n\nGetting clusters info for logical cloud\n\n" +curl -X GET ${cluster_url} + +printf "\n\nGetting Quota info for the logical cloud\n\n" +curl -X GET "${quota_url}/${quota_name}" \ No newline at end of file -- cgit 1.2.3-korg