From: stevenvanrossem Date: Fri, 27 Jan 2017 23:52:22 +0000 (+0100) Subject: fix unittest issue with docker pull X-Git-Tag: v3.1~45^2~24 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=e8d86281d07a5b20aade47b0cd2a450b8af62113;p=osm%2Fvim-emu.git fix unittest issue with docker pull --- diff --git a/src/emuvim/api/sonata/dummygatekeeper.py b/src/emuvim/api/sonata/dummygatekeeper.py index d5daf42..f9ff506 100755 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@ -39,11 +39,12 @@ import hashlib import zipfile import yaml import threading -from docker import DockerClient +from docker import DockerClient, APIClient from flask import Flask, request import flask_restful as fr from collections import defaultdict import pkg_resources +from subprocess import Popen logging.basicConfig() LOG = logging.getLogger("sonata-dummy-gatekeeper") @@ -546,8 +547,18 @@ class Service(object): LOG.debug("Image %r present. Skipping pull." % url) continue LOG.info("Pulling image: %r" % url) - dc.pull(url, - insecure_registry=True) + # this seems to fail with latest docker api version 2.0.2 + # dc.images.pull(url, + # insecure_registry=True) + #using docker cli instead + cmd = ["docker", + "pull", + url, + ] + Popen(cmd).wait() + + + def _check_docker_image_exists(self, image_name): """ diff --git a/src/emuvim/dcemulator/node.py b/src/emuvim/dcemulator/node.py index fd4b8fb..2702bf5 100755 --- a/src/emuvim/dcemulator/node.py +++ b/src/emuvim/dcemulator/node.py @@ -175,13 +175,10 @@ class Datacenter(object): network.append({}) # apply hard-set resource limits=0 - cpu_percentage = kwargs.get('cpu_percent') + cpu_percentage = params.get('cpu_percent') if cpu_percentage: - cpu_period = self.net.cpu_period - cpu_quota = self.net.cpu_period * float(cpu_percentage) - else: - cpu_quota = None - cpu_period = None + params['cpu_period'] = self.net.cpu_period + params['cpu_quota'] = self.net.cpu_period * float(cpu_percentage) # create the container d = self.net.addDocker( @@ -190,9 +187,7 @@ class Datacenter(object): dcmd=command, datacenter=self, flavor_name=flavor_name, - cpu_period = cpu_period, - cpu_quota = cpu_quota, - environment = {'VNF_NAME':name} + environment = {'VNF_NAME':name}, **params ) diff --git a/src/emuvim/test/api_base.py b/src/emuvim/test/api_base.py index 614ecd2..57d4aa5 100755 --- a/src/emuvim/test/api_base.py +++ b/src/emuvim/test/api_base.py @@ -108,7 +108,7 @@ class SimpleTestTopology(unittest.TestCase): Helper to interact with local docker instance. """ if self.docker_cli is None: - self.docker_cli = docker.Client( + self.docker_cli = docker.APIClient( base_url='unix://var/run/docker.sock') return self.docker_cli diff --git a/src/emuvim/test/base.py b/src/emuvim/test/base.py index 1b06f25..397e2a1 100755 --- a/src/emuvim/test/base.py +++ b/src/emuvim/test/base.py @@ -100,7 +100,7 @@ class SimpleTestTopology(unittest.TestCase): Helper to interact with local docker instance. """ if self.docker_cli is None: - self.docker_cli = docker.Client( + self.docker_cli = docker.APIClient( base_url='unix://var/run/docker.sock') return self.docker_cli