[virt-tools-list] [virt-manager RFC PATCH v2 7/7] virtManager: by default use the recommended resources to run an OS

Cole Robinson crobinso at redhat.com
Sat Jan 25 17:09:12 UTC 2014


On 01/24/2014 09:13 AM, Giuseppe Scrivano wrote:
> Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
> ---
>  virtManager/create.py | 24 +++++++++++++++++++-----
>  1 file changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/virtManager/create.py b/virtManager/create.py
> index ef75089..64bcae8 100644
> --- a/virtManager/create.py
> +++ b/virtManager/create.py
> @@ -391,17 +391,12 @@ class vmmCreate(vmmGObjectUI):
>          # Install container OS
>          self.widget("install-oscontainer-fs").set_text("")
>  
> -        # Mem / CPUs
> -        self.widget("config-mem").set_value(DEFAULT_MEM)
> -        self.widget("config-cpus").set_value(1)
> -
>          # Storage
>          label_widget = self.widget("phys-hd-label")
>          label_widget.set_markup("")
>          uihelpers.update_host_space(self.conn, label_widget)
>          self.widget("enable-storage").set_active(True)
>          self.widget("config-storage-create").set_active(True)
> -        self.widget("config-storage-size").set_value(8)
>          self.widget("config-storage-entry").set_text("")
>          self.widget("config-storage-nosparse").set_active(True)
>  
> @@ -1736,6 +1731,25 @@ class vmmCreate(vmmGObjectUI):
>          if path:
>              uihelpers.check_path_search_for_qemu(self.err, self.conn, path)
>  
> +        res = virtinst.osdict.get_recommended_resources(variant, self.capsguest.arch)
> +
> +        #Change the default values suggested to the user.

Minorest bit, but please place a space after #

> +        if res and res.get("ram"):
> +            self.widget("config-mem").set_value(res["ram"] / (1024 ** 2))
> +        else:
> +            self.widget("config-mem").set_value(DEFAULT_MEM)
> +
> +        if res and res.get("n-cpus"):
> +            self.widget("config-cpus").set_value(max(res["n-cpus"], 1))
> +        else:
> +            self.widget("config-cpus").set_value(1)
> +
> +        if res and res.get("storage"):
> +            storage_size = int(res["storage"]) / (1024 ** 3)
> +            self.widget("config-storage-size").set_value(storage_size)
> +        else:
> +            self.widget("config-storage-size").set_value(8)
> +

It's a style thing, but I prefer to format things like:

storage_size = 8
if res and res.get("storage"):
    storage_size = 8
self.widget("config-storage-size").set_value(storage_size)

- Cole




More information about the virt-tools-list mailing list