feat: implement cmd management for targets, LUNs, and TPGTs (fixes #36)

- Fix target delete URL path mismatch (/targets/ -> /target/)
- Implement target create/delete server handlers with proper validation
- Add DeleteTarget method with force flag and mutex locking to SCSITargetService
- Implement full LU management: create/list/delete through CLI, client, and server
- Add TPGT list command to show target portal group tags
- Add unit tests for target/LU router handlers and SCSI service

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lei Xue
2026-03-14 20:30:47 +08:00
parent bbd373ba0e
commit 93e1476a0f
16 changed files with 760 additions and 36 deletions

25
pkg/api/client/lu_list.go Normal file
View File

@@ -0,0 +1,25 @@
package client
import (
"encoding/json"
"net/url"
"github.com/gostor/gotgt/pkg/api"
"golang.org/x/net/context"
)
// LuList lists LUs for a target in the SCSI Target.
func (cli *Client) LuList(ctx context.Context, options api.LuListOptions) ([]api.LuInfo, error) {
var lus []api.LuInfo
query := url.Values{}
if options.TargetName != "" {
query.Set("target", options.TargetName)
}
resp, err := cli.get(ctx, "/lu/list", query, nil)
if err != nil {
return lus, err
}
err = json.NewDecoder(resp.body).Decode(&lus)
ensureReaderClosed(resp)
return lus, err
}