libioc.DevfsRules module¶
ioc module for host devfs rule configuration.
-
class
libioc.DevfsRules.
DevfsRules
(rules_file='/etc/devfs.rules', logger=None)[source]¶ Bases:
list
Abstraction for the hosts /etc/devfs.rules.
Read and edit devfs rules in a programmatic way. Restart the devfs service after applying changes.
-
append
(ruleset, is_system_rule=False)[source]¶ Add a DevfsRuleset to the list.
The rulesets added become indexed, so that lookups and duplication checks are easy and fast
- Parameters
ruleset (libioc.DevfsRules.DevfsRuleset|string) – The ruleset that gets added if it is not already in the list
- Return type
Union
[DevfsRuleset
,str
]
-
property
default_rules_file
¶ Return the default path to the devfs rules file.
- Return type
str
-
new_ruleset
(ruleset)[source]¶ Append a new ruleset.
Similar to append(), but automatically assigns a new number
- Parameters
ruleset (libioc.DevfsRules.DevfsRuleset) – The new devfs ruleset that is going to be added
- Returns
The devfs ruleset number of the created ruleset
- Return type
int
-
property
next_number
¶ Return the next highest ruleset number that is available.
This counting includes the systems default devfs rulesets.
- Return type
int
-
read_rules
()[source]¶ Read existing devfs.rules file.
Existing devfs rules get reset and read from the rules_file
- Return type
None
-
property
rules_file
¶ Path of the devfs.rules file.
- Return type
str
-
-
class
libioc.DevfsRules.
DevfsRuleset
(value=None, number=None, comment=None)[source]¶ Bases:
list
Representation of a devfs ruleset in the devfs.rules file.
DevfsRuleset instances behave like standard lists and can store strings that multiple lines (string)
-
PATTERN
= re.compile('^\\[(?P<name>[a-z](?:[a-z0-9\\-_]*[a-z0-9])?)=\n (?P<number>[0-9]+)\\]\\s*(?:\\#\\s*(?P<comment>.*))?$', re.VERBOSE)¶
-
clone
(source_ruleset)[source]¶ Clone the rules from another ruleset.
- Parameters
source_ruleset (libioc.DevfsRules.DevfsRuleset) – Ruleset to copy all rules from
- Return type
None
-