Skip to content
Snippets Groups Projects
Commit 67b365ec authored by kbeyro's avatar kbeyro
Browse files

cluster delete function

parent 303e8fe6
No related branches found
No related tags found
1 merge request!210Fix dashboard issue
......@@ -331,4 +331,16 @@ public class RemoteClusterManager implements ClusterMonitoringService {
return Files.exists(path) && Files.isRegularFile(path) && Files.isReadable(path);
}
public void removeCluster(Long id) {
try {
if(clusterRepository.existsById(id)) {
this.clusterRepository.deleteById(id);
}
} catch (RuntimeException ex) {
log.warn("Can not delete cluster {}", id);
log.error("Exception: {}", ex.getMessage());
}
}
}
\ No newline at end of file
......@@ -6,7 +6,9 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.geant.nmaas.externalservices.kubernetes.RemoteClusterManager;
import net.geant.nmaas.externalservices.kubernetes.api.model.RemoteClusterView;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -58,4 +60,10 @@ public class RemoteClusterManagerController {
return remoteClusterManager.updateCluster(view, id);
}
@PreAuthorize("hasRole('ROLE_SYSTEM_ADMIN') || hasRole('ROLE_OPERATOR')")
@DeleteMapping("/{id}")
public void deleteCluster(@PathVariable Long id) {
remoteClusterManager.removeCluster(id);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment