[virt-tools-list] [PATCH] osdict, libosinfo: use "minimum" resources when "recommended" is missing

Giuseppe Scrivano gscrivan at redhat.com
Tue Sep 16 07:12:22 UTC 2014


Cole Robinson <crobinso at redhat.com> writes:

> On 09/12/2014 11:50 AM, Giuseppe Scrivano wrote:
>> Some OS entries in libosinfo miss the "recommended" resources block.
>> In this case use the "minimum" resources when available.
>> 
>> Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
>> ---
>>  virtinst/osdict.py | 22 ++++++++++++++++------
>>  1 file changed, 16 insertions(+), 6 deletions(-)
>> 
>> diff --git a/virtinst/osdict.py b/virtinst/osdict.py
>> index 9e48270..76794c3 100644
>> --- a/virtinst/osdict.py
>> +++ b/virtinst/osdict.py
>> @@ -436,18 +436,28 @@ class _OsVariant(_OsVariantType):
>>  
>>      def get_recommended_resources(self, arch):
>>          ret = {}
>> -        def read_resource(resources, arch):
>> +        def read_resource(resources, minimum, arch):
>> +            # If we are reading the "minimum" block, allocate more
>> +            # resources.
>> +            ram_scale = minimum and 2 or 1
>> +            n_cpus_scale = minimum and 2 or 1
>> +            storage_scale = minimum and 2 or 1
>>              for i in range(resources.get_length()):
>>                  r = resources.get_nth(i)
>>                  if r.get_architecture() == arch:
>> -                    ret["ram"] = r.get_ram()
>> +                    ret["ram"] = r.get_ram() * ram_scale
>>                      ret["cpu"] = r.get_cpu()
>> -                    ret["n-cpus"] = r.get_n_cpus()
>> -                    ret["storage"] = r.get_storage()
>> +                    ret["n-cpus"] = r.get_n_cpus() * n_cpus_scale
>> +                    ret["storage"] = r.get_storage() * storage_scale
>>                      break
>>  
>> -        read_resource(self._os.get_recommended_resources(), "all")
>> -        read_resource(self._os.get_recommended_resources(), arch)
>> +        # libosinfo may miss the recommended resources block for some OS,
>> +        # in this case read first the minimum resources (if present)
>> +        # and use them.
>> +        read_resource(self._os.get_minimum_resources(), True, "all")
>> +        read_resource(self._os.get_minimum_resources(), True, arch)
>> +        read_resource(self._os.get_recommended_resources(), False, "all")
>> +        read_resource(self._os.get_recommended_resources(), False, arch)
>>  
>>          return ret
>>  
>> 
>
> ACK

pushed.

Thanks,
Giuseppe




More information about the virt-tools-list mailing list