Skip to content

Commit

Permalink
New release (#104)
Browse files Browse the repository at this point in the history
* build(deps): bump golang.org/x/net from 0.7.0 to 0.17.0 (#98)

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.7.0 to 0.17.0.
- [Commits](golang/net@v0.7.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump github.com/docker/docker (#100)

Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.24+incompatible to 20.10.27+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](moby/moby@v20.10.24...v20.10.27)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Feat/multiple lans (#102)

* feat: added additionalLans parameter

* fix: only machines in pools > 1 wait so the datacenter is created only once

* fix: correct flag name

* test: add tests

* doc: some fixes in docs, added new flag

* fix: add contains function

* fix: check if serverId is set before making requests (#103)

* doc: updated changelog

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
rmocanu-ionos and dependabot[bot] authored Feb 22, 2024
1 parent 4ec1aeb commit 667588b
Show file tree
Hide file tree
Showing 198 changed files with 3,351 additions and 3,396 deletions.
12 changes: 12 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## \[7.0.3]
### Changed
* added:
* option connect to additional lans, flag and option added in RKE1 and RKE2 UIs
* added new cpu family options in UI
* fixed:
* driver was trying to get server state without knowing the server ID
* RKE2: making servers in pool1 start while the others wait to try to avoid creating multiple datacenter
* cloudinit input was not should the old value when updating the config
* known issues:
* multiple data centers and LANs are created in RKE2 if there are multiple machines in pool1, this is because the driver does not know which machine should go first

## \[7.0.2]
### Changed
* added:
Expand Down
4 changes: 3 additions & 1 deletion docs/rancher/rancher-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ You will create a Docker Container with the following command:
sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher
```

> **_NOTE:_** Please note that versions 2.8+ do not currently allow adding the IonosCloud UI extension for RKE2
To use a specific Rancher version, check the [available docker images](https://hub.docker.com/r/rancher/rancher/tags) and add the corresponding tag to the command:

```text
sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:v2.5.x
sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:v2.7.5
```

To output the available docker containers, use:
Expand Down
34 changes: 18 additions & 16 deletions docs/usage/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ docker run -d --name=rancher-server --restart=unless-stopped -p 80:80 -p 443:443

> **_NOTE:_** Note that version 2.7+ is required for Rancher UI Extension support
> **_NOTE:_** Please note that versions 2.8+ do not currently allow adding the IonosCloud UI extension for RKE2
### Configure Rancher (for RKE2)
* Rancher URL

Expand Down Expand Up @@ -72,22 +74,22 @@ docker exec -it <CONTAINER_ID> bash
Create a YAML file containing the driver info
```
echo "apiVersion: management.cattle.io/v3
kind: NodeDriver
metadata:
annotations:
lifecycle.cattle.io/create.node-driver-controller: "true"
privateCredentialFields: "token,username,password,endpoint"
name: ionoscloud
spec:
active: false
addCloudCredential: false
builtin: false
checksum: ""
description: ""
displayName: ionoscloud
externalId: ""
uiUrl: ""
url: https://github.com/ionos-cloud/docker-machine-driver/releases/download/v6.1.4/docker-machine-driver-6.1.4-linux-amd64.tar.gz" > ionos.yaml
kind: NodeDriver
metadata:
annotations:
lifecycle.cattle.io/create.node-driver-controller: "true"
privateCredentialFields: "token,username,password,endpoint"
name: ionoscloud
spec:
active: false
addCloudCredential: false
builtin: false
checksum: ""
description: ""
displayName: ionoscloud
externalId: ""
uiUrl: ""
url: https://github.com/ionos-cloud/docker-machine-driver/releases/download/v6.1.4/docker-machine-driver-6.1.4-linux-amd64.tar.gz" > ionos.yaml
```
use kubetl to create a node driver resource
```
Expand Down
4 changes: 3 additions & 1 deletion docs/usage/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Available Options for the IONOS Cloud Docker Machine Driver:
| `--ionoscloud-datacenter-name` | Existing Ionos Cloud Virtual Data Center Name (string) in which to create the Docker Host |
| `--ionoscloud-lan-id` | Existing Ionos Cloud LAN ID (numeric) in which to create the Docker Host |
| `--ionoscloud-lan-name` | Existing Ionos Cloud LAN Name (string) in which to create the Docker Host |
| `--ionoscloud-additional-lans` | Names of existing IONOS Lans to connect the machine to. Names that are not found are ignored |
| `--ionoscloud-disk-size` | Ionos Cloud Volume Disk-Size in GB \(10, 50, 100, 200, 400\) |
| `--ionoscloud-disk-type` | Ionos Cloud Volume Disk-Type \(HDD, SSD\) |
| `--ionoscloud-image` | Ionos Cloud Image Id or Alias \(ubuntu:latest, ubuntu:20.04\). If Image Id is set, please make sure the disk type supports the image type. |
Expand All @@ -36,7 +37,7 @@ Available Options for the IONOS Cloud Docker Machine Driver:
| `--ionoscloud-template` | Ionos Cloud Template name (CUBES XS, CUBES S, etc.) |
| `--ionoscloud-server-availability-zone` | Ionos Cloud Server Availability Zone \(AUTO, ZONE\_1, ZONE\_2, ZONE\_3\) |
| `--ionoscloud-cores` | Ionos Cloud Server Cores \(2, 3, 4, 5, 6, etc.\) |
| `--ionoscloud-cpu-family` | Ionos Cloud Server CPU families \(AMD\_OPTERON,INTEL\_XEON, INTEL\_SKYLAKE\) |
| `--ionoscloud-cpu-family` | Ionos Cloud Server CPU families \(AMD\_OPTERON,INTEL\_XEON, INTEL\_SKYLAKE\,INTEL\_ICELAKE,AMD\_EPYC) |
| `--ionoscloud-ram` | Ionos Cloud Server Ram in MB \(1024, 2048, 3072, 4096, etc.\) |
| `--ionoscloud-volume-availability-zone` | Ionos Cloud Volume Availability Zone \(AUTO, ZONE\_1, ZONE\_2, ZONE\_3\) |
| `--ionoscloud-cloud-init` | The cloud-init configuration for the volume as multiline text |
Expand Down Expand Up @@ -88,6 +89,7 @@ Environment variables are also supported for setting options. This is a list of
| `--ionoscloud-datacenter-name` | `IONOSCLOUD_DATACENTER_NAME` |
| `--ionoscloud-lan-id` | `IONOSCLOUD_LAN_ID` |
| `--ionoscloud-lan-name` | `IONOSCLOUD_LAN_NAME` |
| `--ionoscloud-additional-lans` | `IONOSCLOUD_ADDITIONAL_LANS` |
| `--ionoscloud-disk-size` | `IONOSCLOUD_DISK_SIZE` |
| `--ionoscloud-disk-type` | `IONOSCLOUD_DISK_TYPE` |
| `--ionoscloud-image` | `IONOSCLOUD_IMAGE` |
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ require (
require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/docker v20.10.24+incompatible // indirect
github.com/docker/docker v20.10.27+incompatible // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/moby/term v0.0.0-20221105221325-4eb28fa6025c // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
golang.org/x/crypto v0.2.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.2.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE=
github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.27+incompatible h1:Id/ZooynV4ZlD6xX20RCd3SR0Ikn7r4QZDa2ECK2TgA=
github.com/docker/docker v20.10.27+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/machine v0.16.2 h1:jyF9k3Zg+oIGxxSdYKPScyj3HqFZ6FjgA/3sblcASiU=
github.com/docker/machine v0.16.2/go.mod h1:I8mPNDeK1uH+JTcUU7X0ZW8KiYz0jyAgNaeSJ1rCfDI=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
Expand Down Expand Up @@ -44,17 +44,17 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE=
golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20230118134722-a68e582fa157 h1:fiNkyhJPUvxbRPbCqY/D9qdjmPzfHcpK3P4bM4gioSY=
golang.org/x/exp v0.0.0-20230118134722-a68e582fa157/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.2.0 h1:GtQkldQ9m7yvzCL1V+LrYow3Khe0eJH0w7RbX/VbaIU=
golang.org/x/oauth2 v0.2.0/go.mod h1:Cwn6afJ8jrQwYMxQDTpISoXmXW9I6qF6vDeuuoX3Ibs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -65,11 +65,11 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
4 changes: 2 additions & 2 deletions internal/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,12 @@ func (c *Client) WaitForNicIpChange(datacenterId, serverId, nicId string, timeou
initialIp = (*nicIps)[0]
}

ticker := time.NewTicker(2 * time.Second)
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
start := time.Now()

for range ticker.C {
if time.Since(start) > time.Second*time.Duration(timeout+5) {
if time.Since(start) > time.Second*time.Duration(timeout+15) {
break
}
nic, err = c.GetNic(datacenterId, serverId, nicId)
Expand Down
10 changes: 10 additions & 0 deletions internal/utils/common_functions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package utils

func Contains(s []string, el string) bool {
for _, x := range s {
if x == el {
return true
}
}
return false
}
68 changes: 61 additions & 7 deletions ionoscloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const (
flagSkipDefaultNatRules = "ionoscloud-skip-default-nat-rules"
flagNatLansToGateways = "ionoscloud-nat-lans-to-gateways"
flagPrivateLan = "ionoscloud-private-lan"
flagAdditionalLans = "ionoscloud-additional-lans"
flagCreateNat = "ionoscloud-create-nat"
// ---
)
Expand Down Expand Up @@ -125,6 +126,9 @@ type Driver struct {
ServerAvailabilityZone string
LanId string
LanName string
AdditionalLans []string
AdditionalLansIds []int
AdditionalNicsIds []string
DatacenterId string
DatacenterName string
VolumeId string
Expand Down Expand Up @@ -229,6 +233,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
EnvVar: extflag.KebabCaseToEnvVarCase(flagPrivateLan),
Usage: "Should the created LAN be private? Does nothing if LAN ID is provided",
},
mcnflag.StringSliceFlag{
Name: flagAdditionalLans,
EnvVar: extflag.KebabCaseToEnvVarCase(flagAdditionalLans),
Usage: "Names of existing IONOS Lans to connect the machine to. Names that are not found are ignored",
},
mcnflag.BoolFlag{
Name: flagWaitForIpChange,
EnvVar: extflag.KebabCaseToEnvVarCase(flagWaitForIpChange),
Expand Down Expand Up @@ -329,7 +338,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Name: flagServerCpuFamily,
EnvVar: extflag.KebabCaseToEnvVarCase(flagServerCpuFamily),
Value: defaultCpuFamily,
Usage: "Ionos Cloud Server CPU families (AMD_OPTERON, INTEL_XEON, INTEL_SKYLAKE)",
Usage: "Ionos Cloud Server CPU families (AMD_OPTERON, INTEL_XEON, INTEL_SKYLAKE, INTEL_ICELAKE, AMD_EPYC)",
},
mcnflag.StringFlag{
Name: flagDatacenterId,
Expand Down Expand Up @@ -428,6 +437,7 @@ func (d *Driver) SetConfigFromFlags(opts drivers.DriverOptions) error {
d.SSHInCloudInit = opts.Bool(flagSSHInCloudInit)
d.CloudInitB64 = opts.String(flagCloudInitB64)
d.PrivateLan = opts.Bool(flagPrivateLan)
d.AdditionalLans = opts.StringSlice(flagAdditionalLans)

d.SwarmMaster = opts.Bool("swarm-master")
d.SwarmHost = opts.String("swarm-host")
Expand Down Expand Up @@ -466,12 +476,18 @@ func (d *Driver) PreCreateCheck() error {
d.LanExists = false
d.NatExists = false

for i := len(d.MachineName) - 1; i >= 0; i-- {
if !unicode.IsNumber(rune(d.MachineName[i])) {
if d.MachineName[i+1:] != "1" {
time.Sleep(60 * time.Second)
if strings.Contains(d.MachineName, "-pool") {
if !strings.Contains(d.MachineName, "-pool1-") {
time.Sleep(60 * time.Second)
}
} else {
for i := len(d.MachineName) - 1; i >= 0; i-- {
if !unicode.IsNumber(rune(d.MachineName[i])) {
if d.MachineName[i+1:] != "1" {
time.Sleep(60 * time.Second)
}
break
}
break
}
}
if d.DatacenterId == "" {
Expand Down Expand Up @@ -513,6 +529,14 @@ func (d *Driver) PreCreateCheck() error {
if lanId, ok := lan.GetIdOk(); ok && lanId != nil {
d.LanId = *lanId
}
} else if utils.Contains(d.AdditionalLans, *lan.Properties.Name) {
if lanId, ok := lan.GetIdOk(); ok && lanId != nil {
lanIdInt, err := strconv.Atoi(*lanId)
if err != nil {
return fmt.Errorf("invalid LAN ID found: %v", *lanId)
}
d.AdditionalLansIds = append(d.AdditionalLansIds, lanIdInt)
}
}
}

Expand Down Expand Up @@ -802,7 +826,11 @@ func (d *Driver) Create() (err error) {
if err != nil {
return fmt.Errorf("error getting server by id: %w", err)
}
d.VolumeId = *(*server.Entities.GetVolumes().Items)[0].GetId()
volumes, ok := server.Entities.GetVolumesOk()
if ok != true {
return fmt.Errorf("error getting server: d.ServerId is empty")
}
d.VolumeId = *(*volumes.Items)[0].GetId()
log.Debugf("Volume ID: %v", d.VolumeId)

// Reserve IP if needed
Expand Down Expand Up @@ -847,6 +875,20 @@ func (d *Driver) Create() (err error) {
}
return err
}
for _, additionalLanId := range d.AdditionalLansIds {
additionalNic, err := d.client().CreateAttachNIC(d.DatacenterId, d.ServerId, d.MachineName, true, int32(additionalLanId), nil)
if err != nil {
// TODO: Duplicated
log.Warn(rollingBackNotice)
if removeErr := d.Remove(); removeErr != nil {
return fmt.Errorf("failed to create machine due to error: %w\n Removing created resources: %v", fmt.Errorf("error attaching additional NIC: %w", err), removeErr)
}
return err
}
if nicId, ok := additionalNic.GetIdOk(); ok && nicId != nil {
d.AdditionalNicsIds = append(d.AdditionalNicsIds, *nicId)
}
}
if nicId, ok := nic.GetIdOk(); ok && nicId != nil {
d.NicId = *nic.Id
log.Debugf("Nic ID: %v", d.NicId)
Expand Down Expand Up @@ -932,6 +974,15 @@ func (d *Driver) Remove() error {
d.NicId = ""
}
}
if d.DatacenterId != "" && d.ServerId != "" {
for _, additionalNicId := range d.AdditionalNicsIds {
log.Debugf("Starting deleting additional Nic with Id: %v", additionalNicId)
err := d.client().RemoveNic(d.DatacenterId, d.ServerId, additionalNicId)
if err != nil {
result = multierror.Append(result, fmt.Errorf("error deleting additional NIC: %w", err))
}
}
}
if d.DatacenterId != "" && d.VolumeId != "" {
log.Debugf("Starting deleting Volume with Id: %v", d.VolumeId)
err = d.client().RemoveVolume(d.DatacenterId, d.VolumeId)
Expand Down Expand Up @@ -1084,6 +1135,9 @@ func (d *Driver) GetIP() (string, error) {

// GetState returns the state of the machine role instance.
func (d *Driver) GetState() (state.State, error) {
if d.ServerId == "" {
return state.None, fmt.Errorf("error getting server: d.ServerID is empty")
}
server, err := d.client().GetServer(d.DatacenterId, d.ServerId)
if err != nil {
return state.None, fmt.Errorf("error getting server: %w", err)
Expand Down
Loading

0 comments on commit 667588b

Please sign in to comment.