@@ -70,16 +70,16 @@ def _pull(self, tag):
70
70
"""Docker pull image tag"""
71
71
self .logger .debug ('Checking tag: %s' , tag )
72
72
try :
73
- if self .config .auth_json :
74
- self .client .login (self .config .auth_json .get (
75
- "username" ), self .config .auth_json .get ("password" ))
76
-
77
73
if self .config .dry_run :
78
74
# The authentication doesn't work with this call
79
75
# See bugs https://github.com/docker/docker-py/issues/2225
80
76
return self .client .images .get_registry_data (tag )
81
77
else :
82
- return self .client .images .pull (tag )
78
+ if self .config .auth_json :
79
+ return_image = self .client .images .pull (tag , auth_config = self .config .auth_json )
80
+ else :
81
+ return_image = self .client .images .pull (tag )
82
+ return return_image
83
83
except APIError as e :
84
84
if '<html>' in str (e ):
85
85
self .logger .debug ("Docker api issue. Ignoring" )
@@ -102,6 +102,8 @@ def _pull(self, tag):
102
102
103
103
104
104
class Container (BaseImageObject ):
105
+ mode = 'container'
106
+
105
107
def __init__ (self , docker_client ):
106
108
super ().__init__ (docker_client )
107
109
self .monitored = self .monitor_filter ()
@@ -226,6 +228,12 @@ def monitor_filter(self):
226
228
return monitored_containers
227
229
228
230
# Socket Functions
231
+ def self_check (self ):
232
+ self .monitored = self .monitor_filter ()
233
+ me_list = [container for container in self .monitored if 'ouroboros' in container .name ]
234
+ if len (me_list ) > 1 :
235
+ self .update_self (count = 2 , me_list = me_list )
236
+
229
237
def socket_check (self ):
230
238
depends_on_names = []
231
239
hard_depends_on_names = []
@@ -236,10 +244,6 @@ def socket_check(self):
236
244
self .logger .info ('No containers are running or monitored on %s' , self .socket )
237
245
return
238
246
239
- me_list = [c for c in self .client .api .containers () if 'ouroboros' in c ['Names' ][0 ].strip ('/' )]
240
- if len (me_list ) > 1 :
241
- self .update_self (count = 2 , me_list = me_list )
242
-
243
247
for container in self .monitored :
244
248
current_image = container .image
245
249
current_tag = container .attrs ['Config' ]['Image' ]
@@ -362,8 +366,8 @@ def update_self(self, count=None, old_container=None, me_list=None, new_image=No
362
366
me_created = self .client .api .create_container (** new_config )
363
367
new_me = self .client .containers .get (me_created .get ("Id" ))
364
368
new_me .start ()
365
- self .logger .debug ('If you strike me down, I shall become \
366
- more powerful than you could possibly imagine.' )
369
+ self .logger .debug ('If you strike me down, I shall become '
370
+ ' more powerful than you could possibly imagine.' )
367
371
self .logger .debug ('https://bit.ly/2VVY7GH' )
368
372
sleep (30 )
369
373
except APIError as e :
@@ -372,6 +376,8 @@ def update_self(self, count=None, old_container=None, me_list=None, new_image=No
372
376
373
377
374
378
class Service (BaseImageObject ):
379
+ mode = 'service'
380
+
375
381
def __init__ (self , docker_client ):
376
382
super ().__init__ (docker_client )
377
383
self .monitored = self .monitor_filter ()
0 commit comments