-
Notifications
You must be signed in to change notification settings - Fork 18
/
openbsd.ts
99 lines (81 loc) · 2.48 KB
/
openbsd.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import * as fs from 'fs'
import * as path from 'path'
import * as core from '@actions/core'
import * as architecture from '../../architecture'
import * as action from '../../action/action'
import {operatingSystem} from '../factory'
import * as vmModule from '../../vm'
import {host} from '../../host'
import {QemuVm} from './qemu_vm'
import * as os from '../../operating_system'
import versions from '../../version'
import {XhyveVm} from './xhyve_vm'
import {Input} from '../../action/input'
@operatingSystem
export default class OpenBsd extends os.OperatingSystem {
constructor(arch: architecture.Architecture, version: string) {
super(arch, version)
}
get hypervisorUrl(): string {
return this.hypervisor.getResourceUrl(this.architecture)
}
get ssHostPort(): number {
return this.hypervisor.sshPort
}
get actionImplementationKind(): action.SshConfigurationKind {
const defaultKind = action.SshConfigurationKind.qemu
const archResult = this.architecture.resolve({
x86_64: action.SshConfigurationKind.xhyve,
default: defaultKind
})
const result = host.hypervisor.resolve({
xhyve: archResult,
default: defaultKind
})
core.debug(
`actionImplementationKind result: ${action.SshConfigurationKind[result]}`
)
return result
}
override async prepareDisk(
diskImage: fs.PathLike,
targetDiskName: fs.PathLike,
resourcesDirectory: fs.PathLike
): Promise<void> {
await os.convertToRawDisk(diskImage, targetDiskName, resourcesDirectory)
}
get virtualMachineImageReleaseVersion(): string {
return versions.operating_system.openbsd
}
createVirtualMachine(
hypervisorDirectory: fs.PathLike,
resourcesDirectory: fs.PathLike,
firmwareDirectory: fs.PathLike,
input: Input,
configuration: os.VmConfiguration
): vmModule.Vm {
core.debug('Creating OpenBSD VM')
const config: vmModule.Configuration = {
...configuration,
ssHostPort: this.ssHostPort,
firmware: path.join(
firmwareDirectory.toString(),
this.architecture.efiHypervisor.firmwareFile
),
// qemu
cpu: this.architecture.cpu,
accelerator: this.architecture.accelerator,
machineType: this.architecture.machineType,
// xhyve
uuid: this.uuid
}
const cls = host.hypervisor.resolve({qemu: QemuVm, xhyve: XhyveVm})
return new cls(
hypervisorDirectory,
resourcesDirectory,
this.architecture,
input,
config
)
}
}