@@ -246,8 +246,6 @@ def api_version(self):
246
246
@check_resource
247
247
def attach (self , container , stdout = True , stderr = True ,
248
248
stream = False , logs = False ):
249
- if isinstance (container , dict ):
250
- container = container .get ('Id' )
251
249
params = {
252
250
'logs' : logs and 1 or 0 ,
253
251
'stdout' : stdout and 1 or 0 ,
@@ -292,9 +290,6 @@ def attach_socket(self, container, params=None, ws=False):
292
290
if ws :
293
291
return self ._attach_websocket (container , params )
294
292
295
- if isinstance (container , dict ):
296
- container = container .get ('Id' )
297
-
298
293
u = self ._url ("/containers/{0}/attach" .format (container ))
299
294
return self ._get_raw_response_socket (self .post (
300
295
u , None , params = self ._attach_params (params ), stream = True ))
@@ -409,8 +404,6 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
409
404
@check_resource
410
405
def commit (self , container , repository = None , tag = None , message = None ,
411
406
author = None , conf = None ):
412
- if isinstance (container , dict ):
413
- container = container .get ('Id' )
414
407
params = {
415
408
'container' : container ,
416
409
'repo' : repository ,
@@ -447,8 +440,6 @@ def containers(self, quiet=False, all=False, trunc=False, latest=False,
447
440
448
441
@check_resource
449
442
def copy (self , container , resource ):
450
- if isinstance (container , dict ):
451
- container = container .get ('Id' )
452
443
res = self ._post_json (
453
444
self ._url ("/containers/{0}/copy" .format (container )),
454
445
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 ()
@@ -961,17 +934,13 @@ def push(self, repository, tag=None, stream=False,
961
934
962
935
@check_resource
963
936
def remove_container (self , container , v = False , link = False , force = False ):
964
- if isinstance (container , dict ):
965
- container = container .get ('Id' )
966
937
params = {'v' : v , 'link' : link , 'force' : force }
967
938
res = self ._delete (self ._url ("/containers/" + container ),
968
939
params = params )
969
940
self ._raise_for_status (res )
970
941
971
942
@check_resource
972
943
def remove_image (self , image , force = False , noprune = False ):
973
- if isinstance (image , dict ):
974
- image = image .get ('Id' )
975
944
params = {'force' : force , 'noprune' : noprune }
976
945
res = self ._delete (self ._url ("/images/" + image ), params = params )
977
946
self ._raise_for_status (res )
@@ -982,27 +951,20 @@ def rename(self, container, name):
982
951
raise errors .InvalidVersion (
983
952
'rename was only introduced in API version 1.17'
984
953
)
985
- if isinstance (container , dict ):
986
- container = container .get ('Id' )
987
954
url = self ._url ("/containers/{0}/rename" .format (container ))
988
955
params = {'name' : name }
989
956
res = self ._post (url , params = params )
990
957
self ._raise_for_status (res )
991
958
992
959
@check_resource
993
960
def resize (self , container , height , width ):
994
- if isinstance (container , dict ):
995
- container = container .get ('Id' )
996
-
997
961
params = {'h' : height , 'w' : width }
998
962
url = self ._url ("/containers/{0}/resize" .format (container ))
999
963
res = self ._post (url , params = params )
1000
964
self ._raise_for_status (res )
1001
965
1002
966
@check_resource
1003
967
def restart (self , container , timeout = 10 ):
1004
- if isinstance (container , dict ):
1005
- container = container .get ('Id' )
1006
968
params = {'t' : timeout }
1007
969
url = self ._url ("/containers/{0}/restart" .format (container ))
1008
970
res = self ._post (url , params = params )
@@ -1067,9 +1029,6 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
1067
1029
ipc_mode = ipc_mode , security_opt = security_opt , ulimits = ulimits
1068
1030
)
1069
1031
1070
- if isinstance (container , dict ):
1071
- container = container .get ('Id' )
1072
-
1073
1032
url = self ._url ("/containers/{0}/start" .format (container ))
1074
1033
if not start_config :
1075
1034
start_config = None
@@ -1088,15 +1047,11 @@ def stats(self, container, decode=None):
1088
1047
raise errors .InvalidVersion (
1089
1048
'Stats retrieval is not supported in API < 1.17!' )
1090
1049
1091
- if isinstance (container , dict ):
1092
- container = container .get ('Id' )
1093
1050
url = self ._url ("/containers/{0}/stats" .format (container ))
1094
1051
return self ._stream_helper (self ._get (url , stream = True ), decode = decode )
1095
1052
1096
1053
@check_resource
1097
1054
def stop (self , container , timeout = 10 ):
1098
- if isinstance (container , dict ):
1099
- container = container .get ('Id' )
1100
1055
params = {'t' : timeout }
1101
1056
url = self ._url ("/containers/{0}/stop" .format (container ))
1102
1057
@@ -1118,8 +1073,6 @@ def tag(self, image, repository, tag=None, force=False):
1118
1073
1119
1074
@check_resource
1120
1075
def top (self , container ):
1121
- if isinstance (container , dict ):
1122
- container = container .get ('Id' )
1123
1076
u = self ._url ("/containers/{0}/top" .format (container ))
1124
1077
return self ._result (self ._get (u ), True )
1125
1078
@@ -1129,16 +1082,12 @@ def version(self, api_version=True):
1129
1082
1130
1083
@check_resource
1131
1084
def unpause (self , container ):
1132
- if isinstance (container , dict ):
1133
- container = container .get ('Id' )
1134
1085
url = self ._url ('/containers/{0}/unpause' .format (container ))
1135
1086
res = self ._post (url )
1136
1087
self ._raise_for_status (res )
1137
1088
1138
1089
@check_resource
1139
1090
def wait (self , container , timeout = None ):
1140
- if isinstance (container , dict ):
1141
- container = container .get ('Id' )
1142
1091
url = self ._url ("/containers/{0}/wait" .format (container ))
1143
1092
res = self ._post (url , timeout = timeout )
1144
1093
self ._raise_for_status (res )
0 commit comments