Skip to content

Commit

Permalink
Attach the internal DHCP server to WAN as well
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheEvilOne committed Nov 23, 2021
1 parent 45c713a commit e46a899
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 64 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/23technologies/gardener-extension-provider-ionos
go 1.16

require (
github.com/23technologies/ionos-api-wrapper v0.1.4
github.com/23technologies/ionos-api-wrapper v0.2.0
github.com/Masterminds/semver v1.5.0
github.com/ahmetb/gen-crd-api-reference-docs v0.2.0
github.com/coreos/go-systemd/v22 v22.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/23technologies/ionos-api-wrapper v0.1.4 h1:xYqYnQue6Qawxr6yzvCdviqa5nph8n47kFye+zh6FIA=
github.com/23technologies/ionos-api-wrapper v0.1.4/go.mod h1:zJ7H+q07Y72JTvunLRz6oMA7vPvXEojKkAxrxzZ7tvg=
github.com/23technologies/ionos-api-wrapper v0.2.0 h1:fpv0owXWORqfaKA70kzuXKwhtOsjNC8RxnQakLkBvB0=
github.com/23technologies/ionos-api-wrapper v0.2.0/go.mod h1:zJ7H+q07Y72JTvunLRz6oMA7vPvXEojKkAxrxzZ7tvg=
github.com/Azure/azure-sdk-for-go v39.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v42.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/infrastructure/actuator_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (a *actuator) reconcile(ctx context.Context, infra *extensionsv1alpha1.Infr
return err
}

dhcpServerID, err := ensurer.EnsureDHCPServer(ctx, client, datacenterID, cpConfig.Zone, actuatorConfig.infraConfig, infraStatus, workerNetworkID)
dhcpServerID, err := ensurer.EnsureDHCPServer(ctx, client, datacenterID, cpConfig.Zone, actuatorConfig.infraConfig, infraStatus, wanNetworkID, workerNetworkID)
if err != nil {
return err
}
Expand Down
17 changes: 11 additions & 6 deletions pkg/controller/infrastructure/ensurer/dhcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import (
)

// Constant ionosPasswordGeneratedLength is the length of the generated random password
const ionosPasswordGeneratedLength = 500
const ionosPasswordGeneratedLength = 32
// Constant ionosVolumeType is the volume type
const ionosVolumeType = "SSD"

func createDHCPServer(ctx context.Context, client *ionossdk.APIClient, datacenterID, zone string, configuration *apis.DHCPServerConfiguration, networkID string) (string, error) {
func createDHCPServer(ctx context.Context, client *ionossdk.APIClient, datacenterID, zone string, configuration *apis.DHCPServerConfiguration, wanNetworkID, workerNetworkID string) (string, error) {
imageID, err := apis.FindMachineImageName(ctx, client, zone, configuration.Image.Name, configuration.Image.Version, "")
if nil != err {
return "", err
Expand Down Expand Up @@ -150,7 +150,12 @@ func createDHCPServer(ctx context.Context, client *ionossdk.APIClient, datacente
return "", fmt.Errorf("IP %q given is invalid", configuration.IP)
}

err = ionosapiwrapper.AttachLANToServerWithIP(ctx, client, datacenterID, serverID, networkID, &dhcpIP)
err = ionosapiwrapper.AttachWANToServer(ctx, client, datacenterID, serverID, wanNetworkID)
if nil != err {
return "", err
}

err = ionosapiwrapper.AttachLANToServerWithIP(ctx, client, datacenterID, serverID, workerNetworkID, &dhcpIP)
if nil != err {
return "", err
}
Expand Down Expand Up @@ -210,7 +215,7 @@ func deleteServerID(ctx context.Context, client *ionossdk.APIClient, datacenterI
return nil
}

func EnsureDHCPServer(ctx context.Context, client *ionossdk.APIClient, datacenterID, zone string, infraConfig *apis.InfrastructureConfig, infraStatus *apis.InfrastructureStatus, networkID string) (string, error) {
func EnsureDHCPServer(ctx context.Context, client *ionossdk.APIClient, datacenterID, zone string, infraConfig *apis.InfrastructureConfig, infraStatus *apis.InfrastructureStatus, wanNetworkID, workerNetworkID string) (string, error) {
cidr := infraConfig.Networks.Workers
configuration := infraConfig.DHCPServerConfiguration
var configurationStatus *apis.DHCPServerConfigurationStatus
Expand Down Expand Up @@ -244,8 +249,8 @@ func EnsureDHCPServer(ctx context.Context, client *ionossdk.APIClient, datacente
}
}

if "" != networkID {
newServerID, err := createDHCPServer(ctx, client, datacenterID, zone, configuration, networkID)
if "" != workerNetworkID {
newServerID, err := createDHCPServer(ctx, client, datacenterID, zone, configuration, wanNetworkID, workerNetworkID)
if nil != err {
return "", err
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

177 changes: 124 additions & 53 deletions vendor/github.com/23technologies/ionos-api-wrapper/pkg/lan.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# github.com/23technologies/ionos-api-wrapper v0.1.4
# github.com/23technologies/ionos-api-wrapper v0.2.0
## explicit
github.com/23technologies/ionos-api-wrapper/pkg
# github.com/BurntSushi/toml v0.3.1
Expand Down

0 comments on commit e46a899

Please sign in to comment.