2015-09-03 15:10:08 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
require 'resources/file'
|
|
|
|
|
|
|
|
module Vulcano::Resources
|
|
|
|
class Bond < File
|
|
|
|
name 'bond'
|
|
|
|
|
|
|
|
def initialize(bond)
|
|
|
|
@path = "/proc/net/bonding/#{bond}"
|
|
|
|
@file = vulcano.file(@path)
|
|
|
|
@content = nil
|
|
|
|
@params = {}
|
|
|
|
@loaded = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def read_content
|
|
|
|
# parse the file
|
|
|
|
@content = @file.content
|
|
|
|
@params = SimpleConfig.new(@file.content,
|
|
|
|
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
|
|
|
|
multiple_values: true
|
|
|
|
).params if @file.exists?
|
|
|
|
@loaded = true
|
|
|
|
@content
|
|
|
|
end
|
|
|
|
|
|
|
|
# ensures the content is loaded before we return the params
|
|
|
|
def params
|
|
|
|
read_content if @loaded == false
|
|
|
|
@params
|
|
|
|
end
|
|
|
|
|
|
|
|
def content
|
|
|
|
read_content if @loaded == false
|
|
|
|
@content
|
|
|
|
end
|
|
|
|
|
|
|
|
def exists?
|
|
|
|
@file.exists?
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_interface?(interface)
|
2015-09-03 18:35:23 +00:00
|
|
|
params()['Slave Interface'].include?(interface)
|
2015-09-03 15:10:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def interfaces
|
2015-09-03 18:35:23 +00:00
|
|
|
params()['Slave Interface']
|
2015-09-03 15:10:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|