From a20b86ed4928ccdc77886b931d0e5014ad9f01c4 Mon Sep 17 00:00:00 2001 From: Parth Yadav Date: Mon, 14 Jun 2021 18:43:20 +0530 Subject: Fix Dockerfile bugs Fixes some Dockerfile bugs. Also, fixes some other syntax bugs, does not covers logical bug fixes. Signed-off-by: Parth Yadav Change-Id: I72cfbf058a2c35148337359d78e1fb8f1b3234d3 --- docs/sdvconfig/user/userguide.rst | 4 ++-- sdv/docker/sdvconfig/Dockerfile | 6 +++++- sdv/docker/sdvconfig/cli_validation.py | 17 ++++++++++++----- sdv/docker/sdvconfig/requirements.txt | 5 +++++ sdv/docker/sdvconfig/validation/info.py | 3 +-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/docs/sdvconfig/user/userguide.rst b/docs/sdvconfig/user/userguide.rst index 917ea8d..21c1210 100644 --- a/docs/sdvconfig/user/userguide.rst +++ b/docs/sdvconfig/user/userguide.rst @@ -18,7 +18,7 @@ curl --header "Content-Type: application/json" --request POST --data '{"pdf_ To run this on commandline, use the following command ``` -python extrapolation.py --pdf_fn="path/to/pdf_fn" --store-at="path/to/storage" +python extrapolation.py --file="path/to/pdf_fn" --store_at="path/to/storage" ``` The pdf_fn key expects absolute filepath to pdf or a raw github file url. @@ -39,4 +39,4 @@ python cli_validation.py --inst_dir=path/to/mani_dir --inst_type=type --pdf=path The pdf_file key expects absolute filepath to pdf or a raw github file url. The inst_dir key expects absolute filepath to installer directory or a github clone url. The inst_type key expects installer type string ("airship", "tripleo", etc.) -sitename: intel-pod10, intel-pod15 etc. +sitename: intel-pod10, intel-pod15 etc. \ No newline at end of file diff --git a/sdv/docker/sdvconfig/Dockerfile b/sdv/docker/sdvconfig/Dockerfile index d66ccc7..085d42e 100644 --- a/sdv/docker/sdvconfig/Dockerfile +++ b/sdv/docker/sdvconfig/Dockerfile @@ -5,6 +5,10 @@ RUN mkdir sdvconfig # change the workdir to the newly created file WORKDIR /sdvconfig/ +# install git +RUN apt update +RUN apt install -y git + # install from requirements.txt COPY requirements.txt /sdvconfig/requirements.txt RUN pip install -r requirements.txt @@ -16,7 +20,7 @@ COPY mapping/ /sdvconfig/mapping/ COPY validation/ /sdvconfig/validation/ COPY server.py /sdvconfig/ COPY cli_validation.py /sdvconfig/ -COPY testapi/ sdvconfig/testapi/ +COPY testapi/ /sdvconfig/testapi/ COPY manifest /sdvconfig/manifest/ # expose port for rest calls diff --git a/sdv/docker/sdvconfig/cli_validation.py b/sdv/docker/sdvconfig/cli_validation.py index 70e498e..30477fd 100644 --- a/sdv/docker/sdvconfig/cli_validation.py +++ b/sdv/docker/sdvconfig/cli_validation.py @@ -70,7 +70,7 @@ class Validate(): # create a directory called /tmp try: - os.mkdir('/tmp') + os.makedirs('/tmp', exist_ok=True) except OSError: self.logger.exception("creation of directory failed") raise @@ -87,7 +87,10 @@ class Validate(): # clone the installer repo try: - Repo.clone_from(inst_dir, os.path.join('/tmp', 'inst')) + clone_dir = os.path.join('/tmp', 'inst') + if os.path.exists(clone_dir) and os.path.isdir(clone_dir): + shutil.rmtree(clone_dir) + Repo.clone_from(inst_dir, clone_dir) self.inst_dir = os.path.join('/tmp', 'inst') self.downloaded = True except ConnectionError: @@ -98,7 +101,10 @@ class Validate(): # download the global file try: - Repo.clone_from(GLOBAL_DIR, os.path.join('/tmp', 'global')) + clone_dir = os.path.join('/tmp', 'global') + if os.path.exists(clone_dir) and os.path.isdir(clone_dir): + shutil.rmtree(clone_dir) + Repo.clone_from(GLOBAL_DIR, clone_dir) self.gsw = os.path.join('/tmp', 'global', 'global', 'software') except ConnectionError: self.logger.exception("failed to download the global git repo") @@ -153,6 +159,7 @@ class Validate(): self.total)) self.result += result + string + # iterate through the roles: have a class for each for each of the roles for _, value in enumerate(self.json["roles"]): role = value["name"] @@ -208,7 +215,7 @@ class Validate(): correct, wrong, total)) self.result += result + string - self.testapi_result["timestamp"] = datetime.datetime.now() + self.testapi_result["timestamp"] = datetime.datetime.now().isoformat() self.testapi_result["correct"] = self.correct self.testapi_result["wrong"] = self.wrong self.testapi_result["total"] = self.total @@ -246,4 +253,4 @@ if __name__ == "__main__": # Read arguments from the command line ARGS = PARSER.parse_args() - print(ARGS.inst_dir, ARGS.inst_type, ARGS.pdf, ARGS.sitename).validate() + Validate(ARGS.inst_dir, ARGS.inst_type, ARGS.pdf, ARGS.sitename).validate() diff --git a/sdv/docker/sdvconfig/requirements.txt b/sdv/docker/sdvconfig/requirements.txt index c3368df..7b5708c 100644 --- a/sdv/docker/sdvconfig/requirements.txt +++ b/sdv/docker/sdvconfig/requirements.txt @@ -1 +1,6 @@ tornado +requests +pyyaml +GitPython +netaddr + diff --git a/sdv/docker/sdvconfig/validation/info.py b/sdv/docker/sdvconfig/validation/info.py index 2d2b498..a66b9f7 100644 --- a/sdv/docker/sdvconfig/validation/info.py +++ b/sdv/docker/sdvconfig/validation/info.py @@ -156,8 +156,7 @@ class InfoValidation(): "data_plane_used", "ironic_deploy_interface", "external_storage_cluster", - "bl_str_connect_method", - "cpu_allocation_ratio"] + "bl_str_connect_method"] val = self.json[profile] -- cgit 1.2.3-korg