Skip to content

Commit 04f71ea

Browse files
authored
Merge pull request #88 from ATIX-AG/fix_nic_format
Fixes nics format for lxc containers
2 parents 0c290b5 + 3cea225 commit 04f71ea

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/fog/proxmox/helpers/nic_helper.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,16 @@ def self.set_mac(nic_id, nic_hash)
9898

9999
# Convert nic attributes hash into API Proxmox parameters string
100100
def self.flatten(nic_hash)
101-
nic_id = nic_hash[nic_name(nic_hash).to_sym]
102-
nic_value = set_mac(nic_id, nic_hash)
103-
options = nic_hash.reject do |key, _value|
104-
[nic_name(nic_hash).to_sym, :id, :macaddr, :hwaddr].include? key.to_sym
101+
if nic_hash[:hwaddr].nil?
102+
nic_id = nic_hash[nic_name(nic_hash).to_sym]
103+
nic_value = set_mac(nic_id, nic_hash)
104+
options = nic_hash.reject do |key, _value|
105+
[nic_name(nic_hash).to_sym, :id, :hwaddr, :macaddr].include? key.to_sym
106+
end
107+
nic_value += ',' + Fog::Proxmox::Hash.stringify(options) unless options.empty?
108+
else
109+
nic_value = Fog::Proxmox::Hash.stringify(nic_hash.except(%i[id model macaddr])) unless nic_hash.empty?
105110
end
106-
nic_value += ',' + Fog::Proxmox::Hash.stringify(options) unless options.empty?
107111
{ "#{nic_hash[:id]}": nic_value }
108112
end
109113

0 commit comments

Comments
 (0)