Re: [virt-tools-list] [virt-install PATCH 3/4] guest: Deal with network install resources

2019-03-11 Thread Cole Robinson
On 3/8/19 11:20 AM, Fabiano Fidêncio wrote:
> Let's add two new methods to deal with network install resources so
> those can be set from the installer.
> 
> Signed-off-by: Fabiano Fidêncio 
> ---
>  virtinst/guest.py | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/virtinst/guest.py b/virtinst/guest.py
> index 2cca3e8d..2bbc7809 100644
> --- a/virtinst/guest.py
> +++ b/virtinst/guest.py
> @@ -167,6 +167,9 @@ class Guest(XMLBuilder):
>  self._capsinfo = None
>  self._domcaps = None
>  
> +self._running_memory = None
> +self._network_install_memory = None
> +
>  
>  ##
>  # Property accessors #
> @@ -645,6 +648,13 @@ class Guest(XMLBuilder):
>  self._add_implied_controllers()
>  self._add_spice_devices()
>  
> +def set_network_install_resources(self):
> +if self._network_install_memory and self._network_install_memory > 
> self.memory:
> +self.memory = self._network_install_memory
> +
> +def unset_network_install_resources(self):
> +self.memory = self._running_memory
> +self.maxmemory = self._running_memory
>  
>  
>  # Private xml routines #
> @@ -659,6 +669,10 @@ class Guest(XMLBuilder):
>  if not self.vcpus:
>  self.vcpus = res.get('n-cpus') if res and res.get('n-cpus') > 0 
> else 1
>  
> +self._running_memory = self.memory
> +res = self.osinfo.get_network_install_resources(self)
> +if res and res.get('ram') > 0:
> +self._network_install_memory = res['ram'] // 1024
>  >  def _set_default_machine(self):
>  if self.os.machine:
> 

This should all live in installer.py. See _prepare_get_install_xml,
_finish_get_install_xml, and _get_install_xml, where we already have
some light infrastructure to set and restore changes to the guest XML.
Also log a message when we actually set and restore the XML so there's a
clear trail of it in the logs

Thanks,
Cole

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Re: [virt-tools-list] [virt-install PATCH 2/4] installertreemedia: Add requires_internet()

2019-03-11 Thread Cole Robinson
On 3/8/19 11:20 AM, Fabiano Fidêncio wrote:
> This method returns whether the installer requires or not internet to
> perform the installation.
> 
> Signed-off-by: Fabiano Fidêncio 
> ---
>  virtinst/installertreemedia.py | 12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/virtinst/installertreemedia.py b/virtinst/installertreemedia.py
> index 86792503..f8ff1b1b 100644
> --- a/virtinst/installertreemedia.py
> +++ b/virtinst/installertreemedia.py
> @@ -14,7 +14,7 @@ from . import util
>  from .devices import DeviceDisk
>  from .initrdinject import perform_initrd_injections
>  from .kernelupload import upload_kernel_initrd
> -from .osdict import OSDB
> +from .osdict import OSDB, _OsinfoIter
>  
>  
>  # Enum of the various install media types we can have
> @@ -232,3 +232,13 @@ class InstallerTreeMedia(object):
>  fetcher = self._get_fetcher(guest, None)
>  cache = self._get_cached_data(guest, fetcher)
>  return cache.os_variant
> +
> +def requires_internet(self):
> +if self._media_type in [MEDIA_URL, MEDIA_DIR]:
> +return True
> +if self._media:
> +variant_list = list(_OsinfoIter(self._media.get_os_variants()))
> +for variant in variant_list:
> +if "netinst" in variant.get_id():
> +return True
> +return False
> 

Since this 'netinst' pattern has come up again, I think we should add a
wrapper class for the osinfomedia object and hide this logic there, so
it isn't sprinkled around. After that_OsinfoIter should be able to stay
private to osdict.py too.

- Cole

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Re: [virt-tools-list] [virt-viewer PATCH 01/14] po: provide custom make rules for po file management

