Draft booking flow
This commit is contained in:
@@ -36,6 +36,10 @@ type Booking struct {
|
||||
ResourceID string `json:"resource_id,omitempty" bson:"resource_id,omitempty" validate:"required"` // could be a Compute or a Storage
|
||||
InstanceID string `json:"instance_id,omitempty" bson:"instance_id,omitempty" validate:"required"` // could be a Compute or a Storage
|
||||
|
||||
// Authorization: identifies who created this draft and the Check session it belongs to.
|
||||
// Used to verify UPDATE and DELETE orders from remote schedulers.
|
||||
SchedulerPeerID string `json:"scheduler_peer_id,omitempty" bson:"scheduler_peer_id,omitempty"`
|
||||
SchedulingSessionID string `json:"scheduling_session_id,omitempty" bson:"scheduling_session_id,omitempty"`
|
||||
}
|
||||
|
||||
func (b *Booking) CalcDeltaOfExecution() map[string]map[string]models.MetricResume {
|
||||
|
||||
@@ -58,10 +58,15 @@ func GenerateShallow(request *tools.APIRequest) (*Planner, error) {
|
||||
|
||||
func generate(request *tools.APIRequest, shallow bool) (*Planner, error) {
|
||||
accessor := booking.NewAccessor(request)
|
||||
bookings, code, err := accessor.Search(nil, "*", false)
|
||||
// Include both confirmed (IsDraft=false) and draft (IsDraft=true) bookings
|
||||
// so the planner reflects the full picture: first-come first-served on all
|
||||
// pending reservations regardless of confirmation state.
|
||||
confirmed, code, err := accessor.Search(nil, "*", false)
|
||||
if code != 200 || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
drafts, _, _ := accessor.Search(nil, "*", true)
|
||||
bookings := append(confirmed, drafts...)
|
||||
|
||||
p := &Planner{
|
||||
GeneratedAt: time.Now(),
|
||||
|
||||
Reference in New Issue
Block a user