Implement review suggestions.

Signed-off-by: Alexey Rokhin <arokhin@mail.ru>
This commit is contained in:
Alexey Rokhin 2017-05-17 23:21:47 +03:00 committed by Joffrey F
parent aeeed0cf2f
commit b815a00e33
2 changed files with 5 additions and 2 deletions

View File

@ -78,7 +78,7 @@
"cpu_percent": {"type": "integer", "minimum": 0, "maximum": 100},
"cpu_shares": {"type": ["number", "string"]},
"cpu_quota": {"type": ["number", "string"]},
"cpus": {"type": ["number", "string"], "minimum": 0},
"cpus": {"type": "number", "minimum": 0},
"cpuset": {"type": "string"},
"depends_on": {
"oneOf": [

View File

@ -803,7 +803,10 @@ class Service(object):
nano_cpus = None
if 'cpus' in options:
nano_cpus = int(options.get('cpus') * 1000000000)
nano_cpus = options.get('cpus') * 1000000000
if isinstance(nano_cpus, float) and not nano_cpus.is_integer():
raise ValueError("cpus is too precise")
nano_cpus = int(nano_cpus)
return self.client.create_host_config(
links=self._get_links(link_to_self=one_off),