resourceName used to create folders and management_zones used to compare.

main
SLW\ARNAUA 2022-01-20 14:49:25 +01:00
parent 34dc324a3d
commit 77112199be
1 changed files with 11 additions and 10 deletions

View File

@ -49,30 +49,31 @@ def createFolderStructure():
# [AA 2022.01.20] Create direcotires and copy associated files
resourcePath = os.path.join(outputFolder + environment + "/", resourceName)
if not resourcePath in resourcePaths.keys():
resourcePaths.setdefault("resourcePaths", [])
resourcePaths["resourcePaths"].append(resourcePath)
# if not resourcePath in resourcePaths.keys():
# resourcePaths.setdefault("resourcePaths", [])
# resourcePaths["resourcePaths"].append(resourcePath)
createDir(resourcePath)
copyFile(file, os.path.join(resourcePath, os.path.basename(file)))
return resourcePaths
return management_zones
def filterCondition(filename):
return '/dashboards/' in filename or '/alerting_profiles/' in filename;
#'/dashboards/' in filename or
def fillOtherResources(resourcePaths):
def fillOtherResources(management_zones):
otherResources = [os.path.normpath(f).replace('\\', '/') for f in glob(sourceFolder + "**/**.tf", recursive=True)]
otherResources_iterator= filter(filterCondition, otherResources)
otherResource_filterd=list(otherResources_iterator)
for resourcePath in resourcePaths["resourcePaths"]:
for management_zone in management_zones:
for element in otherResource_filterd:
elementName = os.path.basename(element).split(".")[0].split(" ")[0]
resourceName = os.path.basename(resourcePath)
if elementName == resourceName:
copyFile("./" + element, resourcePath + "/" + os.path.basename(element))
print("[DEBUG]", "File %s copied to %s." % (os.path.basename(element), resourcePath))
management_zone_name = os.path.basename(management_zone).split(".")[0].split(" ")[0]
folder = os.path.dirname(os.path.dirname(management_zone)).replace("export","")
if elementName == management_zone_name:
copyFile("./" + element, "./output" + folder + "/" + os.path.basename(element))
print("[DEBUG]", "File %s copied to %s." % (os.path.basename(element), "./output" + folder + "/" + os.path.basename(element)))
# [AA, EW 2022.01.20] Set global variables