Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
require 'yaml' yaml = YAML::load(File.open("myyaml.yaml")) def create(sname,vname, mode, policy) agg = "dladm create-aggr" vname.each { |d| agg << "-l #{d}"} agg << " -L #{mode}" agg << " -P #{policy}" agg << " #{ sname}" puts agg end yaml.each do |name, options| if options['type'] == "aggr" vnames = Array.new vnames.push "#{options['device']}" policy = "#{options['policy'].join(',')}" create(name, vnames , "#{options['mode']}", "#{policy}") end end .................................. yaml file notsoconfi: policy: - L2 - L3 device: - vnic3 - vnic6 - vnic9 mode: active type: aggr confivnic: policy: - L3 - L4 device: - vnic1 - vnic2 mode: passive type: aggr ..... this gives me dladm create-aggr-l vnic3vnic6vnic9 -L active -P L2,L3 notsoconfi dladm create-aggr-l vnic1vnic2 -L passive -P L3,L4 confivnic but i want a split like this " -l vnic3 -l vnic6 -l vnic8" and so on for the next one!!!
From the Design Piracy series on my blog: