@@ -251,8 +251,6 @@ def api_version(self):
251
251
@check_resource
252
252
def attach (self , container , stdout = True , stderr = True ,
253
253
stream = False , logs = False ):
254
- if isinstance (container , dict ):
255
- container = container .get ('Id' )
256
254
params = {
257
255
'logs' : logs and 1 or 0 ,
258
256
'stdout' : stdout and 1 or 0 ,
@@ -297,9 +295,6 @@ def attach_socket(self, container, params=None, ws=False):
297
295
if ws :
298
296
return self ._attach_websocket (container , params )
299
297
300
- if isinstance (container , dict ):
301
- container = container .get ('Id' )
302
-
303
298
u = self ._url ("/containers/{0}/attach" .format (container ))
304
299
return self ._get_raw_response_socket (self .post (
305
300
u , None , params = self ._attach_params (params ), stream = True ))
@@ -410,8 +405,6 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
410
405
@check_resource
411
406
def commit (self , container , repository = None , tag = None , message = None ,
412
407
author = None , conf = None ):
413
- if isinstance (container , dict ):
414
- container = container .get ('Id' )
415
408
params = {
416
409
'container' : container ,
417
410
'repo' : repository ,
@@ -448,8 +441,6 @@ def containers(self, quiet=False, all=False, trunc=False, latest=False,
448
441
449
442
@check_resource
450
443
def copy (self , container , resource ):
451
- if isinstance (container , dict ):
452
- container = container .get ('Id' )
453
444
res = self ._post_json (
454
445
self ._url ("/containers/{0}/copy" .format (container )),
455
446
data = {"Resource" : resource },
@@ -493,8 +484,6 @@ def create_container_from_config(self, config, name=None):
493
484
494
485
@check_resource
495
486
def diff (self , container ):
496
- if isinstance (container , dict ):
497
- container = container .get ('Id' )
498
487
return self ._result (self ._get (self ._url ("/containers/{0}/changes" .
499
488
format (container ))), True )
500
489
@@ -539,8 +528,6 @@ def exec_create(self, container, cmd, stdout=True, stderr=True, tty=False,
539
528
raise errors .InvalidVersion (
540
529
'Privileged exec is not supported in API < 1.19'
541
530
)
542
- if isinstance (container , dict ):
543
- container = container .get ('Id' )
544
531
if isinstance (cmd , six .string_types ):
545
532
cmd = shlex .split (str (cmd ))
546
533
@@ -605,8 +592,6 @@ def exec_start(self, exec_id, detach=False, tty=False, stream=False):
605
592
606
593
@check_resource
607
594
def export (self , container ):
608
- if isinstance (container , dict ):
609
- container = container .get ('Id' )
610
595
res = self ._get (self ._url ("/containers/{0}/export" .format (container )),
611
596
stream = True )
612
597
self ._raise_for_status (res )
@@ -744,25 +729,19 @@ def insert(self, image, url, path):
744
729
745
730
@check_resource
746
731
def inspect_container (self , container ):
747
- if isinstance (container , dict ):
748
- container = container .get ('Id' )
749
732
return self ._result (
750
733
self ._get (self ._url ("/containers/{0}/json" .format (container ))),
751
734
True )
752
735
753
736
@check_resource
754
737
def inspect_image (self , image ):
755
- if isinstance (image , dict ):
756
- image = image .get ('Id' )
757
738
return self ._result (
758
739
self ._get (self ._url ("/images/{0}/json" .format (image ))),
759
740
True
760
741
)
761
742
762
743
@check_resource
763
744
def kill (self , container , signal = None ):
764
- if isinstance (container , dict ):
765
- container = container .get ('Id' )
766
745
url = self ._url ("/containers/{0}/kill" .format (container ))
767
746
params = {}
768
747
if signal is not None :
@@ -810,8 +789,6 @@ def login(self, username, password=None, email=None, registry=None,
810
789
@check_resource
811
790
def logs (self , container , stdout = True , stderr = True , stream = False ,
812
791
timestamps = False , tail = 'all' ):
813
- if isinstance (container , dict ):
814
- container = container .get ('Id' )
815
792
if utils .compare_version ('1.11' , self ._version ) >= 0 :
816
793
params = {'stderr' : stderr and 1 or 0 ,
817
794
'stdout' : stdout and 1 or 0 ,
@@ -844,8 +821,6 @@ def logs(self, container, stdout=True, stderr=True, stream=False,
844
821
845
822
@check_resource
846
823
def pause (self , container ):
847
- if isinstance (container , dict ):
848
- container = container .get ('Id' )
849
824
url = self ._url ('/containers/{0}/pause' .format (container ))
850
825
res = self ._post (url )
851
826
self ._raise_for_status (res )
@@ -855,8 +830,6 @@ def ping(self):
855
830
856
831
@check_resource
857
832
def port (self , container , private_port ):
858
- if isinstance (container , dict ):
859
- container = container .get ('Id' )
860
833
res = self ._get (self ._url ("/containers/{0}/json" .format (container )))
861
834
self ._raise_for_status (res )
862
835
json_ = res .json ()
@@ -954,17 +927,13 @@ def push(self, repository, tag=None, stream=False,
954
927
955
928
@check_resource
956
929
def remove_container (self , container , v = False , link = False , force = False ):
957
- if isinstance (container , dict ):
958
- container = container .get ('Id' )
959
930
params = {'v' : v , 'link' : link , 'force' : force }
960
931
res = self ._delete (self ._url ("/containers/" + container ),
961
932
params = params )
962
933
self ._raise_for_status (res )
963
934
964
935
@check_resource
965
936
def remove_image (self , image , force = False , noprune = False ):
966
- if isinstance (image , dict ):
967
- image = image .get ('Id' )
968
937
params = {'force' : force , 'noprune' : noprune }
969
938
res = self ._delete (self ._url ("/images/" + image ), params = params )
970
939
self ._raise_for_status (res )
@@ -975,27 +944,20 @@ def rename(self, container, name):
975
944
raise errors .InvalidVersion (
976
945
'rename was only introduced in API version 1.17'
977
946
)
978
- if isinstance (container , dict ):
979
- container = container .get ('Id' )
980
947
url = self ._url ("/containers/{0}/rename" .format (container ))
981
948
params = {'name' : name }
982
949
res = self ._post (url , params = params )
983
950
self ._raise_for_status (res )
984
951
985
952
@check_resource
986
953
def resize (self , container , height , width ):
987
- if isinstance (container , dict ):
988
- container = container .get ('Id' )
989
-
990
954
params = {'h' : height , 'w' : width }
991
955
url = self ._url ("/containers/{0}/resize" .format (container ))
992
956
res = self ._post (url , params = params )
993
957
self ._raise_for_status (res )
994
958
995
959
@check_resource
996
960
def restart (self , container , timeout = 10 ):
997
- if isinstance (container , dict ):
998
- container = container .get ('Id' )
999
961
params = {'t' : timeout }
1000
962
url = self ._url ("/containers/{0}/restart" .format (container ))
1001
963
res = self ._post (url , params = params )
@@ -1060,9 +1022,6 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
1060
1022
ipc_mode = ipc_mode , security_opt = security_opt , ulimits = ulimits
1061
1023
)
1062
1024
1063
- if isinstance (container , dict ):
1064
- container = container .get ('Id' )
1065
-
1066
1025
url = self ._url ("/containers/{0}/start" .format (container ))
1067
1026
if not start_config :
1068
1027
start_config = None
@@ -1081,15 +1040,11 @@ def stats(self, container, decode=None):
1081
1040
raise errors .InvalidVersion (
1082
1041
'Stats retrieval is not supported in API < 1.17!' )
1083
1042
1084
- if isinstance (container , dict ):
1085
- container = container .get ('Id' )
1086
1043
url = self ._url ("/containers/{0}/stats" .format (container ))
1087
1044
return self ._stream_helper (self ._get (url , stream = True ), decode = decode )
1088
1045
1089
1046
@check_resource
1090
1047
def stop (self , container , timeout = 10 ):
1091
- if isinstance (container , dict ):
1092
- container = container .get ('Id' )
1093
1048
params = {'t' : timeout }
1094
1049
url = self ._url ("/containers/{0}/stop" .format (container ))
1095
1050
@@ -1111,8 +1066,6 @@ def tag(self, image, repository, tag=None, force=False):
1111
1066
1112
1067
@check_resource
1113
1068
def top (self , container ):
1114
- if isinstance (container , dict ):
1115
- container = container .get ('Id' )
1116
1069
u = self ._url ("/containers/{0}/top" .format (container ))
1117
1070
return self ._result (self ._get (u ), True )
1118
1071
@@ -1122,16 +1075,12 @@ def version(self, api_version=True):
1122
1075
1123
1076
@check_resource
1124
1077
def unpause (self , container ):
1125
- if isinstance (container , dict ):
1126
- container = container .get ('Id' )
1127
1078
url = self ._url ('/containers/{0}/unpause' .format (container ))
1128
1079
res = self ._post (url )
1129
1080
self ._raise_for_status (res )
1130
1081
1131
1082
@check_resource
1132
1083
def wait (self , container , timeout = None ):
1133
- if isinstance (container , dict ):
1134
- container = container .get ('Id' )
1135
1084
url = self ._url ("/containers/{0}/wait" .format (container ))
1136
1085
res = self ._post (url , timeout = timeout )
1137
1086
self ._raise_for_status (res )
0 commit comments