From ee77deb2f7cc03395b8923ec53dc7d04660e7cbf Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 18 Aug 2016 14:00:39 +0200 Subject: [PATCH] bug #4583: allow the use of : in nic extra attrs (cherry picked from commit 4dff8953e21e5853da49a1d993deef62b18d013b) --- src/cli/one_helper.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index fa74c263f5..692d66077d 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -936,6 +936,27 @@ EOT objects.each do |obj| obj, *extra_attributes = obj.split(":") + + # When extra attributes do not contain = character include + # them in the previous value. Fixes adding MAC addresses. These + # contain ":" character also used as extra attributes separator. + # + # It may be needed to strip the value from start and end quotes + # as the value could be written as this: + # + # --nic 'some_net:mac="00:0A:12:34:56:78"' + # + attrs = [] + extra_attributes.each do |str| + if str.include?("=") + attrs << str + else + attrs.last << ":#{str}" + end + end + + extra_attributes = attrs + res=parse_user_object(obj) return [-1, "#{section.capitalize} \"#{obj}\" malformed"] if !res user, object=*res