virtinst: network: streamline pretty desc output

This commit is contained in:
Cole Robinson 2019-05-04 17:22:15 -04:00
parent 0ae80d84d7
commit 7597750a59
2 changed files with 20 additions and 19 deletions

View File

@ -1299,7 +1299,7 @@ ba</description>
<network>
<name>nat_to_eth0</name>
<forward dev='eth0'/>
<forward mode='nat' dev='eth0'/>
<ip address='192.168.100.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.100.128' end='192.168.100.254'/>
@ -1338,7 +1338,7 @@ ba</description>
<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
<bridge name="virbr1" stp='off' delay='1'/>
<domain name="example.com"/>
<forward/>
<forward mode='nat'/>
<ip address="192.168.122.1" netmask="255.255.255.0">
<tftp root="/var/lib/tftproot" />
<dhcp>

View File

@ -146,25 +146,26 @@ class Network(XMLBuilder):
"""
@staticmethod
def pretty_forward_desc(mode, dev):
if mode or dev:
if not mode or mode == "nat":
if dev:
desc = _("NAT to %s") % dev
else:
desc = _("NAT")
elif mode == "route":
if dev:
desc = _("Route to %s") % dev
else:
desc = _("Routed network")
if not mode:
return _("Isolated network")
if mode == "nat":
if dev:
desc = _("NAT to %s") % dev
else:
if dev:
desc = (_("%(mode)s to %(device)s") %
{"mode": mode, "device": dev})
else:
desc = _("%s network") % mode.capitalize()
desc = _("NAT")
elif mode == "route":
if dev:
desc = _("Route to %s") % dev
else:
desc = _("Routed network")
else:
desc = _("Isolated network, internal and host routing only")
modestr = mode.capitalize()
if dev:
desc = (_("%(mode)s to %(device)s") %
{"mode": modestr, "device": dev})
else:
desc = _("%s network") % modestr
return desc