@@ -70,16 +70,16 @@ def _pull(self, tag):
7070 """Docker pull image tag"""
7171 self .logger .debug ('Checking tag: %s' , tag )
7272 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-
7773 if self .config .dry_run :
7874 # The authentication doesn't work with this call
7975 # See bugs https://github.com/docker/docker-py/issues/2225
8076 return self .client .images .get_registry_data (tag )
8177 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
8383 except APIError as e :
8484 if '<html>' in str (e ):
8585 self .logger .debug ("Docker api issue. Ignoring" )
@@ -102,6 +102,8 @@ def _pull(self, tag):
102102
103103
104104class Container (BaseImageObject ):
105+ mode = 'container'
106+
105107 def __init__ (self , docker_client ):
106108 super ().__init__ (docker_client )
107109 self .monitored = self .monitor_filter ()
@@ -226,6 +228,12 @@ def monitor_filter(self):
226228 return monitored_containers
227229
228230 # 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+
229237 def socket_check (self ):
230238 depends_on_names = []
231239 hard_depends_on_names = []
@@ -236,10 +244,6 @@ def socket_check(self):
236244 self .logger .info ('No containers are running or monitored on %s' , self .socket )
237245 return
238246
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-
243247 for container in self .monitored :
244248 current_image = container .image
245249 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
362366 me_created = self .client .api .create_container (** new_config )
363367 new_me = self .client .containers .get (me_created .get ("Id" ))
364368 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.' )
367371 self .logger .debug ('https://bit.ly/2VVY7GH' )
368372 sleep (30 )
369373 except APIError as e :
@@ -372,6 +376,8 @@ def update_self(self, count=None, old_container=None, me_list=None, new_image=No
372376
373377
374378class Service (BaseImageObject ):
379+ mode = 'service'
380+
375381 def __init__ (self , docker_client ):
376382 super ().__init__ (docker_client )
377383 self .monitored = self .monitor_filter ()
0 commit comments