vmdesc: parse_size: Support fractional units
This commit is contained in:
@@ -46,7 +46,7 @@ UNITS = {
|
||||
}
|
||||
|
||||
SIZE_RE = re.compile(
|
||||
r'^(?P<value>[0-9]+)\s*'
|
||||
r'^(?P<value>[0-9]+(?:\.[0-9]+)?)\s*'
|
||||
r'(?P<unit>\w+)?\s*$'
|
||||
)
|
||||
|
||||
@@ -72,7 +72,7 @@ def parse_size(size):
|
||||
factor = UNITS[parts['unit']]
|
||||
except KeyError:
|
||||
raise ValueError('Invalid size : {}'.format(size))
|
||||
return int(parts['value']) * factor
|
||||
return int(float(parts['value']) * factor)
|
||||
|
||||
|
||||
class VirtualMachine(object):
|
||||
|
||||
Reference in New Issue
Block a user