calm-dsl
calm-dsl copied to clipboard
Add more validation when checking for valid provider spec with "calm validate"
When running commands like this:
calm validate provider_spec --file ./specs/MYSQL_AWS_provider_spec.yaml
The DSL will throw an exception such as the following:
AWS_provider_spec.yaml
[2020-06-10 04:00:36] calm.dsl.cli.main [INFO] File ./specs/MYSQL_AWS_provider_spec.yaml is invalid AHV_VM spec
Traceback (most recent call last):
File "/home/chris/Data/solutions/nutanix/calm-dsl/calm/dsl/cli/main.py", line 94, in validate_provider_spec
Provider.validate_spec(spec)
File "/home/chris/Data/solutions/nutanix/calm-dsl/calm/dsl/providers/base.py", line 68, in validate_spec
Validator.validate(spec)
File "/home/chris/Data/solutions/nutanix/calm-dsl/venv/lib/python3.8/site-packages/jsonschema/validators.py", line 353, in validate
raise error
calm.dsl.tools.validator.validation_error: Additional properties are not allowed : 'associate_public_ip_address'
Seems as if the DSL assumes AHV spec unless explicitly told that it is not AHV spec.
This error can be avoided by altering command to be as follows (note addition of --type parameter):
calm validate provider_spec --file ./specs/MYSQL_AWS_provider_spec.yaml --type AWS_VM
DSL should be able to take the provided spec and check more than just presence of "type: PROVISION_AWS_VM" or use of "--type" parameter, then validate accordingly.
Comment from @abhijeetkaurav1st as follows:
First check if type attribute is defined, else go for type in spec
This approach makes sense.