vmdesc: parse_size: Support fractional units
parent
7629a5dd97
commit
4c3ec695bf
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue