# SRS-03: iSCSI Management

## 1. Overview
iSCSI Management module provides configuration and management of iSCSI targets, LUNs, initiators, and portals using SCST.

## 2. Functional Requirements

### 2.1 Target Management
**FR-ISCSI-001**: System shall allow users to create iSCSI targets
- **Input**: Target name, alias
- **Output**: Created target with ID
- **Validation**: Target name uniqueness, valid IQN format

**FR-ISCSI-002**: System shall allow users to list all iSCSI targets
- **Output**: Target list with status, LUN count, initiator count

**FR-ISCSI-003**: System shall allow users to view target details
- **Output**: Target configuration, LUNs, initiators, status

**FR-ISCSI-004**: System shall allow users to delete iSCSI targets
- **Validation**: Target must not be in use

**FR-ISCSI-005**: System shall allow users to enable/disable targets
- **Input**: Target ID, enabled flag

### 2.2 LUN Management
**FR-ISCSI-006**: System shall allow users to add LUNs to targets
- **Input**: Target ID, device path, LUN number
- **Validation**: Device exists, LUN number available

**FR-ISCSI-007**: System shall allow users to remove LUNs from targets
- **Input**: Target ID, LUN ID

**FR-ISCSI-008**: System shall display LUN information
- **Output**: LUN number, device, size, status

### 2.3 Initiator Management
**FR-ISCSI-009**: System shall allow users to add initiators to targets
- **Input**: Target ID, initiator IQN
- **Validation**: Valid IQN format

**FR-ISCSI-010**: System shall allow users to remove initiators from targets
- **Input**: Target ID, initiator ID

**FR-ISCSI-011**: System shall allow users to list all initiators
- **Output**: Initiator list with associated targets

**FR-ISCSI-012**: System shall allow users to create initiator groups
- **Input**: Group name, initiator list
- **Output**: Created group with ID

**FR-ISCSI-013**: System shall allow users to manage initiator groups
- **Actions**: Create, update, delete, add/remove initiators

### 2.4 Portal Management
**FR-ISCSI-014**: System shall allow users to create portals
- **Input**: IP address, port
- **Output**: Created portal with ID

**FR-ISCSI-015**: System shall allow users to list portals
- **Output**: Portal list with IP, port, status

**FR-ISCSI-016**: System shall allow users to update portals
- **Input**: Portal ID, updated configuration

**FR-ISCSI-017**: System shall allow users to delete portals
- **Input**: Portal ID

### 2.5 Extent Management
**FR-ISCSI-018**: System shall allow users to create extents
- **Input**: Device path, size, type
- **Output**: Created extent

**FR-ISCSI-019**: System shall allow users to list extents
- **Output**: Extent list with device, size, type

**FR-ISCSI-020**: System shall allow users to delete extents
- **Input**: Extent device

### 2.6 Configuration Management
**FR-ISCSI-021**: System shall allow users to view SCST configuration file
- **Output**: Current SCST configuration

**FR-ISCSI-022**: System shall allow users to update SCST configuration file
- **Input**: Configuration content
- **Validation**: Valid SCST configuration format

**FR-ISCSI-023**: System shall allow users to apply SCST configuration
- **Action**: Reload SCST configuration
- **Side Effect**: Targets may be restarted

## 3. User Interface Requirements

### 3.1 Target List View
- Target cards with status indicators
- Quick actions (enable/disable, delete)
- Filter and search functionality

### 3.2 Target Detail View
- Overview tab (target info, status)
- LUNs tab (LUN list, add/remove)
- Initiators tab (initiator list, add/remove)
- Settings tab (target configuration)

### 3.3 Create Target Wizard
- Target name input
- Alias input
- Initial LUN assignment (optional)
- Initial initiator assignment (optional)

## 4. API Endpoints

```
GET    /api/v1/scst/targets
GET    /api/v1/scst/targets/:id
POST   /api/v1/scst/targets
DELETE /api/v1/scst/targets/:id
POST   /api/v1/scst/targets/:id/enable
POST   /api/v1/scst/targets/:id/disable

POST   /api/v1/scst/targets/:id/luns
DELETE /api/v1/scst/targets/:id/luns/:lunId

POST   /api/v1/scst/targets/:id/initiators
GET    /api/v1/scst/initiators
GET    /api/v1/scst/initiators/:id
DELETE /api/v1/scst/initiators/:id

GET    /api/v1/scst/initiator-groups
GET    /api/v1/scst/initiator-groups/:id
POST   /api/v1/scst/initiator-groups
PUT    /api/v1/scst/initiator-groups/:id
DELETE /api/v1/scst/initiator-groups/:id
POST   /api/v1/scst/initiator-groups/:id/initiators

GET    /api/v1/scst/portals
GET    /api/v1/scst/portals/:id
POST   /api/v1/scst/portals
PUT    /api/v1/scst/portals/:id
DELETE /api/v1/scst/portals/:id

GET    /api/v1/scst/extents
POST   /api/v1/scst/extents
DELETE /api/v1/scst/extents/:device

GET    /api/v1/scst/config/file
PUT    /api/v1/scst/config/file
POST   /api/v1/scst/config/apply

GET    /api/v1/scst/handlers
```

## 5. Permissions
- **iscsi:read**: Required for viewing targets, initiators, portals
- **iscsi:write**: Required for creating, updating, deleting

## 6. Error Handling
- Invalid IQN format
- Target name already exists
- Device not available
- SCST configuration errors
- Insufficient permissions

