Have you tested this for cases where not all uplinks are being removed from the standard switch? This is a reasonable use case.

I would be more comfortable with 

    sw.spec.bridge.nicDevice -= migrating_pnic
    sw.spec.bridge = nil if sw.spec.bridge.nicDevice.empty?