Closed libvirtadept closed 4 years ago
It can be like that
User have a class which describing future VM
In that class we will have methods like
addDisk
Which will add object into array of disks and also checking is disk file exist (fs.exists(Sync)
)
When user sure that his VM ready to deploy he using class method getXML()
which creating XML interface and then pass it to libvirt binding (domainDefine(xml)
+ domainCreate(dom)
)
I guess it is kinda usefull features
Hi, yeah that sounds nice. I'd suggest having a JS/TS interface which is almost identical with the XML description which can be used for domainDefine
and domainCreate
. And then on top of this have something like a DomainBuilder
to construct these description interfaces.
Also having some kind of template engine would be nice because of at least two reasons: There are many parameters like <features><acpi/><apic/></features>
which make sense for almost all kinds of domains and re-specifying them for every domain would be annoying. Also load balancers typically spin up many identical domains (using some kind of template) and just change their name, uuid, mac etc.
interface IDomainDesc {
type: "kvm" | "qemu" | ...,
name: string,
memory: { unit: "kb" | "mb" | "gb", value: number },
...
}
const myDomain: IDomainDesc = new DomainBuilder()
.fromTemplate(myTemplate)
...
.addDisk(...)
.addNetwork(...)
...
.build();
hypervisor.domainCreate(myDomain);
Yep I think something like basic template can be defined in library as basis for other domains XMLs
But i'm not sure what is better to use: XML template or Object
I just wanted to say that I'm still on this. I almost finished a little poc of what I outlined above. I'll try to publish it as a dev branch for you to look at this week.
Hi Got it. I'm randomly returning to testing already implemented features and looking into virsh source code. I think i can implement bindings for some features like network filtering
Ok I've merged the XML thing. The descriptions are not complete but the bindings aren't neither. I think we found a cool way of working with the xml descriptions so I'm gonna close this.
Ok. Preparing virDomainGetInterfaceParameters to PR
Hi, Leon Since the libvirt/qemu/etc using xml to describe elements i'm now thinking about better way of working with XML data. I think it can be a kind of wrapper/class for working with Pools, Networks, VMs and so on configurations (mostly with JS because with C++ it will take a lot of time)