xcp.net.ifrename.dynamic

Object for manipulating dynamic rules.

The dynamic rules file on disk is a JSON file with optional line comments beginning with a # character.

class xcp.net.ifrename.dynamic.DynamicRules(path=None, fd=None)[source]

Bases: object

Object for parsing the dynamic rules configuration.

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

generate(state)[source]

Make rules from the formulae based on global state.

load_and_parse()[source]

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

save(header=True)[source]

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

write(header=True)[source]

Write the dynamic rules to a string