-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexport_vlan.go
More file actions
40 lines (33 loc) · 869 Bytes
/
export_vlan.go
File metadata and controls
40 lines (33 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"compute-api/compute"
"fmt"
"strings"
)
func makeVLANResourceName(uniquenessKey int) string {
return fmt.Sprintf("vlan%02d", uniquenessKey)
}
const configurationTemplateVLAN = `
resource "ddcloud_vlan" "%s" {
name = "%s"
description = "%s"
networkdomain = "%s"
ipv4_base_address = "%s"
ipv4_prefix_size = %d
}
`
// ExportVLAN exports a ddcloud_vlan resource to Terraform configuration.
func (exporter *Exporter) ExportVLAN(vlan compute.VLAN, networkDomainID string, uniquenessKey int) error {
configuration := strings.TrimSpace(
fmt.Sprintf(configurationTemplateVLAN,
makeVLANResourceName(uniquenessKey),
vlan.Name,
vlan.Description,
networkDomainID,
vlan.IPv4Range.BaseAddress,
vlan.IPv4Range.PrefixSize,
),
)
fmt.Println(configuration)
return nil
}