Exemple #1
0
 def _create_layer(self) -> str:
     # Create tmp folders
     tmp_path = FileUtils.create_tmp_dir()
     layer_code_path = FileUtils.create_tmp_dir()
     # Extract 'extra' and 'faassupervisor' from supervisor_zip_path
     with zipfile.ZipFile(self.supervisor_zip_path) as thezip:
         for file in thezip.namelist():
             # Remove the parent folder path
             parent_folder, file_name = file.split('/', 1)
             if file_name.startswith('extra') or file_name.startswith(
                     'faassupervisor'):
                 thezip.extract(file, tmp_path.name)
     # Extract content of 'extra' files in layer_code_path
     extra_folder_path = FileUtils.join_paths(tmp_path.name, parent_folder,
                                              'extra')
     files = FileUtils.get_all_files_in_directory(extra_folder_path)
     for file_path in files:
         FileUtils.unzip_folder(file_path, layer_code_path.name)
     # Copy 'faassupervisor' to layer_code_path
     supervisor_folder_path = FileUtils.join_paths(tmp_path.name,
                                                   parent_folder,
                                                   'faassupervisor')
     shutil.move(
         supervisor_folder_path,
         FileUtils.join_paths(layer_code_path.name, 'python',
                              'faassupervisor'))
     # Create layer zip with content of layer_code_path
     layer_zip_path = FileUtils.join_paths(tmp_path.name,
                                           f'{self.layer_name}.zip')
     FileUtils.zip_folder(layer_zip_path, layer_code_path.name)
     # Register the layer
     props = self._get_supervisor_layer_props(layer_zip_path)
     response = self.layer.create(**props)
     return response['LayerVersionArn']
Exemple #2
0
 def _zip_scar_folder(self):
     FileUtils.zip_folder(self.aws.lambdaf.zip_file_path,
                          self.scar_tmp_function_folder_path,
                          "Creating function package")
Exemple #3
0
 def _zip_scar_folder(self, lambda_payload_path: str) -> None:
     """Zips the tmp folder with all the function's files and
     save it in the expected path of the payload."""
     FileUtils.zip_folder(lambda_payload_path, self.tmp_payload_folder.name,
                          "Creating function package.")
Exemple #4
0
def _create_layer_zip(layer_zip_path: str, layer_code_path: str) -> None:
    FileUtils.zip_folder(layer_zip_path, layer_code_path)