ROBO Example: Backup BE code
[ealt-edge.git] / example-apps / ROBO / backup_BE / src / main / java / org / edgegallery / example_app / service / restoreService.java
1 package org.edgegallery.example_app.service;
2
3 import java.util.ArrayList;
4 import java.util.List;
5 import org.edgegallery.example_app.model.EALTEdgeBackup;
6 import org.edgegallery.example_app.model.EALTEdgeRestore;
7 import org.edgegallery.example_app.util.ShellCommand;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.stereotype.Service;
10
11 @Service
12 public class restoreService {
13
14     @Autowired
15     ShellCommand shellCommand;
16
17     public String create_restore(String restorename, String backupname) {
18         String command = "velero restore create " + restorename + " --from-backup " + backupname;
19
20         String output = shellCommand.executeCommand(command);
21
22         System.out.println(output);
23         return "success";
24     }
25
26     public List<EALTEdgeRestore> getRestoreTables() {
27         EALTEdgeRestore restoreDetails = new EALTEdgeRestore();
28         String command = "velero get restores";
29
30         String output = shellCommand.executeCommand(command);
31
32         //System.out.println(output);
33         List<EALTEdgeRestore> restoresList = new ArrayList<EALTEdgeRestore>();
34
35         String list = shellCommand.parseResult(output);
36
37         //TODO: after parse the result, need to fill info in backup node in list
38         restoreDetails.setName("restore1");
39
40         restoresList.add(restoreDetails);
41         return restoresList;
42     }
43 }