|
| 1 | +// Copyright 2025 SAP SE |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package manila |
| 5 | + |
| 6 | +// Host object from the Manila scheduler pipeline. |
| 7 | +type ExternalSchedulerHost struct { |
| 8 | + // Name of the Manila share host. |
| 9 | + ShareHost string `json:"host"` |
| 10 | +} |
| 11 | + |
| 12 | +// Request generated by the Manila scheduler when calling cortex. |
| 13 | +// The request contains a spec of the share to be scheduled, a list of hosts and |
| 14 | +// their status, and a map of weights that were calculated by the Manila weigher |
| 15 | +// pipeline. Some additional flags are also included. |
| 16 | +type ExternalSchedulerRequest struct { |
| 17 | + // TODO: Use a more specific type for the spec. |
| 18 | + Spec any `json:"spec"` |
| 19 | + // Request context from Manila that contains additional meta information. |
| 20 | + Context ManilaRequestContext `json:"context"` |
| 21 | + // The share hosts that are available for scheduling. |
| 22 | + Hosts []ExternalSchedulerHost `json:"hosts"` |
| 23 | + // Weights map of share hosts to their weights calculated by the Manila weigher pipeline. |
| 24 | + Weights map[string]float64 `json:"weights"` |
| 25 | + |
| 26 | + // Whether the request is a sandboxed request. By default, this is false. |
| 27 | + // |
| 28 | + // Sandboxed requests can be used to notify cortex that the resource is not |
| 29 | + // actually being scheduled, and that sandboxed scheduler steps should be |
| 30 | + // executed for additional validation. |
| 31 | + Sandboxed bool `json:"sandboxed"` |
| 32 | +} |
| 33 | + |
| 34 | +// Response generated by cortex for the Manila scheduler. |
| 35 | +// Cortex returns an ordered list of hosts that the share should be scheduled on. |
| 36 | +type ExternalSchedulerResponse struct { |
| 37 | + Hosts []string `json:"hosts"` |
| 38 | +} |
| 39 | + |
| 40 | +// Manila request context object. For the spec of this object, see: |
| 41 | +// |
| 42 | +// - This: https://github.com/sapcc/manila/blob/4ffdfc/manila/context.py#L29 |
| 43 | +// - And: https://github.com/openstack/oslo.context/blob/db20dd/oslo_context/context.py#L329 |
| 44 | +// |
| 45 | +// Some fields are omitted: "service_catalog", "read_deleted" (same as "show_deleted") |
| 46 | +type ManilaRequestContext struct { |
| 47 | + // Fields added by oslo.context |
| 48 | + |
| 49 | + UserID string `json:"user"` |
| 50 | + ProjectID string `json:"project_id"` |
| 51 | + SystemScope string `json:"system_scope"` |
| 52 | + DomainID string `json:"domain"` |
| 53 | + UserDomainID string `json:"user_domain"` |
| 54 | + ProjectDomainID string `json:"project_domain"` |
| 55 | + IsAdmin bool `json:"is_admin"` |
| 56 | + ReadOnly bool `json:"read_only"` |
| 57 | + ShowDeleted bool `json:"show_deleted"` |
| 58 | + RequestID string `json:"request_id"` |
| 59 | + GlobalRequestID string `json:"global_request_id"` |
| 60 | + ResourceUUID string `json:"resource_uuid"` |
| 61 | + Roles []string `json:"roles"` |
| 62 | + UserIdentity string `json:"user_identity"` |
| 63 | + IsAdminProject bool `json:"is_admin_project"` |
| 64 | + |
| 65 | + // Fields added by the Manila scheduler |
| 66 | + |
| 67 | + RemoteAddress string `json:"remote_address"` |
| 68 | + Timestamp string `json:"timestamp"` |
| 69 | + QuotaClass string `json:"quota_class"` |
| 70 | + ProjectName string `json:"project_name"` |
| 71 | +} |
0 commit comments