Skip to content

Commit f8b02af

Browse files
committed
only checking in the bare minimum to give structure to the APIs
1 parent dd9404e commit f8b02af

File tree

3 files changed

+50
-86
lines changed

3 files changed

+50
-86
lines changed

cns/api.go

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ const (
3333
V1Prefix = "/v0.1"
3434
V2Prefix = "/v0.2"
3535
EndpointPath = "/network/endpoints/"
36-
// IBDevice API paths
37-
IBDevicesPodPath = "/ibdevices/pod" // POST /ibdevices/pod
38-
IBDevicesPath = "/ibdevices/" // GET /ibdevices/{mac-address-of-device}
36+
IBDevicesPath = "/ibdevices"
3937
// Service Fabric SWIFTV2 mode
4038
StandaloneSWIFTV2 SWIFTV2Mode = "StandaloneSWIFTV2"
4139
// K8s SWIFTV2 mode
@@ -387,27 +385,16 @@ type GetVMUniqueIDResponse struct {
387385
VMUniqueID string `json:"vmuniqueid"`
388386
}
389387

390-
// IBDevice API Contracts
391-
392-
// AssignIBDevicesToPodRequest represents the request to assign InfiniBand devices to a pod
393-
// POST /ibdevices/pod
394-
type AssignIBDevicesToPodRequest struct {
395-
PodID string `json:"podID"` // podname-podnamespace format
396-
MACAddresses []string `json:"macAddresses"` // Array of MAC addresses like ["60:45:bd:a4:b5:7a", "7c:1e:52:07:11:36"]
397-
}
398-
399388
// AssignIBDevicesToPodResponse represents the response for assigning InfiniBand devices to a pod
400389
type AssignIBDevicesToPodResponse struct {
401-
ErrorCode infiniband.ErrorCode `json:"errorCode"` // Error code if applicable
402-
Message string `json:"message"` // Additional message or error description
390+
Message string `json:"message"` // Additional message or error description
403391
}
404392

405-
// GET /ibdevices/{mac-address-of-device}
406393
// GetIBDeviceStatusResponse represents the response containing InfiniBand device programming status
407394
type GetIBDeviceStatusResponse struct {
408-
MACAddress string `json:"macAddress"` // MAC address of the device
409-
PodID string `json:"podID"` // Pod that the device is assigned to
410-
Status infiniband.Status `json:"status"` // Device status (e.g., "pendingProgramming", "error", "programmed", "pendingDeletion", "available")
411-
ErrorCode infiniband.ErrorCode `json:"errorCode"` // Error code if applicable
412-
Message string `json:"message"` // Additional message or error description
395+
MACAddress string `json:"macAddress"` // MAC address of the device
396+
PodNamespace string `json:"podNamespace"` // Namespace of pod to which the device is assigned, if any
397+
PodName string `json:"podName"` // Name of pod to which the device is assigned, if any
398+
Status infiniband.Status `json:"status"` // Device status (e.g., "Available", "ProgrammingPending", etc.)"
399+
Message string `json:"message"` // Additional message or error description
413400
}

cns/swagger.yaml

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,35 @@ paths:
120120
schema:
121121
$ref: "#/components/schemas/UnpublishNetworkContainerResponse"
122122

123-
/ibdevices/pod:
123+
/ibdevices:assign:
124124
post:
125-
summary: Assigns IB devices to a pod
126-
description: >-
127-
Assigns the specified IB devices to the pod identified by PodID. The
128-
MAC addresses of the devices are provided in the request body.
129-
requestBody:
130-
required: true
131-
content:
132-
application/json:
133-
schema:
134-
$ref: "#/components/schemas/AssignIBDevicesToPodRequest"
125+
summary: Assign IB devices to a pod
126+
description: >
127+
Assigns one or more Infiniband devices by MAC address to a given pod.
128+
parameters:
129+
- name: ibmacs
130+
in: query
131+
required: true
132+
description: Comma-separated list of IB device MAC addresses.
133+
schema:
134+
type: array
135+
items:
136+
type: string
137+
example: ["60:45:bd:a4:b5:7a", "7c:1e:52:07:11:36"]
138+
- name: podnamespace
139+
in: query
140+
required: true
141+
description: The namespace of the target pod.
142+
schema:
143+
type: string
144+
example: "podnamespace"
145+
- name: podname
146+
in: query
147+
required: true
148+
description: The name of the target pod.
149+
schema:
150+
type: string
151+
example: "podname"
135152
responses:
136153
'200':
137154
description: >-
@@ -142,31 +159,32 @@ paths:
142159
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
143160
'404':
144161
description: >-
145-
The pod specified by PodID was not found
162+
The pod specified by PodID was not found.
146163
content:
147164
application/json:
148165
schema:
149166
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
150167
'400':
151168
description: >-
152-
One of the IB devices specified is not available
169+
One of the IB devices specified is not available.
153170
content:
154171
application/json:
155172
schema:
156173
$ref: "#/components/schemas/AssignIBDevicesToPodResponse"
157174

158-
/ibdevices/{macaddress}:
175+
/ibdevices:
159176
get:
160177
summary: Get status of an IB device
161178
description: >-
162-
Retrieves the current status of the specified IB device.
179+
Retrieves the current programming status of the specified IB device.
163180
parameters:
164-
- name: macaddress
165-
in: path
181+
- name: ibmac
182+
in: query
166183
required: true
167-
description: The MAC address of the IB device (with colons ":")
184+
description: The MAC address of the IB device.
168185
schema:
169186
type: string
187+
example: "60:45:bd:a4:b5:7a"
170188
responses:
171189
'200':
172190
description: >-
@@ -433,11 +451,8 @@ components:
433451
AssignIBDevicesToPodResponse:
434452
type: object
435453
required:
436-
- ErrorCode
437454
- Message
438455
properties:
439-
ErrorCode:
440-
$ref: "#/components/schemas/ErrorCode"
441456
Message:
442457
type: string
443458
description: Human-readable message or error description
@@ -446,50 +461,25 @@ components:
446461
type: object
447462
required:
448463
- MACAddress
449-
- PodID
464+
- PodNamespace
465+
- PodName
450466
- Status
451-
- ErrorCode
452467
- Message
453468
properties:
454469
MACAddress:
455470
type: string
456471
description: MAC address of the IB device
457-
PodID:
472+
PodNamespace:
473+
type: string
474+
description: namespace of the pod to which the device is assigned, if any
475+
PodName:
458476
type: string
459-
description: podname-podnamespace of the pod to which the device is assigned, if any
477+
description: name of the pod to which the device is assigned, if any
460478
Status:
461479
$ref: "#/components/schemas/Status"
462-
ErrorCode:
463-
$ref: "#/components/schemas/ErrorCode"
464480
Message:
465481
type: string
466482
description: Human-readable message or error description
467-
468-
ErrorCode:
469-
type: integer
470-
description: Pre-defined error code of what went wrong, if anything (see cns/types/infiniband/errorcodes.go)
471-
oneOf:
472-
- title: Success
473-
const: 0
474-
description: Successful operation
475-
- title: PodNotFound
476-
const: 1
477-
description: Pod not found
478-
- title: DeviceUnavailable
479-
const: 2
480-
description: Device is unavailable
481-
- title: DeviceNotFound
482-
const: 3
483-
description: Device not found
484-
- title: AnnotationNotFound
485-
const: 4
486-
description: Annotation not found on pod
487-
- title: PodAlreadyAllocated
488-
const: 5
489-
description: Pod was already assigned IB devices (and new ones don't match)
490-
- title: InternalProgrammingError
491-
const: 6
492-
description: Something went wrong programming the devices
493483

494484
Status:
495485
type: integer

cns/types/infiniband/errorcodes.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)