MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / getInstancesByUuid

Function getInstancesByUuid

panel/src/app/service/instance_service.ts:69–149  ·  view source on GitHub ↗
(
  uuid: string,
  targetDaemonId?: string,
  advanced: boolean = false
)

Source from the content-addressed store, hash-verified

67}
68
69export async function getInstancesByUuid(
70 uuid: string,
71 targetDaemonId?: string,
72 advanced: boolean = false
73) {
74 const user = userSystem.getInstance(uuid);
75 if (!user) throw new Error("The UID does not exist");
76
77 // Advanced functions are optional, analyze each instance data
78 let resInstances: IAdvancedInstanceInfo[] = [];
79 if (advanced) {
80 const instances = user.instances;
81 for (const iterator of instances) {
82 if (targetDaemonId && targetDaemonId !== iterator.daemonId) continue;
83 const remoteService = RemoteServiceSubsystem.getInstance(iterator.daemonId);
84 if (!remoteService || !remoteService.available) {
85 // If the remote service doesn't exist at all, load a deleted prompt
86 resInstances.push({
87 hostIp: "-- Unknown --",
88 instanceUuid: iterator.instanceUuid,
89 daemonId: iterator.daemonId,
90 status: -1,
91 nickname: "-- Unknown --",
92 remarks: "",
93 ie: "",
94 oe: "",
95 endTime: 0,
96 lastDatetime: 0,
97 stopCommand: "",
98 processType: "",
99 docker: {},
100 info: {}
101 });
102 continue;
103 }
104 // Note: UUID can be integrated here to save the returned traffic, and this optimization will not be done for the time being
105 try {
106 let instancesInfo = await new RemoteRequest(remoteService).request("instance/section", {
107 instanceUuids: [iterator.instanceUuid]
108 });
109 if (!instancesInfo || instancesInfo.length === 0) continue;
110 instancesInfo = instancesInfo[0];
111 resInstances.push({
112 hostIp: `${remoteService.config.ip}:${remoteService.config.port}`,
113 remarks: remoteService.config.remarks,
114 instanceUuid: instancesInfo.instanceUuid,
115 daemonId: remoteService.uuid,
116 status: instancesInfo.status,
117 nickname: instancesInfo.config.nickname,
118 ie: instancesInfo.config.ie,
119 oe: instancesInfo.config.oe,
120 endTime: instancesInfo.config.endTime,
121 lastDatetime: instancesInfo.config.lastDatetime,
122 stopCommand: instancesInfo.config.stopCommand,
123 processType: instancesInfo.config.processType,
124 docker: instancesInfo.config.docker || {},
125 info: instancesInfo.info || {}
126 });

Callers 2

queryInstanceByUserIdFunction · 0.90

Calls 3

requestMethod · 0.80
getInstanceMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected