networkop / docker-topo

Docker topology builder for network simulations
BSD 3-Clause "New" or "Revised" License
139 stars 41 forks source link

add macvlan support #3

Closed jorisc90 closed 6 years ago

jorisc90 commented 6 years ago

Hi Michael,

I added Macvlan support to be able to connect your cEOS instances to an CVP instance outside of the Docker host. Please check and be kind to my code - I'm an SE and no programmer 😅

networkop commented 6 years ago

Thanks man, looks interesting. I'm a bit busy atm, will have a closer look over the weekend. What's you usecase? Why do you need to connect this to outside box? Because you can run CVP in a container on the same host..

jorisc90 commented 6 years ago

My usecase is double; I already had a CVP instance running on another machine, and in addition to that I was not able to run the CVP container due to my working environment was already within a LXC container (later on I discovered this also breaks cEOS' forwarding plane, but that's a separate issue).

My main thought was that this would make deploying testbeds more flexible.

Op do 3 mei 2018 om 14:32 schreef networkop notifications@github.com:

Thanks man, looks interesting. I'm a bit busy atm, will have a closer look over the weekend. What's you usecase? Why do you need to connect this to outside box? Because you can run CVP in a container on the same host..

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/networkop/arista-ceos-topo/pull/3#issuecomment-386279803, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwLekpDByumIDQ-crDWKK29kfGWxBl-ks5tuvj3gaJpZM4Tw0mG .

networkop commented 6 years ago

I was thinking about using macvlan but in a slightly different way. Since each element in links is a representation of a physical link, i was thinking about adding some metadata to the elements of the list and build a network with a different driver. Something like this: links:

BTW, Why do you need to connect CVP over the macvlan bridge? wouldn't it work just using the normal routed IP?

jorisc90 commented 6 years ago

I agree it's not the nicest implementation, misusing the endpoints to specify a driver. My python was (is) kinda rusty, so that's why I went with the easy way. Thinking of trying to implement this, and in addition also add veth pairs as a second driver option for p2p links seems like a nice feature.

Op do 3 mei 2018 om 17:58 schreef networkop notifications@github.com:

I was thinking about using macvlan but in a slightly different way. Since each element in links is a representation of a physical link, i was thinking about adding some metadata to the elements of the list and build a network with a different driver. Something like this: links:

  • driver: macvlan
  • endpoints: ["Device-1:Interface1", "Device-2:Interface1"]
  • driver: bridge
  • endpoints: ["Device-1:Interface2", "Device-2:Interface2"] Which, I think is similar to what you've done. Anyhow, i'll play with the idea over the weekend.

BTW, Why do you need to connect CVP over the macvlan bridge? wouldn't it work just using the normal routed IP?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/networkop/arista-ceos-topo/pull/3#issuecomment-386345639, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwLeu1aDNjJpB046daU0UKXsLqhg55nks5tuyk1gaJpZM4Tw0mG .

networkop commented 6 years ago

That's exactly what I was thinking. Be able to add direct veth as one of the drivers for folks who like LACP. Do you want to have a shot at it? I was thinking to split the topology build from main into its own function, and also provide yaml file versioning, similar to docker-compose, so that we can make non-backwards compatible changes without breaking things for everyone. This way in topology build function I can basically have something like this if yaml_version == 1: build_topo_v1(args) elif yaml_version == 2: build_topo_v2(args) else: LOG.error("wrong version")

jorisc90 commented 6 years ago

Sounds good. I've got some time today to start works on it. Will push to my git repo; working or broken as I won't have a lot of time this weekend.

Will let you know.

Op vr 4 mei 2018 om 11:35 schreef networkop notifications@github.com:

That's exactly what I was thinking. Be able to add direct veth as one of the drivers for folks who like LACP. Do you want to have a shot at it? I was thinking to split the topology build from main into its own function, and also provide yaml file versioning, similar to docker-compose, so that we can make non-backwards compatible changes without breaking things for everyone. This way in topology build function I can basically have something like this if yaml_version == 1: build_topo_v1(args) elif yaml_version == 2: build_topo_v2(args) else: LOG.error("wrong version")

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/networkop/arista-ceos-topo/pull/3#issuecomment-386550709, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwLenJakhppu9V9l3fTJl-jT_KWGi3iks5tvCDggaJpZM4Tw0mG .

