Revision 976e979f src/vnm_mad/remotes/lib/vnm_driver.rb

View differences:

src/vnm_mad/remotes/lib/vnm_driver.rb
85 85
            nic_conf = {}
86 86

  
87 87
            if nic[:conf]
88
                parse_options(nic[:conf]).each do |opt|
89
                    value = opt[:value]
90

  
88
                parse_options(nic[:conf]).each do |option, value|
91 89
                    case value.downcase
92 90
                    when 'true', 'yes'
93 91
                        value = true
......
95 93
                        value = false
96 94
                    end
97 95

  
98
                    nic_conf[opt[:option].to_sym] = value
96
                    nic_conf[option.to_sym] = value
99 97
                end
100 98
            end
101 99

  
......
126 124
        end
127 125

  
128 126
        def self.parse_options(string)
129
            return [] if !string
127
            options = {}
128
            return options if !string
130 129

  
131
            string.split(',').map do |op|
130
            string.split(',').each do |op|
132 131
                m = op.match(/^\s*(?<option>[^=]+)\s*=\s*(?<value>.*?)\s*$/)
133 132

  
134
                if m
135
                    {
136
                        :option => Shellwords.escape(m['option']),
137
                        :value  => Shellwords.escape(m['value'])
138
                    }
139
                else
140
                    nil
141
                end
142
            end.flatten
133
                options[m['option']] = m['value'] if m
134
            end
135

  
136
            options
143 137
        end
144 138
    end
145 139
end

Also available in: Unified diff