Class: Reyes::IPSet

Inherits:
Struct
  • Object
show all
Defined in:
lib/reyes/ipset.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#headerObject

Returns the value of attribute header

Returns:

  • (Object)

    the current value of header



57
58
59
# File 'lib/reyes/ipset.rb', line 57

def header
  @header
end

#membersObject

Returns the value of attribute members

Returns:

  • (Object)

    the current value of members



57
58
59
# File 'lib/reyes/ipset.rb', line 57

def members
  @members
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



57
58
59
# File 'lib/reyes/ipset.rb', line 57

def name
  @name
end

#referencesObject

Returns the value of attribute references

Returns:

  • (Object)

    the current value of references



57
58
59
# File 'lib/reyes/ipset.rb', line 57

def references
  @references
end

#revisionObject

Returns the value of attribute revision

Returns:

  • (Object)

    the current value of revision



57
58
59
# File 'lib/reyes/ipset.rb', line 57

def revision
  @revision
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



57
58
59
# File 'lib/reyes/ipset.rb', line 57

def size
  @size
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



57
58
59
# File 'lib/reyes/ipset.rb', line 57

def type
  @type
end

Class Method Details

.load(name) ⇒ Object

Parameters:

  • name (Name)

    of the set to load



62
63
64
# File 'lib/reyes/ipset.rb', line 62

def self.load(name)
  new(*load_by_name(name))
end

.load_allObject

Loads all IPSets from the local system



68
69
70
71
72
# File 'lib/reyes/ipset.rb', line 68

def self.load_all
  cmd = ['ipset', 'list']
  output = Subprocess.check_output(cmd)
  return output.split("\n\n").map { |x| new(*parse(x)) }
end

Instance Method Details

#drop!Object

Drops the currect IPSet, destroying it on the underlying system



75
76
77
78
79
80
81
# File 'lib/reyes/ipset.rb', line 75

def drop!
  begin
    Subprocess.check_call(["ipset", "destroy", name])
  rescue Subprocess::NonZeroExit
    raise Error.new("Couldn't destroy #{name}")
  end
end