From 0b89414158aca5dbd0a3dfe9494fc26071701231 Mon Sep 17 00:00:00 2001 From: dido18 Date: Thu, 19 Jan 2017 11:50:33 +0100 Subject: [PATCH] deploy-package is ossible --- analysis/Dockerfile_scanner | 7 +++---- analysis/deploy-package/analysis.py | 7 +++++++ analysis/deploy-package/requirements.txt | 0 analysis/pyFinder/pyfinder/scanner.py | 7 +++++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 analysis/deploy-package/analysis.py create mode 100644 analysis/deploy-package/requirements.txt diff --git a/analysis/Dockerfile_scanner b/analysis/Dockerfile_scanner index 0404858..cdfaf57 100644 --- a/analysis/Dockerfile_scanner +++ b/analysis/Dockerfile_scanner @@ -6,16 +6,15 @@ RUN mkdir /code WORKDIR /code COPY pyFinder/requirements.txt /code/ + RUN pip install --upgrade pip RUN pip install -r requirements.txt # ADD . /code/ -# install pyfinder module in the container -# ADD setup.py /code -# RUN python setup.py install - COPY pyFinder/ /code +COPY deploy-package/analysis.py /code/pyfinder + ENTRYPOINT ["python","/code/entryScanner.py"] CMD ["--help"] diff --git a/analysis/deploy-package/analysis.py b/analysis/deploy-package/analysis.py new file mode 100644 index 0000000..c7c14d6 --- /dev/null +++ b/analysis/deploy-package/analysis.py @@ -0,0 +1,7 @@ + + + + +def handler_analysis(image_name, context): + print ("Hello world "+ image_name) + print (context.get_images()) diff --git a/analysis/deploy-package/requirements.txt b/analysis/deploy-package/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/analysis/pyFinder/pyfinder/scanner.py b/analysis/pyFinder/pyfinder/scanner.py index 114c3ca..2a70f60 100644 --- a/analysis/pyFinder/pyfinder/scanner.py +++ b/analysis/pyFinder/pyfinder/scanner.py @@ -8,6 +8,7 @@ from .client_software import ClientSoftware from .consumer_rabbit import ConsumerRabbit from pyfinder.model.image import Image +from pyfinder.analysis import handler_analysis import logging import datetime import sys @@ -21,6 +22,8 @@ def __init__(self, amqp_url='amqp://guest:guest@127.0.0.1:5672', exchange=None, rmi=True): + + self.rmi = rmi # remove an image after it is scanned self.logger = logging.getLogger(__class__.__name__) @@ -29,6 +32,8 @@ def __init__(self, amqp_url='amqp://guest:guest@127.0.0.1:5672', exchange=None, # client of Software service: the service that return the software to search in the images. self.client_software = ClientSoftware(api_url=software_url) + + # client of Docker daemon running on the local host #self.client_daemon = ClientDaemon(base_url='unix://var/run/docker.sock') self.client_daemon = docker.Client(base_url='unix://var/run/docker.sock') @@ -44,6 +49,8 @@ def __init__(self, amqp_url='amqp://guest:guest@127.0.0.1:5672', exchange=None, # client of Images Service: in order to add and update the image description. self.client_images = ClientImages(images_url=images_url) + handler_analysis("ciao", self.client_images) + # client of Docker Hub. self.client_hub = ClientHub(docker_hub_endpoint=hub_url)