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")
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):
"""
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(
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
)
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
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