Skip to content

Commit 5516db9

Browse files
authored
Merge branch 'main' into offerings
2 parents fdd4d0d + 2d90b19 commit 5516db9

24 files changed

+895
-94
lines changed

.asf.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
github:
219
description: "CloudStack Terraform Provider"
320
homepage: https://cloudstack.apache.org

.github/workflows/setup-cloudstack/action.yml renamed to .github/actions/setup-cloudstack/action.yml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

.github/workflows/acceptance.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ permissions:
3030

3131
env:
3232
CLOUDSTACK_API_URL: http://localhost:8080/client/api
33-
CLOUDSTACK_VERSIONS: "['4.18.2.1', '4.19.0.2']"
33+
CLOUDSTACK_VERSIONS: "['4.19.0.1', '4.19.1.3', '4.19.2.0', '4.19.3.0', '4.20.1.0']"
3434

3535
jobs:
3636
prepare-matrix:
@@ -54,7 +54,7 @@ jobs:
5454
with:
5555
go-version-file: 'go.mod'
5656
- name: Configure Cloudstack v${{ matrix.cloudstack-version }}
57-
uses: ./.github/workflows/setup-cloudstack
57+
uses: ./.github/actions/setup-cloudstack
5858
id: setup-cloudstack
5959
with:
6060
cloudstack-version: ${{ matrix.cloudstack-version }}
@@ -78,8 +78,8 @@ jobs:
7878
fail-fast: false
7979
matrix:
8080
terraform-version:
81-
- '1.8.*'
82-
- '1.9.*'
81+
- '1.11.*'
82+
- '1.12.*'
8383
cloudstack-version: ${{ fromJson(needs.prepare-matrix.outputs.cloudstack-versions) }}
8484

8585
acceptance-opentofu:
@@ -93,11 +93,11 @@ jobs:
9393
with:
9494
go-version-file: 'go.mod'
9595
- name: Configure Cloudstack v${{ matrix.cloudstack-version }}
96-
uses: ./.github/workflows/setup-cloudstack
96+
uses: ./.github/actions/setup-cloudstack
9797
id: setup-cloudstack
9898
with:
9999
cloudstack-version: ${{ matrix.cloudstack-version }}
100-
- uses: opentofu/setup-opentofu@v1
100+
- uses: opentofu/setup-opentofu@000eeb8522f0572907c393e8151076c205fdba1b # v1.0.6
101101
with:
102102
tofu_version: ${{ matrix.opentofu-version }}
103103
- name: Run acceptance test
@@ -116,8 +116,8 @@ jobs:
116116
fail-fast: false
117117
matrix:
118118
opentofu-version:
119-
- '1.6.*'
120-
- '1.7.*'
119+
- '1.8.*'
120+
- '1.9.*'
121121
cloudstack-version: ${{ fromJson(needs.prepare-matrix.outputs.cloudstack-versions) }}
122122

123123
all-jobs-passed: # Will succeed if it is skipped

.github/workflows/rat.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: RAT Check
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
rat:
13+
name: Apache RAT Check
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Java
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: temurin
24+
java-version: 17
25+
26+
- name: Download Apache RAT
27+
run: |
28+
curl -L -O https://downloads.apache.org/creadur/apache-rat-0.16.1/apache-rat-0.16.1-bin.tar.gz
29+
tar -xzf apache-rat-0.16.1-bin.tar.gz
30+
31+
- name: Run RAT
32+
run: |
33+
java -jar apache-rat-0.16.1/apache-rat-0.16.1.jar -d . -E .rat-excludes > rat-report.txt
34+
cat rat-report.txt
35+
# Fail if unapproved licenses are found
36+
grep -qe '^0 Unknown Licenses' rat-report.txt && exit 0 || exit 1

.rat-excludes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CHANGELOG.md
2+
CONTRIBUTING.md
3+
go.sum
4+
rat-report.txt
5+
apache-rat-0.16.1
6+
.gitignore
7+
.rat-excludes
8+
.terraform-registry
9+
website

GNUmakefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
TEST?=$$(go list ./... | grep -v 'vendor')
219
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
320
WEBSITE_REPO=github.com/hashicorp/terraform-website

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ docker pull apache/cloudstack-simulator
128128

129129
or pull it with a particular build tag
130130

131-
docker pull apache/cloudstack-simulator:4.19.0.0
131+
docker pull apache/cloudstack-simulator:4.20.1.0
132132

133133
docker run --name simulator -p 8080:5050 -d apache/cloudstack-simulator
134134

135135
or
136136

137-
docker run --name simulator -p 8080:5050 -d apache/cloudstack-simulator:4.19.0.0
137+
docker run --name simulator -p 8080:5050 -d apache/cloudstack-simulator:4.20.1.0
138138
```
139139

140140
When Docker started the container you can go to http://localhost:8080/client and login to the CloudStack UI as user `admin` with password `password`. It can take a few minutes for the container is fully ready, so you probably need to wait and refresh the page for a few minutes before the login page is shown.
@@ -159,6 +159,12 @@ In order for all the tests to pass, you will need to create a new (empty) projec
159159
$ make testacc
160160
```
161161

162+
To execute specific test:
163+
164+
```sh
165+
$ make testacc TESTARGS='-run ^TestAccCloudStackNetworkACLRule_update$'
166+
```
167+
162168
## Sample Terraform configuration when testing locally
163169

164170
Below is an example configuration to initialize provider and create a Virtual Machine instance

cloudstack/data_source_cloudstack_vpc.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func dataSourceCloudstackVPC() *schema.Resource {
6666
"project": {
6767
Type: schema.TypeString,
6868
Computed: true,
69+
Optional: true,
6970
},
7071

7172
"zone_name": {
@@ -81,6 +82,12 @@ func dataSourceCloudstackVPC() *schema.Resource {
8182
func datasourceCloudStackVPCRead(d *schema.ResourceData, meta interface{}) error {
8283
cs := meta.(*cloudstack.CloudStackClient)
8384
p := cs.VPC.NewListVPCsParams()
85+
86+
// If there is a project supplied, we retrieve and set the project id
87+
if err := setProjectid(p, cs, d); err != nil {
88+
return err
89+
}
90+
8491
csVPCs, err := cs.VPC.ListVPCs(p)
8592

8693
if err != nil {

cloudstack/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func Provider() *schema.Provider {
9696
"cloudstack_affinity_group": resourceCloudStackAffinityGroup(),
9797
"cloudstack_attach_volume": resourceCloudStackAttachVolume(),
9898
"cloudstack_autoscale_vm_profile": resourceCloudStackAutoScaleVMProfile(),
99+
"cloudstack_configuration": resourceCloudStackConfiguration(),
99100
"cloudstack_disk": resourceCloudStackDisk(),
100101
"cloudstack_egress_firewall": resourceCloudStackEgressFirewall(),
101102
"cloudstack_firewall": resourceCloudStackFirewall(),

cloudstack/provider_v6.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
118
package cloudstack
219

320
import (

0 commit comments

Comments
 (0)