Skip to content

Commit

Permalink
B #4361: add NIC_ALIAS to onegate vm show (#4362)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Todorov <a.todorov@storpool.com>
  • Loading branch information
atodorov-storpool authored and rsmontero committed Apr 6, 2020
1 parent 8bc3b13 commit 0c9aa03
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/onegate/onegate-server.rb
Expand Up @@ -381,7 +381,7 @@ def update(object, params)
end
end

NIC_VALID_KEYS = %w(IP IP6_LINK IP6_SITE IP6_GLOBAL NETWORK MAC)
NIC_VALID_KEYS = %w(IP IP6_LINK IP6_SITE IP6_GLOBAL NETWORK MAC NAME PARENT)
USER_TEMPLATE_INVALID_KEYS = %w(SCHED_MESSAGE)

def build_vm_hash(vm_hash)
Expand All @@ -393,6 +393,14 @@ def build_vm_hash(vm_hash)
end
end

alias_nics = []

if vm_hash["TEMPLATE"]["NIC_ALIAS"]
[vm_hash["TEMPLATE"]["NIC_ALIAS"]].flatten.each do |nic|
alias_nics << Hash[nic.select{|k,v| NIC_VALID_KEYS.include?(k)}]
end
end

OpenNebula::VirtualMachine::EXTERNAL_IP_ATTRS.each do |attr|
external_ip = vm_hash["MONITORING"][attr]

Expand All @@ -411,7 +419,8 @@ def build_vm_hash(vm_hash)
!USER_TEMPLATE_INVALID_KEYS.include?(k)
}],
"TEMPLATE" => {
"NIC" => nics
"NIC" => nics,
"NIC_ALIAS" => alias_nics
}
}
}
Expand Down

0 comments on commit 0c9aa03

Please sign in to comment.