Skip to content

Commit

Permalink
Add storage controller mount
Browse files Browse the repository at this point in the history
  • Loading branch information
mahesh-hpe committed Oct 16, 2024
1 parent fb2edb9 commit 78c0fcb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
25 changes: 25 additions & 0 deletions pkg/client/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"fmt"
"reflect"
"strings"

"github.com/antihax/optional"

Expand Down Expand Up @@ -469,3 +470,27 @@ func (a *InstancesAPIService) GetStorageVolTypeID(ctx context.Context, cloudID,

return StorageVol, err
}

func (a *InstancesAPIService) GetStorageControllerMount(ctx context.Context, instanceID int, controllerType string,
busNumber, unitNumber int) (ControllerMount string, err error) {
controllerType = strings.ToLower(controllerType)
instanceResp, err := a.GetASpecificInstance(ctx, instanceID)
if err != nil {
return
}
if instanceResp.Instance.Controllers == nil {
err = fmt.Errorf("no controllers found in the instance response")
return
}
for _, controller := range instanceResp.Instance.Controllers {
if strings.ToLower(controller.Type.Name) == controllerType {
if controller.MaxDevices <= unitNumber {
err = fmt.Errorf("max allowed devices exceed for controller '%s'", controllerType)
return
}
ControllerMount = fmt.Sprintf("%d:%d:%d:%d", controller.ID, busNumber, controller.Type.ID, unitNumber)
}
}

return
}
1 change: 1 addition & 0 deletions pkg/models/instance_tf.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type TFInstanceVolume struct {
ID int `tf:"id"`
Root bool `tf:"root"`
StorageType int `tf:"storage_type"`
Controller string `tf:"controller"`
}

type TFInstanceNetwork struct {
Expand Down
30 changes: 22 additions & 8 deletions pkg/models/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ type GetInstanceResponseInstance struct {
EnvironmentPrefix string `json:"environmentPrefix"`
InstanceContext string `json:"instanceContext"`
ContainerDetails []GetInstanceContainer `json:"containerDetails"`
Controllers []InstanceStorageController `json:"controllers,omitempty"`
}

type InstanceStorageController struct {
ID int64 `json:"id"`
Name string `json:"name"`
Type struct {
ID int `json:"id"`
Code string `json:"code"`
Name string `json:"name"`
} `json:"type"`
MaxDevices int `json:"maxDevices"`
ReservedUnitNumber int `json:"reservedUnitNumber"`
}

// GetInstanceResponseInstanceCloud
Expand Down Expand Up @@ -315,14 +328,15 @@ type GetInstanceResponseInstanceTenant struct {

// GetInstanceResponseInstanceVolumes
type GetInstanceResponseInstanceVolumes struct {
Size int `json:"size,omitempty"`
Name string `json:"name,omitempty"`
RootVolume bool `json:"rootVolume,omitempty"`
StorageType int `json:"storageType,omitempty"`
ID int `json:"id,omitempty"`
DatastoreID interface{} `json:"datastoreId,omitempty"`
MaxStorage float64 `json:"maxStorage,omitempty"`
DeviceDisplayName string `json:"deviceDisplayName,omitempty"`
Size int `json:"size,omitempty"`
Name string `json:"name,omitempty"`
RootVolume bool `json:"rootVolume,omitempty"`
StorageType int `json:"storageType,omitempty"`
ID int `json:"id,omitempty"`
DatastoreID interface{} `json:"datastoreId,omitempty"`
MaxStorage float64 `json:"maxStorage,omitempty"`
DeviceDisplayName string `json:"deviceDisplayName,omitempty"`
ControllerMountPoint string `json:"controllerMountPoint,omitempty"`
}

// ResizeInstanceBody
Expand Down

0 comments on commit 78c0fcb

Please sign in to comment.