from prometheus_client import start_http_server, Summary, Histogram, Gauge, Counter, REGISTRY, CollectorRegistry, \\r
pushadd_to_gateway, push_to_gateway, delete_from_gateway\r
import threading\r
-from subprocess import Popen\r
+from subprocess import Popen, check_call\r
import os\r
import docker\r
import json\r
\r
def _stop_container(self, name):\r
\r
- container = self.dockercli.containers.get(name)\r
- container.remove(force=True)\r
+ #container = self.dockercli.containers.get(name)\r
+ #container.stop()\r
+ #container.remove(force=True)\r
+\r
+ # the only robust way to stop these containers is via Popen, it seems\r
+ time.sleep(1)\r
+ cmd = ['docker', 'rm', '-f', name]\r
+ Popen(cmd)\r
+\r
\r
def update_skewmon(self, vnf_name, resource_name, action):\r
\r
labels=['com.containernet'],\r
name='skewmon'\r
)\r
+ # Wait a while for containers to be completely started\r
+ started = False\r
+ wait_time = 0\r
+ while not started:\r
+ list1 = self.dockercli.containers.list(filters={'status': 'running', 'name': 'prometheus'})\r
+ if len(list1) >= 1:\r
+ time.sleep(1)\r
+ started = True\r
+ if wait_time > 5:\r
+ return 'skewmon not started'\r
+ time.sleep(1)\r
+ wait_time += 1\r
return ret\r
\r
\r