Class: Lenovo::PowerVFw
- Inherits:
-
Object
- Object
- Lenovo::PowerVFw
- Defined in:
- lib/lenovo-powervfw.rb
Instance Method Summary collapse
-
#add_rule(name, options = {}) ⇒ Object
Add a packet filter rule which type is deny.
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(host, user, password) ⇒ PowerVFw
constructor
A new instance of PowerVFw.
Constructor Details
#initialize(host, user, password) ⇒ PowerVFw
Returns a new instance of PowerVFw.
5 6 7 8 9 10 11 |
# File 'lib/lenovo-powervfw.rb', line 5 def initialize(host, user, password) begin @session = Net::SSH.start(host, user, :password => password) rescue puts $! end end |
Instance Method Details
#add_rule(name, options = {}) ⇒ Object
Add a packet filter rule which type is deny.
{
:name => 'Rule Name', # rule name, required.
:id => 'id', # rule id, must be in 1..65535, optional,
# default value is the last one.
:sa => 'any' | '
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/lenovo-powervfw.rb', line 40 def add_rule(name, = {}) type = 'deny' cmd = "rule add type #{type} name #{name} " cmd << "id #{options[:id]} " if .has_key? :id cmd << "sa #{options[:sa] || 'any'} " if .has_key? :sa cmd << "sport #{options[:sport] || 'any'} " if .has_key? :sport cmd << "smac #{options[:smac] || 'any'} " if .has_key? :smac cmd << "da #{options[:da] || 'any'} " if .has_key? :da cmd << "iif #{options[:iif] || 'any'} " if .has_key? :iif cmd << "oif #{options[:oif] || 'any'} " if .has_key? :oif cmd << "service #{options[:service] || 'any'} " if .has_key? :service cmd << "time #{options[:time] || 'none'} " if .has_key? :time cmd << "log #{options[:log] || 'off'} " if .has_key? :log cmd << "active #{options[:active] || 'on'} " if .has_key? :active cmd << "comment #{options[:comment]}" if .has_key? :comment output = @session.exec!(cmd.strip) not output.include? 'Error' end |
#close ⇒ Object
17 18 19 |
# File 'lib/lenovo-powervfw.rb', line 17 def close @session.close end |
#closed? ⇒ Boolean
13 14 15 |
# File 'lib/lenovo-powervfw.rb', line 13 def closed? @session.nil? or @session.closed? end |