Can someone help me? I'm getting this error when r...
# general
b
Can someone help me? I'm getting this error when running this code
Copy code
const d = lib.Network.get("default", "f5cd7f9e-5fb9-44b1-9d97-98019db8db9b");
l
Looks like you're calling it before your stack is set up. How are you running this?
pulumi up
?
b
Do you have any guide to run? I'm kinda lost
l
I think it's best to find out what you're doing and fix it. What did you do to get this error?
b
I am running this code
Copy code
const cluster = new lib.Pool("cluster", {
        type: "dir",
        path: "/home/user/cluster_storage",
      });
l
How are you running it? What command are you typing at the CLI?
b
CLI? I'm not using CLI.
Do you have a guide to help me?
l
All the guides are on pulumi.com. Let's concentrate on what's going wrong. How are you starting the code? What do you do in order to get the code to run?
b
my code
cluster.ts
Copy code
import * as lib from "@pulumi/libvirt";

const cluster = new lib.Pool("cluster", {
  type: "dir",
  path: "/home/user/cluster_storage",
});

console.log(cluster);
l
How are you running your code? What command do you type, what button do you click.. what causes the code to run?
b
The command to run this code is
npx ts-node ./cluser.ts
l
Okay. That's the cause of this problem. You're running a node program.
Pulumi uses node, but it's not node. You need to run Pulumi.
b
I didn't understand..
l
Don't type
npx ts-node
. You type
pulumi preview
or
pulumi up
.
That's how you start a simple Pulumi program.
b
I'll try
What is the relationship between pulumi and libvirt?
l
I don't know what libvirt is. Is it a Pulumi provider?
Ah yes, it is, I see it in your code above.
It is the binary that implements the API that Pulumi needs to interact with the cloud resources.
b
I don't want to use Pulumi, but I want to use libvirt https://www.pulumi.com/registry/packages/libvirt/
l
That's a link to Pulumi's documentation. You can't use a Pulumi plugin (libvirt) outside of Pulumi.
Pulumi runs the plugin.
b
Got it, I'll use it then
b
@brainy-forest-39638 > What is the relationship between pulumi and libvirt? Pulumi is an infrastructure as code tool. Libvirt is an infrastructure provider Pulumi allows you to interact with many different providers. A provider is, as I mention above, something that providers infrastructure. You will need to use the Pulumi CLI to interact with your provider of choice. you might consider starting with the Pulumi fundamentals course: https://www.pulumi.com/learn/pulumi-fundamentals/ which covers some of this
💯 2
l
Or maybe you want to find libvirt's SDK and use that directly?
b
It would be great if I could find it, but I can't find it anywhere, can you help me?
l
b
yes
I don't find lib to connect to libvirt
l
Aren't they on this page? https://libvirt.org/downloads.html
Pulumi is likely to be easier, it's designed for managing cloud resources, keeping them up to date, not updating when not necessary, etc. But if you need to run a simple command against the libvirt API, and you want to manage it yourself, then Pulumi isn't the way to do that.
b
Yes, libvirt is there, but I need to use it with nodejs, and I don't know how to do it without some library
l
Yes, there's no node bindings. I see a couple on npm, but they're 4 and 6 years since last publish. You could try them.. or use Pulumi. Jaxxstorm's link above is worth reading at this point, to see if Pulumi is a good fit for solving your problem.