add storage service
Some checks failed
CI / test-build (push) Failing after 2m4s

This commit is contained in:
2025-12-15 00:01:05 +07:00
parent 54e76d9304
commit 7c33e736f9
6 changed files with 768 additions and 0 deletions

View File

@@ -517,6 +517,14 @@ func (a *App) handleCreateSMBShare(w http.ResponseWriter, r *http.Request) {
return
}
// Apply configuration to Samba service
shares := a.smbStore.List()
if err := a.smbService.ApplyConfiguration(shares); err != nil {
log.Printf("apply SMB configuration error: %v", err)
// Don't fail the request, but log the error
// In production, you might want to queue this for retry
}
writeJSON(w, http.StatusCreated, share)
}
@@ -571,6 +579,13 @@ func (a *App) handleUpdateSMBShare(w http.ResponseWriter, r *http.Request) {
}
share, _ := a.smbStore.Get(id)
// Apply configuration to Samba service
shares := a.smbStore.List()
if err := a.smbService.ApplyConfiguration(shares); err != nil {
log.Printf("apply SMB configuration error: %v", err)
}
writeJSON(w, http.StatusOK, share)
}
@@ -659,6 +674,12 @@ func (a *App) handleCreateNFSExport(w http.ResponseWriter, r *http.Request) {
return
}
// Apply configuration to NFS service
exports := a.nfsStore.List()
if err := a.nfsService.ApplyConfiguration(exports); err != nil {
log.Printf("apply NFS configuration error: %v", err)
}
writeJSON(w, http.StatusCreated, export)
}
@@ -712,6 +733,13 @@ func (a *App) handleUpdateNFSExport(w http.ResponseWriter, r *http.Request) {
}
export, _ := a.nfsStore.Get(id)
// Apply configuration to NFS service
exports := a.nfsStore.List()
if err := a.nfsService.ApplyConfiguration(exports); err != nil {
log.Printf("apply NFS configuration error: %v", err)
}
writeJSON(w, http.StatusOK, export)
}
@@ -732,6 +760,12 @@ func (a *App) handleDeleteNFSExport(w http.ResponseWriter, r *http.Request) {
return
}
// Apply configuration to NFS service
exports := a.nfsStore.List()
if err := a.nfsService.ApplyConfiguration(exports); err != nil {
log.Printf("apply NFS configuration error: %v", err)
}
writeJSON(w, http.StatusOK, map[string]string{"message": "export deleted", "id": id})
}
@@ -774,6 +808,12 @@ func (a *App) handleCreateISCSITarget(w http.ResponseWriter, r *http.Request) {
return
}
// Apply configuration to iSCSI service
targets := a.iscsiStore.List()
if err := a.iscsiService.ApplyConfiguration(targets); err != nil {
log.Printf("apply iSCSI configuration error: %v", err)
}
writeJSON(w, http.StatusCreated, target)
}
@@ -825,6 +865,13 @@ func (a *App) handleUpdateISCSITarget(w http.ResponseWriter, r *http.Request) {
}
target, _ := a.iscsiStore.Get(id)
// Apply configuration to iSCSI service
targets := a.iscsiStore.List()
if err := a.iscsiService.ApplyConfiguration(targets); err != nil {
log.Printf("apply iSCSI configuration error: %v", err)
}
writeJSON(w, http.StatusOK, target)
}
@@ -845,6 +892,12 @@ func (a *App) handleDeleteISCSITarget(w http.ResponseWriter, r *http.Request) {
return
}
// Apply configuration to iSCSI service
targets := a.iscsiStore.List()
if err := a.iscsiService.ApplyConfiguration(targets); err != nil {
log.Printf("apply iSCSI configuration error: %v", err)
}
writeJSON(w, http.StatusOK, map[string]string{"message": "target deleted", "id": id})
}
@@ -910,6 +963,12 @@ func (a *App) handleAddLUN(w http.ResponseWriter, r *http.Request) {
return
}
// Apply configuration to iSCSI service
targets := a.iscsiStore.List()
if err := a.iscsiService.ApplyConfiguration(targets); err != nil {
log.Printf("apply iSCSI configuration error: %v", err)
}
writeJSON(w, http.StatusCreated, lun)
}
@@ -946,6 +1005,12 @@ func (a *App) handleRemoveLUN(w http.ResponseWriter, r *http.Request) {
return
}
// Apply configuration to iSCSI service
targets := a.iscsiStore.List()
if err := a.iscsiService.ApplyConfiguration(targets); err != nil {
log.Printf("apply iSCSI configuration error: %v", err)
}
writeJSON(w, http.StatusOK, map[string]string{"message": "LUN removed", "target_id": id, "lun_id": strconv.Itoa(req.LUNID)})
}