https://pulumi.com logo
Title
b

brainy-forest-39638

08/28/2022, 8:37 PM
Can someone help me? I'm getting this error when running this code
const d = lib.Network.get("default", "f5cd7f9e-5fb9-44b1-9d97-98019db8db9b");
l

little-cartoon-10569

08/28/2022, 8:44 PM
Looks like you're calling it before your stack is set up. How are you running this?
pulumi up
?
b

brainy-forest-39638

08/28/2022, 8:45 PM
Do you have any guide to run? I'm kinda lost
l

little-cartoon-10569

08/28/2022, 8:46 PM
I think it's best to find out what you're doing and fix it. What did you do to get this error?
b

brainy-forest-39638

08/28/2022, 8:47 PM
I am running this code
const cluster = new lib.Pool("cluster", {
        type: "dir",
        path: "/home/user/cluster_storage",
      });
l

little-cartoon-10569

08/28/2022, 8:48 PM
How are you running it? What command are you typing at the CLI?
b

brainy-forest-39638

08/28/2022, 8:49 PM
CLI? I'm not using CLI.
Do you have a guide to help me?
l

little-cartoon-10569

08/28/2022, 8:50 PM
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

brainy-forest-39638

08/28/2022, 8:52 PM
my code
cluster.ts
import * as lib from "@pulumi/libvirt";

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

console.log(cluster);
l

little-cartoon-10569

08/28/2022, 8:52 PM
How are you running your code? What command do you type, what button do you click.. what causes the code to run?
b

brainy-forest-39638

08/28/2022, 8:52 PM
The command to run this code is
npx ts-node ./cluser.ts
l

little-cartoon-10569

08/28/2022, 8:53 PM
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

brainy-forest-39638

08/28/2022, 8:53 PM
I didn't understand..
l

little-cartoon-10569

08/28/2022, 8:53 PM
Don't type
npx ts-node
. You type
pulumi preview
or
pulumi up
.
That's how you start a simple Pulumi program.
b

brainy-forest-39638

08/28/2022, 8:54 PM
I'll try
What is the relationship between pulumi and libvirt?
l

little-cartoon-10569

08/28/2022, 8:59 PM
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

brainy-forest-39638

08/28/2022, 9:01 PM
I don't want to use Pulumi, but I want to use libvirt https://www.pulumi.com/registry/packages/libvirt/
l

little-cartoon-10569

08/28/2022, 9:04 PM
That's a link to Pulumi's documentation. You can't use a Pulumi plugin (libvirt) outside of Pulumi.
Pulumi runs the plugin.
b

brainy-forest-39638

08/28/2022, 9:05 PM
Got it, I'll use it then
b

billowy-army-68599

08/28/2022, 9:05 PM
@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

little-cartoon-10569

08/28/2022, 9:06 PM
Or maybe you want to find libvirt's SDK and use that directly?
b

brainy-forest-39638

08/28/2022, 9:06 PM
It would be great if I could find it, but I can't find it anywhere, can you help me?
l

little-cartoon-10569

08/28/2022, 9:07 PM
b

brainy-forest-39638

08/28/2022, 9:08 PM
yes
I don't find lib to connect to libvirt
l

little-cartoon-10569

08/28/2022, 9:08 PM
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

brainy-forest-39638

08/28/2022, 9:10 PM
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

little-cartoon-10569

08/28/2022, 9:15 PM
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.