resourceName used to create folders and management_zones used to compare.
parent
34dc324a3d
commit
77112199be
21
adapter.py
21
adapter.py
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue