Skip to content

Commit

Permalink
Merge branch 'master' into akstest
Browse files Browse the repository at this point in the history
  • Loading branch information
gejain committed Aug 23, 2024
2 parents 715d1ad + 1c878d4 commit 9d9bbc3
Show file tree
Hide file tree
Showing 33 changed files with 871 additions and 426 deletions.
81 changes: 74 additions & 7 deletions drivers/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/libopenstorage/openstorage/api"
corev1 "github.com/libopenstorage/operator/pkg/apis/core/v1"
"github.com/portworx/torpedo/pkg/errors"
"github.com/vmware/govmomi/object"
)
Expand Down Expand Up @@ -129,6 +128,64 @@ type InitOptions struct {
SpecDir string
}

type DriveSet struct {
// Configs describes the configuration of the drives present in this set
// The key is the volumeID
Configs map[string]DriveConfig
// NodeID is the id of the node where the drive set is being used/last
// used
NodeID string
// ReservedInstanceID if set is the instance ID of the node that's attempting to transfer the driveset to itself
ReservedInstanceID string
// SchedulerNodeName is the name of the node in scheduler context
SchedulerNodeName string
// NodeIndex is the index of the node where the drive set is being
// used/last used
NodeIndex int
// CreateTimestamp is the timestamp when the drive set was created
CreateTimestamp time.Time
// InstanceID is the cloud provider id of the instance using this drive set
InstanceID string
// Zone defines the zone in which the node exists
Zone string
// State state of the drive set from the well defined states
State string
// Labels associated with this drive set
Labels *map[string]string `json:"labels"`
}

// DriveConfig defines the configuration for a cloud drive
type DriveConfig struct {
// Type defines the type of cloud drive
Type string
// Size defines the size of the cloud drive in Gi
Size int64
// ID is the cloud drive id
ID string
// Path is the path where the drive is attached
Path string
// Iops is the iops that the drive supports
Iops int64
// Vpus provide a measure of disk resources available for
// performance (IOPS/GBs) of Oracle drives.
// Oracle uses VPU in lieu of disk types.
Vpus int64
// PXType indicates how this drive is being used by PX
PXType string
// State state of the drive config from the well defined states
State string
// Labels associated with this drive config
Labels map[string]string `json:"labels"`
// AttachOptions for cloud drives to be attached
AttachOptions map[string]string
// Provisioner is a name of provisioner which was used to create a drive
Provisioner string
// Encryption Key string to be passed in device specs
EncryptionKeyInfo string
// UUID of VMDK
DiskUUID string
}

// Driver provides the node driver interface
type Driver interface {
// Init initializes the node driver under the given scheduler
Expand Down Expand Up @@ -217,7 +274,7 @@ type Driver interface {
AddMachine(machineName string) error

// DetachDisk vdisk from node.
DetachDrivesFromVM(stc *corev1.StorageCluster, nodeName string) error
DetachDrivesFromVM(nodeName string, configData map[string]DriveSet) error

//GetCompatibleDatastores
GetCompatibleDatastores(portworxNamespace string, datastoreNames []string) ([]*object.Datastore, error)
Expand Down Expand Up @@ -257,7 +314,10 @@ type Driver interface {
GetSupportedDriveTypes() ([]string, error)

// StorageVmotion selectively relocates specific disks of a virtual machine to a new datastore
StorageVmotion(ctx context.Context, node Node, portworxNamespace string, moveAllDisks bool) error
StorageVmotion(ctx context.Context, node Node, portworxNamespace string, moveAllDisks bool) (*object.Datastore, error)

// GetUUIDFromVMDKPath returns the UUID of the VMDK file
GetUUIDFromVMDKPath(ctx context.Context, node Node, vmdkPath string) (string, error)

// findVMByName finds a virtual machine by its name
FindVMByName(vmName string) (*object.VirtualMachine, error)
Expand Down Expand Up @@ -311,7 +371,7 @@ func (d *notSupportedDriver) RebootNode(node Node, options RebootNodeOpts) error
}
}

func (d *notSupportedDriver) DetachDrivesFromVM(stc *corev1.StorageCluster, nodeName string) error {
func (d *notSupportedDriver) DetachDrivesFromVM(nodeName string, configData map[string]DriveSet) error {
return &errors.ErrNotSupported{
Type: "Function",
Operation: "DetachDrivesFromVM()",
Expand Down Expand Up @@ -581,13 +641,20 @@ func (d *notSupportedDriver) RemoveNonRootDisks(node Node) error {
}
}

func (d *notSupportedDriver) StorageVmotion(ctx context.Context, node Node, portworxNamespace string, moveAllDisks bool) error {
return &errors.ErrNotSupported{
func (d *notSupportedDriver) StorageVmotion(ctx context.Context, node Node, portworxNamespace string, moveAllDisks bool) (*object.Datastore, error) {
return nil, &errors.ErrNotSupported{
Type: "Function",
Operation: "StorageVmotion()",
}
}

func (d *notSupportedDriver) GetUUIDFromVMDKPath(ctx context.Context, node Node, vmdkPath string) (string, error) {
return "", &errors.ErrNotSupported{
Type: "Function",
Operation: "GetUUIDFromVMDKPath()",
}
}

func (d *notSupportedDriver) FindVMByName(vmName string) (*object.VirtualMachine, error) {
return nil, &errors.ErrNotSupported{
Type: "Function",
Expand All @@ -600,4 +667,4 @@ func (d *notSupportedDriver) FindDatastoreByName(dsName string) (*object.Datasto
Type: "Function",
Operation: "FindDatastoreByName()",
}
}
}
Loading

0 comments on commit 9d9bbc3

Please sign in to comment.