Skip to content

Commit 555607a

Browse files
committed
feat: move to @unraid declaration
1 parent 10d18ab commit 555607a

File tree

7 files changed

+181
-88
lines changed

7 files changed

+181
-88
lines changed

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@reflet/cron": "^1.3.1",
6767
"@runonflux/nat-upnp": "^1.0.2",
6868
"@types/diff": "^7.0.1",
69-
"@vmngr/libvirt": "link:/libvirt/",
69+
"@unraid/libvirt": "link:../libvirt",
7070
"accesscontrol": "^2.2.1",
7171
"bycontract": "^2.0.11",
7272
"bytes": "^3.1.2",

api/pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/src/core/modules/vms/get-domains.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const states = {
1919
*/
2020
export const getDomains = async () => {
2121
try {
22-
const { ConnectListAllDomainsFlags } = await import('@vmngr/libvirt');
22+
const { ConnectListAllDomainsFlags } = await import('@unraid/libvirt');
2323
const { UnraidHypervisor } = await import('@app/core/utils/vms/get-hypervisor');
2424

2525
const hypervisor = await UnraidHypervisor.getInstance().getHypervisor();

api/src/core/utils/vms/get-hypervisor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { constants } from 'fs';
22
import { access } from 'fs/promises';
33

4-
import type { Hypervisor as HypervisorType } from '@vmngr/libvirt';
4+
import type { Hypervisor as HypervisorType } from '@unraid/libvirt';
55

66
import { libvirtLogger } from '@app/core/log';
77

@@ -42,7 +42,7 @@ export class UnraidHypervisor {
4242
this.hypervisor = null;
4343
throw new Error('Libvirt is not running');
4444
}
45-
const { Hypervisor } = await import('@vmngr/libvirt');
45+
const { Hypervisor } = await import('@unraid/libvirt');
4646
this.hypervisor = new Hypervisor({ uri });
4747
await this.hypervisor.connectOpen().catch((error: unknown) => {
4848
libvirtLogger.error(

libvirt/README.md

Lines changed: 63 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Cover image][cover]
22

3-
# vmngr / libvirt
3+
# Unraid / libvirt bindings
44

55
![Alpha badge][alphabadge]
66
![CI badge][cibadge]
@@ -15,87 +15,92 @@ Libvirt bindings for Node.js®.
1515

1616
```typescript
1717
import libvirt, {
18-
DomainBuilder,
19-
domainDescToXml,
20-
domainDescFromXml,
21-
} from "@vmngr/libvirt";
18+
DomainBuilder,
19+
domainDescToXml,
20+
domainDescFromXml,
21+
} from "@unraid/libvirt";
2222

2323
const uri = process.env.LIBVIRT_URI || "qemu:///system";
2424
const hypervisor = new libvirt.Hypervisor({ uri });
2525

2626
(async () => {
27-
28-
await hypervisor.connectOpen();
29-
30-
// parse xml template
31-
const template = await domainDescFromXml("<domain>...</domain>");
32-
33-
// build new domain description
34-
const domain = new DomainBuilder()
35-
.fromTemplate(template)
36-
37-
.setName("test1")
38-
.setUUID("148d0864-2354-4c27-b82c-731bdd3f320c")
39-
40-
.addDisk({
41-
type: "file", device: "disk",
42-
driver: { name: "qemu", type: "qcow2" },
43-
source: { file: "/home/leon/test1.img" },
44-
target: { dev: "vda", bus: "virtio" },
45-
})
46-
47-
.addInterface({
48-
type: "network",
49-
source: { network: "default" },
50-
mac: { address: "52:54:00:8e:c6:5f" },
51-
model: { type: "virtio" },
52-
})
53-
54-
.build();
55-
56-
// define and boot domain
57-
const xml = domainDescToXml(domain);
58-
await hypervisor.domainCreateXML(xml);
59-
60-
// list active domains
61-
const activeDomains = await hypervisor.connectListAllDomains(
62-
libvirt.ConnectListAllDomainsFlags.ACTIVE);
63-
64-
// log active domain names
65-
const activeDomainNames = await Promise.all(activeDomains
66-
.map((domain) => hypervisor.domainGetName(domain)));
67-
console.log(activeDomainNames);
68-
69-
await hypervisor.connectClose();
70-
27+
await hypervisor.connectOpen();
28+
29+
// parse xml template
30+
const template = await domainDescFromXml("<domain>...</domain>");
31+
32+
// build new domain description
33+
const domain = new DomainBuilder()
34+
.fromTemplate(template)
35+
36+
.setName("test1")
37+
.setUUID("148d0864-2354-4c27-b82c-731bdd3f320c")
38+
39+
.addDisk({
40+
type: "file",
41+
device: "disk",
42+
driver: { name: "qemu", type: "qcow2" },
43+
source: { file: "/home/leon/test1.img" },
44+
target: { dev: "vda", bus: "virtio" },
45+
})
46+
47+
.addInterface({
48+
type: "network",
49+
source: { network: "default" },
50+
mac: { address: "52:54:00:8e:c6:5f" },
51+
model: { type: "virtio" },
52+
})
53+
54+
.build();
55+
56+
// define and boot domain
57+
const xml = domainDescToXml(domain);
58+
await hypervisor.domainCreateXML(xml);
59+
60+
// list active domains
61+
const activeDomains = await hypervisor.connectListAllDomains(
62+
libvirt.ConnectListAllDomainsFlags.ACTIVE
63+
);
64+
65+
// log active domain names
66+
const activeDomainNames = await Promise.all(
67+
activeDomains.map((domain) => hypervisor.domainGetName(domain))
68+
);
69+
console.log(activeDomainNames);
70+
71+
await hypervisor.connectClose();
7172
})();
7273
```
7374

7475
## Install
7576

7677
### Debian / Ubuntu
78+
7779
```bash
78-
$ sudo apt install build-essential libvirt-dev
79-
$ npm i @vmngr/libvirt
80+
sudo apt install build-essential libvirt-dev
81+
npm i @unraid/libvirt
8082
```
8183

8284
### MacOS
85+
8386
Install Homebrew and Xcode first if not already installed.
87+
8488
```bash
85-
$ brew install libvirt
86-
$ npm i @vmngr/libvirt
89+
brew install libvirt
90+
npm i @unraid/libvirt
8791
```
8892

8993
## Contribute
9094

9195
Any contribution is welcome! To check wether your contribution conforms our style guide run the following tasks:
96+
9297
```bash
93-
$ pip install cppcheck # required once
94-
$ git submodule update --init --recursive # required once
98+
pip install cppcheck # required once
99+
git submodule update --init --recursive # required once
95100

96-
$ npm run lint/bindings
97-
$ npm run lint/lib
98-
$ npm run lint/examples
101+
pnpm run lint/bindings
102+
pnpm run lint/lib
103+
pnpm run lint/examples
99104
```
100105

101106
---
@@ -122,9 +127,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
122127
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
123128
SOFTWARE.
124129

125-
126130
[cover]: cover.png "Cover image"
127-
128131
[alphabadge]: https://img.shields.io/badge/-alpha-green "Alpha badge"
129132
[licensebadge]: https://img.shields.io/github/license/vmngr/libvirt "License badge"
130133
[cibadge]: https://github.com/vmngr/libvirt/workflows/CI/badge.svg "CI badge"

libvirt/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@vmngr/libvirt",
3-
"version": "0.0.6",
4-
"description": "Libvirt bindings for Node.js®",
2+
"name": "@unraid/libvirt",
3+
"version": "1.0.0",
4+
"description": "Libvirt bindings for Node.js® - forked from vmngr/libvirt",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"gypfile": true,

0 commit comments

Comments
 (0)