|
16 | 16 | import re |
17 | 17 | import shlex |
18 | 18 | import struct |
| 19 | +import warnings |
19 | 20 |
|
20 | 21 | import requests |
21 | 22 | import requests.exceptions |
@@ -141,6 +142,14 @@ def _container_config(self, image, command, hostname=None, user=None, |
141 | 142 | attach_stdin = True |
142 | 143 | stdin_once = True |
143 | 144 |
|
| 145 | + if utils.compare_version('1.10', self._version) >= 0: |
| 146 | + message = ('{0!r} parameter has no effect on create_container().' |
| 147 | + ' It has been moved to start()') |
| 148 | + if dns is not None: |
| 149 | + raise errors.DockerException(message.format('dns')) |
| 150 | + if volumes_from is not None: |
| 151 | + raise errors.DockerException(message.format('volumes_from')) |
| 152 | + |
144 | 153 | return { |
145 | 154 | 'Hostname': hostname, |
146 | 155 | 'Domainname': domainname, |
@@ -669,7 +678,8 @@ def search(self, term): |
669 | 678 | True) |
670 | 679 |
|
671 | 680 | def start(self, container, binds=None, port_bindings=None, lxc_conf=None, |
672 | | - publish_all_ports=False, links=None, privileged=False): |
| 681 | + publish_all_ports=False, links=None, privileged=False, |
| 682 | + dns=None, volumes_from=None): |
673 | 683 | if isinstance(container, dict): |
674 | 684 | container = container.get('Id') |
675 | 685 |
|
@@ -711,6 +721,25 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None, |
711 | 721 |
|
712 | 722 | start_config['Privileged'] = privileged |
713 | 723 |
|
| 724 | + if utils.compare_version('1.10', self._version) >= 0: |
| 725 | + if dns is not None: |
| 726 | + start_config['Dns'] = dns |
| 727 | + if volumes_from is not None: |
| 728 | + if isinstance(volumes_from, six.string_types): |
| 729 | + volumes_from = volumes_from.split(',') |
| 730 | + start_config['VolumesFrom'] = volumes_from |
| 731 | + else: |
| 732 | + warning_message = ('{0!r} parameter is discarded. It is only' |
| 733 | + ' available for API version greater or equal' |
| 734 | + ' than 1.10') |
| 735 | + |
| 736 | + if dns is not None: |
| 737 | + warnings.warn(warning_message.format('dns'), |
| 738 | + DeprecationWarning) |
| 739 | + if volumes_from is not None: |
| 740 | + warnings.warn(warning_message.format('volumes_from'), |
| 741 | + DeprecationWarning) |
| 742 | + |
714 | 743 | url = self._url("/containers/{0}/start".format(container)) |
715 | 744 | res = self._post_json(url, data=start_config) |
716 | 745 | self._raise_for_status(res) |
|
0 commit comments