Skip to content

Commit

Permalink
Partitionable model with generated partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbelamaric committed Jun 16, 2024
1 parent 6c42a17 commit 8c008ed
Show file tree
Hide file tree
Showing 2 changed files with 583 additions and 878 deletions.
56 changes: 51 additions & 5 deletions dra-evolution/pkg/api/capacity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,48 @@ type DeviceShape struct {
SharedCapacity []SharedCapacity `json:"sharedCapacity,omitempty"`
}

// Device represents one individual hardware instance that can be selected based
// on its attributes.
// StringOrExpression contains either an explicit string Value or
// a CEL expression that will return a string.
type StringOrExpression struct {
Value *string `json:"value,omitempty"`
Expression *string `json:"expression,omitempty"`
}

// QuantityOrExpression contains either an explicit resource.Quantity Value
// or a CEL expression that results in a resource.Quantity (or a string that parses
// to one).
type QuantityOrExpression struct {
Value *resource.Quantity `json:"value,omitempty"`
Expression *string `json:"expression,omitempty"`
}

// QuantityOrExpression contains either an explicit bool Value
// or a CEL expression that results in a bool
type BoolOrExpression struct {
Value *bool `json:"value,omitempty"`
Expression *string `json:"expression,omitempty"`
}

// Device represents a format for a partition, and a count. The actual partitions of
// the device are generated in-memory by evaluating the format for the index values
// 0..Count.
type DevicePartition struct {

// Count identifies the number of partitions using this format.
//
// +required
Count int `json:"count"`

// Name is unique identifier among all partitions for this device. The
// device name as recorded in the allocation will be the concatenation
// of the device name and the partition name with a '-' separator.
//
// NOTE: may need a better naming scheme
//
// It must be a DNS label.
Name string `json:"name" protobuf:"bytes,1,name=name"`
//
// +required
Name StringOrExpression `json:"name" protobuf:"bytes,1,name=name"`

// Attributes defines the attributes of this partition.
// The name of each attribute must be unique. The values
Expand All @@ -129,7 +160,7 @@ type DevicePartition struct {
//
// +listType=atomic
// +optional
Attributes []DeviceAttribute `json:"attributes,omitempty" protobuf:"bytes,3,opt,name=attributes"`
Attributes []DeviceAttributeFormat `json:"attributes,omitempty" protobuf:"bytes,3,opt,name=attributes"`

// SharedCapacityConsumed defines the set of shared capacity consumed by
// this partition.
Expand All @@ -138,7 +169,7 @@ type DevicePartition struct {
//
// +listType=atomic
// +optional
SharedCapacityConsumed []SharedCapacity `json:"sharedCapacityConsumed,omitempty"`
SharedCapacityConsumed []SharedCapacityFormat `json:"sharedCapacityConsumed,omitempty"`
}

type Device struct {
Expand Down Expand Up @@ -233,6 +264,21 @@ type SharedCapacity struct {
Capacity resource.Quantity `json:"capacity"`
}

type DeviceAttributeFormat struct {
Name StringOrExpression `json:"name"`

QuantityValue *QuantityOrExpression `json:"quantity,omitempty"`
BoolValue *BoolOrExpression `json:"bool,omitempty"`
StringValue *StringOrExpression `json:"string,omitempty"`
VersionValue *StringOrExpression `json:"version,omitempty"`
}

type SharedCapacityFormat struct {
Name StringOrExpression `json:"name"`

Capacity *QuantityOrExpression `json:"capacity,omitempty"`
}

// CStyleIdentifierMaxLength is the maximum length of a c-style identifier used for naming.
const CStyleIdentifierMaxLength = 32

Expand Down
Loading

0 comments on commit 8c008ed

Please sign in to comment.