@highstate/proxmox 0.4.3 → 0.4.5
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/dist/connection/index.js +40 -7
- package/dist/image/index.js +4 -3
- package/dist/provider-BgV8Lmo6.js +19 -0
- package/dist/virtual-machine/index.js +54 -15
- package/package.json +4 -4
- package/dist/provider-QSzoFScT.js +0 -15
package/dist/connection/index.js
CHANGED
@@ -1,21 +1,54 @@
|
|
1
1
|
import { proxmox } from '@highstate/library';
|
2
|
-
import { forUnit, output } from '@highstate/pulumi';
|
3
|
-
import { cluster } from '@muhlba91/pulumi-proxmoxve';
|
4
|
-
import { c as createProvider } from '../provider-QSzoFScT.js';
|
2
|
+
import { forUnit, toPromise, output } from '@highstate/pulumi';
|
3
|
+
import { Provider, cluster, storage } from '@muhlba91/pulumi-proxmoxve';
|
5
4
|
|
6
5
|
const { args, secrets, outputs } = forUnit(proxmox.connection);
|
6
|
+
const provider = await toPromise(
|
7
|
+
output({ args, secrets }).apply(({ args: args2, secrets: secrets2 }) => {
|
8
|
+
return new Provider("proxmox", {
|
9
|
+
endpoint: args2.endpoint,
|
10
|
+
insecure: args2.insecure,
|
11
|
+
username: args2.username,
|
12
|
+
password: secrets2.password,
|
13
|
+
apiToken: secrets2.apiToken
|
14
|
+
});
|
15
|
+
})
|
16
|
+
);
|
17
|
+
const nodes = await cluster.getNodes({ provider });
|
18
|
+
if (nodes.names.length === 0) {
|
19
|
+
throw new Error("No nodes found");
|
20
|
+
}
|
21
|
+
const nodeName = args.defaultNodeName ?? nodes.names[0];
|
22
|
+
if (!nodes.names.includes(nodeName)) {
|
23
|
+
throw new Error(`Node '${nodeName}' not found in the cluster`);
|
24
|
+
}
|
25
|
+
const datastores = await storage.getDatastores({ nodeName }, { provider });
|
26
|
+
if (datastores.datastoreIds.length === 0) {
|
27
|
+
throw new Error(`No datastores found in the node '${nodeName}'`);
|
28
|
+
}
|
29
|
+
const datastoreId = args.defaultDatastoreId ?? datastores.datastoreIds[0];
|
30
|
+
if (!datastores.datastoreIds.includes(datastoreId)) {
|
31
|
+
throw new Error(`Datastore '${datastoreId}' not found in the node '${nodeName}'`);
|
32
|
+
}
|
7
33
|
const proxmoxCluster = output({
|
8
34
|
endpoint: args.endpoint,
|
9
35
|
insecure: args.insecure,
|
10
36
|
username: args.username,
|
11
|
-
defaultNodeName:
|
37
|
+
defaultNodeName: nodeName,
|
38
|
+
defaultDatastoreId: datastoreId,
|
12
39
|
password: secrets.password,
|
13
40
|
apiToken: secrets.apiToken
|
14
41
|
});
|
15
|
-
const provider = createProvider(proxmoxCluster);
|
16
|
-
await cluster.getNodes({ provider });
|
17
42
|
var index = outputs({
|
18
|
-
proxmoxCluster
|
43
|
+
proxmoxCluster,
|
44
|
+
$status: {
|
45
|
+
defaultNodeName: {
|
46
|
+
value: proxmoxCluster.defaultNodeName
|
47
|
+
},
|
48
|
+
defaultDatastoreId: {
|
49
|
+
value: proxmoxCluster.defaultDatastoreId
|
50
|
+
}
|
51
|
+
}
|
19
52
|
});
|
20
53
|
|
21
54
|
export { index as default };
|
package/dist/image/index.js
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
import { proxmox } from '@highstate/library';
|
2
2
|
import { forUnit, output } from '@highstate/pulumi';
|
3
3
|
import { download } from '@muhlba91/pulumi-proxmoxve';
|
4
|
-
import { c as createProvider } from '../provider-
|
4
|
+
import { c as createProvider } from '../provider-BgV8Lmo6.js';
|
5
5
|
|
6
6
|
const { name, args, inputs, outputs } = forUnit(proxmox.image);
|
7
|
+
const provider = await createProvider(inputs.proxmoxCluster);
|
7
8
|
const file = new download.File(
|
8
9
|
name,
|
9
10
|
{
|
10
11
|
contentType: "iso",
|
11
12
|
checksumAlgorithm: "sha256",
|
12
13
|
checksum: args.sha256,
|
13
|
-
datastoreId: args.datastoreId ?? inputs.proxmoxCluster.defaultDatastoreId
|
14
|
+
datastoreId: args.datastoreId ?? inputs.proxmoxCluster.defaultDatastoreId.apply((id) => id ?? "local-lvm"),
|
14
15
|
url: args.url,
|
15
16
|
nodeName: args.nodeName ?? inputs.proxmoxCluster.defaultNodeName,
|
16
17
|
fileName: output(args.url).apply(getNameByUrl).apply(([name2, extension]) => `${name2}-${args.sha256}.${extension}`)
|
17
18
|
},
|
18
|
-
{ provider
|
19
|
+
{ provider }
|
19
20
|
);
|
20
21
|
function getNameByUrl(url) {
|
21
22
|
const fullName = url.split("/").pop().split("?")[0];
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { toPromise, output } from '@highstate/pulumi';
|
2
|
+
import { Provider } from '@muhlba91/pulumi-proxmoxve';
|
3
|
+
import '@highstate/library';
|
4
|
+
|
5
|
+
function createProvider(cluster) {
|
6
|
+
return toPromise(
|
7
|
+
output(cluster).apply((cluster2) => {
|
8
|
+
return new Provider("proxmox", {
|
9
|
+
endpoint: cluster2.endpoint,
|
10
|
+
insecure: cluster2.insecure,
|
11
|
+
username: cluster2.username,
|
12
|
+
password: cluster2.password,
|
13
|
+
apiToken: cluster2.apiToken
|
14
|
+
});
|
15
|
+
})
|
16
|
+
);
|
17
|
+
}
|
18
|
+
|
19
|
+
export { createProvider as c };
|
@@ -1,21 +1,24 @@
|
|
1
1
|
import { proxmox } from '@highstate/library';
|
2
|
-
import { forUnit } from '@highstate/pulumi';
|
2
|
+
import { forUnit, output, interpolate } from '@highstate/pulumi';
|
3
3
|
import { vm } from '@muhlba91/pulumi-proxmoxve';
|
4
|
-
import { c as createProvider } from '../provider-
|
4
|
+
import { c as createProvider } from '../provider-BgV8Lmo6.js';
|
5
5
|
|
6
6
|
const { name, args, inputs, outputs } = forUnit(proxmox.virtualMachine);
|
7
|
+
const provider = await createProvider(inputs.proxmoxCluster);
|
8
|
+
const nodeName = args.nodeName ?? inputs.proxmoxCluster.defaultNodeName;
|
9
|
+
const datastoreId = args.datastoreId ?? inputs.proxmoxCluster.defaultDatastoreId;
|
7
10
|
const machine = new vm.VirtualMachine(
|
8
11
|
name,
|
9
12
|
{
|
10
13
|
name,
|
11
|
-
nodeName
|
14
|
+
nodeName,
|
12
15
|
agent: {
|
13
16
|
enabled: true
|
14
17
|
},
|
15
18
|
cpu: {
|
16
19
|
cores: args.cores,
|
17
20
|
sockets: args.sockets,
|
18
|
-
type: "
|
21
|
+
type: args.cpuType ?? "host"
|
19
22
|
},
|
20
23
|
memory: {
|
21
24
|
dedicated: args.memory
|
@@ -29,7 +32,7 @@ const machine = new vm.VirtualMachine(
|
|
29
32
|
{
|
30
33
|
interface: "scsi0",
|
31
34
|
size: args.diskSize,
|
32
|
-
datastoreId
|
35
|
+
datastoreId
|
33
36
|
}
|
34
37
|
],
|
35
38
|
networkDevices: [
|
@@ -37,10 +40,10 @@ const machine = new vm.VirtualMachine(
|
|
37
40
|
bridge: args.bridge
|
38
41
|
}
|
39
42
|
],
|
40
|
-
initialization: inputs.apply(createCloudInit),
|
43
|
+
initialization: output(inputs).apply(createCloudInit),
|
41
44
|
bootOrders: ["scsi0", "ide1"]
|
42
45
|
},
|
43
|
-
{ provider
|
46
|
+
{ provider }
|
44
47
|
);
|
45
48
|
function findNotLocalHostIpV4(ips) {
|
46
49
|
for (const ip of ips) {
|
@@ -55,7 +58,7 @@ function deriveIpV4Gateway(ip) {
|
|
55
58
|
}
|
56
59
|
function createCloudInit(resolvedInputs) {
|
57
60
|
return {
|
58
|
-
datastoreId
|
61
|
+
datastoreId,
|
59
62
|
interface: "ide2",
|
60
63
|
ipConfigs: args.ipv4 ? [
|
61
64
|
{
|
@@ -64,17 +67,53 @@ function createCloudInit(resolvedInputs) {
|
|
64
67
|
gateway: args.ipv4Gateway ?? deriveIpV4Gateway(args.ipv4)
|
65
68
|
}
|
66
69
|
}
|
67
|
-
] :
|
68
|
-
dns: args.dns ? { servers: args.dns } :
|
69
|
-
userAccount: resolvedInputs.
|
70
|
-
keys: [resolvedInputs.
|
71
|
-
|
70
|
+
] : void 0,
|
71
|
+
dns: args.dns ? { servers: args.dns } : void 0,
|
72
|
+
userAccount: resolvedInputs.sshKeyPair ? {
|
73
|
+
keys: [resolvedInputs.sshKeyPair.publicKey],
|
74
|
+
username: args.sshUser ?? "root"
|
75
|
+
} : void 0
|
72
76
|
};
|
73
77
|
}
|
78
|
+
const endpoint = machine.ipv4Addresses.apply(findNotLocalHostIpV4);
|
74
79
|
var index = outputs({
|
75
80
|
server: {
|
76
|
-
endpoint
|
77
|
-
hostname: name
|
81
|
+
endpoint,
|
82
|
+
hostname: name,
|
83
|
+
sshCredentials: {
|
84
|
+
keyPair: inputs.sshKeyPair
|
85
|
+
}
|
86
|
+
},
|
87
|
+
$status: {
|
88
|
+
endpoint: {
|
89
|
+
value: endpoint
|
90
|
+
},
|
91
|
+
hostname: {
|
92
|
+
value: name
|
93
|
+
}
|
94
|
+
},
|
95
|
+
$terminals: {
|
96
|
+
ssh: {
|
97
|
+
title: "SSH",
|
98
|
+
image: "ghcr.io/exeteres/highstate/terminal-ssh",
|
99
|
+
command: [
|
100
|
+
"sshpass",
|
101
|
+
"-f",
|
102
|
+
"/password",
|
103
|
+
"ssh",
|
104
|
+
"-tt",
|
105
|
+
"-o",
|
106
|
+
"StrictHostKeyChecking=no",
|
107
|
+
"-p",
|
108
|
+
// port.toString(),
|
109
|
+
"22",
|
110
|
+
// `${user}@${args.endpoint}`,
|
111
|
+
interpolate`root@${endpoint}`
|
112
|
+
],
|
113
|
+
files: {
|
114
|
+
// "/password": secrets.sshPassword?.apply(x => x ?? "") ?? "",
|
115
|
+
}
|
116
|
+
}
|
78
117
|
}
|
79
118
|
});
|
80
119
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@highstate/proxmox",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.5",
|
4
4
|
"type": "module",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -18,14 +18,14 @@
|
|
18
18
|
"build": "pkgroll --tsconfig=tsconfig.build.json"
|
19
19
|
},
|
20
20
|
"dependencies": {
|
21
|
-
"@highstate/pulumi": "^0.4.
|
21
|
+
"@highstate/pulumi": "^0.4.5",
|
22
22
|
"@muhlba91/pulumi-proxmoxve": "^6.17.1"
|
23
23
|
},
|
24
24
|
"peerDependencies": {
|
25
|
-
"@highstate/library": "workspace:^"
|
25
|
+
"@highstate/library": "workspace:^0.4.4"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"pkgroll": "^2.5.1"
|
29
29
|
},
|
30
|
-
"gitHead": "
|
30
|
+
"gitHead": "61f6f1b0ff3f97bd7ed5e37c26302f094b892392"
|
31
31
|
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import '@highstate/pulumi';
|
2
|
-
import { Provider } from '@muhlba91/pulumi-proxmoxve';
|
3
|
-
import '@highstate/library';
|
4
|
-
|
5
|
-
function createProvider(cluster) {
|
6
|
-
return new Provider("proxmox", {
|
7
|
-
endpoint: cluster.endpoint,
|
8
|
-
insecure: cluster.insecure?.apply((x) => x ?? false),
|
9
|
-
username: cluster.username?.apply((x) => x ?? ""),
|
10
|
-
password: cluster.password?.apply((x) => x ?? ""),
|
11
|
-
apiToken: cluster.apiToken?.apply((x) => x ?? undefined)
|
12
|
-
});
|
13
|
-
}
|
14
|
-
|
15
|
-
export { createProvider as c };
|