Skip to content

Commit

Permalink
Merge pull request #137 from mika-b/fix-backwards-compatibility-with-…
Browse files Browse the repository at this point in the history
…ovirt-4.3

fix for backwards compatibility with ovirt 4.3
  • Loading branch information
myoung34 authored Jan 11, 2021
2 parents 0309721 + 9d1ef6b commit 17197f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/vagrant-ovirt4/action/read_ssh_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ def read_ssh_info(env)

nics_service = server.nics_service
nics = nics_service.list
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment.reported_devices).collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first rescue nil
begin
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment.reported_devices).collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first
rescue
# for backwards compatibility with ovirt 4.3
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment).reported_devices.collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first rescue nil
end

# Return the info
# TODO: Some info should be configurable in Vagrantfile
Expand Down
8 changes: 7 additions & 1 deletion lib/vagrant-ovirt4/action/read_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ def read_state(env)
end
nics_service = server.nics_service
nics = nics_service.list
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment.reported_devices).collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first rescue nil
begin
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment.reported_devices).collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first
rescue
# for backwards compatibility with ovirt 4.3
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment).reported_devices.collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first rescue nil
end

unless ip_addr.nil?
env[:ip_address] = ip_addr
@logger.debug("Got output #{env[:ip_address]}")
Expand Down
8 changes: 7 additions & 1 deletion lib/vagrant-ovirt4/action/wait_till_up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ def call(env)

nics_service = server.nics_service
nics = nics_service.list
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment.reported_devices).collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first rescue nil
begin
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment.reported_devices).collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first
rescue
# for backwards compatibility with ovirt 4.3
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment).reported_devices.collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first rescue nil
end

unless ip_addr.nil?
env[:ui].info("Got IP: #{ip_addr}")
# Check if SSH-Server is up
Expand Down

0 comments on commit 17197f3

Please sign in to comment.