Commit Graph

13 Commits

Author SHA1 Message Date
Ryan Schroder 9d983e4874 [FIX] Bug fix for template path ValueError
Add cleaning step to remove ending slash in template path entered from CLI

Change-Id: I1ec8f48918b54b4733658ed7001b6e6462bef7a8
2019-12-11 14:44:51 +00:00
Alexander Hughes 9689dae61f Standardize Spyglass code with YAPF
From recently merged document updates in [0] there is a desire to
standardize the Airship project python codebase.  This is the effort
to do so for the Spyglass project.

[0] https://review.opendev.org/#/c/671291/

Co-Authored-By: Ian Pittwood <pittwoodian@gmail.com>
Change-Id: I2b0f2491d83675d7742b168ecb9e1dfb9a11e719
2019-07-25 17:01:33 +00:00
Ian H. Pittwood efe24d8a5f Use data objects for document generation
This is a follow-up change to [0] which further implements data objects
to be used in the generation of documents in Jinja2. The following
additions and changes are made:

- Adds helper functions to data objects to filter hosts and networks for
ease of use in Jinja2 templates
- Adds SiteDocumentData factory function to convert intermediary yaml
dictionaries into a SiteDocumentData object with all associated objects
- Updates Jinja2 templates to use data objects
- Cleans up overly complex looping in Jinja2
- Adds tests for new code in models.py

[0] https://review.opendev.org/#/c/662092/

Change-Id: I66ebfeaf5d6ca76b6dee5a2285a74bad8b06b720
2019-06-26 12:03:40 -05:00
Ian H. Pittwood 0d6eca47a1 Manifest undefined data validation
This change verifies that manifests generated by Jinja2 do not contain
undefined data. If Spyglass attempts to generate a manifest file that
references undefined data, all previously created manifests will be
deleted and an error will be thrown. Users may bypass this function by
using the "--force" CLI option which will change all undefined data
errors to warnings instead.

Adds undefined data validation to Jinja2 manifest generation.

Adds "--force" option to bypass undefined data validation.

Adds tests for site_processor.py and enables tox testing/coverage.

Change-Id: Iff000eb173995156fbc6b44e621c59ba4dffae35
2019-06-11 15:31:53 +00:00
Ian Pittwood 3396b9fa0e Removes remaining yapf: disable statements
The initial addition of yapf into Spyglass caused a few alignment
issues that were temporarily fixed by disabling yapf. This change adds
a knob to the yapf configuration that causes long function statements
to always break before the first statement. This results in more
consistent, visually pleasing code.

Change-Id: I18f9a7677c61524fed12e71a2ecf1003a6ee0ad9
2019-05-14 12:30:29 -05:00
Ian H. Pittwood 7cf016e05f Add yapf configuration file
Some of the default behaviors of yapf do not match the styling
preferences of Airship and OpenDev, such as line breaks between
dictionary key/value pairs. This change sets the style template for yapf
(PEP-8) and sets a few knobs to help remedy problematic behavior.

Adds .style.yapf configuration file.

Updates styling of existing files using new configuration.

Change-Id: Ifea58ef2d7be93f47dd8e4f42cac6aea514b83bd
2019-04-29 15:37:25 -05:00
Alexander Hughes 3bf68e464a PEP-8 code styling and linting
As a newer project, Spyglass is still a work in progress in terms of its
styling. This change is meant to help improve readability and compliance
of Spyglass source code.

To match other Airship projects, this change implements YAPF into tox so
linting is automatically ran. This will hopefully keep formatting grey
areas styled consistently.

PEP-8: https://www.python.org/dev/peps/pep-0008/

OpenStack Style Guidelines:
https://docs.openstack.org/hacking/latest/user/hacking.html

PEP Index: https://www.python.org/dev/peps/

Depends on https://review.openstack.org/#/c/648764.

Change-Id: I45b19cc8a7932fd7823dcb69f64a0a1bf19fc434
2019-04-22 18:46:48 +00:00
Alexander Hughes 03a058bfcf Various fixes to Spyglass to resolve tox errors
The tox configuration needs to be updated in order for it to be helpful
for Zuul. This change makes some minor modifications to the tox config
to improve its usability and uniformity with other Open Stack configs.

Makes bare minimum changes for pep8 tests compliance.

Adds gate scripts for white space linting.

In the future, additional changes will need to be made to add tests to
Spyglass. These changes will need to enable the 'py36' and 'cover' tox
env and set coverage levels. Additional linting should also be
performed to improve Spyglass code readability and organization.

Change-Id: I73f946619786e661d02c69bd8e197453f049e0c7
2019-04-16 12:22:53 -05:00
Zuul 0cf4fb0523 Merge "Set autoescape=True to resolve Bandit B701 error" 2019-04-08 20:48:31 +00:00
Tin Lam 89dfec7b4c Add gate
This patch set puts in a rudimentary gate.

Change-Id: I3a2466bd7be5352b46273b385d215913eb8079ba
Signed-off-by: Tin Lam <tin@irrational.io>
2019-04-04 19:25:58 -05:00
Alexander Hughes fab8844461 Set autoescape=True to resolve Bandit B701 error
From Bandit's read the docs:
Jinja2 is a Python HTML templating system. It is typically used to build web
applications, though appears in other places well, notably the Ansible
automation system. When configuring the Jinja2 environment, the option to use
autoescaping on input can be specified. When autoescaping is enabled, Jinja2
will filter input strings to escape any HTML content submitted via template
variables. Without escaping HTML input the application becomes vulnerable to
Cross Site Scripting (XSS) attacks.

Change-Id: I95481c1e863ee144611f85d63274b4514d99a926
2019-04-01 12:42:05 -05:00
Purnendu Ghosh 4a8e2720e1 Base Code for Tugboat Plugin and Addition of config files, templates 2018-11-29 02:20:31 +05:30
Hemanth Nakkina 296705a0a5 Base code for spyglass
- Spyglass skelton with engine, site processor
- Spyglass data extractor with formation plugin
- Docker files and scripts to run spyglass
2018-11-28 15:19:43 +05:30