fog / fog-vsphere

Fog for vSphere
MIT License
36 stars 63 forks source link

def raw_to_hash(nic) in list_vm_interfaces.rb does not handle nsx-t interfaces #245

Closed robsee closed 4 years ago

robsee commented 4 years ago

def raw_to_hash currently returns nil for the network when an interface is linked to an NSX-T segment. This breaks provisioning within foreman when using nsx-t segments

robsee commented 4 years ago

It looks like a helper such as https://github.com/terraform-providers/terraform-provider-vsphere/blob/master/vsphere/internal/helper/nsx/nsx_helper.go would be needed.

timogoebel commented 4 years ago

@robsee:

If I understand you correctly, the issue occurs here. Do you know what needs to be changed for this to work? I can help you with the ruby side of the issue, but would need some help with the logic.

https://github.com/fog/fog-vsphere/blob/e137fa794f0641c0e59535fbd9ef9a9ed000e85f/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb#L65-L85

robsee commented 4 years ago

Yes this is correct. You have access to nic.backing.opaqueNetworkId which is a UUID. The problem is that you can't work backwards directly from that to a network name or id. As far as I know you have to do a scan of all of the available port groups, and the look for the one with the matching opaqueNetworkId to get the actual portgroup name/id. I couldn't see a way to do this within the existing models of fog-vsphere. I'm sure it can be done using direct rbvmomi calls though

robsee commented 4 years ago

https://github.com/OpenNebula/one/blob/master/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb#L740-759 is how one project handled it

robsee commented 4 years ago

My attempt at a fix: https://github.com/robsee/fog-vsphere/commit/18396a3ff8e73ebe86eabfcc58be74b38668c503

timogoebel commented 4 years ago

@robsee: Nice, do you mind opening a PR? There are some small nits we need to address, but I can totally see the PR merged soon.

fwdIT commented 4 years ago

I think we can close this, no ? @ezr-ondrej can you make a new release plz fingers crossed :) would be nice to also have this included in the v2.0 repo

timogoebel commented 4 years ago

@fwdIT : There you go: https://rubygems.org/gems/fog-vsphere/versions/3.3.0

To bump the version in foreman, do you mind opening a PR at the foreman-packaging repo?

chris1984 commented 4 years ago

@fwdIT let me know if you have any issues bumping the release, I can create the PR if you hit too many issues.

fwdIT commented 4 years ago

@timogoebel thx @chris1984 will have a look at it now, first time but let's see if I can figure it out :)

fwdIT commented 4 years ago

@chris1984 not there yet, it was a busy day at work but through irc I learnt this morning at least about the need / use of git-annex for the reference to the gem. installation on macos was easy but then when following the steps in the README I got stuck on spectool (rpm stuff is not that nice on macos). So I created a docker rhel7 image mapping to my git repo folder (with my ssh/git config) and I got annex to init, setup_sources.sh is running at the moment and taking quite some time (perhaps due to the not so optimal docker workaround) nevertheless it seems to progress so to be continued tomorrow. will first try to learn the process myself before fallback on your suggestion :) keep you updated