jorisc90 commented 6 years ago

See https://github.com/jorisc90/arista-ceos-topo

Current state is broken; had it working before... can't find what I'm doing wrong so quickly.

({'Device-A': <main.CEOS object at 0x7f353b149b00>, 'Device-B': <main.CEOS object at 0x7f353b149b70>}, [<main.Link object at 0x7f353b149e48>]) Traceback (most recent call last): File "./bin/ceos-topo", line 465, in main() File "./bin/ceos-topo", line 430, in main for idx,name in enumerate(sorted(devices.keys())): AttributeError: 'tuple' object has no attribute 'keys'

I put in the config versioning and parsing, both macvlan and bridge logic are in. Veth pairs not started yet.

Cheers,

Op vr 4 mei 2018 om 11:42 schreef Joris Claassen joris@claassen.co:

Sounds good. I've got some time today to start works on it. Will push to my git repo; working or broken as I won't have a lot of time this weekend.

Will let you know.

Op vr 4 mei 2018 om 11:35 schreef networkop notifications@github.com:

That's exactly what I was thinking. Be able to add direct veth as one of the drivers for folks who like LACP. Do you want to have a shot at it? I was thinking to split the topology build from main into its own function, and also provide yaml file versioning, similar to docker-compose, so that we can make non-backwards compatible changes without breaking things for everyone. This way in topology build function I can basically have something like this if yaml_version == 1: build_topo_v1(args) elif yaml_version == 2: build_topo_v2(args) else: LOG.error("wrong version")

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/networkop/arista-ceos-topo/pull/3#issuecomment-386550709, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwLenJakhppu9V9l3fTJl-jT_KWGi3iks5tvCDggaJpZM4Tw0mG .

networkop commented 6 years ago

no worries, will check it out over the weekend. have a good one yourself!

networkop commented 6 years ago

i think i got it working in my dev branch based on what you've done with some modifications. check it out, see if it works for you.

jorisc90 commented 6 years ago

Cool, seems to be working for me. Nice update!

Now I think the most tricky part - veth pairs. What kind of means are you planning on using for that? A python library or just executing ip commands through run_cmd? Op ma 7 mei 2018 om 10:54 schreef networkop notifications@github.com:

i think i got it working in my dev branch based on what you've done with some modifications. check it out, see if it works for you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/networkop/arista-ceos-topo/pull/3#issuecomment-387002159, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwLeknSmzLq3KDChApWgncwAEEtr2VBks5twAu4gaJpZM4Tw0mG .

networkop commented 6 years ago

I've already done veth as well. I couldn't think of a "API" way of doing this so I done it with shell commands. You can test it and see if it works for you. I've tried with a couple of cEOS interconnected B2B and it worked. (at least i could ping over an LACP port-channel). If you know of a better way of doing this, that wouldn't involve bunch of shell commands - let me know. I'd be interested to throw them out and replace with a cleaner code.

jorisc90 commented 6 years ago

I also thought of this as the "easy" way. If I read correctly, support was added to pyroute2: https://github.com/svinota/pyroute2/issues/84

Could be of help to clean the code.

Op ma 7 mei 2018 om 13:25 schreef networkop notifications@github.com:

I've already done veth as well. I couldn't think of a "API" way of doing this so I done it with shell commands. You can test it and see if it works for you. I've tried with a couple of cEOS interconnected B2B and it worked. (at least i could ping over an LACP port-channel). If you know of a better way of doing this, that wouldn't involve bunch of shell commands - let me know. I'd be interested to throw them out and replace with a cleaner code.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/networkop/arista-ceos-topo/pull/3#issuecomment-387035876, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwLenRoW172YNqPrDp8TDJk9vc7eLa7ks5twC8ngaJpZM4Tw0mG .

networkop commented 6 years ago

wow, this is super cool. I've never seen that library before. It's definitely worth re-writing what we can with this.

networkop commented 6 years ago

everything's been merged into master in https://github.com/networkop/arista-ceos-topo/pull/4