subuk / vmango

Your own personal IaaS cloud
https://vmango.org
MIT License
329 stars 55 forks source link

Add support for bridge networking #6

Closed s3rj1k closed 5 years ago

s3rj1k commented 7 years ago

Add support for bridge networking using https://www.isc.org/kea/ as DHCP server listening on bridge uplink port

subuk commented 7 years ago

I think it is possible, i'll check in a few weeks.

hohmd commented 6 years ago

Any update regarding this issue?

subuk commented 6 years ago

Still no, I am working on it, but very very slowly :/

hohmd commented 6 years ago

Is there branch with developement of it? Can we help?

subuk commented 6 years ago

I need some time to finish the domain model, then it will be possible to add new features like bridge networking. I am afraid I cannot give you any estimate, but it will be done soon, yesterday I have almost finished with it.

subuk commented 6 years ago

Hello, again. Here is scripted network support, if you have time, you can test it and add scripts for specific DHCP servers and configurations: https://github.com/subuk/vmango/tree/feature/bridgednet https://github.com/subuk/vmango/commit/6f07c47ba808e08515aa5f05ebd14cfb79c8f521

It has no documentation yet, but in short, three functions have to be implemented. I hope idea is clear from example (fixtures/stub_network_script.py) and source.

hohmd commented 6 years ago

Thanks, on testing.

subuk commented 6 years ago

Script for mikrotik routers https://github.com/subuk/vmango/blob/feature/bridgednet/network_scripts/network_mikrotik.py

hohmd commented 6 years ago

Can you explain a bit how vmango know which network setup do we want? It is not clear from the code (not implemented?). For example i've successfully manually (without vmango) added networking via dhcp daemon and i want to make a script to get ip from /etc/dhcp/dhcpd.conf to show in vmango web interface (because otherwise vmango web interface machine page can not be opened due to undefined ip variable). How can i instruct vmango web interface that i am using dhcp for networking?

I think that it makes sense to use a local database to store machines information. As there are simply no real way for networking to be fully configured on dhcp unless you use openvswitch or some other complex stuff for networking (which is unlikely to be used in personal private cloud) as more than 1 ip can not be connected with dhcp (i think).

subuk commented 6 years ago

Vmango uses libvirt network component. It adds static leases to dhcp server before machine start via libvirt's api. And I think this is the simplest way to configure network for machines: https://vmango.org/docs/configuration/hypervisor/#network https://wiki.libvirt.org/page/Networking https://github.com/subuk/vmango/blob/master/src/vmango/dal/machinerep_libvirt.go#L98

But if you want complex manual network configuration or want to bridge machines into existing network with dhcp server not managed by libvirt, you should write a script to configure this dhcp server. Script should implement three actions: lookup-ip (called every time to fetch machine ip), assign-ip (called on machine create), release-ip (on machine delete).

I think that it makes sense to use a local database to store machines information. As there are simply no real way for networking to be fully configured on dhcp unless you use openvswitch or some other complex stuff for networking

I think local database will add unnecessary exploitation complexity (at least it is extra point to backup) and problems with synchronization of local state in db with remotes, so I am trying to avoid it. And also, I don't understand how database can help you with dhcp configuration. If you have local dhcp server installed, you already have a database with ip addresses, you just need to write a script which will query this database and return response to vmango.

hohmd commented 6 years ago

But if you want complex manual network configuration or want to bridge machines into existing network with dhcp server not managed by libvirt, you should write a script to configure this dhcp server.

But how can i instruct vmango that i want to use own script to lookup-ip, assign-ip, release-ip, and how can i point it to particular script?

subuk commented 6 years ago

Compile this branch and set hypervisor.network to bridge name and hypervisor.network_script to path to script: https://github.com/subuk/vmango/tree/feature/bridgednet

Like this:

hypervisor "DESKTOP" {
   url = "qemu+ssh://virt@192.168.84.19/system?socket=/var/run/libvirt/libvirt-sock"
   image_storage_pool = "vmango-images"
   root_storage_pool = "default"
   network = "br0"
   network_script = "./network_scripts/network_mikrotik.py"
   vm_template = "vm.xml.in"
   volume_template = "volume.xml.in"
   ignore_vms = []
}

I will update documentation and packages soon.

subuk commented 6 years ago

And also update vm.xml.in:

       <readonly/>
     </disk>
-    <interface type='network'>
-      <source network='{{ .Network }}'/>
+    <interface type='bridge'>
+      <source bridge='{{ .Network }}'/>
       <model type='virtio'/>
     </interface>
subuk commented 6 years ago

How is it going? Does it work?