From 9fcb2a78941a8af3a60e87eb41ece637e5a521dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Achim=20Lederm=C3=BCller?= Date: Mon, 16 Jun 2014 22:11:09 +0200 Subject: [PATCH] [opennebula] identify the network by id or name within a flavor --- lib/fog/opennebula/requests/compute/template_pool.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/fog/opennebula/requests/compute/template_pool.rb b/lib/fog/opennebula/requests/compute/template_pool.rb index 7f1954e8e..53b1b9be2 100644 --- a/lib/fog/opennebula/requests/compute/template_pool.rb +++ b/lib/fog/opennebula/requests/compute/template_pool.rb @@ -63,9 +63,14 @@ module Fog h["NIC"] = [] # reset nics to a array if nics.is_a? Array nics.each do |n| - n["model"] = "virtio" if n["model"].nil? - n["uuid"] = "0" if n["uuid"].nil? # is it better is to remove this NIC? - h["NIC"] << interfaces.new({ :vnet => networks.get(n["uuid"]), :model => n["model"]}) + if n["NETWORK_ID"] + vnet = networks.get(n["NETWORK_ID"].to_s) + elsif n["NETWORK"] + vnet = networks.get_by_name(n["NETWORK"].to_s) + else + next + end + h["NIC"] << interfaces.new({ :vnet => vnet, :model => n["MODEL"] || "virtio" }) end elsif nics.is_a? Hash nics["model"] = "virtio" if nics["model"].nil? @@ -82,7 +87,6 @@ module Fog else # should i break? end - # every key should be lowercase ret_hash = {}