@@ -118,7 +118,7 @@ def __init__(self, version, binds=None, port_bindings=None,
118
118
tmpfs = None , oom_score_adj = None , dns_opt = None , cpu_shares = None ,
119
119
cpuset_cpus = None , userns_mode = None , pids_limit = None ,
120
120
isolation = None , auto_remove = False , storage_opt = None ,
121
- init = None , init_path = None ):
121
+ init = None , init_path = None , volume_driver = None ):
122
122
123
123
if mem_limit is not None :
124
124
self ['Memory' ] = parse_bytes (mem_limit )
@@ -428,6 +428,11 @@ def __init__(self, version, binds=None, port_bindings=None,
428
428
raise host_config_version_error ('init_path' , '1.25' )
429
429
self ['InitPath' ] = init_path
430
430
431
+ if volume_driver is not None :
432
+ if version_lt (version , '1.21' ):
433
+ raise host_config_version_error ('volume_driver' , '1.21' )
434
+ self ['VolumeDriver' ] = volume_driver
435
+
431
436
432
437
def host_config_type_error (param , param_value , expected ):
433
438
error_msg = 'Invalid type for {0} param: expected {1} but found {2}'
@@ -456,43 +461,27 @@ def __init__(
456
461
stop_signal = None , networking_config = None , healthcheck = None ,
457
462
stop_timeout = None
458
463
):
459
- if isinstance (command , six .string_types ):
460
- command = split_command (command )
461
-
462
- if isinstance (entrypoint , six .string_types ):
463
- entrypoint = split_command (entrypoint )
464
-
465
- if isinstance (environment , dict ):
466
- environment = format_environment (environment )
467
-
468
- if labels is not None and version_lt (version , '1.18' ):
469
- raise errors .InvalidVersion (
470
- 'labels were only introduced in API version 1.18'
471
- )
464
+ if version_gte (version , '1.10' ):
465
+ message = ('{0!r} parameter has no effect on create_container().'
466
+ ' It has been moved to host_config' )
467
+ if dns is not None :
468
+ raise errors .InvalidVersion (message .format ('dns' ))
469
+ if volumes_from is not None :
470
+ raise errors .InvalidVersion (message .format ('volumes_from' ))
472
471
473
- if cpuset is not None or cpu_shares is not None :
474
- if version_gte (version , '1.18' ):
472
+ if version_lt (version , '1.18' ):
473
+ if labels is not None :
474
+ raise errors .InvalidVersion (
475
+ 'labels were only introduced in API version 1.18'
476
+ )
477
+ else :
478
+ if cpuset is not None or cpu_shares is not None :
475
479
warnings .warn (
476
480
'The cpuset_cpus and cpu_shares options have been moved to'
477
481
' host_config in API version 1.18, and will be removed' ,
478
482
DeprecationWarning
479
483
)
480
484
481
- if stop_signal is not None and version_lt (version , '1.21' ):
482
- raise errors .InvalidVersion (
483
- 'stop_signal was only introduced in API version 1.21'
484
- )
485
-
486
- if stop_timeout is not None and version_lt (version , '1.25' ):
487
- raise errors .InvalidVersion (
488
- 'stop_timeout was only introduced in API version 1.25'
489
- )
490
-
491
- if healthcheck is not None and version_lt (version , '1.24' ):
492
- raise errors .InvalidVersion (
493
- 'Health options were only introduced in API version 1.24'
494
- )
495
-
496
485
if version_lt (version , '1.19' ):
497
486
if volume_driver is not None :
498
487
raise errors .InvalidVersion (
@@ -513,6 +502,38 @@ def __init__(
513
502
'version 1.19'
514
503
)
515
504
505
+ if version_lt (version , '1.21' ):
506
+ if stop_signal is not None :
507
+ raise errors .InvalidVersion (
508
+ 'stop_signal was only introduced in API version 1.21'
509
+ )
510
+ else :
511
+ if volume_driver is not None :
512
+ warnings .warn (
513
+ 'The volume_driver option has been moved to'
514
+ ' host_config in API version 1.21, and will be removed' ,
515
+ DeprecationWarning
516
+ )
517
+
518
+ if stop_timeout is not None and version_lt (version , '1.25' ):
519
+ raise errors .InvalidVersion (
520
+ 'stop_timeout was only introduced in API version 1.25'
521
+ )
522
+
523
+ if healthcheck is not None and version_lt (version , '1.24' ):
524
+ raise errors .InvalidVersion (
525
+ 'Health options were only introduced in API version 1.24'
526
+ )
527
+
528
+ if isinstance (command , six .string_types ):
529
+ command = split_command (command )
530
+
531
+ if isinstance (entrypoint , six .string_types ):
532
+ entrypoint = split_command (entrypoint )
533
+
534
+ if isinstance (environment , dict ):
535
+ environment = format_environment (environment )
536
+
516
537
if isinstance (labels , list ):
517
538
labels = dict ((lbl , six .text_type ('' )) for lbl in labels )
518
539
@@ -566,14 +587,6 @@ def __init__(
566
587
attach_stdin = True
567
588
stdin_once = True
568
589
569
- if version_gte (version , '1.10' ):
570
- message = ('{0!r} parameter has no effect on create_container().'
571
- ' It has been moved to host_config' )
572
- if dns is not None :
573
- raise errors .InvalidVersion (message .format ('dns' ))
574
- if volumes_from is not None :
575
- raise errors .InvalidVersion (message .format ('volumes_from' ))
576
-
577
590
self .update ({
578
591
'Hostname' : hostname ,
579
592
'Domainname' : domainname ,
0 commit comments