summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorJasper Capel <capel@stone-it.com>2009-02-03 14:31:34 +0100
committerJasper Capel <capel@stone-it.com>2009-02-03 14:31:34 +0100
commitc585e77f39b83f96534e6d4bf3bcc25c072e0bde (patch)
tree414808c00342eb195384da948fddc777799f4a2c /func
parentd8d17e21f945f378fb3bc909f789ac6c74f2ecc7 (diff)
downloadfunc-c585e77f39b83f96534e6d4bf3bcc25c072e0bde.tar.gz
func-c585e77f39b83f96534e6d4bf3bcc25c072e0bde.tar.xz
func-c585e77f39b83f96534e6d4bf3bcc25c072e0bde.zip
Added pydoc formatted documentation strings for vlan module.
Diffstat (limited to 'func')
-rw-r--r--func/minion/modules/vlan.py80
1 files changed, 66 insertions, 14 deletions
diff --git a/func/minion/modules/vlan.py b/func/minion/modules/vlan.py
index a973607..6b764c5 100644
--- a/func/minion/modules/vlan.py
+++ b/func/minion/modules/vlan.py
@@ -39,8 +39,10 @@ class Vlan(func_module.FuncModule):
ifdown = Option("/sbin/ifdown")
def list(self):
- # Returns a dictionary, elements look like this:
- # key: interface, value: [id1, id2, id3]
+ """
+ Returns a dictionary, elements look like this:
+ key: interface, value: [id1, id2, id3]
+ """
retlist = {}
@@ -66,8 +68,10 @@ class Vlan(func_module.FuncModule):
return retlist
def list_permanent(self):
- # Returns a dictionary of permanent VLANs, return format is the same as
- # in the list() method.
+ """
+ Returns a dictionary of permanent VLANs, return format is the same as
+ in the list() method.
+ """
retlist = {}
pattern = re.compile('ifcfg-([a-z0-9]+)\.([0-9]+)')
@@ -87,7 +91,13 @@ class Vlan(func_module.FuncModule):
def add(self, interface, vlanid):
- # Adds a vlan with vlanid on interface
+ """
+ Adds a vlan to an interface
+
+ Keyword arguments:
+ interface -- interface to add vlan to (string, for example: "eth0")
+ vlanid -- ID of the vlan to add (string, for example: "1100")
+ """
if vlanid not in self.options.ignorevlans:
exitcode = os.spawnv(os.P_WAIT, self.options.vconfig, [ self.options.vconfig, "add", interface, str(vlanid)] )
else:
@@ -96,7 +106,16 @@ class Vlan(func_module.FuncModule):
return exitcode
def add_permanent(self, interface, vlanid, ipaddr=None, netmask=None, gateway=None):
- # Permanently adds a VLAN by writing to an ifcfg-file
+ """
+ Permanently adds a VLAN by writing to an ifcfg-file
+
+ Keyword arguments:
+ interface -- interface to add vlan to (string, for example: "eth0")
+ vlanid -- ID of the vlan to add (string, for example: "1100")
+ ipaddr -- IP-address for this VLAN (string)
+ netmask -- Netmask for this VLAN (string)
+ gateway -- Gateway for this VLAN (string)
+ """
alreadyup = False
list = self.list()
if interface in list:
@@ -131,7 +150,13 @@ class Vlan(func_module.FuncModule):
return exitcode
def delete(self, interface, vlanid):
- # Deletes a vlan with vlanid from interface
+ """
+ Deletes a vlan from an interface.
+
+ Keyword arguments:
+ interface -- Interface to delete vlan from (string, example: "eth0")
+ vlanid -- Vlan ID to remove (string, example: "1100")
+ """
vintfname = interface + "." + str(vlanid)
if vlanid not in self.options.ignorevlans:
exitcode = os.spawnv(os.P_WAIT, self.options.vconfig, [ self.options.vconfig, "rem", vintfname] )
@@ -141,6 +166,14 @@ class Vlan(func_module.FuncModule):
return exitcode
def delete_permanent(self, interface, vlanid):
+ """
+ Permanently removes a vlan from an interface. This is useful when the vlan is configured through an ifcfg-file.
+
+ Keyword arguments:
+ interface -- interface to delete vlan from (string, example: "eth0")
+ vlanid -- Vlan ID to remove (string, example: "1100")
+ """
+
if vlanid not in self.options.ignorevlans:
device = "%s.%s" % (interface, vlanid)
filename = "/etc/sysconfig/network-scripts/ifcfg-%s" % device
@@ -154,7 +187,14 @@ class Vlan(func_module.FuncModule):
return exitcode
def up(self, interface, vlanid):
- # Marks a vlan interface as up
+ """
+ Marks a vlan interface as up
+
+ Keyword arguments:
+ interface -- interface this vlan resides on (string, example: "eth0")
+ vlanid -- ID for this vlan (string, example: "1100")
+ """
+
vintfname = interface + "." + str(vlanid)
if vlanid not in self.options.ignorevlans:
exitcode = os.spawnv(os.P_WAIT, self.options.ip, [ self.options.ip, "link", "set", vintfname, "up" ])
@@ -164,7 +204,13 @@ class Vlan(func_module.FuncModule):
return exitcode
def down(self, interface, vlanid):
- # Marks a vlan interface as down
+ """
+ Marks a vlan interface as down
+
+ Keyword arguments:
+ interface -- interface this vlan resides on (string, example: "eth0")
+ vlanid -- ID for this vlan (string, example: "1100")
+ """
vintfname = interface + "." + str(vlanid)
if vlanid not in self.ignorevlans:
exitcode = os.spawnv(os.P_WAIT, self.options.ip, [ self.options.ip, "link", "set", vintfname, "down" ])
@@ -174,9 +220,13 @@ class Vlan(func_module.FuncModule):
return exitcode
def make_it_so(self, configuration):
- # Applies the supplied configuration to the system.
- # Configuration is a dictionary, elements should look like this:
- # key: interface, value: [id1, id2, id3]
+ """
+ Applies the supplied configuration to the system.
+
+ Keyword arguments:
+ configuration -- dictionary, elements should look like this: key: interface, value: [id1, id2, id3]
+ """
+
currentconfig = self.list()
newconfig = {}
@@ -220,8 +270,10 @@ class Vlan(func_module.FuncModule):
return self.list()
def write(self):
- # Permantly applies configuration obtained through the list() method to
- # the system.
+ """
+ Permantly applies configuration obtained through the list() method to the system.
+ """
+
currentconfig = self.list_permanent()
newconfig = self.list()