diff --git a/lib/fog/opennebula/models/compute/interface.rb b/lib/fog/opennebula/models/compute/interface.rb index f807b1275..fec3257cb 100644 --- a/lib/fog/opennebula/models/compute/interface.rb +++ b/lib/fog/opennebula/models/compute/interface.rb @@ -9,10 +9,8 @@ module Fog identity :id attribute :vnet attribute :model - - def uuid - :id - end + attribute :name + attribute :mac def initialize attributes = {} super defaults.merge(attributes) @@ -22,6 +20,10 @@ module Fog raise Fog::Errors::Error.new('Creating a new interface is not yet implemented. Contributions welcome!') end + def new? + mac.nil? + end + def destroy raise Fog::Errors::Error.new('Destroying an interface is not yet implemented. Contributions welcome!') end diff --git a/lib/fog/opennebula/models/compute/server.rb b/lib/fog/opennebula/models/compute/server.rb index 1e34a8d19..8ea65140f 100644 --- a/lib/fog/opennebula/models/compute/server.rb +++ b/lib/fog/opennebula/models/compute/server.rb @@ -29,6 +29,15 @@ module Fog #reload end + def interfaces + #[] << Fog::Compute::OpenNebula::Interfaces.new + [] + end + + def interfaces_attributes=(attributes) + true + end + def vm_ip_address ip end diff --git a/lib/fog/opennebula/requests/compute/vm_allocate.rb b/lib/fog/opennebula/requests/compute/vm_allocate.rb index 85b285187..7b7a4c78b 100644 --- a/lib/fog/opennebula/requests/compute/vm_allocate.rb +++ b/lib/fog/opennebula/requests/compute/vm_allocate.rb @@ -48,9 +48,14 @@ module Fog temp = one["VM"]["TEMPLATE"] data["cpu"] = temp["VCPU"] unless temp["VCPU"].nil? data["memory"] = temp["MEMORY"] unless temp["MEMORY"].nil? - unless (temp["NIC"].nil?) then - data["mac"] = temp["NIC"]["MAC"] unless temp["NIC"]["MAC"].nil? - data["ip"] = temp["NIC"]["IP"] unless temp["NIC"]["IP"].nil? + unless (temp["NIC"].nil?) then + if one["VM"]["TEMPLATE"]["NIC"].is_a?(Array) + data["mac"] = temp["NIC"][0]["MAC"] unless temp["NIC"][0]["MAC"].nil? + data["ip"] = temp["NIC"][0]["IP"] unless temp["NIC"][0]["IP"].nil? + else + data["mac"] = temp["NIC"]["MAC"] unless temp["NIC"]["MAC"].nil? + data["ip"] = temp["NIC"]["IP"] unless temp["NIC"]["IP"].nil? + end end end