@inkeep/impulse-compute 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -2
- package/dist/impulse-compute.mjs +1426 -0
- package/dist/internal/launch.js +34 -0
- package/guest/windows/end-of-life.ps1 +15 -0
- package/guest/windows/extend.ps1 +24 -0
- package/guest/windows/lib.ps1 +22 -0
- package/guest/windows/prepare-ssh.ps1 +15 -0
- package/guest/windows/read-host-key.ps1 +2 -0
- package/guest/windows/read-task.ps1 +8 -0
- package/guest/windows/ssh-bootstrap.ps1 +24 -0
- package/package.json +34 -3
- package/team-mac/host-claim.sh +23 -0
- package/team-mac/host-hold-check.sh +23 -0
- package/team-mac/host-hold-read.sh +17 -0
- package/team-mac/host-hold.sh +88 -0
- package/team-mac/host-prepare.sh +158 -0
- package/team-mac/vm-list.sh +38 -0
- package/team-mac/vm-start.sh +278 -0
- package/team-mac/vm-stop.sh +137 -0
- package/team-mac/vz-start-probe.swift +60 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Virtualization
|
|
3
|
+
|
|
4
|
+
let dir = URL(fileURLWithPath: CommandLine.arguments[1])
|
|
5
|
+
guard let raw = try? Data(contentsOf: dir.appendingPathComponent("config.json")),
|
|
6
|
+
let cfg = try? JSONSerialization.jsonObject(with: raw) as? [String: Any],
|
|
7
|
+
let hmText = cfg["hardwareModel"] as? String, let hmData = Data(base64Encoded: hmText),
|
|
8
|
+
let midText = cfg["machineIdentifier"] as? String, let midData = Data(base64Encoded: midText),
|
|
9
|
+
let hm = VZMacHardwareModel(dataRepresentation: hmData),
|
|
10
|
+
let mid = VZMacMachineIdentifier(dataRepresentation: midData),
|
|
11
|
+
let cpus = cfg["cpuCount"] as? NSNumber, let mem = cfg["memorySize"] as? NSNumber
|
|
12
|
+
else {
|
|
13
|
+
print("PROBE: unreadable config")
|
|
14
|
+
exit(2)
|
|
15
|
+
}
|
|
16
|
+
let platform = VZMacPlatformConfiguration()
|
|
17
|
+
platform.hardwareModel = hm
|
|
18
|
+
platform.machineIdentifier = mid
|
|
19
|
+
platform.auxiliaryStorage = VZMacAuxiliaryStorage(contentsOf: dir.appendingPathComponent("nvram.bin"))
|
|
20
|
+
let config = VZVirtualMachineConfiguration()
|
|
21
|
+
config.platform = platform
|
|
22
|
+
config.bootLoader = VZMacOSBootLoader()
|
|
23
|
+
config.cpuCount = cpus.intValue
|
|
24
|
+
config.memorySize = mem.uint64Value
|
|
25
|
+
guard let disk = try? VZDiskImageStorageDeviceAttachment(url: dir.appendingPathComponent("disk.img"), readOnly: false) else {
|
|
26
|
+
print("PROBE: unreadable disk")
|
|
27
|
+
exit(2)
|
|
28
|
+
}
|
|
29
|
+
config.storageDevices = [VZVirtioBlockDeviceConfiguration(attachment: disk)]
|
|
30
|
+
let graphics = VZMacGraphicsDeviceConfiguration()
|
|
31
|
+
graphics.displays = [VZMacGraphicsDisplayConfiguration(widthInPixels: 1024, heightInPixels: 768, pixelsPerInch: 80)]
|
|
32
|
+
config.graphicsDevices = [graphics]
|
|
33
|
+
do {
|
|
34
|
+
try config.validate()
|
|
35
|
+
} catch {
|
|
36
|
+
let e = error as NSError
|
|
37
|
+
print("PROBE: validate failed domain=\(e.domain) code=\(e.code) desc=\(e.localizedDescription)")
|
|
38
|
+
exit(3)
|
|
39
|
+
}
|
|
40
|
+
let vm = VZVirtualMachine(configuration: config)
|
|
41
|
+
let began = Date()
|
|
42
|
+
vm.start { result in
|
|
43
|
+
switch result {
|
|
44
|
+
case .success:
|
|
45
|
+
print("PROBE: started after \(Date().timeIntervalSince(began)) s, state=\(vm.state.rawValue); stopping")
|
|
46
|
+
vm.stop { stopError in
|
|
47
|
+
if let s = stopError as NSError? { print("PROBE: stop error domain=\(s.domain) code=\(s.code)") } else { print("PROBE: stopped") }
|
|
48
|
+
exit(0)
|
|
49
|
+
}
|
|
50
|
+
case .failure(let error):
|
|
51
|
+
let e = error as NSError
|
|
52
|
+
print("PROBE: start failed after \(Date().timeIntervalSince(began)) s domain=\(e.domain) code=\(e.code) desc=\(e.localizedDescription)")
|
|
53
|
+
exit(1)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 60) {
|
|
57
|
+
print("PROBE: no completion within 60 s")
|
|
58
|
+
exit(4)
|
|
59
|
+
}
|
|
60
|
+
dispatchMain()
|