From c82debd18ab02a8049dc6f9735cfa1d380750ba2 Mon Sep 17 00:00:00 2001 From: Pawan Singh Pal <pawansingh126@gmail.com> Date: Thu, 29 Nov 2018 23:29:17 +0530 Subject: [PATCH] Update build settings and documentation --- MANIFEST.in | 2 ++ doc/source/getting_started.rst | 12 +++++++++++- doc/source/tugboat.rst | 15 +++++++++------ doc/source/yaml-editor.rst | 8 ++++---- setup.py | 2 +- .../data_extractor/plugins/tugboat/__init__.py | 0 spyglass/parser/engine.py | 15 ++++++++------- 7 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 spyglass/data_extractor/plugins/tugboat/__init__.py diff --git a/MANIFEST.in b/MANIFEST.in index d90a4e1..e00b83e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,4 @@ recursive-include spyglass/utils/editor/static * recursive-include spyglass/utils/editor/templates * +recursive-include spyglass/ **.yaml +recursive-include spyglass/ **.json diff --git a/doc/source/getting_started.rst b/doc/source/getting_started.rst index fec8cc6..d8d52ba 100644 --- a/doc/source/getting_started.rst +++ b/doc/source/getting_started.rst @@ -187,7 +187,17 @@ spyglass -mg --type formation -f <URL> -u <user_id> -p <password> -d <site_confi spyglass -mg --type tugboat -x <Excel File> -e <Excel Spec> -d <Site Config> -s <Region> --template_dir=<j2 template dir> for example: -spyglass -mg -t tugboat -x SiteDesignSpec_v1.1.xlsx -e excel_spec_upstream.yaml -d site_config.yaml -s airship-seaworthy --template_dir=<j2 template dir> + 2.1 Generating intermediary and manifests + spyglass -mg -t tugboat -x SiteDesignSpec_v1.1.xlsx -e excel_spec_upstream.yaml -d site_config.yaml -s airship-seaworthy --template_dir=<j2 template dir> + + 2.2 Generating intermediary without manifests + spyglass -g -t tugboat -x SiteDesignSpec_v1.1.xlsx -e excel_spec_upstream.yaml -d site_config.yaml -s airship-seaworthy + + 2.3 Generating manifests without intermediary + spyglass -m -t tugboat -x SiteDesignSpec_v1.1.xlsx -e excel_spec_upstream.yaml -d site_config.yaml -s airship-seaworthy --template_dir=<j2 template dir> + + 2.4 Generating manifests using intermediary + spyglass -mi <intermediary.yaml> --template_dir=<j2 template dir> Where sample 'excel_spec_upstream.yaml', 'SiteDesignSpec_v0.1.xlsx' 'site_config.yaml' and J2 templates can be found under 'spyglass/examples' diff --git a/doc/source/tugboat.rst b/doc/source/tugboat.rst index 9851149..c17508d 100644 --- a/doc/source/tugboat.rst +++ b/doc/source/tugboat.rst @@ -85,13 +85,16 @@ Below is the definition for each key in the Excel spec Example: Tugboat Plugin Usage ----------------------------- + 1. Required Input(Refer to 'spyglass/examples' folder to get these inputs) - a) Excel File: SiteDesignSpec_v0.1.xlsx - b) Excel Spec: excel_spec_upstream.yaml - c) Site Config: site_config.yaml - d) Template_dir: '../examples/templates' - e) Site name: airship-seaworthy + + a) Excel File: SiteDesignSpec_v0.1.xlsx + b) Excel Spec: excel_spec_upstream.yaml + c) Site Config: site_config.yaml + d) Template_dir: '../examples/templates' + e) Site name: airship-seaworthy 2. Spyglass CLI Command: - spyglass -mg -t tugboat -x SiteDesignSpec_v0.1.xlsx -e excel_spec_upstream.yaml -d site_config.yaml -s airship-seaworthy --template_dir=<relative path to '../examples/templates' +:: + spyglass -mg -t tugboat -x SiteDesignSpec_v0.1.xlsx -e excel_spec_upstream.yaml -d site_config.yaml -s airship-seaworthy --template_dir=<relative path to '../examples/templates' diff --git a/doc/source/yaml-editor.rst b/doc/source/yaml-editor.rst index 56b9ec5..7e5a246 100644 --- a/doc/source/yaml-editor.rst +++ b/doc/source/yaml-editor.rst @@ -32,10 +32,10 @@ could not be fetched via :ref:`tugboatinfo` plugin. Yaml Editor Utility Inputs -------------------------- -a) Yaml File: Yaml file required to be edited (This is required field) -b) Port: Port on which app shall be running -c) Host: This is only used to form URL which can be followed to open file in browser -d) String: String which is required to be updated in the file (default is '#CHANGE_ME') + a) Yaml File: Yaml file required to be edited (This is required field) + b) Port: Port on which app shall be running + c) Host: This is only used to form URL which can be followed to open file in browser + d) String: String which is required to be updated in the file (default is '#CHANGE_ME') Yaml Editor Utility Usage ------------------------- diff --git a/setup.py b/setup.py index c022d7b..6cbf558 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='spyglass', version='0.0.1', description='Generate Airship specific yaml manifests from data sources', - url='http://github.com/att-comdev/tugboat', + url='http://github.com/att-comdev/spyglass', python_requires='>=3.5.0', license='Apache 2.0', packages=find_packages(), diff --git a/spyglass/data_extractor/plugins/tugboat/__init__.py b/spyglass/data_extractor/plugins/tugboat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/spyglass/parser/engine.py b/spyglass/parser/engine.py index 27b2b05..6e92a89 100644 --- a/spyglass/parser/engine.py +++ b/spyglass/parser/engine.py @@ -121,8 +121,8 @@ class ProcessDataSource(): json_schema = json.load(f) try: # Suppressing writing of data2.json. Can use it for debugging - with open('data2.json', 'w') as outfile: - json.dump(temp_data, outfile, sort_keys=True, indent=4) + # with open('data2.json', 'w') as outfile: + # json.dump(temp_data, outfile, sort_keys=True, indent=4) jsonschema.validate(json_data, json_schema) except jsonschema.exceptions.ValidationError as e: LOG.error("Validation Error") @@ -336,11 +336,12 @@ class ProcessDataSource(): self.data = extracted_data LOG.debug("Extracted data from plugin:\n{}".format( pprint.pformat(extracted_data))) - extracted_file = "extracted_file.yaml" - yaml_file = yaml.dump(extracted_data, default_flow_style=False) - with open(extracted_file, 'w') as f: - f.write(yaml_file) - f.close() + # Uncommeent following segment for debugging purpose. + # extracted_file = "extracted_file.yaml" + # yaml_file = yaml.dump(extracted_data, default_flow_style=False) + # with open(extracted_file, 'w') as f: + # f.write(yaml_file) + # f.close() # Append region_data supplied from CLI to self.data self.data['region_name'] = self.region_name