Handle extra spaces in merge-svc-map-files

During internal testing we are getting the following error from
merge-svc-map-files
File "/tmp/image.K2MYCphY/hooks/extra-data.d/10-merge-svc-map-files", line 54, in main
    with open(data_path, 'r') as dataFile:
IOError: [Errno 21] Is a directory: '...diskimage-builder/elements/svc-map'

Somehow IMAGE_ELEMENT contains a extra white space that manifests itself
as an element without a name. It is very hard to find where this is coming from so
instead this patch makes merge-svc-map-files more robost to this situation

Change-Id: Id1500ead8a77d691408617dcdc4e095bc5775be8
This commit is contained in:
Michael Kerrin 2014-10-20 12:59:57 +01:00
parent 8ba6a26e0a
commit 730e7bd76e

View File

@ -48,6 +48,8 @@ def main():
element_paths = os.environ.get("ELEMENTS_PATH").split(':') element_paths = os.environ.get("ELEMENTS_PATH").split(':')
service_names = dict() service_names = dict()
for element in elements: for element in elements:
if not element.strip():
continue
for element_path in element_paths: for element_path in element_paths:
data_path = os.path.join(element_path, element, "svc-map") data_path = os.path.join(element_path, element, "svc-map")
if os.path.exists(data_path): if os.path.exists(data_path):