Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Iptables returns hashes:
- {"status" => false
- "output" => "Failed to add 1.2.3.4: <ip tables output>"}
- The helper would be:
- @agents["iptables"].firewall("1.2.3.4")
- @agents["iptables"].unfirewall("1.2.3.4")
- @agents["iptables"].firewalled?("1.2.3.4")
- And would return lets say:
- {"status" => false,
- "nodestatuses => [ <node 1 status as from the agent>, <node 2 status as from the agent> ]}
- today without the helper it's:
- req = {"command" => "isblocked", "ip" => @ips[device]}
- @options[:filter]["agent"] = "iptables"
- client = MCollective::Client.new(@options[:config])
- client.req(req, "iptables", @options, @options[:waitfor]) do |resp|
- unless resp[:body]["status"]
- raise("Not blocked on #{resp[:senderid]}")
- end
- end
- It could become, and the helper would do all the above 'today' steps:
- @agents.options = options
- ret = @agents["iptables"].firewall("1.2.3.4")
- raise("Failed to firewall 1.2.3.4") unless ret["status"]
- Or:
- raise("1.2.3.4 is not firewalled") unless @agents["iptables"].firewall("1.2.3.4")["status"]
Add Comment
Please, Sign In to add comment