-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker.py
More file actions
60 lines (48 loc) · 1.38 KB
/
docker.py
File metadata and controls
60 lines (48 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# import syslog
import logging
from docker import Client
# Logging Class Initialization
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
try:
value = "sock"
dockerurl = parser.get('main', 'docker_url')
dockerport = parser.get('main', 'docker_port')
if re.search("(so.*)", value) in docker_url:
c = Client(base_url=dockerurl)
else:
c = Client(base_url="http://%s:%s" % (dockerurl, dockerport)
except Exception, e:
logger.debug(e)
class DockerSystemInfo():
def docker_get_version(self):
"""
Get the Docker Service Version Information
Installed on the Server
"""
try:
return c.version()
except Exception, e:
logger.info(e)
def docker_image_list(self):
"""
Get the List of images available in the local Registry
"""
try:
return c.images()
except Exception, e:
logger.debug(e)
def docker_running_containers(self):
"""
Will get the information about the running
containers on the Server
"""
try:
return c.containers()
except Exception, e:
logger.info(e)
return "Hello World"
def docker_container_start(self):
return "Hello World"
def docker_container_remove(self):
return "Hello World"