Skip to content

Commit

Permalink
Update specs of virtualserver
Browse files Browse the repository at this point in the history
  • Loading branch information
GJSBRT committed Apr 18, 2023
1 parent aa11bdd commit a54689f
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions dutchis/virtualserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

type VirtualServer struct {
Success bool `json:"success"`
Data struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Class string `json:"class"`
Status string `json:"status"`
Node string `json:"node"`
}
}

// using a global variable here so that we have an internally accessible
// way to look into our own resource definition. Useful for dynamically doing typecasts
// so that we can print (debug) our ResourceData constructs
Expand Down Expand Up @@ -225,13 +214,31 @@ func resourceVirtualServerRead(d *schema.ResourceData, meta interface{}) error {
return err
}

type VirtualServer struct {
Success bool `json:"success"`
Data struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Class string `json:"class"`
Status string `json:"status"`
Node string `json:"node"`
Cpus int `json:"cpus"`
Maxmem int `json:"maxmem"`
Maxdisk int `json:"maxdisk"`
}
}

var virtualserver VirtualServer
if err := json.Unmarshal(body, &virtualserver); err != nil {
logger.Error().Err(err).Msg("Failed to unmarshal JSON")
return err
}

d.Set("hostname", virtualserver.Data.Name)
d.Set("class", virtualserver.Data.Class)
d.Set("cores", virtualserver.Data.Cpus)
d.Set("memory", virtualserver.Data.Maxmem)
d.Set("disk", virtualserver.Data.Maxdisk)

logger.Info().Msg("Read configuration for virtual server: " + d.Id())

Expand Down

0 comments on commit a54689f

Please sign in to comment.