@highstate/proxmox 0.2.0 → 0.2.1

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.
@@ -0,0 +1,16 @@
1
+ import { proxmox } from '@highstate/library';
2
+ import { forUnit } from '@highstate/pulumi';
3
+
4
+ const { args, secrets, outputs } = forUnit(proxmox.connection);
5
+ var index = outputs({
6
+ proxmoxCluster: {
7
+ endpoint: args.endpoint,
8
+ insecure: args.insecure,
9
+ username: args.username,
10
+ defaultNodeName: args.defaultNodeName,
11
+ password: secrets.password,
12
+ apiToken: secrets.apiToken
13
+ }
14
+ });
15
+
16
+ export { index as default };
@@ -0,0 +1,11 @@
1
+ import { proxmox } from '@highstate/library';
2
+ import { forUnit } from '@highstate/pulumi';
3
+
4
+ const { args, outputs } = forUnit(proxmox.existingImage);
5
+ var index = outputs({
6
+ image: {
7
+ id: args.id
8
+ }
9
+ });
10
+
11
+ export { index as default };
@@ -0,0 +1,33 @@
1
+ import { proxmox } from '@highstate/library';
2
+ import { forUnit, output } from '@highstate/pulumi';
3
+ import { download } from '@muhlba91/pulumi-proxmoxve';
4
+ import { c as createProvider } from '../provider-DyXtZ5E3.mjs';
5
+
6
+ const { name, args, inputs, outputs } = forUnit(proxmox.image);
7
+ const file = new download.File(
8
+ name,
9
+ {
10
+ contentType: "iso",
11
+ checksumAlgorithm: "sha256",
12
+ checksum: args.sha256,
13
+ datastoreId: args.datastoreId ?? inputs.proxmoxCluster.defaultDatastoreId?.apply((id) => id ?? "") ?? "",
14
+ url: args.url,
15
+ nodeName: args.nodeName ?? inputs.proxmoxCluster.defaultNodeName,
16
+ fileName: output(args.url).apply(getNameByUrl).apply(([name2, extension]) => `${name2}-${args.sha256}.${extension}`)
17
+ },
18
+ { provider: createProvider(inputs.proxmoxCluster) }
19
+ );
20
+ function getNameByUrl(url) {
21
+ const fullName = url.split("/").pop().split("?")[0];
22
+ const parts = fullName.split(".");
23
+ const name2 = parts.slice(0, parts.length - 1).join(".");
24
+ const extension = parts[parts.length - 1];
25
+ return [name2, extension];
26
+ }
27
+ var index = outputs({
28
+ image: {
29
+ id: file.id
30
+ }
31
+ });
32
+
33
+ export { index as default };
@@ -0,0 +1,15 @@
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 ?? "")
12
+ });
13
+ }
14
+
15
+ export { createProvider as c };
@@ -0,0 +1,83 @@
1
+ import { proxmox } from '@highstate/library';
2
+ import { forUnit } from '@highstate/pulumi';
3
+ import { vm } from '@muhlba91/pulumi-proxmoxve';
4
+ import { c as createProvider } from '../provider-DyXtZ5E3.mjs';
5
+
6
+ const { name, args, inputs, outputs } = forUnit(proxmox.virtualMachine);
7
+ const machine = new vm.VirtualMachine(
8
+ name,
9
+ {
10
+ name,
11
+ nodeName: args.nodeName ?? inputs.proxmoxCluster.defaultNodeName,
12
+ agent: {
13
+ enabled: true
14
+ },
15
+ cpu: {
16
+ cores: args.cores,
17
+ sockets: args.sockets,
18
+ type: "x86-64-v2-AES"
19
+ },
20
+ memory: {
21
+ dedicated: args.memory
22
+ },
23
+ cdrom: {
24
+ enabled: true,
25
+ interface: "ide1",
26
+ fileId: inputs.image.id
27
+ },
28
+ disks: [
29
+ {
30
+ interface: "scsi0",
31
+ size: args.diskSize,
32
+ datastoreId: args.datastoreId
33
+ }
34
+ ],
35
+ networkDevices: [
36
+ {
37
+ bridge: args.bridge
38
+ }
39
+ ],
40
+ initialization: inputs.apply(createCloudInit),
41
+ bootOrders: ["scsi0", "ide1"]
42
+ },
43
+ { provider: createProvider(inputs.proxmoxCluster), ignoreChanges: ["disks"] }
44
+ );
45
+ function findNotLocalHostIpV4(ips) {
46
+ for (const ip of ips) {
47
+ if (ip[0] && ip[0] !== "127.0.0.1") {
48
+ return ip[0];
49
+ }
50
+ }
51
+ return;
52
+ }
53
+ function deriveIpV4Gateway(ip) {
54
+ return ip.split(".").slice(0, 3).join(".") + ".1";
55
+ }
56
+ function createCloudInit(resolvedInputs) {
57
+ return {
58
+ datastoreId: args.datastoreId,
59
+ interface: "ide2",
60
+ ipConfigs: args.ipv4 ? [
61
+ {
62
+ ipv4: {
63
+ address: args.ipv4,
64
+ gateway: args.ipv4Gateway ?? deriveIpV4Gateway(args.ipv4)
65
+ }
66
+ }
67
+ ] : void 0,
68
+ dns: args.dns ? { servers: args.dns } : void 0,
69
+ userAccount: resolvedInputs.sshPublicKey ? {
70
+ keys: [resolvedInputs.sshPublicKey.publicKey]
71
+ } : void 0
72
+ };
73
+ }
74
+ var index = outputs({
75
+ server: {
76
+ endpoint: machine.ipv4Addresses.apply(findNotLocalHostIpV4),
77
+ sshCredentials: {
78
+ privateKey: inputs.sshKeyPair
79
+ }
80
+ }
81
+ });
82
+
83
+ export { index as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highstate/proxmox",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -18,12 +18,12 @@
18
18
  "build": "pkgroll --clean-dist"
19
19
  },
20
20
  "dependencies": {
21
- "@highstate/library": "^0.2.0",
22
- "@highstate/pulumi": "^0.2.0",
21
+ "@highstate/library": "^0.2.1",
22
+ "@highstate/pulumi": "^0.2.1",
23
23
  "@muhlba91/pulumi-proxmoxve": "^6.17.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "pkgroll": "^2.5.1"
27
27
  },
28
- "gitHead": "41f789ef9d6da623923812bba9783c216605495d"
28
+ "gitHead": "205bae57e7b9e8e8ebe979859df3f18fdb8cfe81"
29
29
  }