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

View File

@ -146,25 +146,26 @@ class Network(XMLBuilder):
""" """
@staticmethod @staticmethod
def pretty_forward_desc(mode, dev): def pretty_forward_desc(mode, dev):
if mode or dev: if not mode:
if not mode or mode == "nat": return _("Isolated network")
if dev:
desc = _("NAT to %s") % dev if mode == "nat":
else: if dev:
desc = _("NAT") desc = _("NAT to %s") % dev
elif mode == "route":
if dev:
desc = _("Route to %s") % dev
else:
desc = _("Routed network")
else: else:
if dev: desc = _("NAT")
desc = (_("%(mode)s to %(device)s") % elif mode == "route":
{"mode": mode, "device": dev}) if dev:
else: desc = _("Route to %s") % dev
desc = _("%s network") % mode.capitalize() else:
desc = _("Routed network")
else: 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 return desc