Merge ~chad.smith/cloud-init:schema-subcommand into cloud-init:master
| Status: | Merged |
|---|---|
| Merged at revision: | cc9762a2d737ead386ffb9f067adc5e543224560 |
| Proposed branch: | ~chad.smith/cloud-init:schema-subcommand |
| Merge into: | cloud-init:master |
| Prerequisite: | ~chad.smith/cloud-init:analyze |
| Diff against target: |
902 lines (+541/-91) 9 files modified
cloudinit/cmd/devel/__init__.py (+0/-0) cloudinit/cmd/devel/parser.py (+26/-0) cloudinit/cmd/main.py (+14/-7) cloudinit/config/cc_runcmd.py (+54/-28) cloudinit/config/schema.py (+165/-34) doc/rtd/topics/capabilities.rst (+9/-9) tests/unittests/test_cli.py (+20/-1) tests/unittests/test_handler/test_handler_runcmd.py (+108/-0) tests/unittests/test_handler/test_schema.py (+145/-12) |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Server Team CI bot | continuous-integration | Approve on 2017-08-23 | |
| Scott Moser | 2017-08-17 | Approve on 2017-08-22 | |
|
Review via email:
|
|||
Commit Message
schema cli: Add schema subcommand to cloud-init cli and cc_runcmd schema
This branch does a few things:
- Add 'schema' subcommand to cloud-init CLI for validating
cloud-config files against strict module jsonschema definitions
- Add --annotate parameter to 'cloud-init schema' to annotate
existing cloud-config file content with validation errors
- Add jsonschema definition to cc_runcmd
- Add unit test coverage for cc_runcmd
- Update CLI capabilities documentation
This branch only imports development (and analyze) subparsers when the
specific subcommand is provided on the CLI to avoid adding costly unused
file imports during cloud-init system boot.
The schema command allows a person to quickly validate a cloud-config text
file against cloud-init's known module schemas to avoid costly roundtrips
deploying instances in their cloud of choice. As of this branch, only
cc_ntp and cc_runcmd cloud-config modules define schemas. Schema
validation will ignore all undefined config keys until all modules define
a strict schema.
To perform validation of runcmd and ntp sections of a cloud-config file:
$ cat > cloud.cfg <<EOF
runcmd: bogus
EOF
$ python -m cloudinit.cmd.main schema --config-file cloud.cfg
$ python -m cloudinit.cmd.main schema --config-file cloud.cfg \
--annotate
Once jsonschema is defined for all ~55 cc modules, we will move this
schema subcommand up as a proper subcommand of the cloud-init CLI.
Description of the Change
schema cli: Add schema subcommand to cloud-init cli and cc_runcmd schema
This branch does a few things:
- Add 'devel schema' subcommand to cloud-init CLI for validating
cloud-config files against strict module jsonschema definitions
- Add --annotate parameter to 'cloud-init devel schema' to annotate
existing cloud-config file content with validation errors
- Add jsonschema definition to cc_runcmd
- Add unit test coverage for cc_runcmd
- Update CLI capabilities documentation
This branch only imports development (and analyze) subparsers when the
specific subcommand is provided on the CLI to avoid adding costly unused
file imports during cloud-init system boot.
The 'devel' subcommand is intended to be the home for developer tools
which can be run on the commandline on a system with cloud-init installed.
The schema command allows a person to quickly validate a cloud-config text
file against cloud-init's known module schemas to avoid costly roundtrips
deploying instances in their cloud of choice. As of this branch, only
cc_ntp and cc_runcmd cloud-config modules define schemas. Schema
validation will ignore all undefined config keys until all modules define
a strict schema.
To perform validation of runcmd and ntp sections of a cloud-config file:
$ cat > cloud.cfg <<EOF
runcmd: bogus
EOF
$ python -m cloudinit.cmd.main devel schema --config-file cloud.cfg
$ python -m cloudinit.cmd.main devel schema --config-file cloud.cfg \
--annotate
Once jsonschema is defined for all ~55 cc modules, we will move this
schema subcommand up as a proper subcommand of the cloud-init CLI.
To test:
$ cat > invalid-cloud.cfg <<EOF runcmd: bogus EOF
$ python -m cloudinit.cmd.main devel schema --config-file
invalid-cloud.cfg
# print docs as manpages
$ python -m cloudinit.cmd.main devel schema --doc | rst2man | man -l -
# generate docs and check capabilities topic
tox -e doc
PASSED: Continuous integration, rev:b57e9f11d3e
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
PASSED: Continuous integration, rev:51be991d3d0
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
- 30e8ffa... by Chad Smith on 2017-08-22
- 39ccb27... by Chad Smith on 2017-08-22
| Scott Moser (smoser) wrote : | # |
I think we decided with 'analyze' to move not move this to being "under 'devel'", but rther just having the help show 'Devel tool', and having the devel commands later in help output.
So, make similar changes to this merge proposal.
And t hen last, if you could drop the FIXME from cloudinit/
# FIXME put this under 'devel' subcommand (coming in next branch)
as I think its *not* coming in next branch.
Please also make sure your changes to doc/rtd/
- a96682b... by Chad Smith on 2017-08-22
- cd0a774... by Chad Smith on 2017-08-22
FAILED: Continuous integration, rev:a96682bc94d
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
- 54e9623... by Chad Smith on 2017-08-22
FAILED: Continuous integration, rev:54e96236793
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
- bc90905... by Chad Smith on 2017-08-22
- 1b1be36... by Chad Smith on 2017-08-22
FAILED: Continuous integration, rev:1b1be361dd1
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
FAILED: MAAS Compatability Testing
Click here to trigger a rebuild:
https:/
- 32af13a... by Chad Smith on 2017-08-22
FAILED: Continuous integration, rev:32af13a431d
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
FAILED: MAAS Compatability Testing
Click here to trigger a rebuild:
https:/
| Scott Moser (smoser) wrote : | # |
c-i stilldoesnt like your branch.
I updated the commit message, please do re-read it though to make sure it still is sane.
assuming you get c-i happy, I approve.
- 313dd89... by Chad Smith on 2017-08-22
PASSED: Continuous integration, rev:313dd8997fe
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/


FAILED: Continuous integration, rev:a154884b66a 2914c7fbb4c6df1 7a5a9c697e7d7e /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 163/
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
FAILED: MAAS Compatability Testing
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 163/rebuild
https:/