fix storage management and nfs
Some checks failed
CI / test-build (push) Has been cancelled
CI / test-build (pull_request) Has been cancelled

This commit is contained in:
2025-12-20 12:41:50 +00:00
parent 3a25138d5b
commit 45aaec9e47
5 changed files with 595 additions and 77 deletions

View File

@@ -958,6 +958,41 @@ func (s *Service) DestroyDataset(name string, recursive bool) error {
return nil
}
// UpdateDataset updates ZFS dataset properties
func (s *Service) UpdateDataset(name string, quota string, compression string, options map[string]string) error {
// Update quota if provided
if quota != "" {
quotaValue := quota
if quota == "none" || quota == "0" {
quotaValue = "none"
}
args := []string{"set", fmt.Sprintf("quota=%s", quotaValue), name}
if _, err := s.execCommand(s.zfsPath, args...); err != nil {
return translateZFSError(err, "mengupdate quota dataset", name)
}
}
// Update compression if provided
if compression != "" {
args := []string{"set", fmt.Sprintf("compression=%s", compression), name}
if _, err := s.execCommand(s.zfsPath, args...); err != nil {
return translateZFSError(err, "mengupdate compression dataset", name)
}
}
// Update other options if provided
if options != nil {
for key, value := range options {
args := []string{"set", fmt.Sprintf("%s=%s", key, value), name}
if _, err := s.execCommand(s.zfsPath, args...); err != nil {
return translateZFSError(err, fmt.Sprintf("mengupdate property %s dataset", key), name)
}
}
}
return nil
}
// ListZVOLs returns all ZVOLs
func (s *Service) ListZVOLs(pool string) ([]models.ZVOL, error) {
args := []string{"list", "-H", "-o", "name,volsize,used", "-t", "volume"}