xcp.net.ifrename.static

Object for manipulating static rules.

Rules are of the form:

<target name>: <id method> = “value”

target name must be in the form eth* id methods are: - mac: value should be the MAC address of a device (e.g. DE:AD:C0:DE:00:00) - pci: value should be the PCI bus location of the device, optionally with an index (e.g. 0000:01:01.1[0]) - ppn: value should be the result of the biosdevname physical naming policy of a device (e.g. p1p1) - label: value should be the SMBIOS label of a device (for SMBIOS 2.6 or above)

Any line starting with ‘#’ is considered to be a comment

class xcp.net.ifrename.static.StaticRules(path=None, fd=None)[source]

Bases: object

Object for parsing the static rules configuration.

There are two distinct usecases; the installer needs to write the static rules from scratch, whereas interface-rename.py in dom0 needs to read them.

generate(state)[source]

Make rules from the formulae based on global state.

load_and_parse()[source]

Parse the static rules file. Returns boolean indicating success or failure.

methods = ['mac', 'pci', 'ppn', 'label', 'guess']
save(header=True)[source]

Save the static rules to a file/path. Returns boolean indicating success or failure.

validators = {'mac': re.compile('^([\\da-fA-F]{1,2}:){5}[\\da-fA-F]{1,2}$'), 'pci': re.compile('^(?P<sbdf>(?:(?P<segment> [\\da-dA-F]{4}):)?     (?P<bus>     [\\da-fA-F]{2}):     (?P<device>  [\\da-fA-F]{2})\\.     (?P<function>[\\da-fA-F]))  (?:[\\[](?P<index>[\\d]{1,2})[\\]])?$', re.VERBOSE), 'ppn': re.compile('^(?:em\\d+|p(?:ci)?\\d+p\\d+)$')}
write(header=True)[source]

Write the static rules to a string