Skip to content

Commit

Permalink
Fix assignment of a configured IP to the DHCP server
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheEvilOne committed Nov 21, 2021
1 parent 97f9006 commit 6c7b999
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 17 deletions.
1 change: 1 addition & 0 deletions example/30-infrastructure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ spec:
version: "20.04"
cores: 1
memory: 1024
ip: 10.15.100.254
userData: |-
#cloud-config
package_update: true
Expand Down
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.3
github.com/23technologies/ionos-api-wrapper v0.1.4
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.3 h1:xGsqzWil8LDXgkGN3+Q98/Coq+nhFdlgTb+Uu8XSyF0=
github.com/23technologies/ionos-api-wrapper v0.1.3/go.mod h1:zJ7H+q07Y72JTvunLRz6oMA7vPvXEojKkAxrxzZ7tvg=
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/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
9 changes: 8 additions & 1 deletion pkg/controller/infrastructure/ensurer/dhcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import (
"context"
"encoding/base64"
"errors"
"fmt"
"math"
"math/rand"
"net"
"strings"
"time"

Expand Down Expand Up @@ -143,7 +145,12 @@ func createDHCPServer(ctx context.Context, client *ionossdk.APIClient, datacente
return "", err
}

err = ionosapiwrapper.AttachLANToServerWithoutDHCP(ctx, client, datacenterID, serverID, networkID)
dhcpIP := net.ParseIP(configuration.IP)
if nil == dhcpIP {
return "", fmt.Errorf("IP %q given is invalid", configuration.IP)
}

err = ionosapiwrapper.AttachLANToServerWithIP(ctx, client, datacenterID, serverID, networkID, &dhcpIP)
if nil != err {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ionos/apis/mock/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ const (
"name": "test",
"version": "1.0"
},
"sshKey": "ssh-rsa invalid",
"userData": ""
"ip": "10.250.31.254",
"userData": "#cloud-config"
},
"floatingPoolName": "MY-FLOATING-POOL",
"networks": {"workers": "10.250.0.0/19"}
Expand Down
2 changes: 2 additions & 0 deletions pkg/ionos/apis/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type DHCPServerConfiguration struct {
//
Memory uint `json:"memory"`
//
IP string `json:"ip"`
//
UserData string `json:"userData"`

//
Expand Down
2 changes: 2 additions & 0 deletions pkg/ionos/apis/v1alpha1/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type DHCPServerConfiguration struct {
//
Memory uint `json:"memory"`
//
IP string `json:"ip"`
//
UserData string `json:"userData"`

//
Expand Down
2 changes: 2 additions & 0 deletions pkg/ionos/apis/v1alpha1/zz_generated.conversion.go

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

34 changes: 24 additions & 10 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.3
# github.com/23technologies/ionos-api-wrapper v0.1.4
## explicit
github.com/23technologies/ionos-api-wrapper/pkg
# github.com/BurntSushi/toml v0.3.1
Expand Down

0 comments on commit 6c7b999

Please sign in to comment.