Skip to content

Commit 204eaf5

Browse files
authored
Merge branch 'main' into feature/role
2 parents bc1e1c2 + aba1fde commit 204eaf5

File tree

48 files changed

+3215
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3215
-120
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/acceptance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
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

.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_network_offering.go

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,64 @@ func dataSourceCloudstackNetworkOffering() *schema.Resource {
5454
Type: schema.TypeString,
5555
Computed: true,
5656
},
57+
"network_rate": {
58+
Type: schema.TypeInt,
59+
Computed: true,
60+
},
61+
"network_mode": {
62+
Type: schema.TypeString,
63+
Computed: true,
64+
},
65+
"conserve_mode": {
66+
Type: schema.TypeBool,
67+
Computed: true,
68+
},
69+
"enable": {
70+
Type: schema.TypeBool,
71+
Computed: true,
72+
},
73+
"for_vpc": {
74+
Type: schema.TypeBool,
75+
Computed: true,
76+
},
77+
"for_nsx": {
78+
Type: schema.TypeBool,
79+
Computed: true,
80+
},
81+
"specify_vlan": {
82+
Type: schema.TypeBool,
83+
Computed: true,
84+
},
85+
"specify_ip_ranges": {
86+
Type: schema.TypeBool,
87+
Computed: true,
88+
},
89+
"specify_as_number": {
90+
Type: schema.TypeBool,
91+
Computed: true,
92+
},
93+
"internet_protocol": {
94+
Type: schema.TypeString,
95+
Computed: true,
96+
},
97+
"routing_mode": {
98+
Type: schema.TypeString,
99+
Computed: true,
100+
},
101+
"max_connections": {
102+
Type: schema.TypeInt,
103+
Computed: true,
104+
},
105+
"supported_services": {
106+
Type: schema.TypeSet,
107+
Computed: true,
108+
Elem: &schema.Schema{Type: schema.TypeString},
109+
},
110+
"service_provider_list": {
111+
Type: schema.TypeMap,
112+
Computed: true,
113+
Elem: &schema.Schema{Type: schema.TypeString},
114+
},
57115
},
58116
}
59117
}
@@ -91,7 +149,12 @@ func datasourceCloudStackNetworkOfferingRead(d *schema.ResourceData, meta interf
91149
}
92150
log.Printf("[DEBUG] Selected network offerings: %s\n", networkOffering.Displaytext)
93151

94-
return networkOfferingDescriptionAttributes(d, networkOffering)
152+
fullNetworkOffering, _, err := cs.NetworkOffering.GetNetworkOfferingByName(networkOffering.Name)
153+
if err != nil {
154+
return fmt.Errorf("Error retrieving full network offering details: %s", err)
155+
}
156+
157+
return networkOfferingDescriptionAttributes(d, fullNetworkOffering)
95158
}
96159

97160
func networkOfferingDescriptionAttributes(d *schema.ResourceData, networkOffering *cloudstack.NetworkOffering) error {
@@ -100,6 +163,50 @@ func networkOfferingDescriptionAttributes(d *schema.ResourceData, networkOfferin
100163
d.Set("display_text", networkOffering.Displaytext)
101164
d.Set("guest_ip_type", networkOffering.Guestiptype)
102165
d.Set("traffic_type", networkOffering.Traffictype)
166+
d.Set("network_rate", networkOffering.Networkrate)
167+
168+
// Only set if CloudStack supports these fields (4.20.0+)
169+
if networkOffering.Networkmode != "" {
170+
d.Set("network_mode", networkOffering.Networkmode)
171+
}
172+
173+
d.Set("conserve_mode", networkOffering.Conservemode)
174+
d.Set("enable", networkOffering.State == "Enabled")
175+
d.Set("for_vpc", networkOffering.Forvpc)
176+
d.Set("for_nsx", networkOffering.Fornsx)
177+
d.Set("specify_vlan", networkOffering.Specifyvlan)
178+
d.Set("specify_ip_ranges", networkOffering.Specifyipranges)
179+
d.Set("specify_as_number", networkOffering.Specifyasnumber)
180+
d.Set("internet_protocol", networkOffering.Internetprotocol)
181+
182+
// Only set if CloudStack supports this field (4.20.0+)
183+
if networkOffering.Routingmode != "" {
184+
d.Set("routing_mode", networkOffering.Routingmode)
185+
}
186+
187+
if networkOffering.Maxconnections > 0 {
188+
d.Set("max_connections", networkOffering.Maxconnections)
189+
}
190+
191+
// Set supported services
192+
if len(networkOffering.Service) > 0 {
193+
services := make([]string, len(networkOffering.Service))
194+
for i, service := range networkOffering.Service {
195+
services[i] = service.Name
196+
}
197+
d.Set("supported_services", services)
198+
}
199+
200+
// Set service provider list
201+
if len(networkOffering.Service) > 0 {
202+
serviceProviders := make(map[string]string)
203+
for _, service := range networkOffering.Service {
204+
if len(service.Provider) > 0 {
205+
serviceProviders[service.Name] = service.Provider[0].Name
206+
}
207+
}
208+
d.Set("service_provider_list", serviceProviders)
209+
}
103210

104211
return nil
105212
}

0 commit comments

Comments
 (0)