summaryrefslogtreecommitdiffstats
path: root/os_net_config/cli.py
AgeCommit message (Collapse)AuthorFilesLines
2017-07-12Add schema-based config data validationFrank A. Zdarsky1-0/+19
This patch adds a jsonschema for os-net-config's configuration data and a library function to validate configuration data based on this schema. Adding schema-based validation allows catching a larger class of errors (typos, missing required parameters, etc.) for all devices configurable through os-net-config. The validation is run in the os-net-config CLI after loading the config file. If the config file fails to validate, the current default is to just log a warning and try to continue. By providing the new CLI option '--exit-on-validation-errors', this can be changed to log an error and exist instead. This validation is meant to be reusable, for example for pre-deployment validation of network environments (see change Ic16ee0bc353c46f8fe512454176a07ee95347346). Packaging with os-net-config makes it easier to keep object model and schema in sync. Change-Id: Ie4a905863b2d46c88d9cd6c3afc50e7d0a877090 Signed-off-by: Frank A. Zdarsky <fzdarsky@redhat.com>
2017-01-05Make os-net-config pass tox py3 testsFrank A. Zdarsky1-1/+1
This patch improves Python 3 compatibility by replacing .iteritems() with .items() for iterating over dicts and fixing two tests to use portable string comparison. Change-Id: I8e1acafe372f1696823561d6aa8aae5437d34025 Closes-Bug: #1654187
2015-08-14Add --detailed-exit-codesDan Prince1-0/+11
This patch adds a new --detailed-exit-codes option which can be used to optionally enable the os-net-config CLI to return exit code 2 if there have been modifications. Detailed exit codes are useful if you need to trigger subsequent external actions based whether os-net-config made changes or not. Change-Id: I8f22fa15335d1276f4e444a6454a24ff486e1495
2015-08-02Allow to specify the root directory of the filesystemFrederic Lepied1-11/+19
Change-Id: Ice1b8d17804cf7a0aafd308945a5e960fe927bbc
2015-04-30-v trumps -d on the CLIDan Prince1-3/+3
This patch updates the handling of the --debug and --verbose options so that if both are specified then log level is set to DEBUG. Change-Id: I65d5665631f5575d1c8343bb7c1b197a61e0e176 Closes-bug: #1450586
2015-03-05Add a --no-activate option to disable device up/down actionsSteven Hardy1-1/+9
Allows you to only install the config, but not take interfaces down/up. Useful if you wish to defer activation of a new config until a later time (e.g reboot). Change-Id: I42f3195e1d3d5d3b9d1c9dbb1f7cf1364503cbd3
2015-02-24Move noop flag to provider base-classSteven Hardy1-6/+6
Moving this flag makes it easier to implement additional functions which work differently depending on noop mode being set, vs passing it into every function like apply() Change-Id: I796792aece3e40322523e910a3b87f7ab9a451dd
2015-02-24Add a persist_mapping option to the mapping fileSteven Hardy1-1/+14
This adds the option to permanently rewrite the configuration so the aliases are used instead of the system name. This is useful where you have a variety of hardware and you want to have consistent device naming accross all platforms - this allows you to essentially rename the interfaces permanently so they match the abstracted nicN names. Note, this needs to be run with --cleanup or the old (now conflicting) configs will still be in place, and it may require a reboot before the changes are fully applied. Change-Id: I5af146e764b72c4beaa41c549fabff0af8802152
2015-02-24Add mapping option to influence nicN mapping orderSteven Hardy1-0/+19
Currently there's a fixed mapping between abstracted interface names (nic1, nic2 etc) and the underlying biosdevname for the device. In many cases, this mapping based on system enumeration is sufficient, but in some cases, particularly when you perform detailed pre-deployment discovery of interfaces, you may wish to alter the mapping independently of the config (e.g if the config is in a heat template, and the discovery data is provided at runtime). So this adds a -m option to os-net-config, which enables a mapping file to be provided, such that specific interfaces may be mapped to their abstract names based on knowledge of the devices or the networks they are connected to. The mapping file has the following format, where em1 and em2 are device names as detected by the OS (e.g biosdevname): interface_mapping: nic1: em2 nic2: em1 Or you can use the device MAC instead: interface_mapping: nic1: 12:34:56:78:9a:bc nic2: 12:34:56:de:f0:12 Change-Id: I93e6d3ed733244834bb3c2126c91db705b4d9167
2014-12-06Fix verbose/debug loglevelsSteven Hardy1-2/+2
These options seem to be reversed, in most other tools verbose means INFO and debug means DEBUG. Change-Id: I31005e4e10372018685a93dc2f80619f16c513d9
2014-09-04Move versioning into version.pyDan Prince1-2/+2
2014-08-20Add support for parsing YAMLDan Prince1-3/+3
Adds new YAML examples. Also adds some new CLI test cases which compare --noop stdout (from the CLI) for the json and yaml examples to verify they generate the same things.
2014-08-14Correct add_object call.Dan Prince1-1/+1
Missed this in 9e515950c7eb4a73e02a4f4883c223dd24ba93ff
2014-08-14Add --cleanup, and impl for ifcfgDan Prince1-1/+8
Adds a new cleanup option which can be used to ifdown and remove interfaces that exists but aren't specified in the object model (or JSON).
2014-08-11Use --noop instead of --mock.Dan Prince1-8/+9
Updates the apply() function for each NetConfig object so that it now accepts noop instead. Also, the updated files are not returned (always instead of conditionally if mock was used).
2014-08-11Adds mock ability to the ENI and Ifcfg providersmarios1-3/+14
Specifying mock=True for 'apply' will return a string representing the changes required, or commands to be used in order to implement the requested/specified configuration. This is also exposed to the cli, with -m (--mock), e.g. os-net-config --mock -c ./etc/example_os_net_config_1.json -p eni
2014-07-10Uncomment the provider.apply callDan Prince1-1/+1
This fixes issues where running os-net-config did nothing.
2014-07-09Add -d and -v options for logging level controlDan Prince1-14/+32
Adds -d (--debug) and -v (--verbose) options to control the log levels.
2014-07-07Add copyrights to files.Dan Prince1-0/+2
2014-07-01Add os-net-config CLIDan Prince1-0/+103
Adds a new CLI which parses the JSON and calls the configured provider to apply the configuration.