[08/19] incubator-ariatosca git commit: ARIA-210 Handle relative paths in CLI service-templates
ARIA-210 Handle relative paths in CLI service-templates This was a rather simple change, mainly involving adding absolute path references. The problems were only in `service-templates store` and in `service-templates create-archive`. `service-templates validate` was not affected. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d0411d3d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d0411d3d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d0411d3d Branch: refs/heads/ARIA-208-Missing-back-refrences-for-models Commit: d0411d3de37bb31073fda605cd9b73431b685d92 Parents: 16fcca4 Author: Avia EfratAuthored: Mon May 8 17:45:23 2017 +0300 Committer: Avia Efrat Committed: Tue May 9 17:30:22 2017 +0300 -- aria/cli/commands/service_templates.py | 4 +++- aria/cli/csar.py | 18 ++ aria/cli/service_template_utils.py | 2 +- tests/cli/test_service_templates.py| 22 ++ 4 files changed, 36 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/commands/service_templates.py -- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 2537012..e459871 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -195,7 +195,9 @@ def create_archive(service_template_path, destination, logger): `destination` is the path of the output CSAR archive file """ logger.info('Creating a CSAR archive') -csar.write(os.path.dirname(service_template_path), service_template_path, destination, logger) +if not destination.endswith(csar.CSAR_FILE_EXTENSION): +destination += csar.CSAR_FILE_EXTENSION +csar.write(service_template_path, destination, logger) logger.info('CSAR archive created at {0}'.format(destination)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/csar.py -- diff --git a/aria/cli/csar.py b/aria/cli/csar.py index 5bc35ac..8f44557 100644 --- a/aria/cli/csar.py +++ b/aria/cli/csar.py @@ -22,7 +22,7 @@ import zipfile import requests from ruamel import yaml - +CSAR_FILE_EXTENSION = '.csar' META_FILE = 'TOSCA-Metadata/TOSCA.meta' META_FILE_VERSION_KEY = 'TOSCA-Meta-File-Version' META_FILE_VERSION_VALUE = '1.0' @@ -38,17 +38,19 @@ BASE_METADATA = { } -def write(source, entry, destination, logger): -source = os.path.expanduser(source) -destination = os.path.expanduser(destination) -entry_definitions = os.path.join(source, entry) +def write(service_template_path, destination, logger): + +service_template_path = os.path.abspath(os.path.expanduser(service_template_path)) +source = os.path.dirname(service_template_path) +entry = os.path.basename(service_template_path) + meta_file = os.path.join(source, META_FILE) if not os.path.isdir(source): raise ValueError('{0} is not a directory. Please specify the service template ' 'directory.'.format(source)) -if not os.path.isfile(entry_definitions): +if not os.path.isfile(service_template_path): raise ValueError('{0} does not exists. Please specify a valid entry point.' - .format(entry_definitions)) + .format(service_template_path)) if os.path.exists(destination): raise ValueError('{0} already exists. Please provide a path to where the CSAR should be ' 'created.'.format(destination)) @@ -175,4 +177,4 @@ def read(source, destination=None, logger=None): def is_csar_archive(source): -return source.endswith('.csar') +return source.endswith(CSAR_FILE_EXTENSION) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/service_template_utils.py -- diff --git a/aria/cli/service_template_utils.py b/aria/cli/service_template_utils.py index 382cce1..c953c02 100644 --- a/aria/cli/service_template_utils.py +++ b/aria/cli/service_template_utils.py @@ -53,7 +53,7 @@ def get(source, service_template_filename): return _get_service_template_file_from_archive(source, service_template_filename) else: # Maybe check if yaml. -return source +return os.path.abspath(source) elif len(source.split('/')) == 2: url = _map_to_github_url(source) downloaded_file = utils.download_file(url)
[01/12] incubator-ariatosca git commit: ARIA-210 Handle relative paths in CLI service-templates [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-213-Sporadic-tests-failures-over-locked-database-issue 1b9c63dcc -> 254f879ff (forced update) ARIA-210 Handle relative paths in CLI service-templates This was a rather simple change, mainly involving adding absolute path references. The problems were only in `service-templates store` and in `service-templates create-archive`. `service-templates validate` was not affected. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d0411d3d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d0411d3d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d0411d3d Branch: refs/heads/ARIA-213-Sporadic-tests-failures-over-locked-database-issue Commit: d0411d3de37bb31073fda605cd9b73431b685d92 Parents: 16fcca4 Author: Avia EfratAuthored: Mon May 8 17:45:23 2017 +0300 Committer: Avia Efrat Committed: Tue May 9 17:30:22 2017 +0300 -- aria/cli/commands/service_templates.py | 4 +++- aria/cli/csar.py | 18 ++ aria/cli/service_template_utils.py | 2 +- tests/cli/test_service_templates.py| 22 ++ 4 files changed, 36 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/commands/service_templates.py -- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 2537012..e459871 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -195,7 +195,9 @@ def create_archive(service_template_path, destination, logger): `destination` is the path of the output CSAR archive file """ logger.info('Creating a CSAR archive') -csar.write(os.path.dirname(service_template_path), service_template_path, destination, logger) +if not destination.endswith(csar.CSAR_FILE_EXTENSION): +destination += csar.CSAR_FILE_EXTENSION +csar.write(service_template_path, destination, logger) logger.info('CSAR archive created at {0}'.format(destination)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/csar.py -- diff --git a/aria/cli/csar.py b/aria/cli/csar.py index 5bc35ac..8f44557 100644 --- a/aria/cli/csar.py +++ b/aria/cli/csar.py @@ -22,7 +22,7 @@ import zipfile import requests from ruamel import yaml - +CSAR_FILE_EXTENSION = '.csar' META_FILE = 'TOSCA-Metadata/TOSCA.meta' META_FILE_VERSION_KEY = 'TOSCA-Meta-File-Version' META_FILE_VERSION_VALUE = '1.0' @@ -38,17 +38,19 @@ BASE_METADATA = { } -def write(source, entry, destination, logger): -source = os.path.expanduser(source) -destination = os.path.expanduser(destination) -entry_definitions = os.path.join(source, entry) +def write(service_template_path, destination, logger): + +service_template_path = os.path.abspath(os.path.expanduser(service_template_path)) +source = os.path.dirname(service_template_path) +entry = os.path.basename(service_template_path) + meta_file = os.path.join(source, META_FILE) if not os.path.isdir(source): raise ValueError('{0} is not a directory. Please specify the service template ' 'directory.'.format(source)) -if not os.path.isfile(entry_definitions): +if not os.path.isfile(service_template_path): raise ValueError('{0} does not exists. Please specify a valid entry point.' - .format(entry_definitions)) + .format(service_template_path)) if os.path.exists(destination): raise ValueError('{0} already exists. Please provide a path to where the CSAR should be ' 'created.'.format(destination)) @@ -175,4 +177,4 @@ def read(source, destination=None, logger=None): def is_csar_archive(source): -return source.endswith('.csar') +return source.endswith(CSAR_FILE_EXTENSION) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/service_template_utils.py -- diff --git a/aria/cli/service_template_utils.py b/aria/cli/service_template_utils.py index 382cce1..c953c02 100644 --- a/aria/cli/service_template_utils.py +++ b/aria/cli/service_template_utils.py @@ -53,7 +53,7 @@ def get(source, service_template_filename): return _get_service_template_file_from_archive(source, service_template_filename) else: # Maybe check if yaml. -return source +
[8/9] incubator-ariatosca git commit: ARIA-210 Handle relative paths in CLI service-templates
ARIA-210 Handle relative paths in CLI service-templates This was a rather simple change, mainly involving adding absolute path references. The problems were only in `service-templates store` and in `service-templates create-archive`. `service-templates validate` was not affected. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d0411d3d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d0411d3d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d0411d3d Branch: refs/heads/ARIA-140-version-utils Commit: d0411d3de37bb31073fda605cd9b73431b685d92 Parents: 16fcca4 Author: Avia EfratAuthored: Mon May 8 17:45:23 2017 +0300 Committer: Avia Efrat Committed: Tue May 9 17:30:22 2017 +0300 -- aria/cli/commands/service_templates.py | 4 +++- aria/cli/csar.py | 18 ++ aria/cli/service_template_utils.py | 2 +- tests/cli/test_service_templates.py| 22 ++ 4 files changed, 36 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/commands/service_templates.py -- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 2537012..e459871 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -195,7 +195,9 @@ def create_archive(service_template_path, destination, logger): `destination` is the path of the output CSAR archive file """ logger.info('Creating a CSAR archive') -csar.write(os.path.dirname(service_template_path), service_template_path, destination, logger) +if not destination.endswith(csar.CSAR_FILE_EXTENSION): +destination += csar.CSAR_FILE_EXTENSION +csar.write(service_template_path, destination, logger) logger.info('CSAR archive created at {0}'.format(destination)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/csar.py -- diff --git a/aria/cli/csar.py b/aria/cli/csar.py index 5bc35ac..8f44557 100644 --- a/aria/cli/csar.py +++ b/aria/cli/csar.py @@ -22,7 +22,7 @@ import zipfile import requests from ruamel import yaml - +CSAR_FILE_EXTENSION = '.csar' META_FILE = 'TOSCA-Metadata/TOSCA.meta' META_FILE_VERSION_KEY = 'TOSCA-Meta-File-Version' META_FILE_VERSION_VALUE = '1.0' @@ -38,17 +38,19 @@ BASE_METADATA = { } -def write(source, entry, destination, logger): -source = os.path.expanduser(source) -destination = os.path.expanduser(destination) -entry_definitions = os.path.join(source, entry) +def write(service_template_path, destination, logger): + +service_template_path = os.path.abspath(os.path.expanduser(service_template_path)) +source = os.path.dirname(service_template_path) +entry = os.path.basename(service_template_path) + meta_file = os.path.join(source, META_FILE) if not os.path.isdir(source): raise ValueError('{0} is not a directory. Please specify the service template ' 'directory.'.format(source)) -if not os.path.isfile(entry_definitions): +if not os.path.isfile(service_template_path): raise ValueError('{0} does not exists. Please specify a valid entry point.' - .format(entry_definitions)) + .format(service_template_path)) if os.path.exists(destination): raise ValueError('{0} already exists. Please provide a path to where the CSAR should be ' 'created.'.format(destination)) @@ -175,4 +177,4 @@ def read(source, destination=None, logger=None): def is_csar_archive(source): -return source.endswith('.csar') +return source.endswith(CSAR_FILE_EXTENSION) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/service_template_utils.py -- diff --git a/aria/cli/service_template_utils.py b/aria/cli/service_template_utils.py index 382cce1..c953c02 100644 --- a/aria/cli/service_template_utils.py +++ b/aria/cli/service_template_utils.py @@ -53,7 +53,7 @@ def get(source, service_template_filename): return _get_service_template_file_from_archive(source, service_template_filename) else: # Maybe check if yaml. -return source +return os.path.abspath(source) elif len(source.split('/')) == 2: url = _map_to_github_url(source) downloaded_file = utils.download_file(url)
[08/10] incubator-ariatosca git commit: ARIA-210 Handle relative paths in CLI service-templates
ARIA-210 Handle relative paths in CLI service-templates This was a rather simple change, mainly involving adding absolute path references. The problems were only in `service-templates store` and in `service-templates create-archive`. `service-templates validate` was not affected. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d0411d3d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d0411d3d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d0411d3d Branch: refs/heads/ARIA-139-attributes Commit: d0411d3de37bb31073fda605cd9b73431b685d92 Parents: 16fcca4 Author: Avia EfratAuthored: Mon May 8 17:45:23 2017 +0300 Committer: Avia Efrat Committed: Tue May 9 17:30:22 2017 +0300 -- aria/cli/commands/service_templates.py | 4 +++- aria/cli/csar.py | 18 ++ aria/cli/service_template_utils.py | 2 +- tests/cli/test_service_templates.py| 22 ++ 4 files changed, 36 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/commands/service_templates.py -- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 2537012..e459871 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -195,7 +195,9 @@ def create_archive(service_template_path, destination, logger): `destination` is the path of the output CSAR archive file """ logger.info('Creating a CSAR archive') -csar.write(os.path.dirname(service_template_path), service_template_path, destination, logger) +if not destination.endswith(csar.CSAR_FILE_EXTENSION): +destination += csar.CSAR_FILE_EXTENSION +csar.write(service_template_path, destination, logger) logger.info('CSAR archive created at {0}'.format(destination)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/csar.py -- diff --git a/aria/cli/csar.py b/aria/cli/csar.py index 5bc35ac..8f44557 100644 --- a/aria/cli/csar.py +++ b/aria/cli/csar.py @@ -22,7 +22,7 @@ import zipfile import requests from ruamel import yaml - +CSAR_FILE_EXTENSION = '.csar' META_FILE = 'TOSCA-Metadata/TOSCA.meta' META_FILE_VERSION_KEY = 'TOSCA-Meta-File-Version' META_FILE_VERSION_VALUE = '1.0' @@ -38,17 +38,19 @@ BASE_METADATA = { } -def write(source, entry, destination, logger): -source = os.path.expanduser(source) -destination = os.path.expanduser(destination) -entry_definitions = os.path.join(source, entry) +def write(service_template_path, destination, logger): + +service_template_path = os.path.abspath(os.path.expanduser(service_template_path)) +source = os.path.dirname(service_template_path) +entry = os.path.basename(service_template_path) + meta_file = os.path.join(source, META_FILE) if not os.path.isdir(source): raise ValueError('{0} is not a directory. Please specify the service template ' 'directory.'.format(source)) -if not os.path.isfile(entry_definitions): +if not os.path.isfile(service_template_path): raise ValueError('{0} does not exists. Please specify a valid entry point.' - .format(entry_definitions)) + .format(service_template_path)) if os.path.exists(destination): raise ValueError('{0} already exists. Please provide a path to where the CSAR should be ' 'created.'.format(destination)) @@ -175,4 +177,4 @@ def read(source, destination=None, logger=None): def is_csar_archive(source): -return source.endswith('.csar') +return source.endswith(CSAR_FILE_EXTENSION) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/service_template_utils.py -- diff --git a/aria/cli/service_template_utils.py b/aria/cli/service_template_utils.py index 382cce1..c953c02 100644 --- a/aria/cli/service_template_utils.py +++ b/aria/cli/service_template_utils.py @@ -53,7 +53,7 @@ def get(source, service_template_filename): return _get_service_template_file_from_archive(source, service_template_filename) else: # Maybe check if yaml. -return source +return os.path.abspath(source) elif len(source.split('/')) == 2: url = _map_to_github_url(source) downloaded_file = utils.download_file(url)
[4/5] incubator-ariatosca git commit: ARIA-210 Handle relative paths in CLI service-templates
ARIA-210 Handle relative paths in CLI service-templates This was a rather simple change, mainly involving adding absolute path references. The problems were only in `service-templates store` and in `service-templates create-archive`. `service-templates validate` was not affected. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d0411d3d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d0411d3d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d0411d3d Branch: refs/heads/ARIA-148-extra-cli-commands Commit: d0411d3de37bb31073fda605cd9b73431b685d92 Parents: 16fcca4 Author: Avia EfratAuthored: Mon May 8 17:45:23 2017 +0300 Committer: Avia Efrat Committed: Tue May 9 17:30:22 2017 +0300 -- aria/cli/commands/service_templates.py | 4 +++- aria/cli/csar.py | 18 ++ aria/cli/service_template_utils.py | 2 +- tests/cli/test_service_templates.py| 22 ++ 4 files changed, 36 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/commands/service_templates.py -- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 2537012..e459871 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -195,7 +195,9 @@ def create_archive(service_template_path, destination, logger): `destination` is the path of the output CSAR archive file """ logger.info('Creating a CSAR archive') -csar.write(os.path.dirname(service_template_path), service_template_path, destination, logger) +if not destination.endswith(csar.CSAR_FILE_EXTENSION): +destination += csar.CSAR_FILE_EXTENSION +csar.write(service_template_path, destination, logger) logger.info('CSAR archive created at {0}'.format(destination)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/csar.py -- diff --git a/aria/cli/csar.py b/aria/cli/csar.py index 5bc35ac..8f44557 100644 --- a/aria/cli/csar.py +++ b/aria/cli/csar.py @@ -22,7 +22,7 @@ import zipfile import requests from ruamel import yaml - +CSAR_FILE_EXTENSION = '.csar' META_FILE = 'TOSCA-Metadata/TOSCA.meta' META_FILE_VERSION_KEY = 'TOSCA-Meta-File-Version' META_FILE_VERSION_VALUE = '1.0' @@ -38,17 +38,19 @@ BASE_METADATA = { } -def write(source, entry, destination, logger): -source = os.path.expanduser(source) -destination = os.path.expanduser(destination) -entry_definitions = os.path.join(source, entry) +def write(service_template_path, destination, logger): + +service_template_path = os.path.abspath(os.path.expanduser(service_template_path)) +source = os.path.dirname(service_template_path) +entry = os.path.basename(service_template_path) + meta_file = os.path.join(source, META_FILE) if not os.path.isdir(source): raise ValueError('{0} is not a directory. Please specify the service template ' 'directory.'.format(source)) -if not os.path.isfile(entry_definitions): +if not os.path.isfile(service_template_path): raise ValueError('{0} does not exists. Please specify a valid entry point.' - .format(entry_definitions)) + .format(service_template_path)) if os.path.exists(destination): raise ValueError('{0} already exists. Please provide a path to where the CSAR should be ' 'created.'.format(destination)) @@ -175,4 +177,4 @@ def read(source, destination=None, logger=None): def is_csar_archive(source): -return source.endswith('.csar') +return source.endswith(CSAR_FILE_EXTENSION) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/service_template_utils.py -- diff --git a/aria/cli/service_template_utils.py b/aria/cli/service_template_utils.py index 382cce1..c953c02 100644 --- a/aria/cli/service_template_utils.py +++ b/aria/cli/service_template_utils.py @@ -53,7 +53,7 @@ def get(source, service_template_filename): return _get_service_template_file_from_archive(source, service_template_filename) else: # Maybe check if yaml. -return source +return os.path.abspath(source) elif len(source.split('/')) == 2: url = _map_to_github_url(source) downloaded_file = utils.download_file(url)
incubator-ariatosca git commit: ARIA-210 Handle relative paths in CLI service-templates
Repository: incubator-ariatosca Updated Branches: refs/heads/master 16fcca45f -> d0411d3de ARIA-210 Handle relative paths in CLI service-templates This was a rather simple change, mainly involving adding absolute path references. The problems were only in `service-templates store` and in `service-templates create-archive`. `service-templates validate` was not affected. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d0411d3d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d0411d3d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d0411d3d Branch: refs/heads/master Commit: d0411d3de37bb31073fda605cd9b73431b685d92 Parents: 16fcca4 Author: Avia EfratAuthored: Mon May 8 17:45:23 2017 +0300 Committer: Avia Efrat Committed: Tue May 9 17:30:22 2017 +0300 -- aria/cli/commands/service_templates.py | 4 +++- aria/cli/csar.py | 18 ++ aria/cli/service_template_utils.py | 2 +- tests/cli/test_service_templates.py| 22 ++ 4 files changed, 36 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/commands/service_templates.py -- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 2537012..e459871 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -195,7 +195,9 @@ def create_archive(service_template_path, destination, logger): `destination` is the path of the output CSAR archive file """ logger.info('Creating a CSAR archive') -csar.write(os.path.dirname(service_template_path), service_template_path, destination, logger) +if not destination.endswith(csar.CSAR_FILE_EXTENSION): +destination += csar.CSAR_FILE_EXTENSION +csar.write(service_template_path, destination, logger) logger.info('CSAR archive created at {0}'.format(destination)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/csar.py -- diff --git a/aria/cli/csar.py b/aria/cli/csar.py index 5bc35ac..8f44557 100644 --- a/aria/cli/csar.py +++ b/aria/cli/csar.py @@ -22,7 +22,7 @@ import zipfile import requests from ruamel import yaml - +CSAR_FILE_EXTENSION = '.csar' META_FILE = 'TOSCA-Metadata/TOSCA.meta' META_FILE_VERSION_KEY = 'TOSCA-Meta-File-Version' META_FILE_VERSION_VALUE = '1.0' @@ -38,17 +38,19 @@ BASE_METADATA = { } -def write(source, entry, destination, logger): -source = os.path.expanduser(source) -destination = os.path.expanduser(destination) -entry_definitions = os.path.join(source, entry) +def write(service_template_path, destination, logger): + +service_template_path = os.path.abspath(os.path.expanduser(service_template_path)) +source = os.path.dirname(service_template_path) +entry = os.path.basename(service_template_path) + meta_file = os.path.join(source, META_FILE) if not os.path.isdir(source): raise ValueError('{0} is not a directory. Please specify the service template ' 'directory.'.format(source)) -if not os.path.isfile(entry_definitions): +if not os.path.isfile(service_template_path): raise ValueError('{0} does not exists. Please specify a valid entry point.' - .format(entry_definitions)) + .format(service_template_path)) if os.path.exists(destination): raise ValueError('{0} already exists. Please provide a path to where the CSAR should be ' 'created.'.format(destination)) @@ -175,4 +177,4 @@ def read(source, destination=None, logger=None): def is_csar_archive(source): -return source.endswith('.csar') +return source.endswith(CSAR_FILE_EXTENSION) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d0411d3d/aria/cli/service_template_utils.py -- diff --git a/aria/cli/service_template_utils.py b/aria/cli/service_template_utils.py index 382cce1..c953c02 100644 --- a/aria/cli/service_template_utils.py +++ b/aria/cli/service_template_utils.py @@ -53,7 +53,7 @@ def get(source, service_template_filename): return _get_service_template_file_from_archive(source, service_template_filename) else: # Maybe check if yaml. -return source +return os.path.abspath(source) elif len(source.split('/')) == 2: url = _map_to_github_url(source)
[4/4] incubator-ariatosca git commit: ARIA-210 Handle relative paths in CLI service-templates
ARIA-210 Handle relative paths in CLI service-templates This was a rather simple change, mainly involving adding absolute path references. The problems were only in `service-templates store` and in `service-templates create-archive`. `service-templates validate` was not affected. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/66727c39 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/66727c39 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/66727c39 Branch: refs/heads/ARIA-210-handle-relative-paths-in-cli-service-templates Commit: 66727c395ad6407304e8f67679d5dbd95828f08e Parents: 16fcca4 Author: Avia EfratAuthored: Mon May 8 17:45:23 2017 +0300 Committer: Avia Efrat Committed: Tue May 9 16:47:50 2017 +0300 -- aria/cli/commands/service_templates.py | 4 +++- aria/cli/csar.py | 18 ++ aria/cli/service_template_utils.py | 2 +- tests/cli/test_service_templates.py| 24 4 files changed, 38 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/66727c39/aria/cli/commands/service_templates.py -- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 2537012..e459871 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -195,7 +195,9 @@ def create_archive(service_template_path, destination, logger): `destination` is the path of the output CSAR archive file """ logger.info('Creating a CSAR archive') -csar.write(os.path.dirname(service_template_path), service_template_path, destination, logger) +if not destination.endswith(csar.CSAR_FILE_EXTENSION): +destination += csar.CSAR_FILE_EXTENSION +csar.write(service_template_path, destination, logger) logger.info('CSAR archive created at {0}'.format(destination)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/66727c39/aria/cli/csar.py -- diff --git a/aria/cli/csar.py b/aria/cli/csar.py index 5bc35ac..8f44557 100644 --- a/aria/cli/csar.py +++ b/aria/cli/csar.py @@ -22,7 +22,7 @@ import zipfile import requests from ruamel import yaml - +CSAR_FILE_EXTENSION = '.csar' META_FILE = 'TOSCA-Metadata/TOSCA.meta' META_FILE_VERSION_KEY = 'TOSCA-Meta-File-Version' META_FILE_VERSION_VALUE = '1.0' @@ -38,17 +38,19 @@ BASE_METADATA = { } -def write(source, entry, destination, logger): -source = os.path.expanduser(source) -destination = os.path.expanduser(destination) -entry_definitions = os.path.join(source, entry) +def write(service_template_path, destination, logger): + +service_template_path = os.path.abspath(os.path.expanduser(service_template_path)) +source = os.path.dirname(service_template_path) +entry = os.path.basename(service_template_path) + meta_file = os.path.join(source, META_FILE) if not os.path.isdir(source): raise ValueError('{0} is not a directory. Please specify the service template ' 'directory.'.format(source)) -if not os.path.isfile(entry_definitions): +if not os.path.isfile(service_template_path): raise ValueError('{0} does not exists. Please specify a valid entry point.' - .format(entry_definitions)) + .format(service_template_path)) if os.path.exists(destination): raise ValueError('{0} already exists. Please provide a path to where the CSAR should be ' 'created.'.format(destination)) @@ -175,4 +177,4 @@ def read(source, destination=None, logger=None): def is_csar_archive(source): -return source.endswith('.csar') +return source.endswith(CSAR_FILE_EXTENSION) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/66727c39/aria/cli/service_template_utils.py -- diff --git a/aria/cli/service_template_utils.py b/aria/cli/service_template_utils.py index 382cce1..c953c02 100644 --- a/aria/cli/service_template_utils.py +++ b/aria/cli/service_template_utils.py @@ -53,7 +53,7 @@ def get(source, service_template_filename): return _get_service_template_file_from_archive(source, service_template_filename) else: # Maybe check if yaml. -return source +return os.path.abspath(source) elif len(source.split('/')) == 2: url = _map_to_github_url(source) downloaded_file = utils.download_file(url)
incubator-ariatosca git commit: ARIA-210 Handle relative paths in CLI service-templates
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-210-handle-relative-paths-in-cli-service-templates [created] 0a3ea7991 ARIA-210 Handle relative paths in CLI service-templates This was a rather simple change, mainly involving adding absolute path references. The problems were only in `service-templates store` and in `service-templates create-archive`. `service-templates validate` was not affected. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/0a3ea799 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/0a3ea799 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/0a3ea799 Branch: refs/heads/ARIA-210-handle-relative-paths-in-cli-service-templates Commit: 0a3ea7991d6218438318d93232f82e7d7d42d4ae Parents: 0ec2370 Author: Avia EfratAuthored: Mon May 8 17:45:23 2017 +0300 Committer: Avia Efrat Committed: Mon May 8 17:45:23 2017 +0300 -- aria/cli/commands/service_templates.py | 4 +++- aria/cli/csar.py | 14 -- aria/cli/service_template_utils.py | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0a3ea799/aria/cli/commands/service_templates.py -- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 2537012..460d6cb 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -195,7 +195,9 @@ def create_archive(service_template_path, destination, logger): `destination` is the path of the output CSAR archive file """ logger.info('Creating a CSAR archive') -csar.write(os.path.dirname(service_template_path), service_template_path, destination, logger) +if not destination.endswith('.csar'): +destination += '.csar' +csar.write(service_template_path, destination, logger) logger.info('CSAR archive created at {0}'.format(destination)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0a3ea799/aria/cli/csar.py -- diff --git a/aria/cli/csar.py b/aria/cli/csar.py index 5bc35ac..f1608cd 100644 --- a/aria/cli/csar.py +++ b/aria/cli/csar.py @@ -38,17 +38,19 @@ BASE_METADATA = { } -def write(source, entry, destination, logger): -source = os.path.expanduser(source) -destination = os.path.expanduser(destination) -entry_definitions = os.path.join(source, entry) +def write(service_template_path, destination, logger): + +service_template_path = os.path.abspath(os.path.expanduser(service_template_path)) +source = os.path.dirname(service_template_path) +entry = os.path.basename(service_template_path) + meta_file = os.path.join(source, META_FILE) if not os.path.isdir(source): raise ValueError('{0} is not a directory. Please specify the service template ' 'directory.'.format(source)) -if not os.path.isfile(entry_definitions): +if not os.path.isfile(service_template_path): raise ValueError('{0} does not exists. Please specify a valid entry point.' - .format(entry_definitions)) + .format(service_template_path)) if os.path.exists(destination): raise ValueError('{0} already exists. Please provide a path to where the CSAR should be ' 'created.'.format(destination)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0a3ea799/aria/cli/service_template_utils.py -- diff --git a/aria/cli/service_template_utils.py b/aria/cli/service_template_utils.py index 382cce1..c953c02 100644 --- a/aria/cli/service_template_utils.py +++ b/aria/cli/service_template_utils.py @@ -53,7 +53,7 @@ def get(source, service_template_filename): return _get_service_template_file_from_archive(source, service_template_filename) else: # Maybe check if yaml. -return source +return os.path.abspath(source) elif len(source.split('/')) == 2: url = _map_to_github_url(source) downloaded_file = utils.download_file(url)