def createWorkflowYaml(yamlPath): # Initialize workflow workflow = Workflow() # EXAMPLE AREA - DELETE BEFORE EXECUTION # Create RawWriteStep rawStep = RawWriteStep(workflow, content=b'Testing', description="Write test string", position=1, positionType=PositionType.SECTOR) # Create step for loading boot sector from config file an write to disk fatStep = FAT32CreateBootSectorStep(workflow, pathToConfig=os.path.join( os.path.dirname(yamlPath), "fat32.yml")) # Adding steps to workflow workflow.addStep(rawStep) workflow.addStep(fatStep) # EXAMPLE AREA - DELETE BEFORE EXECUTION # Write workflow to yaml config file yaml = ruamel.yaml.YAML() with open(yamlPath, 'w') as fout: yaml.dump(workflow, fout)
def createWorkflowYaml(yamlPath): # Initialize workflow workflow = Workflow() workflow.fatLast = 0x0FFFFFFF copyStep = CreateImageStep(workflow, srcDisk="disk/src.img", destDisk="disk/dest.img") workflow.addStep(copyStep) delStep = CreateFileStep(workflow, fullPath="/Kontakte/besenfelder.txt", deleted=True) workflow.addStep(delStep) # Write workflow to yaml config file yaml = ruamel.yaml.YAML() with open(yamlPath, 'w') as fout: yaml.dump(workflow, fout)
def createWorkflowYaml(yamlPath): # Initialize workflow workflow = Workflow() diskStep = CreateImageStep(workflow, destDisk="disk/dest.img", diskSize=256 << 20, description="Create new image") fatStep = FAT32CreateBootSectorStep(workflow, pathToConfig=os.path.join( os.path.dirname(yamlPath), "fat32.yml"), description="Create FAT32 filesystem") workflow.addStep(diskStep) workflow.addStep(fatStep) # Create directories for testing short and long format entries parentDir = CreateDirStep(workflow, dirName="Parent", description="Create dir in root dir") shortDir = CreateDirStep(workflow, dirName="short", description="Create short dir entry") longDir = CreateDirStep(workflow, dirName="ThisIsALongDirName", description="Create long dir entry") existingFile = CreateFileStep(workflow, fullPath="/short/content.txt", contentFile="files/content.txt", description="Copy file to disk") workflow.addStep(parentDir) workflow.addStep(shortDir) workflow.addStep(existingFile) workflow.addStep(longDir) # Create file with manipulated timestamps (written before created) childTimeDir = CreateDirStep( workflow, fullPath="/Parent/ChildTime", description="Create subdir for time manipulation") fileTime = CreateFileStep(workflow, fullPath="/Parent/ChildTime/time.txt", cDate="2000-01-01 12:00:00", mDate="2000-01-01 11:00:00", aDate="2000-01-01 00:00:00", content=512 * 'Time') workflow.addStep(childTimeDir) workflow.addStep(fileTime) # Demonstrate deleting operations childDelDir = CreateDirStep( workflow, fullPath="/Parent/ChildDel", description="Create subdir for delete operation") nodeleteDir = CreateDirStep(workflow, fullPath="/Parent/ChildDel/nodelete", description="Create subdir") deletedDir = CreateDirStep(workflow, fullPath="/Parent/ChildDel/delete", deleted=True, description="Create subdir delete") workflow.addStep(childDelDir) workflow.addStep(nodeleteDir) workflow.addStep(deletedDir) # Demonstrate reallocation of dir entries and data cluster childRealDir = CreateDirStep(workflow, fullPath="/Parent/ChildRealloc", description="Create subdir for reallocation") sectorContent = 512 * 'A' + 512 * 'B' + 512 * 'C' deletedFile = CreateFileStep( workflow, fullPath="/Parent/ChildRealloc/LongDeletedFileName.txt", content=sectorContent, deleted=True, description="Create file for deletion") newFile = CreateFileStep( workflow, fullPath="/Parent/ChildRealloc/newfile.txt", description="Create reallocation file", content="Das ist die Datei, die den Cluster neu belegt.") workflow.addStep(childRealDir) workflow.addStep(deletedFile) workflow.addStep(newFile) # Write workflow to yaml config file yaml = ruamel.yaml.YAML() with open(yamlPath, 'w') as fout: yaml.dump(workflow, fout)
def main(yamlPath): # Initialize workflow workflow = Workflow() destDisk = "../tests/images/Testimage_new.img" diskStep = CreateImageStep(workflow, destDisk=destDisk, diskSize=256 << 20) # Create RawWriteStep #rawStep = RawWriteStep(workflow, content=b'Testing', description="Write test string", position=1, positionType=PositionType.SECTOR) # Create step for loading boot sector from config file an write to disk fatStep = FAT32CreateBootSectorStep( workflow, pathToConfig= "/datadisk/Repos/github/syntheticdisc/helper/yaml/fat32.yml") mkdirStep = CreateDirStep(workflow=workflow, dirName="First", description="Create first directory!", cDate="2016-01-01 02:02:02", mDate="2016-01-02 02:02:02", aDate="2016-01-03 02:02:02") mkSubdirStep = CreateDirStep(workflow=workflow, fullPath="/First/Subdir/", description="Create subdir") #mkSubSubdirStep = CreateDirStep(workflow=workflow, parentDir="First/Subdir", dirName="SubSubdir", description="Create sub subdir") mkSubSubdirStep = CreateDirStep(workflow=workflow, parentDir="First/Subdir", dirName="SubSubdir", deleted=False, cDate="2016-01-01 02:02:02", mDate="2016-01-02 02:02:02", aDate="2016-01-03 02:02:02", description="Create sub subdir") mkSubSubdirStepDel = CreateDirStep(workflow=workflow, parentDir="First/Subdir", dirName="SubSubdir", deleted=True, cDate="2016-01-01 02:02:02", mDate="2016-01-02 02:02:02", aDate="2016-01-03 02:02:02", description="Create sub subdir") file1 = CreateFileStep(workflow=workflow, description="Create first file", cDate="2016-01-01 02:02:02", mDate="2016-01-02 02:02:02", aDate="2016-01-03 02:02:02", fullPath="/First/Test.txt", deleted=True, content="Das ist ein Test") file2 = CreateFileStep(workflow=workflow, description="File from file", contentFile="files/content.txt", fullPath="/First/content.txt") # Adding steps to workflow workflow.addStep(diskStep) #workflow.addStep(rawStep) workflow.addStep(fatStep) workflow.addStep(mkdirStep) workflow.addStep(mkSubdirStep) #workflow.addStep(mkSubSubdirStep) workflow.addStep(mkSubSubdirStep) workflow.addStep(file1) #workflow.addStep(mkSubSubdirStepDel) workflow.addStep(file2) # Write workflow to yaml config file yaml = ruamel.yaml.YAML() with open(yamlPath, 'w') as fout: yaml.dump(workflow, fout)