add exec
This commit is contained in:
parent
0e84db61de
commit
301ef8dc05
@ -16,6 +16,7 @@ import (
|
|||||||
type Booking struct {
|
type Booking struct {
|
||||||
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
||||||
DestPeerID string `json:"dest_peer_id,omitempty"` // DestPeerID is the ID of the destination peer
|
DestPeerID string `json:"dest_peer_id,omitempty"` // DestPeerID is the ID of the destination peer
|
||||||
|
WorkflowID string `json:"workflow_id,omitempty" bson:"workflow_id,omitempty"` // WorkflowID is the ID of the workflow
|
||||||
ExecutionID string `json:"execution_id,omitempty" bson:"execution_id,omitempty" validate:"required"`
|
ExecutionID string `json:"execution_id,omitempty" bson:"execution_id,omitempty" validate:"required"`
|
||||||
State common.ScheduledType `json:"state,omitempty" bson:"state,omitempty" validate:"required"` // State is the state of the booking
|
State common.ScheduledType `json:"state,omitempty" bson:"state,omitempty" validate:"required"` // State is the state of the booking
|
||||||
ExpectedStartDate time.Time `json:"expected_start_date,omitempty" bson:"expected_start_date,omitempty" validate:"required"` // ExpectedStartDate is the expected start date of the booking
|
ExpectedStartDate time.Time `json:"expected_start_date,omitempty" bson:"expected_start_date,omitempty" validate:"required"` // ExpectedStartDate is the expected start date of the booking
|
||||||
@ -25,7 +26,7 @@ type Booking struct {
|
|||||||
RealEndDate *time.Time `json:"real_end_date,omitempty" bson:"real_end_date,omitempty"` // RealEndDate is the real end date of the booking
|
RealEndDate *time.Time `json:"real_end_date,omitempty" bson:"real_end_date,omitempty"` // RealEndDate is the real end date of the booking
|
||||||
|
|
||||||
ResourceType tools.DataType `json:"resource_type,omitempty" bson:"resource_type,omitempty" validate:"required"` // ResourceType is the type of the resource
|
ResourceType tools.DataType `json:"resource_type,omitempty" bson:"resource_type,omitempty" validate:"required"` // ResourceType is the type of the resource
|
||||||
ResourceID string `json:"compute_resource_id,omitempty" bson:"compute_resource_id,omitempty" validate:"required"` // could be a Compute or a Storage
|
ResourceID string `json:"resource_id,omitempty" bson:"resource_id,omitempty" validate:"required"` // could be a Compute or a Storage
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckBooking checks if a booking is possible on a specific compute resource
|
// CheckBooking checks if a booking is possible on a specific compute resource
|
||||||
|
@ -176,7 +176,7 @@ func (o *Order) draftBookOrder(scheduler *workflow_execution.WorkflowSchedule, r
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return draftedBookings, errors.New("could not planify the workflow" + fmt.Sprintf("%v", err))
|
return draftedBookings, errors.New("could not planify the workflow" + fmt.Sprintf("%v", err))
|
||||||
}
|
}
|
||||||
bookings := exec.Book(priceds)
|
bookings := exec.Book(scheduler.Workflow.UUID, priceds)
|
||||||
for _, booking := range bookings {
|
for _, booking := range bookings {
|
||||||
_, err := (&peer.Peer{}).LaunchPeerExecution(booking.DestPeerID, "",
|
_, err := (&peer.Peer{}).LaunchPeerExecution(booking.DestPeerID, "",
|
||||||
tools.BOOKING, tools.POST, booking.Serialize(booking), request.Caller)
|
tools.BOOKING, tools.POST, booking.Serialize(booking), request.Caller)
|
||||||
|
@ -104,13 +104,13 @@ func (d *WorkflowExecutions) VerifyAuth(request *tools.APIRequest) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WorkflowExecutions) Book(priceds map[tools.DataType][]pricing.PricedItemITF) []*booking.Booking {
|
func (d *WorkflowExecutions) Book(wfID string, priceds map[tools.DataType][]pricing.PricedItemITF) []*booking.Booking {
|
||||||
booking := d.bookEach(tools.STORAGE_RESOURCE, priceds[tools.STORAGE_RESOURCE])
|
booking := d.bookEach(wfID, tools.STORAGE_RESOURCE, priceds[tools.STORAGE_RESOURCE])
|
||||||
booking = append(booking, d.bookEach(tools.PROCESSING_RESOURCE, priceds[tools.PROCESSING_RESOURCE])...)
|
booking = append(booking, d.bookEach(wfID, tools.PROCESSING_RESOURCE, priceds[tools.PROCESSING_RESOURCE])...)
|
||||||
return booking
|
return booking
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WorkflowExecutions) bookEach(dt tools.DataType, priceds []pricing.PricedItemITF) []*booking.Booking {
|
func (d *WorkflowExecutions) bookEach(wfID string, dt tools.DataType, priceds []pricing.PricedItemITF) []*booking.Booking {
|
||||||
items := []*booking.Booking{}
|
items := []*booking.Booking{}
|
||||||
for _, priced := range priceds {
|
for _, priced := range priceds {
|
||||||
start := d.ExecDate
|
start := d.ExecDate
|
||||||
@ -123,6 +123,7 @@ func (d *WorkflowExecutions) bookEach(dt tools.DataType, priceds []pricing.Price
|
|||||||
ResourceID: priced.GetID(),
|
ResourceID: priced.GetID(),
|
||||||
ResourceType: dt,
|
ResourceType: dt,
|
||||||
DestPeerID: priced.GetCreatorID(),
|
DestPeerID: priced.GetCreatorID(),
|
||||||
|
WorkflowID: wfID,
|
||||||
ExecutionID: d.GetID(),
|
ExecutionID: d.GetID(),
|
||||||
ExpectedStartDate: start,
|
ExpectedStartDate: start,
|
||||||
ExpectedEndDate: &end,
|
ExpectedEndDate: &end,
|
||||||
|
@ -71,7 +71,7 @@ func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest)
|
|||||||
return false, wf, []*WorkflowExecutions{}, err
|
return false, wf, []*WorkflowExecutions{}, err
|
||||||
}
|
}
|
||||||
for _, exec := range execs {
|
for _, exec := range execs {
|
||||||
bookings := exec.Book(priceds)
|
bookings := exec.Book(wfID, priceds)
|
||||||
for _, booking := range bookings {
|
for _, booking := range bookings {
|
||||||
_, err := (&peer.Peer{}).LaunchPeerExecution(booking.DestPeerID, "",
|
_, err := (&peer.Peer{}).LaunchPeerExecution(booking.DestPeerID, "",
|
||||||
tools.BOOKING, tools.POSTCHECK, booking.Serialize(booking), request.Caller)
|
tools.BOOKING, tools.POSTCHECK, booking.Serialize(booking), request.Caller)
|
||||||
|
Loading…
Reference in New Issue
Block a user