@@ -49,33 +49,57 @@ runs:
4949 ((T+=1))
5050 sleep 30
5151 done
52+
53+ # After loop, check if Cloudstack is up
54+ if ! curl -sfSL http://localhost:8080 --output /dev/null; then
55+ echo "Cloudstack did not become ready in time"
56+ curl -v http://localhost:8080 || true
57+ exit 22
58+ fi
5259 - name : Setting up Cloudstack
5360 id : setup-cloudstack
5461 shell : bash
5562 run : |
56- docker exec $(docker container ls --format=json -l | jq -r .ID) python /root/tools/marvin/marvin/deployDataCenter.py -i /root/setup/dev/advanced.cfg
57- curl -sf --location "${CLOUDSTACK_API_URL}" \
58- --header 'Content-Type: application/x-www-form-urlencoded' \
59- --data-urlencode 'command=login' \
60- --data-urlencode 'username=admin' \
61- --data-urlencode 'password=password' \
62- --data-urlencode 'response=json' \
63- --data-urlencode 'domain=/' -j -c cookies.txt --output /dev/null
64-
65- CLOUDSTACK_USER_ID=$(curl -fs "${CLOUDSTACK_API_URL}?command=listUsers&response=json" -b cookies.txt | jq -r '.listusersresponse.user[0].id')
66- CLOUDSTACK_API_KEY=$(curl -s "${CLOUDSTACK_API_URL}?command=getUserKeys&id=${CLOUDSTACK_USER_ID}&response=json" -b cookies.txt | jq -r '.getuserkeysresponse.userkeys.apikey')
67- CLOUDSTACK_SECRET_KEY=$(curl -fs "${CLOUDSTACK_API_URL}?command=getUserKeys&id=${CLOUDSTACK_USER_ID}&response=json" -b cookies.txt | jq -r '.getuserkeysresponse.userkeys.secretkey')
63+
64+ set -euo pipefail
65+
66+ echo "Deploying Data Center..."
67+ docker exec $(docker container ls --format=json -l | jq -r .ID) \
68+ python /root/tools/marvin/marvin/deployDataCenter.py -i /root/setup/dev/advanced.cfg
69+
70+ # Get the container ID of the running simulator
71+ CONTAINER_ID=$(docker ps --filter "ancestor=apache/cloudstack-simulator:${{ matrix.cloudstack-version }}" --format "{{.ID}}" | head -n1)
72+
73+ # Install CloudMonkey
74+ docker exec $CONTAINER_ID bash -c "curl -sfSL https://github.com/apache/cloudstack-cloudmonkey/releases/download/6.4.0/cmk.linux.x86-64 -o /usr/local/bin/cmk && chmod +x /usr/local/bin/cmk"
75+
76+ # Write the CloudMonkey config file with a profile using user/pass
77+ docker exec $CONTAINER_ID mkdir -p /root/.cmk
78+ docker exec $CONTAINER_ID bash -c "printf '[core]\nprofile = localcloud\n\n[localcloud]\nurl = http://localhost:8080/client/api\nusername = admin\npassword = password\ndomain = /\napikey =\nsecretkey =\ntimeout = 3600\n' > /root/.cmk/config"
79+
80+
81+ # Use CloudMonkey with the profile to list users and extract API key/secret key
82+ docker exec $CONTAINER_ID cmk -p localcloud list users --output json > users.json
83+
84+ # Generate API keys
85+ docker exec $CONTAINER_ID cmk -p localcloud registeruserKeys id=$(jq -r '.user[0].id' users.json) > api.json
86+
87+ # Extract the first user's keys (assuming admin is first)
88+ CLOUDSTACK_API_KEY=$(jq -r '.userkeys.apikey' api.json)
89+ CLOUDSTACK_SECRET_KEY=$(jq -r '.userkeys.secretkey' api.json)
90+ CLOUDSTACK_USER_ID=$(jq -r '.user[0].id' users.json)
6891
6992 echo "::add-mask::$CLOUDSTACK_API_KEY"
7093 echo "::add-mask::$CLOUDSTACK_SECRET_KEY"
7194
7295 echo "user_id=$CLOUDSTACK_USER_ID" >> $GITHUB_OUTPUT
7396 echo "api_key=$CLOUDSTACK_API_KEY" >> $GITHUB_OUTPUT
7497 echo "secret_key=$CLOUDSTACK_SECRET_KEY" >> $GITHUB_OUTPUT
98+
7599 - name : Install CMK
76100 shell : bash
77101 run : |
78- curl -sfL https://github.com/apache/cloudstack-cloudmonkey/releases/download/6.3 .0/cmk.linux.x86-64 -o /usr/local/bin/cmk
102+ curl -sfSL https://github.com/apache/cloudstack-cloudmonkey/releases/download/6.4 .0/cmk.linux.x86-64 -o /usr/local/bin/cmk
79103 chmod +x /usr/local/bin/cmk
80104 - name : Create extra resources
81105 shell : bash
0 commit comments