diff --git a/Dockerfile b/Containerfile similarity index 82% rename from Dockerfile rename to Containerfile index 4d68d13..9e9cab0 100644 --- a/Dockerfile +++ b/Containerfile @@ -1,4 +1,4 @@ -FROM python:2.7.14-alpine3.6 +FROM python:3.8.5-alpine3.12 # Update the packages RUN apk update @@ -8,7 +8,7 @@ RUN apk add gcc libffi-dev musl-dev openssl-dev sshpass make # RUN apk add py-crypto python-dev # Install td4a -RUN pip install td4a==1.7 +RUN pip install td4a==2.0.3 # Clear out extras RUN rm -rf /var/cache/apk/* diff --git a/README.md b/README.md index 75d0de6..b9be3d1 100644 --- a/README.md +++ b/README.md @@ -9,17 +9,16 @@ https://td4a.codethenetwork.com TD4A is a visual design aid for building and testing jinja2 templates. It will combine data in yaml format with a jinja2 template and render the output. -All jinja2 filters are supported along with the filter plugins from Ansible version 2.4.1.0. +All jinja2 filters are supported along with the filter plugins from Ansible version 2.9.12 ### Installation: -#### using docker: - +##### using podman (or docker): ``` -docker pull cidrblock/td4a +podman pull cidrblock/td4a ``` -The docker hub page can be found here: +The container registry page can be found here: https://hub.docker.com/r/cidrblock/td4a/ @@ -39,9 +38,9 @@ https://pypi.python.org/pypi/td4a #### Simple -##### using docker: +##### using podman (or docker): ``` -docker run -p 5000:5000 cidrblock/td4a +podman run -p 5000:5000 cidrblock/td4a ``` ##### using the cli: @@ -61,10 +60,9 @@ TD4A support two different modes of operation. #### Enabling a mode -##### using docker: - +##### using podman (or docker): ``` -docker run -p 5000:5000 \ +podman run -p 5000:5000 \ -it \ cidrblock/td4a \ td4a-server -m mode @@ -81,13 +79,14 @@ where `mode` is either jinja2 (default) or schema #### Loading custom filter plugins (jinja2 mode only) -##### using docker: TD4A supports custom filter plugins within the container. Pass your custom filter_plugins directory as a volume and use the -f option to specify to custom filter plugin directory. + +##### using podman (or docker): ``` -docker run -p 5000:5000 \ +podman run -p 5000:5000 \ -it \ - -v `pwd`/my_filter_plugins:/filter_plugins + -v `pwd`/my_filter_plugins:/filter_plugins \ cidrblock/td4a \ td4a-server -f /filter_plugins ``` @@ -101,11 +100,13 @@ td4a-server -f ./my_filter_plugins #### Loading an ansible inventory (jinja2 and schema mode) -##### using docker: - Mount the inventory as `/inventory` in the container, and run TD4A with the `-i` option. + + +##### using podman (or docker): + ``` -docker run -p 5000:5000 \ +podman run -p 5000:5000 \ -it \ -v '/Users/me/github/ansible_network_inventory:/inventory' \ cidrblock/td4a \ @@ -114,7 +115,7 @@ docker run -p 5000:5000 \ If environment variables are needed for a dynamic inventory, they can be passed to the docker container. ``` -docker run -p 5000:5000 \ +podman run -p 5000:5000 \ -it \ -v `pwd`/my_filter_plugins:/filter_plugins \ -v '/Users/me/github/ansible_network_inventory:/inventory' \ @@ -142,10 +143,10 @@ The CouchDB needs to previously created. To enable link support, and add the link button to the UI, set the following environ variables: -##### using docker: +##### using podman (or docker): ``` -docker run -p 5000:5000 \ +podman run -p 5000:5000 \ -v `pwd`/my_filter_plugins:/filter_plugins \ -e "COUCH_USERNAME=admin" \ -e "COUCH_PASSWORD=password" \ @@ -182,7 +183,7 @@ The UI is broken into three sections: ### Python version -To date, this has only been tested with python 2.7. +To date, this has only been tested with python 3.8.5. ### Development diff --git a/gcp/Dockerfile b/gcp/Dockerfile new file mode 100644 index 0000000..cb17c57 --- /dev/null +++ b/gcp/Dockerfile @@ -0,0 +1,2 @@ +FROM cidrblock/td4a:2.0.3 +EXPOSE 5000 diff --git a/now/Dockerfile b/now/Dockerfile deleted file mode 100644 index 5aa9fb7..0000000 --- a/now/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM cidrblock/td4a:1.7 -EXPOSE 5000 diff --git a/requirements.txt b/requirements.txt index 7ccdeae..5af9713 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -ansible==2.4.1.0 -Flask==0.12.2 -netaddr==0.7.19 -Twisted==17.9.0 -requests==2.18.4 -ruamel.yaml==0.15.35 -genson==0.2.3 -jsonschema==2.6.0 +ansible==2.9.12 +Flask==1.1.2 +netaddr==0.8.0 +Twisted==20.3.0 +requests==2.24.0 +ruamel.yaml==0.16.10 +genson==1.2.1 +jsonschema==3.2.0 \ No newline at end of file diff --git a/setup.py b/setup.py index b3c6d20..821c303 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup setup(name='td4a', - version='1.7', + version='2.0.3', description='A browser based jinja template renderer', url='http://github.com/cidrblock/td4a', author='Bradley A. Thornton', @@ -13,11 +13,13 @@ ], scripts=['td4a-server'], install_requires=[ - 'ansible==2.4.1.0', - 'Flask==0.12.2', - 'netaddr==0.7.19', - 'Twisted==17.9.0', - 'requests==2.18.4', - 'ruamel.yaml==0.15.35' + 'ansible==2.9.12', + 'Flask==1.1.2', + 'netaddr==0.8.0', + 'Twisted==20.3.0', + 'requests==2.24.0', + 'ruamel.yaml==0.16.10', + 'genson==1.2.1', + 'jsonschema==3.2.0' ], zip_safe=False) diff --git a/td4a-server b/td4a-server index 29e5c31..ae9c05f 100755 --- a/td4a-server +++ b/td4a-server @@ -34,7 +34,7 @@ def parse_args(): return args def main(): - print "Loading..." + print("Loading...") app.args = parse_args() app.filters = filters_load(app.args.custom_filters) if app.args.inventory_source: @@ -51,7 +51,7 @@ def main(): reactor_args['installSignalHandlers'] = 0 import werkzeug.serving wsgi = werkzeug.serving.run_with_reloader(wsgi) - print "Ready." + print("Ready.") wsgi() if __name__ == '__main__': diff --git a/td4a/controllers/render.py b/td4a/controllers/render.py index dfc3027..0058439 100644 --- a/td4a/controllers/render.py +++ b/td4a/controllers/render.py @@ -96,9 +96,9 @@ def rest_render(): """ render path """ try: - print "Checking and parsing data..." + print("Checking and parsing data...") response = render(payload=request.json, filters=app.filters, typ="page") - print "Done." + print("Done.") return jsonify(response) except HandledException as error: return jsonify(error.json()) diff --git a/td4a/controllers/validate.py b/td4a/controllers/validate.py index f862e30..91abcca 100644 --- a/td4a/controllers/validate.py +++ b/td4a/controllers/validate.py @@ -34,7 +34,7 @@ def validation(payload): if errors: return {"p3": yaml.dump({"messages":errors})} return {"p3": yaml.dump({"messages":["validation passed"]})} - except UnknownType, error: + except UnknownType as error: error_message = str(error) lines = error_message.splitlines() message = [x for x in lines if x.startswith('Unknown type')] diff --git a/td4a/models/exception_handler.py b/td4a/models/exception_handler.py index 1c7f853..ce06d8b 100644 --- a/td4a/models/exception_handler.py +++ b/td4a/models/exception_handler.py @@ -31,7 +31,7 @@ def __init__(self, function): def __call__(self, *args, **kwargs): try: return self.function(*args, **kwargs) - except Exception, error: + except Exception as error: self.error = error self.exc_type, self.exc_value, self.exc_traceback = sys.exc_info() self.tback = traceback.extract_tb(self.exc_traceback) @@ -115,7 +115,7 @@ def type_error(self): line_number=line_number) def unhandled(self): - print self.exc_type, self.exc_value, self.exc_traceback, self.tback, self.error + print(self.exc_type, self.exc_value, self.exc_traceback, self.tback, self.error) line_numbers = [x for x in self.tback if re.search('^<.*>$', x[0])] if line_numbers: line_number = line_numbers[0][1] diff --git a/td4a/models/filters.py b/td4a/models/filters.py index 8c4f499..e7fc237 100644 --- a/td4a/models/filters.py +++ b/td4a/models/filters.py @@ -13,7 +13,7 @@ def load_dir(directory): for entry in os.listdir(directory): if entry != '__init__.py' and entry.split('.')[-1] == 'py': filters = importlib.import_module(entry[:-3]).FilterModule().filters() - for key, value in filters.iteritems(): + for key, value in filters.items(): filter_list.append((key, value)) return filter_list diff --git a/td4a/static/template.j2 b/td4a/static/template.j2 index bf8e0f0..4f7e547 100644 --- a/td4a/static/template.j2 +++ b/td4a/static/template.j2 @@ -1,4 +1,4 @@ -{% for key, value in interfaces.iteritems() %} +{% for key, value in interfaces.items() %} {% if value['name'].startswith('Ethernet') %} - parents: - interface {{ value['name'] }}