proxmox-sdk 0.0.1 → 0.0.3
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/package.json +1 -1
- package/dist/src/http-proxmox.repository.js +0 -336
- package/dist/src/proxmox.provider.js +0 -23
- package/dist/src/tools/encode-ssh-key.js +0 -7
- package/dist/src/types/clone-qemu-machine.js +0 -2
- package/dist/src/types/create-qemu-machine.js +0 -2
- package/dist/src/types/delete-qemu-machine.js +0 -2
- package/dist/src/types/download-iso-image.js +0 -2
- package/dist/src/types/index.js +0 -26
- package/dist/src/types/ip.js +0 -2
- package/dist/src/types/list-qemu-machines.js +0 -2
- package/dist/src/types/start-qemu-machine.js +0 -2
- package/dist/src/types/stop-qemu-machine.js +0 -2
- package/dist/src/types/update-qemu-machine.js +0 -2
- package/dist/src/types/upid.js +0 -2
- package/index.ts +0 -2
- package/src/http-proxmox.repository.ts +0 -362
- package/src/tools/encode-ssh-key.ts +0 -3
- package/src/types/clone-qemu-machine.ts +0 -6
- package/src/types/create-qemu-machine.ts +0 -149
- package/src/types/delete-qemu-machine.ts +0 -26
- package/src/types/download-iso-image.ts +0 -23
- package/src/types/index.ts +0 -10
- package/src/types/ip.ts +0 -1
- package/src/types/list-qemu-machines.ts +0 -39
- package/src/types/start-qemu-machine.ts +0 -5
- package/src/types/stop-qemu-machine.ts +0 -5
- package/src/types/update-qemu-machine.ts +0 -205
- package/src/types/upid.ts +0 -1
- package/tsconfig.json +0 -11
package/package.json
CHANGED
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.HttpProxmoxRepository = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const encode_ssh_key_1 = require("./tools/encode-ssh-key");
|
|
18
|
-
// authorize self signed cert if you do not use a valid SSL certificat
|
|
19
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
20
|
-
// https://pve.proxmox.com/wiki/Proxmox_VE_API#Authentication
|
|
21
|
-
class HttpProxmoxRepository {
|
|
22
|
-
constructor(parameters, logger) {
|
|
23
|
-
this.parameters = parameters;
|
|
24
|
-
this.logger = logger;
|
|
25
|
-
}
|
|
26
|
-
getProxmoxVersion() {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
let data;
|
|
29
|
-
try {
|
|
30
|
-
data = yield (0, axios_1.default)({
|
|
31
|
-
url: this.computeUrl("/api2/json/version"),
|
|
32
|
-
headers: yield this.prepareHeaders(),
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
console.log(err);
|
|
37
|
-
}
|
|
38
|
-
return data.data.data.version;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
listQemuMachines(node) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
let data;
|
|
44
|
-
try {
|
|
45
|
-
data = yield (0, axios_1.default)({
|
|
46
|
-
url: this.computeUrl(`/api2/json/nodes/${node}/qemu`),
|
|
47
|
-
headers: yield this.prepareHeaders(),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
console.log(err);
|
|
52
|
-
}
|
|
53
|
-
return data.data.data;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
getQemuMachineVlanTag(node, vmid) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
let data;
|
|
59
|
-
try {
|
|
60
|
-
data = yield (0, axios_1.default)({
|
|
61
|
-
url: this.computeUrl(`/api2/json/nodes/${node}/qemu/${vmid}/config`),
|
|
62
|
-
headers: yield this.prepareHeaders(),
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
this.logger.error(err);
|
|
67
|
-
return 1;
|
|
68
|
-
}
|
|
69
|
-
const tag = data.data.data.net0.split(",").find((e) => e.startsWith("tag"));
|
|
70
|
-
if (tag) {
|
|
71
|
-
return parseInt(tag.split("=").at(1), 10);
|
|
72
|
-
}
|
|
73
|
-
return 1;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
listQemuMachineIps(node, vmid) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
var _a;
|
|
79
|
-
let data;
|
|
80
|
-
try {
|
|
81
|
-
data = yield (0, axios_1.default)({
|
|
82
|
-
url: this.computeUrl(`/api2/json/nodes/${node}/qemu/${vmid}/agent/network-get-interfaces`),
|
|
83
|
-
headers: yield this.prepareHeaders(),
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
this.logger.error(err);
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
const payload = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
91
|
-
console.log(payload);
|
|
92
|
-
const answer = payload.result
|
|
93
|
-
.map(eth => eth["ip-addresses"]
|
|
94
|
-
.filter(ip => ip["ip-address-type"] === "ipv4")
|
|
95
|
-
.map(ip => ip["ip-address"]))
|
|
96
|
-
.flat()
|
|
97
|
-
.filter(ip => !["127.0.0.1"].includes(ip));
|
|
98
|
-
return answer;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
createQemuMachine(payload) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
var _a;
|
|
104
|
-
let data;
|
|
105
|
-
// According to this answer https://forum.proxmox.com/threads/can-not-create-vm-with-qcow2-format.114881/post-496759
|
|
106
|
-
// when your Proxmox uses a local-lvm, the logical block storage does not support qcow2, only raw.
|
|
107
|
-
const FORMAT = payload.localStorageName === "local" ? "qcow2" : "raw";
|
|
108
|
-
const proxmoxPayload = {
|
|
109
|
-
autostart: payload.autostart,
|
|
110
|
-
bios: payload.bios,
|
|
111
|
-
cores: payload.coreCount,
|
|
112
|
-
efidisk0: `${payload.localStorageName}:1,efitype=4m,pre-enrolled-keys=1,format=${FORMAT}`,
|
|
113
|
-
memory: payload.memory,
|
|
114
|
-
name: payload.name,
|
|
115
|
-
net0: "virtio,bridge=vmbr0,firewall=1,vlanid=10",
|
|
116
|
-
node: payload.node,
|
|
117
|
-
numa: 0,
|
|
118
|
-
ostype: payload.ostype,
|
|
119
|
-
scsi0: `${payload.localStorageName}:32,format=${FORMAT},iothread=on`,
|
|
120
|
-
scsihw: "virtio-scsi-single",
|
|
121
|
-
sockets: 1,
|
|
122
|
-
vmid: payload.vmid,
|
|
123
|
-
};
|
|
124
|
-
if (payload.isoName) {
|
|
125
|
-
proxmoxPayload.scsi2 = `${payload.localStorageName}:iso/${payload.isoName},media=cdrom`;
|
|
126
|
-
}
|
|
127
|
-
try {
|
|
128
|
-
data = yield (0, axios_1.default)({
|
|
129
|
-
data: proxmoxPayload,
|
|
130
|
-
headers: yield this.prepareHeaders(),
|
|
131
|
-
method: "POST",
|
|
132
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu`),
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
catch (err) {
|
|
136
|
-
this.logger.error({ status: err.response.status, vmid: payload.vmid, errors: err.response.data.errors }, err.response.statusText);
|
|
137
|
-
}
|
|
138
|
-
return (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
updateQemuMachine(payload) {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
var _a, _b;
|
|
144
|
-
let data;
|
|
145
|
-
// @ts-ignore
|
|
146
|
-
const proxmoxPayload = {
|
|
147
|
-
cores: payload.coreCount,
|
|
148
|
-
memory: payload.memory,
|
|
149
|
-
name: payload.name,
|
|
150
|
-
tags: payload.tags,
|
|
151
|
-
ipconfig0: "ip=dhcp",
|
|
152
|
-
// ide2: `local:${payload.vmid}/vm-${payload.vmid}-cloudinit.qcow2,media=cdrom`,
|
|
153
|
-
// overridenUsername: "toto",
|
|
154
|
-
// overridenPassword: "toto",
|
|
155
|
-
ciuser: payload.overridenUser,
|
|
156
|
-
cipassword: payload.overridenPassword,
|
|
157
|
-
};
|
|
158
|
-
if (payload.sshkey) {
|
|
159
|
-
proxmoxPayload.sshkeys = (0, encode_ssh_key_1.encodeSSHKey)(payload.sshkey);
|
|
160
|
-
}
|
|
161
|
-
if ((_a = payload.networks) === null || _a === void 0 ? void 0 : _a[0]) {
|
|
162
|
-
proxmoxPayload.net0 = `model=${payload.networks[0].model},bridge=${payload.networks[0].bridge},firewall=${payload.networks[0].firewall}`;
|
|
163
|
-
if (payload.networks[0].tag) {
|
|
164
|
-
proxmoxPayload.net0 += `,tag=${payload.networks[0].tag}`;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
try {
|
|
168
|
-
data = yield (0, axios_1.default)({
|
|
169
|
-
data: proxmoxPayload,
|
|
170
|
-
headers: yield this.prepareHeaders(),
|
|
171
|
-
method: "PUT",
|
|
172
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/config`),
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
catch (err) {
|
|
176
|
-
this.logger.error({ status: err.response.status, vmid: payload.vmid, errors: err.response.data.errors }, err.response.statusText);
|
|
177
|
-
}
|
|
178
|
-
return (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.data;
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
deleteQemuMachine(port) {
|
|
182
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
var _a;
|
|
184
|
-
let data;
|
|
185
|
-
try {
|
|
186
|
-
data = yield (0, axios_1.default)({
|
|
187
|
-
headers: yield this.prepareHeaders(),
|
|
188
|
-
method: "DELETE",
|
|
189
|
-
url: this.computeUrl(`/api2/json/nodes/${port.node}/qemu/${port.vmid}`),
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
catch (err) {
|
|
193
|
-
this.logger.error({ status: err.response.status, vmid: port.vmid, errors: err.response.data.errors }, err.response.statusText);
|
|
194
|
-
}
|
|
195
|
-
const payload = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
196
|
-
return payload;
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
downloadISOImage(payload) {
|
|
200
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
var _a;
|
|
202
|
-
const params = new URLSearchParams({
|
|
203
|
-
url: payload.url,
|
|
204
|
-
content: payload.content,
|
|
205
|
-
filename: payload.filename,
|
|
206
|
-
});
|
|
207
|
-
let data;
|
|
208
|
-
try {
|
|
209
|
-
data = yield (0, axios_1.default)({
|
|
210
|
-
headers: yield this.prepareHeaders(),
|
|
211
|
-
method: "POST",
|
|
212
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/storage/${payload.storage}/download-url?${params.toString()}`),
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
catch (err) {
|
|
216
|
-
this.logger.error(Object.assign(Object.assign({ status: err.response.status }, payload), { errors: err.response.data.errors }), err.response.statusText);
|
|
217
|
-
}
|
|
218
|
-
return (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
startQemuMachine(payload) {
|
|
222
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
-
var _a;
|
|
224
|
-
let data;
|
|
225
|
-
try {
|
|
226
|
-
data = yield (0, axios_1.default)({
|
|
227
|
-
method: "POST",
|
|
228
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/status/start`),
|
|
229
|
-
headers: yield this.prepareHeaders(),
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
catch (err) {
|
|
233
|
-
this.logger.error(Object.assign(Object.assign({ status: err.response.status }, payload), { errors: err.response.data.errors }), err.response.statusText);
|
|
234
|
-
}
|
|
235
|
-
return (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
stopQemuMachine(payload) {
|
|
239
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
-
var _a;
|
|
241
|
-
let data;
|
|
242
|
-
try {
|
|
243
|
-
data = yield (0, axios_1.default)({
|
|
244
|
-
method: "POST",
|
|
245
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/status/stop`),
|
|
246
|
-
headers: yield this.prepareHeaders(),
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
catch (err) {
|
|
250
|
-
this.logger.error(Object.assign(Object.assign({ status: err.response.status }, payload), { errors: err.response.data.errors }), err.response.statusText);
|
|
251
|
-
}
|
|
252
|
-
return (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
cloneQemuMarchine(payload) {
|
|
256
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
-
var _a;
|
|
258
|
-
let data;
|
|
259
|
-
try {
|
|
260
|
-
data = yield (0, axios_1.default)({
|
|
261
|
-
method: "POST",
|
|
262
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/clone`),
|
|
263
|
-
headers: Object.assign({}, yield this.prepareHeaders()),
|
|
264
|
-
data: {
|
|
265
|
-
full: 1,
|
|
266
|
-
name: "azdzfaef2233",
|
|
267
|
-
newid: payload.newid,
|
|
268
|
-
target: payload.node,
|
|
269
|
-
},
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
catch (err) {
|
|
273
|
-
this.logger.error(Object.assign(Object.assign({ status: err.response.status }, payload), { errors: err.response.data.errors }), err.response.statusText);
|
|
274
|
-
}
|
|
275
|
-
return (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
resizeDisk(payload) {
|
|
279
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
280
|
-
var _a;
|
|
281
|
-
let data;
|
|
282
|
-
try {
|
|
283
|
-
data = yield (0, axios_1.default)({
|
|
284
|
-
method: "PUT",
|
|
285
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/resize`),
|
|
286
|
-
headers: yield this.prepareHeaders(),
|
|
287
|
-
data: {
|
|
288
|
-
disk: payload.disk,
|
|
289
|
-
size: `+${payload.size}G`
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
catch (err) {
|
|
294
|
-
this.logger.error(Object.assign(Object.assign({ status: err.response.status }, payload), { errors: err.response.data.errors }), err.response.statusText);
|
|
295
|
-
}
|
|
296
|
-
return (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
computeUrl(path) {
|
|
300
|
-
return `${this.parameters.host}${path}`;
|
|
301
|
-
}
|
|
302
|
-
prepareHeaders() {
|
|
303
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
304
|
-
const ticket = yield this.getTicket();
|
|
305
|
-
return {
|
|
306
|
-
CSRFPreventionToken: ticket.CSRFPreventionToken,
|
|
307
|
-
Cookie: `PVEAuthCookie=${ticket.ticket}`,
|
|
308
|
-
};
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
getTicket() {
|
|
312
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
-
const params = new URLSearchParams({
|
|
314
|
-
username: this.parameters.username,
|
|
315
|
-
password: this.parameters.password,
|
|
316
|
-
});
|
|
317
|
-
let data;
|
|
318
|
-
try {
|
|
319
|
-
const url = this.computeUrl(`/api2/json/access/ticket?${params.toString()}`);
|
|
320
|
-
({ data } = yield (0, axios_1.default)({
|
|
321
|
-
url,
|
|
322
|
-
method: "POST",
|
|
323
|
-
headers: {
|
|
324
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
325
|
-
},
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
catch (err) {
|
|
329
|
-
console.log(err.response.status);
|
|
330
|
-
console.log(err.response.statusText);
|
|
331
|
-
}
|
|
332
|
-
return data.data;
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
exports.HttpProxmoxRepository = HttpProxmoxRepository;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ProxmoxProvider = void 0;
|
|
7
|
-
const config_1 = __importDefault(require("config"));
|
|
8
|
-
const nestjs_pino_1 = require("nestjs-pino");
|
|
9
|
-
const constants_1 = require("../../common/constants");
|
|
10
|
-
const http_proxmox_repository_1 = require("./http-proxmox.repository");
|
|
11
|
-
exports.ProxmoxProvider = {
|
|
12
|
-
provide: constants_1.PROXMOX_PROVIDER,
|
|
13
|
-
useFactory: (logger) => {
|
|
14
|
-
console.log(config_1.default.get('services.proxmox.weidian'));
|
|
15
|
-
const configuration = {
|
|
16
|
-
username: config_1.default.get("services.proxmox.weidian.username"),
|
|
17
|
-
password: config_1.default.get("services.proxmox.weidian.password"),
|
|
18
|
-
host: config_1.default.get("services.proxmox.weidian.url"),
|
|
19
|
-
};
|
|
20
|
-
return new http_proxmox_repository_1.HttpProxmoxRepository(configuration, logger);
|
|
21
|
-
},
|
|
22
|
-
inject: [nestjs_pino_1.Logger],
|
|
23
|
-
};
|
package/dist/src/types/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./clone-qemu-machine"), exports);
|
|
18
|
-
__exportStar(require("./create-qemu-machine"), exports);
|
|
19
|
-
__exportStar(require("./delete-qemu-machine"), exports);
|
|
20
|
-
__exportStar(require("./download-iso-image"), exports);
|
|
21
|
-
__exportStar(require("./index"), exports);
|
|
22
|
-
__exportStar(require("./ip"), exports);
|
|
23
|
-
__exportStar(require("./list-qemu-machines"), exports);
|
|
24
|
-
__exportStar(require("./start-qemu-machine"), exports);
|
|
25
|
-
__exportStar(require("./stop-qemu-machine"), exports);
|
|
26
|
-
__exportStar(require("./upid"), exports);
|
package/dist/src/types/ip.js
DELETED
package/dist/src/types/upid.js
DELETED
package/index.ts
DELETED
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { Logger } from "nestjs-pino";
|
|
3
|
-
|
|
4
|
-
import { encodeSSHKey } from "./tools/encode-ssh-key";
|
|
5
|
-
import { CloneQemuMachinePayload } from "./types/clone-qemu-machine";
|
|
6
|
-
import { CreateQemuMachinePayload, CreateQemuMachineProxmoxPayload } from "./types/create-qemu-machine";
|
|
7
|
-
import { DeleteQemuMachinePayload } from "./types/delete-qemu-machine";
|
|
8
|
-
import { DownloadIsoImagePayload } from "./types/download-iso-image";
|
|
9
|
-
import { ListQemuMachinesAnswer } from "./types/list-qemu-machines";
|
|
10
|
-
import { StartQemuMachinePayload } from "./types/start-qemu-machine";
|
|
11
|
-
import { StopQemuMachinePayload } from "./types/stop-qemu-machine";
|
|
12
|
-
import { UpdateQemuMachinePayload, UpdateQemuMachineProxmoxPayload } from "./types/update-qemu-machine";
|
|
13
|
-
import { IP } from "./types/ip";
|
|
14
|
-
import { UPID } from "./types";
|
|
15
|
-
|
|
16
|
-
export type AuthConfig = {
|
|
17
|
-
host: string;
|
|
18
|
-
password: string;
|
|
19
|
-
username: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// authorize self signed cert if you do not use a valid SSL certificat
|
|
23
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
24
|
-
|
|
25
|
-
// https://pve.proxmox.com/wiki/Proxmox_VE_API#Authentication
|
|
26
|
-
export class HttpProxmoxRepository {
|
|
27
|
-
constructor (
|
|
28
|
-
private readonly parameters: AuthConfig,
|
|
29
|
-
private readonly logger: Logger,
|
|
30
|
-
) {}
|
|
31
|
-
|
|
32
|
-
async getProxmoxVersion (): Promise<string> {
|
|
33
|
-
let data;
|
|
34
|
-
try {
|
|
35
|
-
data = await axios({
|
|
36
|
-
url: this.computeUrl("/api2/json/version"),
|
|
37
|
-
headers: await this.prepareHeaders(),
|
|
38
|
-
});
|
|
39
|
-
} catch (err) {
|
|
40
|
-
console.log(err);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return (data as unknown as any).data.data.version;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async listQemuMachines (node: string): Promise<ListQemuMachinesAnswer> {
|
|
47
|
-
let data;
|
|
48
|
-
try {
|
|
49
|
-
data = await axios({
|
|
50
|
-
url: this.computeUrl(`/api2/json/nodes/${node}/qemu`),
|
|
51
|
-
headers: await this.prepareHeaders(),
|
|
52
|
-
});
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.log(err);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return (data as unknown as any).data.data;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async getQemuMachineVlanTag (node: string, vmid: number): Promise<number> {
|
|
61
|
-
let data;
|
|
62
|
-
try {
|
|
63
|
-
data = await axios({
|
|
64
|
-
url: this.computeUrl(`/api2/json/nodes/${node}/qemu/${vmid}/config`),
|
|
65
|
-
headers: await this.prepareHeaders(),
|
|
66
|
-
});
|
|
67
|
-
} catch (err) {
|
|
68
|
-
this.logger.error(err);
|
|
69
|
-
return 1;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const tag = data.data.data.net0.split(",").find((e: string) => e.startsWith("tag"));
|
|
73
|
-
if (tag) {
|
|
74
|
-
return parseInt(tag.split("=").at(1), 10);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return 1;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async listQemuMachineIps (node: string, vmid: number): Promise<Array<IP>> {
|
|
81
|
-
let data;
|
|
82
|
-
try {
|
|
83
|
-
data = await axios({
|
|
84
|
-
url: this.computeUrl(`/api2/json/nodes/${node}/qemu/${vmid}/agent/network-get-interfaces`),
|
|
85
|
-
headers: await this.prepareHeaders(),
|
|
86
|
-
});
|
|
87
|
-
} catch (err) {
|
|
88
|
-
this.logger.error(err);
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
type PAYLOAD = {
|
|
93
|
-
result: Array<{
|
|
94
|
-
"hardware-address": string;
|
|
95
|
-
"ip-addresses": Array<{ "ip-address": IP, "ip-address-type": "ipv4"|"ipv6", prefix: number }>,
|
|
96
|
-
name: string;
|
|
97
|
-
statistics: {
|
|
98
|
-
"rx-bytes": number,
|
|
99
|
-
"rx-dropped": number,
|
|
100
|
-
"rx-errs": number,
|
|
101
|
-
"rx-packets": number,
|
|
102
|
-
"tx-bytes": number,
|
|
103
|
-
"tx-dropped": number,
|
|
104
|
-
"tx-errs": number,
|
|
105
|
-
"tx-packets": number,
|
|
106
|
-
}
|
|
107
|
-
}>
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const payload = (data as unknown as any)?.data?.data as PAYLOAD;
|
|
111
|
-
console.log(payload);
|
|
112
|
-
const answer = payload.result
|
|
113
|
-
.map(
|
|
114
|
-
eth => eth["ip-addresses"]
|
|
115
|
-
.filter(ip => ip["ip-address-type"] === "ipv4")
|
|
116
|
-
.map(ip => ip["ip-address"]),
|
|
117
|
-
)
|
|
118
|
-
.flat()
|
|
119
|
-
.filter(ip => !["127.0.0.1"].includes(ip));
|
|
120
|
-
|
|
121
|
-
return answer;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async createQemuMachine (payload: CreateQemuMachinePayload): Promise<string> {
|
|
125
|
-
let data;
|
|
126
|
-
|
|
127
|
-
// According to this answer https://forum.proxmox.com/threads/can-not-create-vm-with-qcow2-format.114881/post-496759
|
|
128
|
-
// when your Proxmox uses a local-lvm, the logical block storage does not support qcow2, only raw.
|
|
129
|
-
const FORMAT = payload.localStorageName === "local" ? "qcow2" : "raw";
|
|
130
|
-
|
|
131
|
-
const proxmoxPayload: CreateQemuMachineProxmoxPayload = {
|
|
132
|
-
autostart: payload.autostart,
|
|
133
|
-
bios: payload.bios,
|
|
134
|
-
cores: payload.coreCount,
|
|
135
|
-
efidisk0: `${payload.localStorageName}:1,efitype=4m,pre-enrolled-keys=1,format=${FORMAT}`,
|
|
136
|
-
memory: payload.memory,
|
|
137
|
-
name: payload.name,
|
|
138
|
-
net0: "virtio,bridge=vmbr0,firewall=1,vlanid=10",
|
|
139
|
-
node: payload.node,
|
|
140
|
-
numa: 0,
|
|
141
|
-
ostype: payload.ostype,
|
|
142
|
-
scsi0: `${payload.localStorageName}:32,format=${FORMAT},iothread=on`,
|
|
143
|
-
scsihw: "virtio-scsi-single",
|
|
144
|
-
sockets: 1,
|
|
145
|
-
vmid: payload.vmid,
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
if (payload.isoName) {
|
|
149
|
-
proxmoxPayload.scsi2 = `${payload.localStorageName}:iso/${payload.isoName},media=cdrom`;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
data = await axios({
|
|
154
|
-
data: proxmoxPayload,
|
|
155
|
-
headers: await this.prepareHeaders(),
|
|
156
|
-
method: "POST",
|
|
157
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu`),
|
|
158
|
-
});
|
|
159
|
-
} catch (err) {
|
|
160
|
-
this.logger.error({ status: (err as unknown as any).response.status, vmid: payload.vmid, errors: (err as unknown as any).response.data.errors }, (err as unknown as any).response.statusText);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return (data as unknown as any)?.data?.data as string;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async updateQemuMachine (payload: UpdateQemuMachinePayload): Promise<string> {
|
|
167
|
-
let data;
|
|
168
|
-
|
|
169
|
-
// @ts-ignore
|
|
170
|
-
const proxmoxPayload: UpdateQemuMachineProxmoxPayload = {
|
|
171
|
-
cores: payload.coreCount,
|
|
172
|
-
memory: payload.memory,
|
|
173
|
-
name: payload.name,
|
|
174
|
-
tags: payload.tags,
|
|
175
|
-
ipconfig0: "ip=dhcp",
|
|
176
|
-
// ide2: `local:${payload.vmid}/vm-${payload.vmid}-cloudinit.qcow2,media=cdrom`,
|
|
177
|
-
// overridenUsername: "toto",
|
|
178
|
-
// overridenPassword: "toto",
|
|
179
|
-
ciuser: payload.overridenUser,
|
|
180
|
-
cipassword: payload.overridenPassword,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
if (payload.sshkey) {
|
|
184
|
-
proxmoxPayload.sshkeys = encodeSSHKey(payload.sshkey);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (payload.networks?.[0]) {
|
|
188
|
-
proxmoxPayload.net0 = `model=${payload.networks[0].model},bridge=${payload.networks[0].bridge},firewall=${payload.networks[0].firewall}`;
|
|
189
|
-
if (payload.networks[0].tag) {
|
|
190
|
-
proxmoxPayload.net0 += `,tag=${payload.networks[0].tag}`;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
try {
|
|
195
|
-
data = await axios({
|
|
196
|
-
data: proxmoxPayload,
|
|
197
|
-
headers: await this.prepareHeaders(),
|
|
198
|
-
method: "PUT",
|
|
199
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/config`),
|
|
200
|
-
});
|
|
201
|
-
} catch (err) {
|
|
202
|
-
this.logger.error({ status: (err as unknown as any).response.status, vmid: payload.vmid, errors: (err as unknown as any).response.data.errors }, (err as unknown as any).response.statusText);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return (data as unknown as any)?.data?.data as string;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
async deleteQemuMachine (port: DeleteQemuMachinePayload): Promise<UPID> {
|
|
209
|
-
let data;
|
|
210
|
-
try {
|
|
211
|
-
data = await axios({
|
|
212
|
-
headers: await this.prepareHeaders(),
|
|
213
|
-
method: "DELETE",
|
|
214
|
-
url: this.computeUrl(`/api2/json/nodes/${port.node}/qemu/${port.vmid}`),
|
|
215
|
-
});
|
|
216
|
-
} catch (err) {
|
|
217
|
-
this.logger.error({ status: (err as unknown as any).response.status, vmid: port.vmid, errors: (err as unknown as any).response.data.errors }, (err as unknown as any).response.statusText);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const payload = (data as unknown as any)?.data?.data as UPID;
|
|
221
|
-
|
|
222
|
-
return payload;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
async downloadISOImage (payload: DownloadIsoImagePayload): Promise<string> {
|
|
226
|
-
const params = new URLSearchParams({
|
|
227
|
-
url: payload.url,
|
|
228
|
-
content: payload.content,
|
|
229
|
-
filename: payload.filename,
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
let data;
|
|
233
|
-
try {
|
|
234
|
-
data = await axios({
|
|
235
|
-
headers: await this.prepareHeaders(),
|
|
236
|
-
method: "POST",
|
|
237
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/storage/${payload.storage}/download-url?${params.toString()}`),
|
|
238
|
-
});
|
|
239
|
-
} catch (err) {
|
|
240
|
-
this.logger.error({ status: (err as unknown as any).response.status, ...payload, errors: (err as unknown as any).response.data.errors }, (err as unknown as any).response.statusText);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return (data as unknown as any)?.data?.data as string;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
async startQemuMachine (payload: StartQemuMachinePayload) {
|
|
247
|
-
let data;
|
|
248
|
-
try {
|
|
249
|
-
data = await axios({
|
|
250
|
-
method: "POST",
|
|
251
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/status/start`),
|
|
252
|
-
headers: await this.prepareHeaders(),
|
|
253
|
-
});
|
|
254
|
-
} catch (err) {
|
|
255
|
-
this.logger.error({ status: (err as unknown as any).response.status, ...payload, errors: (err as unknown as any).response.data.errors }, (err as unknown as any).response.statusText);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return (data as unknown as any)?.data?.data as string;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
async stopQemuMachine (payload: StopQemuMachinePayload) {
|
|
262
|
-
let data;
|
|
263
|
-
try {
|
|
264
|
-
data = await axios({
|
|
265
|
-
method: "POST",
|
|
266
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/status/stop`),
|
|
267
|
-
headers: await this.prepareHeaders(),
|
|
268
|
-
});
|
|
269
|
-
} catch (err) {
|
|
270
|
-
this.logger.error({ status: (err as unknown as any).response.status, ...payload, errors: (err as unknown as any).response.data.errors }, (err as unknown as any).response.statusText);
|
|
271
|
-
}
|
|
272
|
-
return (data as unknown as any)?.data?.data as string;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
async cloneQemuMarchine (payload: CloneQemuMachinePayload) {
|
|
276
|
-
let data;
|
|
277
|
-
try {
|
|
278
|
-
data = await axios({
|
|
279
|
-
method: "POST",
|
|
280
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/clone`),
|
|
281
|
-
headers: {
|
|
282
|
-
...await this.prepareHeaders(),
|
|
283
|
-
},
|
|
284
|
-
data: {
|
|
285
|
-
full: 1,
|
|
286
|
-
name: "azdzfaef2233",
|
|
287
|
-
newid: payload.newid,
|
|
288
|
-
target: payload.node,
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
} catch (err) {
|
|
292
|
-
this.logger.error({ status: (err as unknown as any).response.status, ...payload, errors: (err as unknown as any).response.data.errors }, (err as unknown as any).response.statusText);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return (data as unknown as any)?.data?.data as string;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
async resizeDisk (
|
|
299
|
-
payload: { node: string; vmid: number, size: number, disk: string, unit: "G" }
|
|
300
|
-
) {
|
|
301
|
-
let data;
|
|
302
|
-
try {
|
|
303
|
-
data = await axios({
|
|
304
|
-
method: "PUT",
|
|
305
|
-
url: this.computeUrl(`/api2/json/nodes/${payload.node}/qemu/${payload.vmid}/resize`),
|
|
306
|
-
headers: await this.prepareHeaders(),
|
|
307
|
-
data: {
|
|
308
|
-
disk: payload.disk,
|
|
309
|
-
size: `+${payload.size}G`
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
} catch (err) {
|
|
313
|
-
this.logger.error({ status: (err as unknown as any).response.status, ...payload, errors: (err as unknown as any).response.data.errors }, (err as unknown as any).response.statusText);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
return (data as unknown as any)?.data?.data as string;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
private computeUrl (path: string) {
|
|
320
|
-
return `${this.parameters.host}${path}`;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
private async prepareHeaders () {
|
|
324
|
-
const ticket = await this.getTicket();
|
|
325
|
-
return {
|
|
326
|
-
CSRFPreventionToken: ticket.CSRFPreventionToken,
|
|
327
|
-
Cookie: `PVEAuthCookie=${ticket.ticket}`,
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
private async getTicket (): Promise<{
|
|
332
|
-
CSRFPreventionToken: string;
|
|
333
|
-
cap: {
|
|
334
|
-
dc: any;
|
|
335
|
-
nodes: any;
|
|
336
|
-
},
|
|
337
|
-
ticket: string;
|
|
338
|
-
username: string;
|
|
339
|
-
}> {
|
|
340
|
-
const params = new URLSearchParams({
|
|
341
|
-
username: this.parameters.username,
|
|
342
|
-
password: this.parameters.password,
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
let data;
|
|
346
|
-
try {
|
|
347
|
-
const url = this.computeUrl(`/api2/json/access/ticket?${params.toString()}`);
|
|
348
|
-
({ data } = await axios({
|
|
349
|
-
url,
|
|
350
|
-
method: "POST",
|
|
351
|
-
headers: {
|
|
352
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
353
|
-
},
|
|
354
|
-
}));
|
|
355
|
-
} catch (err) {
|
|
356
|
-
console.log((err as unknown as any).response.status);
|
|
357
|
-
console.log((err as unknown as any).response.statusText);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return (data as unknown as any).data;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
// https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu
|
|
2
|
-
type CreateQemuMachineBasePayload = {
|
|
3
|
-
/**
|
|
4
|
-
* Automatic restart after crash (currently ignored).
|
|
5
|
-
*/
|
|
6
|
-
autostart?: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Select BIOS implementation.
|
|
9
|
-
*
|
|
10
|
-
* default = seabios.
|
|
11
|
-
*/
|
|
12
|
-
bios?: "seabios" | "ovmf";
|
|
13
|
-
/**
|
|
14
|
-
* Memory quantity.
|
|
15
|
-
*
|
|
16
|
-
* default = 512(MB)
|
|
17
|
-
*/
|
|
18
|
-
memory?: number;
|
|
19
|
-
/**
|
|
20
|
-
* The name of the VM.
|
|
21
|
-
*/
|
|
22
|
-
name: string;
|
|
23
|
-
/**
|
|
24
|
-
* The cluster node name.
|
|
25
|
-
*/
|
|
26
|
-
node: string;
|
|
27
|
-
/**
|
|
28
|
-
* Specify guest operating system. This is used to enable special
|
|
29
|
-
* optimization/features for specific operating systems:
|
|
30
|
-
*
|
|
31
|
-
* - l24: Linux 2.4 Kernel
|
|
32
|
-
* - l26: Linux 2.6 - 6.X Kernel
|
|
33
|
-
* - other: unspecified OS
|
|
34
|
-
* - solaris: Solaris/OpenSolaris/OpenIndiania kernel
|
|
35
|
-
* - w2k3: Microsoft Windows 2003
|
|
36
|
-
* - w2k8: Microsoft Windows 2008
|
|
37
|
-
* - w2k: Microsoft Windows 2000
|
|
38
|
-
* - win10: Microsoft Windows 10/2016/2019
|
|
39
|
-
* - win11: Microsoft Windows 11/2022
|
|
40
|
-
* - win7: Microsoft Windows 7
|
|
41
|
-
* - win8: Microsoft Windows 8/2012/2012r2
|
|
42
|
-
* - wvista: Microsoft Windows Vista
|
|
43
|
-
* - wxp: Microsoft Windows XP
|
|
44
|
-
*/
|
|
45
|
-
ostype?: OS;
|
|
46
|
-
/**
|
|
47
|
-
* The (unique) ID of the VM.
|
|
48
|
-
* It should be between 100 and 999999999.
|
|
49
|
-
*/
|
|
50
|
-
vmid: number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type CreateQemuMachinePayload = CreateQemuMachineBasePayload & {
|
|
54
|
-
/**
|
|
55
|
-
* The number of cores per socket.
|
|
56
|
-
*
|
|
57
|
-
* default = 1
|
|
58
|
-
*/
|
|
59
|
-
coreCount?: number;
|
|
60
|
-
/**
|
|
61
|
-
* ISO name
|
|
62
|
-
*
|
|
63
|
-
* The name of the filename you gave to the ISO.
|
|
64
|
-
* (e.g: debian.iso)
|
|
65
|
-
*/
|
|
66
|
-
isoName?: string;
|
|
67
|
-
/**
|
|
68
|
-
* Specify the name of the storage, according to the Proxmox installation
|
|
69
|
-
* it can be different
|
|
70
|
-
*
|
|
71
|
-
* It's the storage where you have a section "VM Disks"
|
|
72
|
-
*/
|
|
73
|
-
localStorageName: "local" | "local-lvm";
|
|
74
|
-
/**
|
|
75
|
-
* Networks configurations
|
|
76
|
-
*/
|
|
77
|
-
networks?: Array<QemuNetwork>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export type CreateQemuMachineProxmoxPayload = CreateQemuMachineBasePayload & {
|
|
81
|
-
/**
|
|
82
|
-
* The number of cores per socket.
|
|
83
|
-
*
|
|
84
|
-
* default = 1
|
|
85
|
-
*/
|
|
86
|
-
cores?: number;
|
|
87
|
-
efidisk0: string;
|
|
88
|
-
/**
|
|
89
|
-
* cloud-init: Specify IP addresses and gateways for the corresponding interface.
|
|
90
|
-
*
|
|
91
|
-
* IP addresses use CIDR notation, gateways are optional but need an IP of the same type specified.
|
|
92
|
-
* The special string 'dhcp' can be used for IP addresses to use DHCP, in which case no explicit
|
|
93
|
-
* gateway should be provided.
|
|
94
|
-
*
|
|
95
|
-
* For IPv6 the special string 'auto' can be used to use stateless autoconfiguration. This requires
|
|
96
|
-
* cloud-init 19.4 or newer.
|
|
97
|
-
*
|
|
98
|
-
* If cloud-init is enabled and neither an IPv4 nor an IPv6 address is specified, it defaults to using
|
|
99
|
-
* dhcp on IPv4.
|
|
100
|
-
*
|
|
101
|
-
* [gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]
|
|
102
|
-
*/
|
|
103
|
-
ipconfig0?: string;
|
|
104
|
-
/**
|
|
105
|
-
* cloud-init: Specify IP addresses and gateways for the corresponding interface.
|
|
106
|
-
*
|
|
107
|
-
* IP addresses use CIDR notation, gateways are optional but need an IP of the same type specified.
|
|
108
|
-
* The special string 'dhcp' can be used for IP addresses to use DHCP, in which case no explicit
|
|
109
|
-
* gateway should be provided.
|
|
110
|
-
*
|
|
111
|
-
* For IPv6 the special string 'auto' can be used to use stateless autoconfiguration. This requires
|
|
112
|
-
* cloud-init 19.4 or newer.
|
|
113
|
-
*
|
|
114
|
-
* If cloud-init is enabled and neither an IPv4 nor an IPv6 address is specified, it defaults to using
|
|
115
|
-
* dhcp on IPv4.
|
|
116
|
-
*
|
|
117
|
-
* [gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]
|
|
118
|
-
*/
|
|
119
|
-
ipconfig1?: string;
|
|
120
|
-
net0: string;
|
|
121
|
-
numa: number;
|
|
122
|
-
/**
|
|
123
|
-
* scsi[n]
|
|
124
|
-
* Use volume as SCSI hard disk or CD-ROM (n is 0 to 30).
|
|
125
|
-
* Use the special syntax STORAGE_ID:SIZE_IN_GiB to allocate a new volume.
|
|
126
|
-
* Use STORAGE_ID:0 and the 'import-from' parameter to import
|
|
127
|
-
* from an existing volume.
|
|
128
|
-
*/
|
|
129
|
-
scsi0?: string;
|
|
130
|
-
/**
|
|
131
|
-
* scsi[n]
|
|
132
|
-
* Use volume as SCSI hard disk or CD-ROM (n is 0 to 30).
|
|
133
|
-
* Use the special syntax STORAGE_ID:SIZE_IN_GiB to allocate a new volume.
|
|
134
|
-
* Use STORAGE_ID:0 and the 'import-from' parameter to import
|
|
135
|
-
* from an existing volume.
|
|
136
|
-
*/
|
|
137
|
-
scsi2?: string;
|
|
138
|
-
scsihw?: "virtio-scsi-single";
|
|
139
|
-
|
|
140
|
-
sockets: number;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export type OS = "other" | "wxp" | "w2k" | "w2k3" | "w2k8" | "wvista" | "win7" | "win8" | "win10" | "win11" | "l24" | "l26" | "solaris";
|
|
144
|
-
|
|
145
|
-
export type QemuNetwork = {
|
|
146
|
-
bridge: "vmbr0";
|
|
147
|
-
firewall: boolean;
|
|
148
|
-
model: "virtio";
|
|
149
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}
|
|
2
|
-
export type DeleteQemuMachinePayload = {
|
|
3
|
-
/**
|
|
4
|
-
* If set, destroy additionally all disks not referenced in the config but with a matching VMID from all enabled storages.
|
|
5
|
-
*
|
|
6
|
-
* default = false
|
|
7
|
-
*/
|
|
8
|
-
"destroy-unreferenced-disks"?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* The cluster node name.
|
|
11
|
-
*/
|
|
12
|
-
node: string;
|
|
13
|
-
/**
|
|
14
|
-
* Remove VMID from configurations, like backup & replication jobs and HA.
|
|
15
|
-
*/
|
|
16
|
-
purge?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* ignore locks - only root is allowed to use this option.
|
|
19
|
-
*/
|
|
20
|
-
skiplock?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* The (unique) ID of the VM.
|
|
23
|
-
* It should be between 100 and 999999999.
|
|
24
|
-
*/
|
|
25
|
-
vmid: number;
|
|
26
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/storage/{storage}/download-url
|
|
2
|
-
export type DownloadIsoImagePayload = {
|
|
3
|
-
/**
|
|
4
|
-
* Content type.
|
|
5
|
-
*/
|
|
6
|
-
content: "iso" | "vztmpl";
|
|
7
|
-
/**
|
|
8
|
-
* The name of the file to create. Caution: This will be normalized!
|
|
9
|
-
*/
|
|
10
|
-
filename: string;
|
|
11
|
-
/**
|
|
12
|
-
* The cluster node name.
|
|
13
|
-
*/
|
|
14
|
-
node: string;
|
|
15
|
-
/**
|
|
16
|
-
* The storage identifier.
|
|
17
|
-
*/
|
|
18
|
-
storage: string;
|
|
19
|
-
/**
|
|
20
|
-
* The URL to download the file from.
|
|
21
|
-
*/
|
|
22
|
-
url: string;
|
|
23
|
-
}
|
package/src/types/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './clone-qemu-machine';
|
|
2
|
-
export * from './create-qemu-machine';
|
|
3
|
-
export * from './delete-qemu-machine';
|
|
4
|
-
export * from './download-iso-image';
|
|
5
|
-
export * from './index';
|
|
6
|
-
export * from './ip';
|
|
7
|
-
export * from './list-qemu-machines';
|
|
8
|
-
export * from './start-qemu-machine';
|
|
9
|
-
export * from './stop-qemu-machine';
|
|
10
|
-
export * from './upid';
|
package/src/types/ip.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type IP = string & { readonly "": unique symbol };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}
|
|
2
|
-
export type ListQemuMachinesPayload = {
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export type QemuMachine = {
|
|
6
|
-
/**
|
|
7
|
-
* Maximum usable CPUs.
|
|
8
|
-
*/
|
|
9
|
-
cpus: number;
|
|
10
|
-
/**
|
|
11
|
-
* Root disk size in bytes.
|
|
12
|
-
*/
|
|
13
|
-
maxdisk: number;
|
|
14
|
-
/**
|
|
15
|
-
* Maximum memory in bytes.
|
|
16
|
-
*/
|
|
17
|
-
maxmem: number;
|
|
18
|
-
name: string;
|
|
19
|
-
/**
|
|
20
|
-
* Current state of the VM.
|
|
21
|
-
*
|
|
22
|
-
* QEMU process status.
|
|
23
|
-
*/
|
|
24
|
-
status: "running" | "stopped";
|
|
25
|
-
/**
|
|
26
|
-
* The current configured tags, if any
|
|
27
|
-
* Splitted by ;
|
|
28
|
-
*/
|
|
29
|
-
tags: string;
|
|
30
|
-
/**
|
|
31
|
-
* Uptime duration in second.
|
|
32
|
-
*/
|
|
33
|
-
uptime: string;
|
|
34
|
-
/**
|
|
35
|
-
* The (unique) ID of the VM.
|
|
36
|
-
*/
|
|
37
|
-
vmid: number;
|
|
38
|
-
}
|
|
39
|
-
export type ListQemuMachinesAnswer = Array<QemuMachine>;
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
export type OS = "other" | "wxp" | "w2k" | "w2k3" | "w2k8" | "wvista" | "win7" | "win8" | "win10" | "win11" | "l24" | "l26" | "solaris";
|
|
2
|
-
|
|
3
|
-
export type QemuNetwork = {
|
|
4
|
-
bridge: "vmbr0" |"vmbr1";
|
|
5
|
-
/**
|
|
6
|
-
* By default Proxmox set true
|
|
7
|
-
*/
|
|
8
|
-
firewall: boolean;
|
|
9
|
-
model: "virtio";
|
|
10
|
-
/**
|
|
11
|
-
* If wanted, we can associated the machine to a VLAN
|
|
12
|
-
*/
|
|
13
|
-
tag?: number;
|
|
14
|
-
}
|
|
15
|
-
// PUT https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/config
|
|
16
|
-
type UpdateQemuMachineBasePayload = {
|
|
17
|
-
/**
|
|
18
|
-
* Automatic restart after crash (currently ignored).
|
|
19
|
-
*/
|
|
20
|
-
autostart?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Select BIOS implementation.
|
|
23
|
-
*
|
|
24
|
-
* default = seabios.
|
|
25
|
-
*/
|
|
26
|
-
bios?: "seabios" | "ovmf";
|
|
27
|
-
/**
|
|
28
|
-
* Memory quantity.
|
|
29
|
-
*
|
|
30
|
-
* default = 512(MB)
|
|
31
|
-
*/
|
|
32
|
-
memory?: number;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The name of the VM.
|
|
36
|
-
*/
|
|
37
|
-
name: string;
|
|
38
|
-
/**
|
|
39
|
-
* The cluster node name.
|
|
40
|
-
*/
|
|
41
|
-
node: string;
|
|
42
|
-
/**
|
|
43
|
-
* Specify guest operating system. This is used to enable special
|
|
44
|
-
* optimization/features for specific operating systems:
|
|
45
|
-
*
|
|
46
|
-
* - l24: Linux 2.4 Kernel
|
|
47
|
-
* - l26: Linux 2.6 - 6.X Kernel
|
|
48
|
-
* - other: unspecified OS
|
|
49
|
-
* - solaris: Solaris/OpenSolaris/OpenIndiania kernel
|
|
50
|
-
* - w2k3: Microsoft Windows 2003
|
|
51
|
-
* - w2k8: Microsoft Windows 2008
|
|
52
|
-
* - w2k: Microsoft Windows 2000
|
|
53
|
-
* - win10: Microsoft Windows 10/2016/2019
|
|
54
|
-
* - win11: Microsoft Windows 11/2022
|
|
55
|
-
* - win7: Microsoft Windows 7
|
|
56
|
-
* - win8: Microsoft Windows 8/2012/2012r2
|
|
57
|
-
* - wvista: Microsoft Windows Vista
|
|
58
|
-
* - wxp: Microsoft Windows XP
|
|
59
|
-
*/
|
|
60
|
-
ostype?: OS;
|
|
61
|
-
/**
|
|
62
|
-
* Tags of the VM. This is only meta information.
|
|
63
|
-
*/
|
|
64
|
-
tags: Array<string>;
|
|
65
|
-
/**
|
|
66
|
-
* The (unique) ID of the VM.
|
|
67
|
-
* It should be between 100 and 999999999.
|
|
68
|
-
*/
|
|
69
|
-
vmid: number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export type UpdateQemuMachinePayload = UpdateQemuMachineBasePayload & {
|
|
73
|
-
/**
|
|
74
|
-
* The number of cores per socket.
|
|
75
|
-
*
|
|
76
|
-
* default = 1
|
|
77
|
-
*/
|
|
78
|
-
coreCount?: number;
|
|
79
|
-
/**
|
|
80
|
-
* ISO name
|
|
81
|
-
*
|
|
82
|
-
* The name of the filename you gave to the ISO.
|
|
83
|
-
* (e.g: debian.iso)
|
|
84
|
-
*/
|
|
85
|
-
isoName?: string;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Networks configurations
|
|
89
|
-
*/
|
|
90
|
-
networks?: Array<QemuNetwork>;
|
|
91
|
-
/**
|
|
92
|
-
* Override the default password.
|
|
93
|
-
*
|
|
94
|
-
* PROXMOX DOCS
|
|
95
|
-
*
|
|
96
|
-
* cloud-init: Password to assign the user. Using this is generally not recommended. Use ssh keys instead.
|
|
97
|
-
* Also note that older cloud-init versions do not support hashed passwords.
|
|
98
|
-
*/
|
|
99
|
-
overridenPassword?: string;
|
|
100
|
-
/**
|
|
101
|
-
* Override the default user
|
|
102
|
-
*
|
|
103
|
-
* PROXMOX DOCS
|
|
104
|
-
*
|
|
105
|
-
* cloud-init: User name to change ssh keys and password for instead of the image's configured default user.
|
|
106
|
-
*/
|
|
107
|
-
overridenUser?: string;
|
|
108
|
-
sshkey?: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export type UpdateQemuMachineProxmoxPayload = UpdateQemuMachineBasePayload & {
|
|
112
|
-
/**
|
|
113
|
-
* cloud-init: Password to assign the user. Using this is generally not recommended. Use ssh keys instead.
|
|
114
|
-
* Also note that older cloud-init versions do not support hashed passwords.
|
|
115
|
-
*/
|
|
116
|
-
cipassword?: string;
|
|
117
|
-
/**
|
|
118
|
-
* cloud-init: User name to change ssh keys and password for instead of the image's configured default user.
|
|
119
|
-
*/
|
|
120
|
-
ciuser?: string;
|
|
121
|
-
/**
|
|
122
|
-
* The number of cores per socket.
|
|
123
|
-
*
|
|
124
|
-
* default = 1
|
|
125
|
-
*/
|
|
126
|
-
cores?: number;
|
|
127
|
-
efidisk0: string;
|
|
128
|
-
/**
|
|
129
|
-
* Use volume as IDE hard disk or CD-ROM (n is 0 to 3). Use the special syntax STORAGE_ID:SIZE_IN_GiB to allocate a new volume.
|
|
130
|
-
* Use STORAGE_ID:0 and the 'import-from' parameter to import from an existing volume.
|
|
131
|
-
*
|
|
132
|
-
* [file=]<volume> [,aio=<native|threads|io_uring>] [,backup=<1|0>] [,bps=<bps>] [,bps_max_length=<seconds>] [,bps_rd=<bps>] [,bps_rd_max_length=<seconds>] [,bps_wr=<bps>] [,bps_wr_max_length=<seconds>] [,cache=<enum>] [,cyls=<integer>] [,detect_zeroes=<1|0>] [,discard=<ignore|on>] [,format=<enum>] [,heads=<integer>] [,import-from=<source volume>] [,iops=<iops>] [,iops_max=<iops>] [,iops_max_length=<seconds>] [,iops_rd=<iops>] [,iops_rd_max=<iops>] [,iops_rd_max_length=<seconds>] [,iops_wr=<iops>] [,iops_wr_max=<iops>] [,iops_wr_max_length=<seconds>] [,mbps=<mbps>] [,mbps_max=<mbps>] [,mbps_rd=<mbps>] [,mbps_rd_max=<mbps>] [,mbps_wr=<mbps>] [,mbps_wr_max=<mbps>] [,media=<cdrom|disk>] [,model=<model>] [,replicate=<1|0>] [,rerror=<ignore|report|stop>] [,secs=<integer>] [,serial=<serial>] [,shared=<1|0>] [,size=<DiskSize>] [,snapshot=<1|0>] [,ssd=<1|0>] [,trans=<none|lba|auto>] [,werror=<enum>] [,wwn=<wwn>]
|
|
133
|
-
*/
|
|
134
|
-
ide0?: string;
|
|
135
|
-
/**
|
|
136
|
-
* Use volume as IDE hard disk or CD-ROM (n is 0 to 3). Use the special syntax STORAGE_ID:SIZE_IN_GiB to allocate a new volume.
|
|
137
|
-
* Use STORAGE_ID:0 and the 'import-from' parameter to import from an existing volume.
|
|
138
|
-
*
|
|
139
|
-
* [file=]<volume> [,aio=<native|threads|io_uring>] [,backup=<1|0>] [,bps=<bps>] [,bps_max_length=<seconds>] [,bps_rd=<bps>] [,bps_rd_max_length=<seconds>] [,bps_wr=<bps>] [,bps_wr_max_length=<seconds>] [,cache=<enum>] [,cyls=<integer>] [,detect_zeroes=<1|0>] [,discard=<ignore|on>] [,format=<enum>] [,heads=<integer>] [,import-from=<source volume>] [,iops=<iops>] [,iops_max=<iops>] [,iops_max_length=<seconds>] [,iops_rd=<iops>] [,iops_rd_max=<iops>] [,iops_rd_max_length=<seconds>] [,iops_wr=<iops>] [,iops_wr_max=<iops>] [,iops_wr_max_length=<seconds>] [,mbps=<mbps>] [,mbps_max=<mbps>] [,mbps_rd=<mbps>] [,mbps_rd_max=<mbps>] [,mbps_wr=<mbps>] [,mbps_wr_max=<mbps>] [,media=<cdrom|disk>] [,model=<model>] [,replicate=<1|0>] [,rerror=<ignore|report|stop>] [,secs=<integer>] [,serial=<serial>] [,shared=<1|0>] [,size=<DiskSize>] [,snapshot=<1|0>] [,ssd=<1|0>] [,trans=<none|lba|auto>] [,werror=<enum>] [,wwn=<wwn>]
|
|
140
|
-
*/
|
|
141
|
-
ide1?: string;
|
|
142
|
-
/**
|
|
143
|
-
* Use volume as IDE hard disk or CD-ROM (n is 0 to 3). Use the special syntax STORAGE_ID:SIZE_IN_GiB to allocate a new volume.
|
|
144
|
-
* Use STORAGE_ID:0 and the 'import-from' parameter to import from an existing volume.
|
|
145
|
-
*
|
|
146
|
-
* [file=]<volume> [,aio=<native|threads|io_uring>] [,backup=<1|0>] [,bps=<bps>] [,bps_max_length=<seconds>] [,bps_rd=<bps>] [,bps_rd_max_length=<seconds>] [,bps_wr=<bps>] [,bps_wr_max_length=<seconds>] [,cache=<enum>] [,cyls=<integer>] [,detect_zeroes=<1|0>] [,discard=<ignore|on>] [,format=<enum>] [,heads=<integer>] [,import-from=<source volume>] [,iops=<iops>] [,iops_max=<iops>] [,iops_max_length=<seconds>] [,iops_rd=<iops>] [,iops_rd_max=<iops>] [,iops_rd_max_length=<seconds>] [,iops_wr=<iops>] [,iops_wr_max=<iops>] [,iops_wr_max_length=<seconds>] [,mbps=<mbps>] [,mbps_max=<mbps>] [,mbps_rd=<mbps>] [,mbps_rd_max=<mbps>] [,mbps_wr=<mbps>] [,mbps_wr_max=<mbps>] [,media=<cdrom|disk>] [,model=<model>] [,replicate=<1|0>] [,rerror=<ignore|report|stop>] [,secs=<integer>] [,serial=<serial>] [,shared=<1|0>] [,size=<DiskSize>] [,snapshot=<1|0>] [,ssd=<1|0>] [,trans=<none|lba|auto>] [,werror=<enum>] [,wwn=<wwn>]
|
|
147
|
-
*/
|
|
148
|
-
ide2?: string;
|
|
149
|
-
/**
|
|
150
|
-
* cloud-init: Specify IP addresses and gateways for the corresponding interface.
|
|
151
|
-
*
|
|
152
|
-
* IP addresses use CIDR notation, gateways are optional but need an IP of the same type specified.
|
|
153
|
-
* The special string 'dhcp' can be used for IP addresses to use DHCP, in which case no explicit
|
|
154
|
-
* gateway should be provided.
|
|
155
|
-
*
|
|
156
|
-
* For IPv6 the special string 'auto' can be used to use stateless autoconfiguration. This requires
|
|
157
|
-
* cloud-init 19.4 or newer.
|
|
158
|
-
*
|
|
159
|
-
* If cloud-init is enabled and neither an IPv4 nor an IPv6 address is specified, it defaults to using
|
|
160
|
-
* dhcp on IPv4.
|
|
161
|
-
*
|
|
162
|
-
* [gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]
|
|
163
|
-
*/
|
|
164
|
-
ipconfig0?: string;
|
|
165
|
-
/**
|
|
166
|
-
* cloud-init: Specify IP addresses and gateways for the corresponding interface.
|
|
167
|
-
*
|
|
168
|
-
* IP addresses use CIDR notation, gateways are optional but need an IP of the same type specified.
|
|
169
|
-
* The special string 'dhcp' can be used for IP addresses to use DHCP, in which case no explicit
|
|
170
|
-
* gateway should be provided.
|
|
171
|
-
*
|
|
172
|
-
* For IPv6 the special string 'auto' can be used to use stateless autoconfiguration. This requires
|
|
173
|
-
* cloud-init 19.4 or newer.
|
|
174
|
-
*
|
|
175
|
-
* If cloud-init is enabled and neither an IPv4 nor an IPv6 address is specified, it defaults to using
|
|
176
|
-
* dhcp on IPv4.
|
|
177
|
-
*
|
|
178
|
-
* [gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]
|
|
179
|
-
*/
|
|
180
|
-
ipconfig1?: string;
|
|
181
|
-
net0: string;
|
|
182
|
-
numa: number;
|
|
183
|
-
/**
|
|
184
|
-
* scsi[n]
|
|
185
|
-
* Use volume as SCSI hard disk or CD-ROM (n is 0 to 30).
|
|
186
|
-
* Use the special syntax STORAGE_ID:SIZE_IN_GiB to allocate a new volume.
|
|
187
|
-
* Use STORAGE_ID:0 and the 'import-from' parameter to import
|
|
188
|
-
* from an existing volume.
|
|
189
|
-
*/
|
|
190
|
-
scsi0?: string;
|
|
191
|
-
/**
|
|
192
|
-
* scsi[n]
|
|
193
|
-
* Use volume as SCSI hard disk or CD-ROM (n is 0 to 30).
|
|
194
|
-
* Use the special syntax STORAGE_ID:SIZE_IN_GiB to allocate a new volume.
|
|
195
|
-
* Use STORAGE_ID:0 and the 'import-from' parameter to import
|
|
196
|
-
* from an existing volume.
|
|
197
|
-
*/
|
|
198
|
-
scsi2?: string;
|
|
199
|
-
scsihw?: "virtio-scsi-single";
|
|
200
|
-
sockets: number;
|
|
201
|
-
/**
|
|
202
|
-
* cloud-init: Setup public SSH keys (one key per line, OpenSSH format).
|
|
203
|
-
*/
|
|
204
|
-
sshkeys?: string;
|
|
205
|
-
}
|
package/src/types/upid.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type UPID = string & { readonly "": unique symbol };
|