mirror of https://github.com/docker/docker-py.git
add nano-cpus parameter
Signed-off-by: Piotr Kruk <piotr@kruk.co>
This commit is contained in:
parent
845d31dbd2
commit
949446e1ff
|
@ -1190,9 +1190,9 @@ class ContainerApiMixin(object):
|
|||
@utils.check_resource('container')
|
||||
def update_container(
|
||||
self, container, blkio_weight=None, cpu_period=None, cpu_quota=None,
|
||||
cpu_shares=None, cpuset_cpus=None, cpuset_mems=None, mem_limit=None,
|
||||
mem_reservation=None, memswap_limit=None, kernel_memory=None,
|
||||
restart_policy=None
|
||||
cpu_shares=None, nano_cpus=None, cpuset_cpus=None, cpuset_mems=None,
|
||||
mem_limit=None, mem_reservation=None, memswap_limit=None,
|
||||
kernel_memory=None, restart_policy=None
|
||||
):
|
||||
"""
|
||||
Update resource configs of one or more containers.
|
||||
|
@ -1203,6 +1203,7 @@ class ContainerApiMixin(object):
|
|||
cpu_period (int): Limit CPU CFS (Completely Fair Scheduler) period
|
||||
cpu_quota (int): Limit CPU CFS (Completely Fair Scheduler) quota
|
||||
cpu_shares (int): CPU shares (relative weight)
|
||||
nano_cpus (int): Number of CPUs
|
||||
cpuset_cpus (str): CPUs in which to allow execution
|
||||
cpuset_mems (str): MEMs in which to allow execution
|
||||
mem_limit (int or str): Memory limit
|
||||
|
@ -1233,6 +1234,13 @@ class ContainerApiMixin(object):
|
|||
data['CpusetCpus'] = cpuset_cpus
|
||||
if cpuset_mems:
|
||||
data['CpusetMems'] = cpuset_mems
|
||||
if nano_cpus:
|
||||
if utils.version_lt(self._version, '1.29'):
|
||||
raise errors.InvalidVersion(
|
||||
'Setting NanoCPUs is not supported '
|
||||
'for API version < 1.29'
|
||||
)
|
||||
data['NanoCPUs'] = nano_cpus
|
||||
if mem_limit:
|
||||
data['Memory'] = utils.parse_bytes(mem_limit)
|
||||
if mem_reservation:
|
||||
|
|
|
@ -466,6 +466,7 @@ class Container(Model):
|
|||
cpu_period (int): Limit CPU CFS (Completely Fair Scheduler) period
|
||||
cpu_quota (int): Limit CPU CFS (Completely Fair Scheduler) quota
|
||||
cpu_shares (int): CPU shares (relative weight)
|
||||
nano_cpus (int): Number of CPUs
|
||||
cpuset_cpus (str): CPUs in which to allow execution
|
||||
cpuset_mems (str): MEMs in which to allow execution
|
||||
mem_limit (int or str): Memory limit
|
||||
|
|
|
@ -1438,11 +1438,12 @@ class ContainerTest(BaseAPIClientTest):
|
|||
def test_container_update(self):
|
||||
self.client.update_container(
|
||||
fake_api.FAKE_CONTAINER_ID, mem_limit='2k', cpu_shares=124,
|
||||
blkio_weight=345
|
||||
blkio_weight=345, nano_cpus=2
|
||||
)
|
||||
args = fake_request.call_args
|
||||
assert args[0][1] == url_prefix + 'containers/3cc2351ab11b/update'
|
||||
assert json.loads(args[1]['data']) == {
|
||||
'Memory': 2 * 1024, 'CpuShares': 124, 'BlkioWeight': 345
|
||||
'Memory': 2 * 1024, 'CpuShares': 124, 'BlkioWeight': 345,
|
||||
'NanoCPUs': 2
|
||||
}
|
||||
assert args[1]['headers']['Content-Type'] == 'application/json'
|
||||
|
|
Loading…
Reference in New Issue