Networks now assigned to interfaces when interface profile is applied

This commit adds 'networks' to the list of fields to be copied in/out
of interface profiles. Now, when an interface profile is applied to
a node, the networks will also be assigned to the appropriate interfaces.

In addition, the command 'system interface-network-list' now requires a
host ID/name instead of the field being optional.

Closes-Bug: 1794546

Change-Id: I739c355c06f6adbea4444fabe45a5032827f6bf5
Signed-off-by: Patrick Bonnell <patrick.bonnell@windriver.com>
This commit is contained in:
Patrick Bonnell 2018-09-26 11:41:25 -04:00
parent 82ef088da8
commit f3cdb2c55a
2 changed files with 6 additions and 10 deletions

View File

@ -26,7 +26,6 @@ def _print_interface_network_show(cc, obj):
@utils.arg('hostnameorid',
metavar='<hostname or id>',
nargs='?',
help="Name or ID of host")
@utils.arg('ifnameoruuid',
metavar='<interface name or uuid>',
@ -35,15 +34,12 @@ def _print_interface_network_show(cc, obj):
def do_interface_network_list(cc, args):
"""List network interfaces."""
fields = ['hostname', 'uuid', 'ifname', 'network_name']
if args.hostnameorid is None and args.ifnameoruuid is None:
interface_networks = cc.interface_network.list()
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
if args.ifnameoruuid is None:
interface_networks = cc.interface_network.list_by_host(ihost.uuid)
else:
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
if args.ifnameoruuid is None:
interface_networks = cc.interface_network.list_by_host(ihost.uuid)
else:
interface = iinterface_utils._find_interface(cc, ihost, args.ifnameoruuid)
interface_networks = cc.interface_network.list_by_interface(interface.uuid)
interface = iinterface_utils._find_interface(cc, ihost, args.ifnameoruuid)
interface_networks = cc.interface_network.list_by_interface(interface.uuid)
# Add a hostname column using the forihostid field
for i in interface_networks[:]:
host_id = str(getattr(i, 'forihostid', ''))

View File

@ -73,7 +73,7 @@ CONF.import_opt('journal_default_size',
# Defines the fields that must be copied in/out of interface profiles
INTERFACE_PROFILE_FIELDS = ['ifname', 'iftype', 'imtu', 'networktype',
'ifclass', 'aemode',
'ifclass', 'aemode', 'networks',
'txhashpolicy', 'forihostid', 'providernetworks',
'vlan_id', 'ipv4_mode', 'ipv6_mode',
'ipv4_pool', 'ipv6_pool',