Commit aa7d8ecb authored by Nikos Psaromanolakis's avatar Nikos Psaromanolakis
Browse files

Merge changes from main

parents 7f8b859c d0706abe
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
#!/bin/bash

set -e

# Get the VM IP (IP of the default route interface)
VM_IP=$(hostname -I | awk '{print $1}')

TOKEN_URL="http://${VM_IP}:30081/realms/tmf/protocol/openid-connect/token"
API_URL="http://${VM_IP}:30095/fabric-api/network/controller"

echo "Detected VM IP: ${VM_IP}"
echo "Requesting access token..."

TOKEN_RESPONSE=$(curl -s --location "$TOKEN_URL" \
    --header "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "client_id=tmf-api" \
    --data-urlencode "client_secret=A0cx2x4YT5vqYX3hpmA4kURyGncsl4Vd" \
    --data-urlencode "grant_type=password" \
    --data-urlencode "username=admin" \
    --data-urlencode "password=hypo@nss@")

ACCESS_TOKEN=$(echo "$TOKEN_RESPONSE" | jq -r '.access_token')

if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" = "null" ]; then
    echo "Failed to obtain access token."
    echo "$TOKEN_RESPONSE"
    exit 1
fi

echo "Access token obtained."

curl --location "$API_URL" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer ${ACCESS_TOKEN}" \
    --data '{
      "networkName": "UBITECH Controller",
      "networkOwner": "UBI",
      "networkLocation": "Athens",
      "networkEndpoint": "https://ztc.euprojects.net:8441",
      "username": "admin",
      "password": "ubi9nsit0tech"
    }'

echo
echo "Done."
+33 −12
Original line number Diff line number Diff line
@@ -20,20 +20,21 @@ if [[ "$ACCESS_TOKEN" == "null" || -z "$ACCESS_TOKEN" ]]; then
  echo "$response"
else
  echo "✅ Access token:"
  #echo $ACCESS_TOKEN
  echo $ACCESS_TOKEN
  echo -e "\n\n"
fi

GITLAB_TOKEN="$1"
PROJECT_ID="1672"
FILE_PATH="peering%2F$2.json"
REF="master"
REF="main"

API_URL="https://gitlab.ubitech.eu/api/v4/projects/${PROJECT_ID}/repository/files/$FILE_PATH?ref=$REF"
API_URL="https://labs.etsi.org/rep/api/v4/projects/482/repository/files/src%2Ftest%2Fresources%2Fpayloads%2Forganization%2Fcreate-organization.json/raw?ref=$REF"

response=$(curl -s --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "$API_URL")

# Decode the Base64 content
echo "$response" | jq -r .content | base64 --decode > data.json
echo "$response" > data.json

TARGET_ENDPOINT="http://$NODE_IP:30088/tmf-api/party/v4/organization"

@@ -43,19 +44,38 @@ response=$(curl -s -X POST "$TARGET_ENDPOINT" \
  -d @data.json
)

#echo $response
echo $response

echo -e "\n\n"

sleep 3

ORG_JSON=$(curl -s \
  --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
  "$API_URL")

PAYLOAD=$(jq -n \
  --argjson organization "$ORG_JSON" \
  '{
    organization: $organization,
    serviceSpecs: {
      "c04f3d66-5350-49ea-8b31-ff325f149232": "K8aaS",
      "dca55236-93ca-4ae0-b1ae-07f7a081dd17": "K8aaS-OCM",
    },
    peeredSpecs: {},
    serviceCatalogs: []
  }')

TARGET_ENDPOINT="http://$NODE_IP:30093/peering-api/peering"

reponse=$(curl -s -X POST "$TARGET_ENDPOINT" \
response=$(curl -s -X POST "$TARGET_ENDPOINT" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d @data.json
)
  -d "$PAYLOAD")

#echo $response
echo $response

echo -e "\n\n"

sleep 3

@@ -64,13 +84,14 @@ TARGET_ENDPOINT="http://$NODE_IP:30093/peering-api/peering/add"
response=$(curl -s -X POST "$TARGET_ENDPOINT" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d @data.json
)
  -d "$PAYLOAD")

#echo $response
echo $response

sleep 3

echo -e "\n\n"

TARGET_ENDPOINT="http://$NODE_IP:30088/tmf-api/serviceCatalogManagement/v4/serviceSpecification?fields=id,name,description,lastUpdate,version"

curl -s -X GET "$TARGET_ENDPOINT" \