2019-03-11 Thread Daniel P . Berrangé
On Mon, Mar 11, 2019 at 12:05:25PM +0100, Christophe Fergeau wrote:
> Hey,
> 
> On Thu, Mar 07, 2019 at 02:42:45PM +, Daniel P. Berrangé wrote:
> > After investigating in more detail it seems you can provide custom rules
> > for XML files by setting GETTEXTDATADIR, so I can support mime files with
> > this extra diff:
> 
> Ah indeed, nice finding. Seeing what is shipped in
> https://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/its
> (gsettings, glade, ... rules), this mime rule could probably go there as
> well.
> 
> > 
> > diff --git a/data/Makefile.am b/data/Makefile.am
> > index 0e50f3d..d4089be 100644
> > --- a/data/Makefile.am
> > +++ b/data/Makefile.am
> > @@ -4,6 +4,8 @@ MANUFACTURER = Virt Manager Project
> >  
> >  EXTRA_DIST =   \
> > virt-viewer.wxs.in  \
> > +   gettext/its/mime.its\
> > +   gettext/its/mime.loc\
> > $(NULL)
> >  
> >  # this make sure those files are regenerated when they change
> > @@ -71,8 +73,11 @@ desktop_DATA = $(DESKTOPFILES:.desktop.in=.desktop)
> >  %.desktop: %.desktop.in
> > $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o 
> > $@
> >  
> > +MIMEFILES = virt-viewer-mime.xml.in
> >  mimedir = $(datadir)/mime/packages
> >  mime_DATA = virt-viewer-mime.xml
> > +%-mime.xml: %-mime.xml.in
> > +   $(AM_V_GEN)GETTEXTDATADIR=$(srcdir)/gettext $(MSGFMT) --xml 
> > --template $< -d $(top_srcdir)/po -o $@
> 
> Something I just noticed (but which is related to the initial patch
> rather than this one) is that the .xml.in -> .xml rule is no longer
> triggered when one of the .po file changes (same for the .desktop file).
> I tried adding $(wildcard $(top_srcdir)/po/*.po) as a dependency, and as
> far as I can tell, this is giving the behaviour I want.

Yes, I can see the original rule had such a dep

$ grep XML_RULE /usr/share/aclocal/intltool.m4
  INTLTOOL_XML_RULE='%.xml:   %.xml.in   $(INTLTOOL_MERGE) 
$(wildcard $(top_srcdir)/po/*.po)

I'll add this dep before pushing.

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Re: [virt-tools-list] [virt-viewer PATCH 01/14] po: provide custom make rules for po file management

2019-03-11 Thread Christophe Fergeau
Hey,

On Thu, Mar 07, 2019 at 02:42:45PM +, Daniel P. Berrangé wrote:
> After investigating in more detail it seems you can provide custom rules
> for XML files by setting GETTEXTDATADIR, so I can support mime files with
> this extra diff:

Ah indeed, nice finding. Seeing what is shipped in
https://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/its
(gsettings, glade, ... rules), this mime rule could probably go there as
well.

> 
> diff --git a/data/Makefile.am b/data/Makefile.am
> index 0e50f3d..d4089be 100644
> --- a/data/Makefile.am
> +++ b/data/Makefile.am
> @@ -4,6 +4,8 @@ MANUFACTURER = Virt Manager Project
>  
>  EXTRA_DIST =   \
> virt-viewer.wxs.in  \
> +   gettext/its/mime.its\
> +   gettext/its/mime.loc\
> $(NULL)
>  
>  # this make sure those files are regenerated when they change
> @@ -71,8 +73,11 @@ desktop_DATA = $(DESKTOPFILES:.desktop.in=.desktop)
>  %.desktop: %.desktop.in
> $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
>  
> +MIMEFILES = virt-viewer-mime.xml.in
>  mimedir = $(datadir)/mime/packages
>  mime_DATA = virt-viewer-mime.xml
> +%-mime.xml: %-mime.xml.in
> +   $(AM_V_GEN)GETTEXTDATADIR=$(srcdir)/gettext $(MSGFMT) --xml 
> --template $< -d $(top_srcdir)/po -o $@

Something I just noticed (but which is related to the initial patch
rather than this one) is that the .xml.in -> .xml rule is no longer
triggered when one of the .po file changes (same for the .desktop file).
I tried adding $(wildcard $(top_srcdir)/po/*.po) as a dependency, and as
far as I can tell, this is giving the behaviour I want. 

A similar change is needed in po/Makefile.am in the call to xgettext,
and virt-viewer-mime.xml.in needs to be listed in POTFILES, with these
changes I can now translate the mime file!

Thanks,

Christophe


signature.asc
Description: PGP signature
___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list