Generalized interface and network configuration
- Added the name field to the network table - Removed mtu, link_capacity and vlan_id from the network table - Removed unused networktypes for bm, control and data-vrs - Added four interface classes (platform, data, pci-passthrough, pci-sriov) to interface table - Assign networks to interface during interface creation and modification - Allow infrastructure network and management network to share an interface with or without VLAN. - Updated sysinv puppet for interface and network Story: 2003087 Task: 23171 Depends-On: https://review.openstack.org/#/c/601155 Change-Id: I2e211767639484992f868084eb47baacbe5ea83a Signed-off-by: Teresa Ho <teresa.ho@windriver.com>
This commit is contained in:
parent
2b7e71b20b
commit
c9f23471e3
|
@ -1443,11 +1443,9 @@ class ConfigAssistant():
|
|||
user_input == self.external_oam_interface):
|
||||
self.infrastructure_interface = user_input
|
||||
self.infrastructure_interface_name = user_input
|
||||
if ((self.management_interface_configured and
|
||||
user_input == self.management_interface) or
|
||||
(self.external_oam_interface_configured and
|
||||
user_input == self.external_oam_interface and
|
||||
not self.external_oam_vlan)):
|
||||
if (self.external_oam_interface_configured and
|
||||
user_input == self.external_oam_interface and
|
||||
not self.external_oam_vlan):
|
||||
infra_vlan_required = True
|
||||
break
|
||||
else:
|
||||
|
@ -4007,15 +4005,11 @@ class ConfigAssistant():
|
|||
# create the network for the pool
|
||||
values = {
|
||||
'type': sysinv_constants.NETWORK_TYPE_MGMT,
|
||||
'mtu': self.management_mtu,
|
||||
'link_capacity': self.management_link_capacity,
|
||||
'name': sysinv_constants.NETWORK_TYPE_MGMT,
|
||||
'dynamic': self.dynamic_address_allocation,
|
||||
'pool_uuid': pool.uuid,
|
||||
}
|
||||
|
||||
if self.management_vlan:
|
||||
values.update({'vlan_id': int(self.management_vlan)})
|
||||
|
||||
client.sysinv.network.create(**values)
|
||||
|
||||
def _populate_pxeboot_network(self, client):
|
||||
|
@ -4032,7 +4026,7 @@ class ConfigAssistant():
|
|||
# create the network for the pool
|
||||
values = {
|
||||
'type': sysinv_constants.NETWORK_TYPE_PXEBOOT,
|
||||
'mtu': self.management_mtu,
|
||||
'name': sysinv_constants.NETWORK_TYPE_PXEBOOT,
|
||||
'dynamic': True,
|
||||
'pool_uuid': pool.uuid,
|
||||
}
|
||||
|
@ -4055,15 +4049,11 @@ class ConfigAssistant():
|
|||
# create the network for the pool
|
||||
values = {
|
||||
'type': sysinv_constants.NETWORK_TYPE_INFRA,
|
||||
'mtu': self.infrastructure_mtu,
|
||||
'link_capacity': self.infrastructure_link_capacity,
|
||||
'name': sysinv_constants.NETWORK_TYPE_INFRA,
|
||||
'dynamic': self.dynamic_address_allocation,
|
||||
'pool_uuid': pool.uuid,
|
||||
}
|
||||
|
||||
if self.infrastructure_vlan:
|
||||
values.update({'vlan_id': int(self.infrastructure_vlan)})
|
||||
|
||||
client.sysinv.network.create(**values)
|
||||
|
||||
def _populate_oam_network(self, client):
|
||||
|
@ -4096,14 +4086,11 @@ class ConfigAssistant():
|
|||
# create the network for the pool
|
||||
values = {
|
||||
'type': sysinv_constants.NETWORK_TYPE_OAM,
|
||||
'mtu': self.external_oam_mtu,
|
||||
'name': sysinv_constants.NETWORK_TYPE_OAM,
|
||||
'dynamic': False,
|
||||
'pool_uuid': pool.uuid,
|
||||
}
|
||||
|
||||
if self.external_oam_vlan:
|
||||
values.update({'vlan_id': int(self.external_oam_vlan)})
|
||||
|
||||
client.sysinv.network.create(**values)
|
||||
|
||||
def _populate_multicast_network(self, client):
|
||||
|
@ -4120,7 +4107,7 @@ class ConfigAssistant():
|
|||
# create the network for the pool
|
||||
values = {
|
||||
'type': sysinv_constants.NETWORK_TYPE_MULTICAST,
|
||||
'mtu': self.management_mtu,
|
||||
'name': sysinv_constants.NETWORK_TYPE_MULTICAST,
|
||||
'dynamic': False,
|
||||
'pool_uuid': pool.uuid,
|
||||
}
|
||||
|
@ -4139,7 +4126,7 @@ class ConfigAssistant():
|
|||
# create the network for the pool
|
||||
values = {
|
||||
'type': sysinv_constants.NETWORK_TYPE_SYSTEM_CONTROLLER,
|
||||
'mtu': '1500', # unused in subcloud
|
||||
'name': sysinv_constants.NETWORK_TYPE_SYSTEM_CONTROLLER,
|
||||
'dynamic': False,
|
||||
'pool_uuid': pool.uuid,
|
||||
}
|
||||
|
@ -4262,6 +4249,14 @@ class ConfigAssistant():
|
|||
else:
|
||||
raise ConfigFail("Unknown interface AE mode: %s" % aemode)
|
||||
|
||||
def _get_network(self, client, network_type):
|
||||
networks = client.sysinv.network.list()
|
||||
for net in networks:
|
||||
if net.type == network_type:
|
||||
return net
|
||||
else:
|
||||
raise ConfigFail("Failed to find network %s" % type)
|
||||
|
||||
def _get_interface_mtu(self, ifname):
|
||||
"""
|
||||
This function determines the MTU value that must be configured on an
|
||||
|
@ -4295,10 +4290,13 @@ class ConfigAssistant():
|
|||
def _populate_management_interface(self, client, controller):
|
||||
"""Configure the management/pxeboot interface(s)"""
|
||||
|
||||
interface_class = sysinv_constants.INTERFACE_CLASS_PLATFORM
|
||||
if self.management_vlan:
|
||||
networktype = sysinv_constants.NETWORK_TYPE_PXEBOOT
|
||||
network = self._get_network(client,
|
||||
sysinv_constants.NETWORK_TYPE_PXEBOOT)
|
||||
else:
|
||||
networktype = sysinv_constants.NETWORK_TYPE_MGMT
|
||||
network = self._get_network(client,
|
||||
sysinv_constants.NETWORK_TYPE_MGMT)
|
||||
|
||||
if self.lag_management_interface:
|
||||
members = [self.lag_management_interface_member0]
|
||||
|
@ -4318,7 +4316,8 @@ class ConfigAssistant():
|
|||
'iftype': 'ae',
|
||||
'aemode': aemode,
|
||||
'txhashpolicy': txhashpolicy,
|
||||
'networktype': networktype,
|
||||
'ifclass': interface_class,
|
||||
'networks': [str(network.id)],
|
||||
'uses': members,
|
||||
}
|
||||
|
||||
|
@ -4331,7 +4330,8 @@ class ConfigAssistant():
|
|||
'ifname': self.management_interface,
|
||||
'imtu': self.management_mtu,
|
||||
'iftype': sysinv_constants.INTERFACE_TYPE_VIRTUAL,
|
||||
'networktype': networktype,
|
||||
'ifclass': interface_class,
|
||||
'networks': [str(network.id)],
|
||||
}
|
||||
client.sysinv.iinterface.create(**values)
|
||||
else:
|
||||
|
@ -4340,17 +4340,21 @@ class ConfigAssistant():
|
|||
'ihost_uuid': controller.uuid,
|
||||
'ifname': self.management_interface,
|
||||
'imtu': self.management_mtu,
|
||||
'networktype': networktype,
|
||||
'ifclass': interface_class,
|
||||
'networks': str(network.id),
|
||||
}
|
||||
self._update_interface_config(client, values)
|
||||
|
||||
if self.management_vlan:
|
||||
mgmt_network = self._get_network(
|
||||
client, sysinv_constants.NETWORK_TYPE_MGMT)
|
||||
values = {
|
||||
'ihost_uuid': controller.uuid,
|
||||
'ifname': self.management_interface_name,
|
||||
'imtu': self.management_mtu,
|
||||
'iftype': sysinv_constants.INTERFACE_TYPE_VLAN,
|
||||
'networktype': sysinv_constants.NETWORK_TYPE_MGMT,
|
||||
'ifclass': interface_class,
|
||||
'networks': [str(mgmt_network.id)],
|
||||
'uses': [self.management_interface],
|
||||
'vlan_id': self.management_vlan,
|
||||
}
|
||||
|
@ -4375,10 +4379,9 @@ class ConfigAssistant():
|
|||
if not self.infrastructure_interface:
|
||||
return # No infrastructure interface configured
|
||||
|
||||
if self.infrastructure_vlan:
|
||||
networktype = sysinv_constants.NETWORK_TYPE_NONE
|
||||
else:
|
||||
networktype = sysinv_constants.NETWORK_TYPE_INFRA
|
||||
interface_class = sysinv_constants.INTERFACE_CLASS_PLATFORM
|
||||
network = self._get_network(client,
|
||||
sysinv_constants.NETWORK_TYPE_INFRA)
|
||||
|
||||
if self.lag_infrastructure_interface:
|
||||
members = [self.lag_infrastructure_interface_member0]
|
||||
|
@ -4398,7 +4401,8 @@ class ConfigAssistant():
|
|||
'iftype': sysinv_constants.INTERFACE_TYPE_AE,
|
||||
'aemode': aemode,
|
||||
'txhashpolicy': txhashpolicy,
|
||||
'networktype': networktype,
|
||||
'ifclass': interface_class,
|
||||
'networks': [str(network.id)],
|
||||
'uses': members,
|
||||
}
|
||||
|
||||
|
@ -4408,13 +4412,14 @@ class ConfigAssistant():
|
|||
values = {
|
||||
'ihost_uuid': controller.uuid,
|
||||
'ifname': self.infrastructure_interface,
|
||||
'ifclass': interface_class,
|
||||
}
|
||||
values.update({
|
||||
'imtu': self._get_interface_mtu(self.infrastructure_interface)
|
||||
})
|
||||
if networktype != sysinv_constants.NETWORK_TYPE_NONE:
|
||||
if not self.infrastructure_vlan:
|
||||
values.update({
|
||||
'networktype': networktype
|
||||
'networks': str(network.id)
|
||||
})
|
||||
|
||||
self._update_interface_config(client, values)
|
||||
|
@ -4425,7 +4430,8 @@ class ConfigAssistant():
|
|||
'ifname': self.infrastructure_interface_name,
|
||||
'imtu': self.infrastructure_mtu,
|
||||
'iftype': sysinv_constants.INTERFACE_TYPE_VLAN,
|
||||
'networktype': sysinv_constants.NETWORK_TYPE_INFRA,
|
||||
'ifclass': interface_class,
|
||||
'networks': [str(network.id)],
|
||||
'uses': [self.infrastructure_interface],
|
||||
'vlan_id': self.infrastructure_vlan,
|
||||
}
|
||||
|
@ -4434,10 +4440,8 @@ class ConfigAssistant():
|
|||
def _populate_oam_interface(self, client, controller):
|
||||
"""Configure the OAM interface(s)"""
|
||||
|
||||
if self.external_oam_vlan:
|
||||
networktype = sysinv_constants.NETWORK_TYPE_NONE
|
||||
else:
|
||||
networktype = sysinv_constants.NETWORK_TYPE_OAM
|
||||
network = self._get_network(client,
|
||||
sysinv_constants.NETWORK_TYPE_OAM)
|
||||
|
||||
if self.lag_external_oam_interface:
|
||||
members = [self.lag_external_oam_interface_member0]
|
||||
|
@ -4457,7 +4461,8 @@ class ConfigAssistant():
|
|||
'iftype': sysinv_constants.INTERFACE_TYPE_AE,
|
||||
'aemode': aemode,
|
||||
'txhashpolicy': txhashpolicy,
|
||||
'networktype': networktype,
|
||||
'ifclass': sysinv_constants.INTERFACE_CLASS_PLATFORM,
|
||||
'networks': [str(network.id)],
|
||||
'uses': members,
|
||||
}
|
||||
|
||||
|
@ -4467,13 +4472,14 @@ class ConfigAssistant():
|
|||
values = {
|
||||
'ihost_uuid': controller.uuid,
|
||||
'ifname': self.external_oam_interface,
|
||||
'ifclass': sysinv_constants.INTERFACE_CLASS_PLATFORM,
|
||||
}
|
||||
values.update({
|
||||
'imtu': self._get_interface_mtu(self.external_oam_interface)
|
||||
})
|
||||
if networktype != sysinv_constants.NETWORK_TYPE_NONE:
|
||||
if not self.external_oam_vlan:
|
||||
values.update({
|
||||
'networktype': networktype
|
||||
'networks': str(network.id),
|
||||
})
|
||||
|
||||
self._update_interface_config(client, values)
|
||||
|
@ -4484,7 +4490,8 @@ class ConfigAssistant():
|
|||
'ifname': self.external_oam_interface_name,
|
||||
'imtu': self.external_oam_mtu,
|
||||
'iftype': sysinv_constants.INTERFACE_TYPE_VLAN,
|
||||
'networktype': sysinv_constants.NETWORK_TYPE_OAM,
|
||||
'ifclass': sysinv_constants.INTERFACE_CLASS_PLATFORM,
|
||||
'networks': [str(network.id)],
|
||||
'uses': [self.external_oam_interface],
|
||||
'vlan_id': self.external_oam_vlan,
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ from cgtsclient import exc
|
|||
from cgtsclient.v1 import port
|
||||
|
||||
|
||||
CREATION_ATTRIBUTES = ['ifname', 'iftype', 'ihost_uuid', 'imtu', 'networktype', 'aemode', 'txhashpolicy',
|
||||
CREATION_ATTRIBUTES = ['ifname', 'iftype', 'ihost_uuid', 'imtu', 'ifclass',
|
||||
'networks', 'network_uuid', 'networktype', 'aemode', 'txhashpolicy',
|
||||
'providernetworks', 'providernetworksdict', 'ifcapabilities', 'ports', 'imac',
|
||||
'vlan_id', 'uses', 'used_by',
|
||||
'ipv4_mode', 'ipv6_mode', 'ipv4_pool', 'ipv6_pool',
|
||||
|
|
|
@ -13,11 +13,12 @@ from cgtsclient.common import utils
|
|||
from cgtsclient import exc
|
||||
from cgtsclient.v1 import ihost as ihost_utils
|
||||
from cgtsclient.v1 import iinterface as iinterface_utils
|
||||
from cgtsclient.v1 import network as network_utils
|
||||
|
||||
|
||||
def _print_iinterface_show(iinterface):
|
||||
fields = ['ifname', 'networktype', 'iftype', 'ports', 'providernetworks',
|
||||
'imac', 'imtu',
|
||||
fields = ['ifname', 'iftype', 'ports', 'providernetworks',
|
||||
'imac', 'imtu', 'ifclass', 'networks',
|
||||
'aemode', 'schedpolicy', 'txhashpolicy',
|
||||
'uuid', 'ihost_uuid',
|
||||
'vlan_id', 'uses', 'used_by',
|
||||
|
@ -72,7 +73,7 @@ def do_host_if_list(cc, args):
|
|||
for i in iinterfaces[:]:
|
||||
iinterface_utils._get_ports(cc, ihost, i)
|
||||
if not args.all:
|
||||
if i.networktype is None and i.used_by == []:
|
||||
if i.ifclass is None and i.used_by == []:
|
||||
iinterfaces.remove(i)
|
||||
attr_str = "MTU=%s" % i.imtu
|
||||
if i.iftype == 'ae':
|
||||
|
@ -80,17 +81,15 @@ def do_host_if_list(cc, args):
|
|||
if i.aemode in ['balanced', '802.3ad']:
|
||||
attr_str = "%s,AE_XMIT_POLICY=%s" % (
|
||||
attr_str, i.txhashpolicy)
|
||||
if (i.networktype and
|
||||
any(network in ['data'] for
|
||||
network in i.networktype.split(","))):
|
||||
if i.ifclass and i.ifclass == 'data':
|
||||
if False in i.dpdksupport:
|
||||
attr_str = "%s,accelerated=False" % attr_str
|
||||
else:
|
||||
attr_str = "%s,accelerated=True" % attr_str
|
||||
setattr(i, 'attrs', attr_str)
|
||||
|
||||
field_labels = ['uuid', 'name', 'network type', 'type', 'vlan id', 'ports', 'uses i/f', 'used by i/f', 'attributes', 'provider networks']
|
||||
fields = ['uuid', 'ifname', 'networktype', 'iftype', 'vlan_id', 'ports', 'uses', 'used_by', 'attrs', 'providernetworks']
|
||||
field_labels = ['uuid', 'name', 'class', 'type', 'vlan id', 'ports', 'uses i/f', 'used by i/f', 'attributes', 'provider networks']
|
||||
fields = ['uuid', 'ifname', 'ifclass', 'iftype', 'vlan_id', 'ports', 'uses', 'used_by', 'attrs', 'providernetworks']
|
||||
utils.print_list(iinterfaces, fields, field_labels, sortby=0, no_wrap_fields=['ports'])
|
||||
|
||||
|
||||
|
@ -146,6 +145,13 @@ def do_host_if_delete(cc, args):
|
|||
const='data',
|
||||
default='data',
|
||||
help='The networktype of the interface (default: %(default)s)')
|
||||
@utils.arg('-c', '--ifclass',
|
||||
metavar='<class>',
|
||||
choices=['platform', 'data', 'pci-passthrough', 'pci-sriov'],
|
||||
help='The class of the interface')
|
||||
@utils.arg('--networks',
|
||||
metavar='<network name or id>',
|
||||
help="Name or ID of network")
|
||||
@utils.arg('portsorifaces',
|
||||
metavar='<portsorifaces>',
|
||||
nargs='+',
|
||||
|
@ -167,7 +173,8 @@ def do_host_if_delete(cc, args):
|
|||
def do_host_if_add(cc, args):
|
||||
"""Add an interface."""
|
||||
|
||||
field_list = ['ifname', 'iftype', 'imtu', 'networktype', 'aemode',
|
||||
field_list = ['ifname', 'iftype', 'imtu', 'ifclass', 'networks',
|
||||
'networktype', 'aemode',
|
||||
'txhashpolicy', 'providernetworks', 'vlan_id',
|
||||
'ipv4_mode', 'ipv6_mode', 'ipv4_pool', 'ipv6_pool']
|
||||
|
||||
|
@ -193,6 +200,9 @@ def do_host_if_add(cc, args):
|
|||
del user_specified_fields['providernetworks']
|
||||
if 'networktype' in user_specified_fields.keys():
|
||||
user_specified_fields['networktype'] = user_specified_fields['networktype'].replace(" ", "")
|
||||
if 'networks' in user_specified_fields.keys():
|
||||
network = network_utils._find_network(cc, args.networks)
|
||||
user_specified_fields['networks'] = [str(network.id)]
|
||||
|
||||
user_specified_fields['ihost_uuid'] = ihost.uuid
|
||||
user_specified_fields['ports'] = portnamesoruuids
|
||||
|
@ -234,6 +244,12 @@ def do_host_if_add(cc, args):
|
|||
@utils.arg('-nt', '--networktype',
|
||||
metavar='<networktype>',
|
||||
help='The networktype of the interface')
|
||||
@utils.arg('-c', '--ifclass',
|
||||
metavar='<class>',
|
||||
help='The class of the interface')
|
||||
@utils.arg('--networks',
|
||||
metavar='<network name or id>',
|
||||
help="Name or ID of network")
|
||||
@utils.arg('--ipv4-mode',
|
||||
metavar='<ipv4_mode>',
|
||||
choices=['disabled', 'static', 'pool'],
|
||||
|
@ -256,7 +272,8 @@ def do_host_if_modify(cc, args):
|
|||
"""Modify interface attributes."""
|
||||
|
||||
rwfields = ['iftype', 'ifname', 'imtu', 'aemode', 'txhashpolicy',
|
||||
'providernetworks', 'ports', 'networktype',
|
||||
'providernetworks', 'ports', 'ifclass', 'networktype',
|
||||
'networks',
|
||||
'ipv4_mode', 'ipv6_mode', 'ipv4_pool', 'ipv6_pool',
|
||||
'sriov_numvfs']
|
||||
|
||||
|
@ -272,18 +289,21 @@ def do_host_if_modify(cc, args):
|
|||
fields = interface.__dict__
|
||||
fields.update(user_specified_fields)
|
||||
|
||||
if 'networks' in user_specified_fields.keys():
|
||||
network = network_utils._find_network(cc, args.networks)
|
||||
user_specified_fields['networks'] = str(network.id)
|
||||
|
||||
# Allow setting an interface back to a None type
|
||||
if 'networktype' in user_specified_fields.keys():
|
||||
user_specified_fields['networktype'] = user_specified_fields['networktype'].replace(" ", "")
|
||||
if args.networktype == 'none':
|
||||
if 'ifclass' in user_specified_fields.keys():
|
||||
if args.ifclass == 'none':
|
||||
user_specified_fields['networktype'] = 'none'
|
||||
iinterface_utils._get_ports(cc, ihost, interface)
|
||||
if interface.ports or interface.uses:
|
||||
if interface.iftype != 'ae' and interface.iftype != 'vlan':
|
||||
for p in interface.ports:
|
||||
user_specified_fields['ifname'] = p
|
||||
break
|
||||
if any(network in ['data'] for
|
||||
network in interface.networktype.split(",")):
|
||||
if interface.ifclass == 'data':
|
||||
user_specified_fields['providernetworks'] = 'none'
|
||||
|
||||
patch = []
|
||||
|
|
|
@ -46,9 +46,7 @@ LOG = log.getLogger(__name__)
|
|||
ALLOWED_NETWORK_TYPES = [constants.NETWORK_TYPE_MGMT,
|
||||
constants.NETWORK_TYPE_INFRA,
|
||||
constants.NETWORK_TYPE_OAM,
|
||||
constants.NETWORK_TYPE_DATA,
|
||||
constants.NETWORK_TYPE_DATA_VRS,
|
||||
constants.NETWORK_TYPE_CONTROL]
|
||||
constants.NETWORK_TYPE_DATA]
|
||||
|
||||
|
||||
class Address(base.APIBase):
|
||||
|
@ -247,12 +245,11 @@ class AddressController(rest.RestController):
|
|||
|
||||
def _check_interface_type(self, interface_id):
|
||||
interface = pecan.request.dbapi.iinterface_get(interface_id)
|
||||
networktype = cutils.get_primary_network_type(interface)
|
||||
if not networktype:
|
||||
if not interface.networktype:
|
||||
raise exception.InterfaceNetworkTypeNotSet()
|
||||
if networktype not in ALLOWED_NETWORK_TYPES:
|
||||
if interface.networktype not in ALLOWED_NETWORK_TYPES:
|
||||
raise exception.UnsupportedInterfaceNetworkType(
|
||||
networktype=networktype)
|
||||
networktype=interface.networktype)
|
||||
return
|
||||
|
||||
def _check_infra_address(self, interface_id, address):
|
||||
|
@ -317,17 +314,13 @@ class AddressController(rest.RestController):
|
|||
|
||||
def _check_address_count(self, interface_id, host_id):
|
||||
interface = pecan.request.dbapi.iinterface_get(interface_id)
|
||||
networktype = cutils.get_primary_network_type(interface)
|
||||
networktype = interface['networktype']
|
||||
sdn_enabled = utils.get_sdn_enabled()
|
||||
|
||||
if networktype == constants.NETWORK_TYPE_DATA and not sdn_enabled:
|
||||
# Is permitted to add multiple addresses only
|
||||
# if SDN L3 mode is not enabled.
|
||||
return
|
||||
addresses = (
|
||||
pecan.request.dbapi.addresses_get_by_interface(interface_id))
|
||||
if len(addresses) != 0:
|
||||
raise exception.AddressCountLimitedToOne(iftype=networktype)
|
||||
|
||||
# There can only be one 'data' interface with an IP address
|
||||
# where SDN is enabled
|
||||
|
@ -338,8 +331,7 @@ class AddressController(rest.RestController):
|
|||
# skip the one we came in with
|
||||
if uuid == interface_id:
|
||||
continue
|
||||
nt = cutils.get_primary_network_type(iface)
|
||||
if nt == constants.NETWORK_TYPE_DATA:
|
||||
if iface['ifclass'] == constants.NETWORK_TYPE_DATA:
|
||||
addresses = (
|
||||
pecan.request.dbapi.addresses_get_by_interface(uuid))
|
||||
if len(addresses) != 0:
|
||||
|
@ -385,7 +377,7 @@ class AddressController(rest.RestController):
|
|||
def _check_managed_addr(self, host_id, interface_id):
|
||||
# Check that static address alloc is enabled
|
||||
interface = pecan.request.dbapi.iinterface_get(interface_id)
|
||||
networktype = cutils.get_primary_network_type(interface)
|
||||
networktype = interface['networktype']
|
||||
if networktype not in [constants.NETWORK_TYPE_MGMT,
|
||||
constants.NETWORK_TYPE_INFRA,
|
||||
constants.NETWORK_TYPE_OAM]:
|
||||
|
@ -467,8 +459,7 @@ class AddressController(rest.RestController):
|
|||
self._check_interface_type(interface_id)
|
||||
self._check_host_state(host_id)
|
||||
self._check_address_mode(interface_id, address_dict['family'])
|
||||
if (cutils.get_primary_network_type(interface) ==
|
||||
constants.NETWORK_TYPE_INFRA):
|
||||
if (interface['networktype'] == constants.NETWORK_TYPE_INFRA):
|
||||
result = self._create_infra_addr(
|
||||
address_dict, host_id, interface_id)
|
||||
else:
|
||||
|
@ -527,8 +518,7 @@ class AddressController(rest.RestController):
|
|||
self._check_host_state(getattr(address, 'forihostid'))
|
||||
self._check_from_pool(getattr(address, 'pool_uuid'))
|
||||
interface = pecan.request.dbapi.iinterface_get(interface_uuid)
|
||||
if (cutils.get_primary_network_type(interface) ==
|
||||
constants.NETWORK_TYPE_INFRA):
|
||||
if (interface['networktype'] == constants.NETWORK_TYPE_INFRA):
|
||||
self._delete_infra_addr(address)
|
||||
else:
|
||||
pecan.request.dbapi.address_destroy(address_uuid)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -215,10 +215,11 @@ class InfraNetworkController(rest.RestController):
|
|||
if utils.is_host_active_controller(host):
|
||||
interface_list = pecan.request.dbapi.iinterface_get_by_ihost(
|
||||
host.uuid)
|
||||
network = pecan.request.dbapi.network_get_by_type(constants.NETWORK_TYPE_INFRA)
|
||||
for interface in interface_list:
|
||||
if (cutils.get_primary_network_type(interface) ==
|
||||
constants.NETWORK_TYPE_INFRA):
|
||||
return True
|
||||
if interface['ifclass'] == constants.INTERFACE_CLASS_PLATFORM:
|
||||
if str(network['id']) in interface['networks']:
|
||||
return True
|
||||
raise wsme.exc.ClientSideError(_(
|
||||
"Infrastructure interface must be configured on the active "
|
||||
"controller prior to applying infrastructure network "
|
||||
|
@ -376,10 +377,6 @@ class InfraNetworkController(rest.RestController):
|
|||
for index, field in enumerate(InfraNetwork.address_names.keys()):
|
||||
infra[field] = str(start_address + index)
|
||||
|
||||
self._check_mtu_syntax(infra)
|
||||
self._check_vlan_id_syntax(infra)
|
||||
self._check_interface_mtu(infra)
|
||||
self._check_interface_vlan_id(infra)
|
||||
return infra
|
||||
|
||||
def _create_infra_network(self, infra):
|
||||
|
@ -407,17 +404,10 @@ class InfraNetworkController(rest.RestController):
|
|||
|
||||
values = {
|
||||
'type': constants.NETWORK_TYPE_INFRA,
|
||||
'mtu': infra['infra_mtu'],
|
||||
'dynamic': mgmt_network.dynamic,
|
||||
'address_pool_id': pool.id,
|
||||
'link_capacity': constants.LINK_SPEED_10G,
|
||||
}
|
||||
|
||||
if infra['infra_vlan_id']:
|
||||
values.update({
|
||||
'vlan_id': infra['infra_vlan_id'],
|
||||
})
|
||||
|
||||
pecan.request.dbapi.network_create(values)
|
||||
|
||||
# reserve static network addresses
|
||||
|
@ -565,10 +555,6 @@ class InfraNetworkController(rest.RestController):
|
|||
changed_fields.append(field)
|
||||
|
||||
rpc_infra.save()
|
||||
# If mtu or vlan has changed, update the infrastructure interface
|
||||
if any(field in ['infra_mtu', 'infra_vlan_id']
|
||||
for field in changed_fields):
|
||||
self._update_interface(infra)
|
||||
|
||||
if action == constants.APPLY_ACTION:
|
||||
# perform rpc to conductor to perform config apply
|
||||
|
|
|
@ -72,7 +72,8 @@ CONF.import_opt('journal_default_size',
|
|||
group='journal')
|
||||
|
||||
# Defines the fields that must be copied in/out of interface profiles
|
||||
INTERFACE_PROFILE_FIELDS = ['ifname', 'iftype', 'imtu', 'networktype', 'aemode',
|
||||
INTERFACE_PROFILE_FIELDS = ['ifname', 'iftype', 'imtu', 'networktype',
|
||||
'ifclass', 'aemode',
|
||||
'txhashpolicy', 'forihostid', 'providernetworks',
|
||||
'vlan_id', 'ipv4_mode', 'ipv6_mode',
|
||||
'ipv4_pool', 'ipv6_pool',
|
||||
|
|
|
@ -46,8 +46,6 @@ SYSINV_ROUTE_MAX_PATHS = 4
|
|||
|
||||
# Defines the list of interface network types that support routes
|
||||
ALLOWED_NETWORK_TYPES = [constants.NETWORK_TYPE_DATA,
|
||||
constants.NETWORK_TYPE_DATA_VRS,
|
||||
constants.NETWORK_TYPE_CONTROL,
|
||||
constants.NETWORK_TYPE_MGMT]
|
||||
|
||||
|
||||
|
@ -265,7 +263,7 @@ class RouteController(rest.RestController):
|
|||
|
||||
def _check_interface_type(self, interface_id):
|
||||
interface = pecan.request.dbapi.iinterface_get(interface_id)
|
||||
networktype = cutils.get_primary_network_type(interface)
|
||||
networktype = interface['networktype']
|
||||
if networktype not in ALLOWED_NETWORK_TYPES:
|
||||
raise exception.RoutesNotSupportedOnInterfaces(iftype=networktype)
|
||||
return
|
||||
|
@ -334,13 +332,6 @@ class RouteController(rest.RestController):
|
|||
self._check_duplicate_route(host_id, route)
|
||||
self._check_duplicate_subnet(host_id, route)
|
||||
|
||||
def _check_allowed_routes(self, interface_id, route):
|
||||
if route['prefix'] == 0:
|
||||
interface = pecan.request.dbapi.iinterface_get(interface_id)
|
||||
networktype = cutils.get_primary_network_type(interface)
|
||||
if networktype in [constants.NETWORK_TYPE_DATA_VRS]:
|
||||
raise exception.DefaultRouteNotAllowedOnVRSInterface()
|
||||
|
||||
def _create_route(self, route):
|
||||
route.validate_syntax()
|
||||
route = route.as_dict()
|
||||
|
@ -350,7 +341,6 @@ class RouteController(rest.RestController):
|
|||
host_id, interface_id = self._get_parent_id(interface_uuid)
|
||||
# Check for semantic conflicts
|
||||
self._check_interface_type(interface_id)
|
||||
self._check_allowed_routes(interface_id, route)
|
||||
self._check_route_conflicts(host_id, route)
|
||||
self._check_local_gateway(host_id, route)
|
||||
self._check_reachable_gateway(interface_id, route)
|
||||
|
|
|
@ -586,6 +586,16 @@ class SystemController(rest.RestController):
|
|||
|
||||
@wsme_pecan.wsexpose(int)
|
||||
def mgmtvlan(self):
|
||||
mgmt_network = pecan.request.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
return mgmt_network.vlan_id if mgmt_network.vlan_id else 0
|
||||
local_hostname = cutils.get_local_controller_hostname()
|
||||
controller = pecan.request.dbapi.ihost_get(local_hostname)
|
||||
host_id = controller['id']
|
||||
interface_list = pecan.request.dbapi.iinterface_get_by_ihost(host_id)
|
||||
for interface in interface_list:
|
||||
for network_id in interface['networks']:
|
||||
network = pecan.request.dbapi.network_get_by_id(network_id)
|
||||
if network.type == constants.NETWORK_TYPE_MGMT:
|
||||
if 'vlan_id' not in interface:
|
||||
return 0
|
||||
else:
|
||||
return interface['vlan_id']
|
||||
return None
|
||||
|
|
|
@ -584,14 +584,17 @@ NETWORK_TYPE_OAM = 'oam'
|
|||
NETWORK_TYPE_BM = 'bm'
|
||||
NETWORK_TYPE_MULTICAST = 'multicast'
|
||||
NETWORK_TYPE_DATA = 'data'
|
||||
NETWORK_TYPE_DATA_VRS = 'data-vrs'
|
||||
NETWORK_TYPE_CONTROL = 'control'
|
||||
NETWORK_TYPE_SYSTEM_CONTROLLER = 'system-controller'
|
||||
|
||||
NETWORK_TYPE_PCI_PASSTHROUGH = 'pci-passthrough'
|
||||
NETWORK_TYPE_PCI_SRIOV = 'pci-sriov'
|
||||
NETWORK_TYPE_PXEBOOT = 'pxeboot'
|
||||
|
||||
PLATFORM_NETWORK_TYPES = [NETWORK_TYPE_PXEBOOT,
|
||||
NETWORK_TYPE_MGMT,
|
||||
NETWORK_TYPE_INFRA,
|
||||
NETWORK_TYPE_OAM]
|
||||
|
||||
PCI_NETWORK_TYPES = [NETWORK_TYPE_PCI_PASSTHROUGH,
|
||||
NETWORK_TYPE_PCI_SRIOV]
|
||||
|
||||
|
@ -600,6 +603,12 @@ INTERFACE_TYPE_VLAN = 'vlan'
|
|||
INTERFACE_TYPE_AE = 'ae'
|
||||
INTERFACE_TYPE_VIRTUAL = 'virtual'
|
||||
|
||||
INTERFACE_CLASS_NONE = 'none'
|
||||
INTERFACE_CLASS_PLATFORM = 'platform'
|
||||
INTERFACE_CLASS_DATA = 'data'
|
||||
INTERFACE_CLASS_PCI_PASSTHROUGH = 'pci-passthrough'
|
||||
INTERFACE_CLASS_PCI_SRIOV = 'pci-sriov'
|
||||
|
||||
SM_MULTICAST_MGMT_IP_NAME = "sm-mgmt-ip"
|
||||
MTCE_MULTICAST_MGMT_IP_NAME = "mtce-mgmt-ip"
|
||||
PATCH_CONTROLLER_MULTICAST_MGMT_IP_NAME = "patch-controller-mgmt-ip"
|
||||
|
|
|
@ -1058,19 +1058,22 @@ def get_primary_network_type(interface):
|
|||
network types, discards the secondary type (if any) and returns the primary
|
||||
network type.
|
||||
"""
|
||||
if not interface['networktype'] or interface['networktype'] == constants.NETWORK_TYPE_NONE:
|
||||
if not interface['ifclass'] or interface['ifclass'] == constants.INTERFACE_CLASS_NONE:
|
||||
return None
|
||||
networktypes = get_network_type_list(interface)
|
||||
if len(networktypes) > 1:
|
||||
networktypes = [n for n in networktypes if n != constants.NETWORK_TYPE_DATA]
|
||||
# If the network type is the combined PCI passthrough and SRIOV then
|
||||
# return pci-sriov as the primary network type
|
||||
if is_pci_network_types(networktypes):
|
||||
return constants.NETWORK_TYPE_PCI_SRIOV
|
||||
if len(networktypes) > 1:
|
||||
raise exception.CannotDeterminePrimaryNetworkType(
|
||||
iface=interface['uuid'], types=interface['networktype'])
|
||||
return networktypes[0]
|
||||
primary_network_type = None
|
||||
if interface['ifclass'] == constants.INTERFACE_CLASS_DATA:
|
||||
primary_network_type = constants.NETWORK_TYPE_DATA
|
||||
elif interface['ifclass'] == constants.INTERFACE_CLASS_PCI_PASSTHROUGH:
|
||||
primary_network_type = constants.NETWORK_TYPE_PCI_PASSTHROUGH
|
||||
elif interface['ifclass'] == constants.INTERFACE_CLASS_PCI_SRIOV:
|
||||
primary_network_type = constants.NETWORK_TYPE_PCI_SRIOV
|
||||
elif interface['ifclass'] == constants.INTERFACE_CLASS_PLATFORM:
|
||||
if not interface['networktype'] or interface[
|
||||
'networktype'] == constants.NETWORK_TYPE_NONE:
|
||||
return None
|
||||
primary_network_type = interface['networktype']
|
||||
|
||||
return primary_network_type
|
||||
|
||||
|
||||
def get_sw_version():
|
||||
|
@ -1160,6 +1163,15 @@ def gethostbyname(hostname):
|
|||
return socket.getaddrinfo(hostname, None)[0][4][0]
|
||||
|
||||
|
||||
def get_local_controller_hostname():
|
||||
try:
|
||||
local_hostname = socket.gethostname()
|
||||
except Exception as e:
|
||||
raise exception.SysinvException(_(
|
||||
"Failed to get the local hostname: %s") % str(e))
|
||||
return local_hostname
|
||||
|
||||
|
||||
def get_mate_controller_hostname(hostname=None):
|
||||
if not hostname:
|
||||
try:
|
||||
|
|
|
@ -1244,10 +1244,20 @@ class ConductorManager(service.PeriodicService):
|
|||
port_list = self.dbapi.port_get_all(host_id)
|
||||
ports = dict((p['interface_id'], p) for p in port_list)
|
||||
for interface in interface_list:
|
||||
iface_network_type = cutils.get_primary_network_type(interface)
|
||||
if iface_network_type == network_type:
|
||||
if interface.networktype == network_type:
|
||||
return cutils.get_interface_os_ifname(interface, ifaces, ports)
|
||||
|
||||
def _find_local_mgmt_interface_vlan_id(self):
|
||||
"""Lookup the local interface name for a given network type."""
|
||||
host_id = self.get_my_host_id()
|
||||
interface_list = self.dbapi.iinterface_get_all(host_id, expunge=True)
|
||||
for interface in interface_list:
|
||||
if interface.networktype == constants.NETWORK_TYPE_MGMT:
|
||||
if 'vlan_id' not in interface:
|
||||
return 0
|
||||
else:
|
||||
return interface['vlan_id']
|
||||
|
||||
def _remove_leases_by_mac_address(self, mac_address):
|
||||
"""Remove any leases that were added without a CID that we were not
|
||||
able to delete. This is specifically looking for leases on the pxeboot
|
||||
|
@ -1734,20 +1744,19 @@ class ConductorManager(service.PeriodicService):
|
|||
if i.networktype == constants.NETWORK_TYPE_MGMT:
|
||||
break
|
||||
|
||||
mgmt_network = self.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
|
||||
cloning = False
|
||||
for inic in inic_dict_array:
|
||||
LOG.debug("Processing inic %s" % inic)
|
||||
interface_exists = False
|
||||
networktype = None
|
||||
ifclass = None
|
||||
bootp = None
|
||||
create_tagged_interface = False
|
||||
new_interface = None
|
||||
set_address_interface = False
|
||||
mtu = constants.DEFAULT_MTU
|
||||
port = None
|
||||
vlan_id = self._find_local_mgmt_interface_vlan_id()
|
||||
# ignore port if no MAC address present, this will
|
||||
# occur for data port after they are configured via DPDK driver
|
||||
if not inic['mac']:
|
||||
|
@ -1762,16 +1771,16 @@ class ConductorManager(service.PeriodicService):
|
|||
if ihost['hostname'] != hostname:
|
||||
# auto create management/pxeboot network for all
|
||||
# nodes but the active controller
|
||||
if mgmt_network.vlan_id:
|
||||
if vlan_id:
|
||||
create_tagged_interface = True
|
||||
networktype = constants.NETWORK_TYPE_PXEBOOT
|
||||
ifname = 'pxeboot0'
|
||||
else:
|
||||
networktype = constants.NETWORK_TYPE_MGMT
|
||||
ifname = 'mgmt0'
|
||||
ifclass = constants.INTERFACE_CLASS_PLATFORM
|
||||
set_address_interface = True
|
||||
bootp = 'True'
|
||||
mtu = mgmt_network.mtu
|
||||
|
||||
clone_mac_updated = False
|
||||
for interface in iinterfaces:
|
||||
|
@ -1834,6 +1843,7 @@ class ConductorManager(service.PeriodicService):
|
|||
'imac': inic['mac'],
|
||||
'imtu': mtu,
|
||||
'iftype': 'ethernet',
|
||||
'ifclass': ifclass,
|
||||
'networktype': networktype
|
||||
}
|
||||
|
||||
|
@ -1849,6 +1859,21 @@ class ConductorManager(service.PeriodicService):
|
|||
{'interface_id': new_interface['id'],
|
||||
'bootp': bootp
|
||||
})
|
||||
if networktype in [constants.NETWORK_TYPE_MGMT,
|
||||
constants.NETWORK_TYPE_PXEBOOT]:
|
||||
network = self.dbapi.network_get_by_type(networktype)
|
||||
# create interface network association
|
||||
ifnet_dict = {
|
||||
'interface_id': new_interface['id'],
|
||||
'network_id': network['id']
|
||||
}
|
||||
try:
|
||||
self.dbapi.interface_network_create(ifnet_dict)
|
||||
except Exception:
|
||||
LOG.exception(
|
||||
"Failed to create interface %s "
|
||||
"network %s association" %
|
||||
(new_interface['id'], network['id']))
|
||||
except Exception:
|
||||
LOG.exception("Failed to create new interface %s" %
|
||||
inic['mac'])
|
||||
|
@ -1860,11 +1885,12 @@ class ConductorManager(service.PeriodicService):
|
|||
'forihostid': ihost['id'],
|
||||
'ifname': 'mgmt0',
|
||||
'imac': inic['mac'],
|
||||
'imtu': mgmt_network.mtu,
|
||||
'imtu': constants.DEFAULT_MTU,
|
||||
'iftype': 'vlan',
|
||||
'ifclass': constants.INTERFACE_CLASS_PLATFORM,
|
||||
'networktype': constants.NETWORK_TYPE_MGMT,
|
||||
'uses': [ifname],
|
||||
'vlan_id': mgmt_network.vlan_id,
|
||||
'vlan_id': vlan_id,
|
||||
}
|
||||
|
||||
try:
|
||||
|
@ -1873,6 +1899,21 @@ class ConductorManager(service.PeriodicService):
|
|||
new_interface = self.dbapi.iinterface_create(
|
||||
ihost['id'], interface_dict
|
||||
)
|
||||
network = self.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_MGMT
|
||||
)
|
||||
# create interface network association
|
||||
ifnet_dict = {
|
||||
'interface_id': new_interface['id'],
|
||||
'network_id': network['id']
|
||||
}
|
||||
try:
|
||||
self.dbapi.interface_network_create(ifnet_dict)
|
||||
except Exception:
|
||||
LOG.exception(
|
||||
"Failed to create interface %s "
|
||||
"network %s association" %
|
||||
(new_interface['id'], network['id']))
|
||||
except Exception:
|
||||
LOG.exception(
|
||||
"Failed to create new vlan interface %s" %
|
||||
|
@ -7891,7 +7932,7 @@ class ConductorManager(service.PeriodicService):
|
|||
|
||||
if nettype:
|
||||
iinterfaces[:] = [i for i in iinterfaces if
|
||||
cutils.get_primary_network_type(i) == nettype]
|
||||
i.networktype == nettype]
|
||||
return iinterfaces
|
||||
|
||||
def mgmt_ip_set_by_ihost(self,
|
||||
|
|
|
@ -470,10 +470,7 @@ class OpenStackOperator(object):
|
|||
try:
|
||||
iinterfaces = self.try_interface_get_by_host(ihost_uuid)
|
||||
for interface in iinterfaces:
|
||||
networktypelist = []
|
||||
if interface.networktype:
|
||||
networktypelist = [network.strip() for network in interface['networktype'].split(",")]
|
||||
if constants.NETWORK_TYPE_DATA in networktypelist:
|
||||
if interface['ifclass'] == constants.INTERFACE_CLASS_DATA:
|
||||
providernets = interface.providernetworks
|
||||
for providernet in providernets.split(',') if providernets else []:
|
||||
ihost_aggset_provider.add(aggregate_name_prefix +
|
||||
|
@ -591,11 +588,7 @@ class OpenStackOperator(object):
|
|||
try:
|
||||
iinterfaces = self.try_interface_get_by_host(ihost_uuid)
|
||||
for interface in iinterfaces:
|
||||
networktypelist = []
|
||||
if interface.networktype:
|
||||
networktypelist = [network.strip() for network in
|
||||
interface['networktype'].split(",")]
|
||||
if constants.NETWORK_TYPE_DATA in networktypelist:
|
||||
if interface['ifclass'] == constants.INTERFACE_CLASS_DATA:
|
||||
providernets = interface.providernetworks
|
||||
for providernet in (
|
||||
providernets.split(',') if providernets else []):
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright (c) 2018 Wind River Systems, Inc.
|
||||
#
|
||||
# The right to copy, distribute, modify, or otherwise make use
|
||||
# of this software may be licensed only pursuant to the terms
|
||||
# of an applicable Wind River license agreement.
|
||||
#
|
||||
|
||||
from sqlalchemy import Column, MetaData, Table
|
||||
from sqlalchemy import String
|
||||
from sysinv.openstack.common import log
|
||||
|
||||
ENGINE = 'InnoDB'
|
||||
CHARSET = 'utf8'
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Perform sysinv database upgrade for network interface
|
||||
"""
|
||||
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
interface = Table('interfaces', meta, autoload=True)
|
||||
interface.create_column(Column('ifclass', String(255)))
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
# As per other openstack components, downgrade is
|
||||
# unsupported in this release.
|
||||
raise NotImplementedError('SysInv database downgrade is unsupported.')
|
|
@ -0,0 +1,30 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright (c) 2018 Wind River Systems, Inc.
|
||||
#
|
||||
# The right to copy, distribute, modify, or otherwise make use
|
||||
# of this software may be licensed only pursuant to the terms
|
||||
# of an applicable Wind River license agreement.
|
||||
#
|
||||
|
||||
from sqlalchemy import MetaData, Table
|
||||
|
||||
ENGINE = 'InnoDB'
|
||||
CHARSET = 'utf8'
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
network = Table('networks', meta, autoload=True)
|
||||
network.drop_column('mtu')
|
||||
network.drop_column('link_capacity')
|
||||
network.drop_column('vlan_id')
|
||||
return True
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
# As per other openstack components, downgrade is
|
||||
# unsupported in this release.
|
||||
raise NotImplementedError('SysInv database downgrade is unsupported.')
|
|
@ -331,7 +331,7 @@ class iinterface(Base):
|
|||
iftype = Column(String(255))
|
||||
imac = Column(String(255), unique=True)
|
||||
imtu = Column(Integer)
|
||||
networktype = Column(String(255)) # e.g. mgmt, data, ext, api
|
||||
networktype = Column(String(255))
|
||||
aemode = Column(String(255)) # e.g. balanced, active_standby
|
||||
aedict = Column(JSONEncodedDict) # e.g. 802.3ad parameters
|
||||
txhashpolicy = Column(String(255)) # e.g. L2, L2L3, L3L4
|
||||
|
@ -362,7 +362,8 @@ class Interfaces(Base):
|
|||
iftype = Column(String(255))
|
||||
|
||||
ifname = Column(String(255))
|
||||
networktype = Column(String(255)) # e.g. mgmt, data, ext, api
|
||||
ifclass = Column(String(255))
|
||||
networktype = Column(String(255))
|
||||
ifcapabilities = Column(JSONEncodedDict)
|
||||
farend = Column(JSONEncodedDict)
|
||||
sriov_numvfs = Column(Integer)
|
||||
|
@ -1153,9 +1154,6 @@ class Networks(Base):
|
|||
name = Column(String(255), unique=True)
|
||||
type = Column(String(255), unique=True)
|
||||
dynamic = Column(Boolean, nullable=False)
|
||||
link_capacity = Column(Integer)
|
||||
mtu = Column(Integer, nullable=False)
|
||||
vlan_id = Column(Integer)
|
||||
|
||||
address_pool_id = Column(Integer,
|
||||
ForeignKey('address_pools.id',
|
||||
|
|
|
@ -79,6 +79,15 @@ def get_host_uuid(field, db_server):
|
|||
return host_uuid
|
||||
|
||||
|
||||
def get_networks(field, db_object):
|
||||
result = []
|
||||
if hasattr(db_object, 'interface_networks'):
|
||||
for entry in getattr(db_object, 'interface_networks', []):
|
||||
id_str = str(entry.network_id)
|
||||
result.append(id_str)
|
||||
return result
|
||||
|
||||
|
||||
class Interface(base.SysinvObject):
|
||||
# VERSION 1.0: Initial version
|
||||
# VERSION 1.1: Added VLAN and uses/used_by interface support
|
||||
|
@ -94,6 +103,7 @@ class Interface(base.SysinvObject):
|
|||
|
||||
'ifname': utils.str_or_none,
|
||||
'iftype': utils.str_or_none,
|
||||
'ifclass': utils.str_or_none,
|
||||
'imac': utils.str_or_none,
|
||||
'imtu': utils.int_or_none,
|
||||
'networktype': utils.str_or_none,
|
||||
|
@ -102,6 +112,7 @@ class Interface(base.SysinvObject):
|
|||
'txhashpolicy': utils.str_or_none,
|
||||
'providernetworks': utils.str_or_none,
|
||||
'providernetworksdict': utils.dict_or_none,
|
||||
'networks': utils.list_of_strings_or_none,
|
||||
|
||||
'ifcapabilities': utils.dict_or_none,
|
||||
|
||||
|
@ -124,7 +135,8 @@ class Interface(base.SysinvObject):
|
|||
'ipv6_mode': get_ipv6_address_mode,
|
||||
'ipv4_pool': get_ipv4_address_pool,
|
||||
'ipv6_pool': get_ipv6_address_pool,
|
||||
'ihost_uuid': get_host_uuid}
|
||||
'ihost_uuid': get_host_uuid,
|
||||
'networks': get_networks}
|
||||
|
||||
_optional_fields = ['aemode', 'txhashpolicy', 'schedpolicy',
|
||||
'vlan_id', 'vlan_type']
|
||||
|
|
|
@ -25,9 +25,6 @@ class Network(base.SysinvObject):
|
|||
'type': utils.str_or_none,
|
||||
'dynamic': utils.bool_or_none,
|
||||
'pool_uuid': utils.uuid_or_none,
|
||||
'mtu': utils.int_or_none,
|
||||
'link_capacity': utils.int_or_none,
|
||||
'vlan_id': utils.int_or_none,
|
||||
}
|
||||
|
||||
_foreign_fields = {'pool_uuid': 'address_pool:uuid'}
|
||||
|
|
|
@ -34,8 +34,6 @@ class InfraNetwork(base.SysinvObject):
|
|||
'infra_subnet': utils.str_or_none,
|
||||
'infra_start': utils.str_or_none,
|
||||
'infra_end': utils.str_or_none,
|
||||
'infra_mtu': utils.str_or_none,
|
||||
'infra_vlan_id': utils.str_or_none,
|
||||
|
||||
'infra_c0_ip': utils.str_or_none,
|
||||
'infra_c1_ip': utils.str_or_none,
|
||||
|
@ -74,8 +72,6 @@ class InfraNetwork(base.SysinvObject):
|
|||
'infra_subnet': subnet,
|
||||
'infra_start': address_range.start,
|
||||
'infra_end': address_range.end,
|
||||
'infra_mtu': network.mtu,
|
||||
'infra_vlan_id': network.vlan_id,
|
||||
})
|
||||
|
||||
# update standard DB fields (i.e. id, uuid)
|
||||
|
@ -124,13 +120,6 @@ class InfraNetwork(base.SysinvObject):
|
|||
values = {'address': self[field]}
|
||||
self.dbapi.address_update(address.uuid, values)
|
||||
|
||||
# update infrastructure network entry
|
||||
values = {
|
||||
'mtu': self['infra_mtu'],
|
||||
'vlan_id': self['infra_vlan_id'],
|
||||
}
|
||||
self.dbapi.network_update(self.uuid, values)
|
||||
|
||||
self.obj_reset_changes()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import collections
|
||||
import copy
|
||||
import six
|
||||
import uuid
|
||||
|
||||
from netaddr import IPAddress
|
||||
from netaddr import IPNetwork
|
||||
|
@ -26,16 +25,18 @@ LOG = log.getLogger(__name__)
|
|||
PLATFORM_NETWORK_TYPES = [constants.NETWORK_TYPE_PXEBOOT,
|
||||
constants.NETWORK_TYPE_MGMT,
|
||||
constants.NETWORK_TYPE_INFRA,
|
||||
constants.NETWORK_TYPE_OAM,
|
||||
constants.NETWORK_TYPE_DATA_VRS, # For HP/Nuage
|
||||
constants.NETWORK_TYPE_BM, # For internal use only
|
||||
constants.NETWORK_TYPE_CONTROL]
|
||||
constants.NETWORK_TYPE_OAM]
|
||||
|
||||
DATA_NETWORK_TYPES = [constants.NETWORK_TYPE_DATA]
|
||||
|
||||
DATA_INTERFACE_CLASSES = [constants.INTERFACE_CLASS_DATA]
|
||||
|
||||
PCI_NETWORK_TYPES = [constants.NETWORK_TYPE_PCI_SRIOV,
|
||||
constants.NETWORK_TYPE_PCI_PASSTHROUGH]
|
||||
|
||||
PCI_INTERFACE_CLASSES = [constants.INTERFACE_CLASS_PCI_PASSTHROUGH,
|
||||
constants.INTERFACE_CLASS_PCI_SRIOV]
|
||||
|
||||
ACTIVE_STANDBY_AE_MODES = ['active_backup', 'active-backup', 'active_standby']
|
||||
BALANCED_AE_MODES = ['balanced', 'balanced-xor']
|
||||
LACP_AE_MODES = ['802.3ad']
|
||||
|
@ -77,14 +78,6 @@ class InterfacePuppet(base.BasePuppet):
|
|||
# use when parsing the interface list.
|
||||
context = self._create_interface_context(host)
|
||||
|
||||
if host.personality == constants.CONTROLLER:
|
||||
# Insert a fake BMC interface because BMC information is only
|
||||
# stored on the host and in the global config. This makes it
|
||||
# easier to setup the BMC interface from the interface handling
|
||||
# code. Hopefully we can add real interfaces in the DB some day
|
||||
# and remove this code.
|
||||
self._create_bmc_interface(host, context)
|
||||
|
||||
# interface configuration is organized into sets of network_config,
|
||||
# route_config and address_config resource hashes (dict)
|
||||
config = {
|
||||
|
@ -137,62 +130,17 @@ class InterfacePuppet(base.BasePuppet):
|
|||
}
|
||||
return context
|
||||
|
||||
def _create_bmc_interface(self, host, context):
|
||||
"""
|
||||
Creates a fake BMC interface and inserts it into the context interface
|
||||
list. It also creates a fake BMC address and inserts it into the
|
||||
context address list. This is required because these two entities
|
||||
exist only as attributes on the host and in local context variables.
|
||||
Rather than have different code to generate manifest entries based on
|
||||
these other data structures it is easier to create fake context entries
|
||||
and re-use the existing code base.
|
||||
"""
|
||||
try:
|
||||
network = self.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_BM)
|
||||
except exception.NetworkTypeNotFound:
|
||||
# No BMC network configured
|
||||
return
|
||||
|
||||
lower_iface = _find_bmc_lower_interface(context)
|
||||
if not lower_iface:
|
||||
# No mgmt or pxeboot?
|
||||
return
|
||||
|
||||
addr = self._get_address_by_name(host.hostname,
|
||||
constants.NETWORK_TYPE_BM)
|
||||
|
||||
iface = {
|
||||
'uuid': str(uuid.uuid4()),
|
||||
'ifname': 'bmc0',
|
||||
'iftype': constants.INTERFACE_TYPE_VLAN,
|
||||
'networktype': constants.NETWORK_TYPE_BM,
|
||||
'imtu': network.mtu,
|
||||
'vlan_id': network.vlan_id,
|
||||
'uses': [lower_iface['ifname']],
|
||||
'used_by': []
|
||||
}
|
||||
|
||||
lower_iface['used_by'] = ['bmc0']
|
||||
address = {
|
||||
'ifname': iface['ifname'],
|
||||
'family': addr.family,
|
||||
'prefix': addr.prefix,
|
||||
'address': addr.address,
|
||||
'networktype': iface['networktype']
|
||||
}
|
||||
|
||||
context['interfaces'].update({iface['ifname']: iface})
|
||||
context['addresses'].update({iface['ifname']: [address]})
|
||||
|
||||
def _find_host_interface(self, host, networktype):
|
||||
"""
|
||||
Search the host interface list looking for an interface with a given
|
||||
primary network type.
|
||||
"""
|
||||
for iface in self.dbapi.iinterface_get_by_ihost(host.id):
|
||||
if networktype == utils.get_primary_network_type(iface):
|
||||
return iface
|
||||
for ni in self.dbapi.interface_network_get_by_interface(
|
||||
iface['id']):
|
||||
network = self.dbapi.network_get(ni.id)
|
||||
if network.type == networktype:
|
||||
return iface
|
||||
|
||||
def _get_port_interface_id_index(self, host):
|
||||
"""
|
||||
|
@ -328,30 +276,11 @@ class InterfacePuppet(base.BasePuppet):
|
|||
|
||||
|
||||
def is_platform_network_type(iface):
|
||||
networktype = utils.get_primary_network_type(iface)
|
||||
return bool(networktype in PLATFORM_NETWORK_TYPES)
|
||||
return bool(iface['ifclass'] == constants.INTERFACE_CLASS_PLATFORM)
|
||||
|
||||
|
||||
def is_data_network_type(iface):
|
||||
networktypelist = utils.get_network_type_list(iface)
|
||||
return bool(any(n in DATA_NETWORK_TYPES for n in networktypelist))
|
||||
|
||||
|
||||
def _find_bmc_lower_interface(context):
|
||||
"""
|
||||
Search the profile interface list looking for either a pxeboot or mgmt
|
||||
interface that can be used to attach a BMC VLAN interface. If a pxeboot
|
||||
interface exists then it is preferred since we do not want to create a VLAN
|
||||
over another VLAN interface.
|
||||
"""
|
||||
selected_iface = None
|
||||
for ifname, iface in six.iteritems(context['interfaces']):
|
||||
networktype = utils.get_primary_network_type(iface)
|
||||
if networktype == constants.NETWORK_TYPE_PXEBOOT:
|
||||
return iface
|
||||
elif networktype == constants.NETWORK_TYPE_MGMT:
|
||||
selected_iface = iface
|
||||
return selected_iface
|
||||
return bool(iface['ifclass'] == constants.INTERFACE_CLASS_DATA)
|
||||
|
||||
|
||||
def is_controller(context):
|
||||
|
@ -378,8 +307,7 @@ def is_pci_interface(iface):
|
|||
"""
|
||||
Determine if the interface is one of the PCI device types.
|
||||
"""
|
||||
networktype = utils.get_primary_network_type(iface)
|
||||
return bool(networktype in PCI_NETWORK_TYPES)
|
||||
return bool(iface['ifclass'] in PCI_INTERFACE_CLASSES)
|
||||
|
||||
|
||||
def is_platform_interface(context, iface):
|
||||
|
@ -594,14 +522,6 @@ def get_interface_routes(context, iface):
|
|||
return context['routes'][iface['ifname']]
|
||||
|
||||
|
||||
def get_network_speed(context, networktype):
|
||||
if 'networks' in context:
|
||||
network = context['networks'].get(networktype, None)
|
||||
if network:
|
||||
return network['link_capacity']
|
||||
return 0
|
||||
|
||||
|
||||
def _set_address_netmask(address):
|
||||
"""
|
||||
The netmask is not supplied by sysinv but is required by the puppet
|
||||
|
@ -615,14 +535,20 @@ def _set_address_netmask(address):
|
|||
return address
|
||||
|
||||
|
||||
def get_interface_primary_address(context, iface):
|
||||
def get_interface_primary_address(context, iface, network_id=None):
|
||||
"""
|
||||
Determine the primary IP address on an interface (if any). If multiple
|
||||
addresses exist then the first address is returned.
|
||||
"""
|
||||
addresses = context['addresses'].get(iface['ifname'], [])
|
||||
if len(addresses) > 0:
|
||||
if len(addresses) > 0 and network_id is None:
|
||||
return _set_address_netmask(addresses[0])
|
||||
elif network_id:
|
||||
for address in addresses:
|
||||
net = find_network_by_pool_uuid(context,
|
||||
address.pool_uuid)
|
||||
if net and network_id == net.id:
|
||||
return _set_address_netmask(address)
|
||||
|
||||
|
||||
def get_interface_address_family(context, iface):
|
||||
|
@ -640,11 +566,10 @@ def get_interface_address_family(context, iface):
|
|||
return 'inet6'
|
||||
|
||||
|
||||
def get_interface_gateway_address(context, iface):
|
||||
def get_interface_gateway_address(context, networktype):
|
||||
"""
|
||||
Determine if the interface has a default gateway.
|
||||
"""
|
||||
networktype = utils.get_primary_network_type(iface)
|
||||
return context['gateways'].get(networktype, None)
|
||||
|
||||
|
||||
|
@ -652,32 +577,25 @@ def get_interface_address_method(context, iface):
|
|||
"""
|
||||
Determine what type of interface to configure for each network type.
|
||||
"""
|
||||
networktype = utils.get_primary_network_type(iface)
|
||||
if not networktype:
|
||||
|
||||
if not iface.ifclass or iface.ifclass == constants.INTERFACE_CLASS_NONE:
|
||||
# Interfaces that are configured purely as a dependency from other
|
||||
# interfaces (i.e., vlan lower interface, bridge member, bond slave)
|
||||
# should be left as manual config
|
||||
return 'manual'
|
||||
elif networktype in DATA_NETWORK_TYPES:
|
||||
elif iface.ifclass == constants.INTERFACE_CLASS_DATA:
|
||||
# All data interfaces configured in the kernel because they are not
|
||||
# natively supported in vswitch or need to be shared with the kernel
|
||||
# because of a platform VLAN should be left as manual config
|
||||
return 'manual'
|
||||
elif networktype == constants.NETWORK_TYPE_CONTROL:
|
||||
return 'static'
|
||||
elif networktype == constants.NETWORK_TYPE_DATA_VRS:
|
||||
# All HP/Nuage interfaces have their own IP address defined statically
|
||||
return 'static'
|
||||
elif networktype == constants.NETWORK_TYPE_BM:
|
||||
return 'static'
|
||||
elif networktype in PCI_NETWORK_TYPES:
|
||||
elif iface.ifclass in PCI_INTERFACE_CLASSES:
|
||||
return 'manual'
|
||||
else:
|
||||
if is_controller(context):
|
||||
# All other interface types that exist on a controller are setup
|
||||
# statically since the controller themselves run the DHCP server.
|
||||
return 'static'
|
||||
elif networktype == constants.NETWORK_TYPE_PXEBOOT:
|
||||
elif iface.networktype == constants.NETWORK_TYPE_PXEBOOT:
|
||||
# All pxeboot interfaces that exist on non-controller nodes are set
|
||||
# to manual as they are not needed/used once the install is done.
|
||||
# They exist only in support of the vlan mgmt interface above it.
|
||||
|
@ -691,14 +609,16 @@ def get_interface_traffic_classifier(context, iface):
|
|||
"""
|
||||
Get the interface traffic classifier command line (if any)
|
||||
"""
|
||||
networktype = utils.get_primary_network_type(iface)
|
||||
if networktype in [constants.NETWORK_TYPE_MGMT,
|
||||
constants.NETWORK_TYPE_INFRA]:
|
||||
networkspeed = get_network_speed(context, networktype)
|
||||
return '/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' % (
|
||||
get_interface_os_ifname(context, iface),
|
||||
networktype,
|
||||
networkspeed)
|
||||
|
||||
for net_id in iface.networks:
|
||||
networktype = find_networktype_by_network_id(context, int(net_id))
|
||||
if networktype in [constants.NETWORK_TYPE_MGMT,
|
||||
constants.NETWORK_TYPE_INFRA]:
|
||||
networkspeed = constants.LINK_SPEED_10G
|
||||
return '/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' \
|
||||
% (get_interface_os_ifname(context, iface),
|
||||
networktype,
|
||||
networkspeed)
|
||||
return None
|
||||
|
||||
|
||||
|
@ -879,7 +799,7 @@ def get_ethernet_network_config(context, iface, config):
|
|||
Augments a basic config dictionary with the attributes specific to an
|
||||
ethernet interface.
|
||||
"""
|
||||
networktype = utils.get_primary_network_type(iface)
|
||||
interface_class = iface['ifclass']
|
||||
options = {}
|
||||
# Increased to accommodate devices that require more time to
|
||||
# complete link auto-negotiation
|
||||
|
@ -890,7 +810,7 @@ def get_ethernet_network_config(context, iface, config):
|
|||
options['SLAVE'] = 'yes'
|
||||
options['MASTER'] = get_master_interface(context, iface)
|
||||
options['PROMISC'] = 'yes'
|
||||
elif networktype == constants.NETWORK_TYPE_PCI_SRIOV:
|
||||
elif interface_class == constants.INTERFACE_CLASS_PCI_SRIOV:
|
||||
if not is_a_mellanox_cx3_device(context, iface):
|
||||
# CX3 device can only use kernel module options to enable vfs
|
||||
# others share the same pci-sriov sysfs enabling mechanism
|
||||
|
@ -898,7 +818,7 @@ def get_ethernet_network_config(context, iface, config):
|
|||
get_interface_port_name(context, iface))
|
||||
options['pre_up'] = "echo 0 > %s; echo %s > %s" % (
|
||||
sriovfs_path, iface['sriov_numvfs'], sriovfs_path)
|
||||
elif networktype == constants.NETWORK_TYPE_PCI_PASSTHROUGH:
|
||||
elif interface_class == constants.INTERFACE_CLASS_PCI_PASSTHROUGH:
|
||||
sriovfs_path = ("/sys/class/net/%s/device/sriov_numvfs" %
|
||||
get_interface_port_name(context, iface))
|
||||
options['pre_up'] = "if [ -f %s ]; then echo 0 > %s; fi" % (
|
||||
|
@ -931,35 +851,38 @@ def get_route_config(route, ifname):
|
|||
return config
|
||||
|
||||
|
||||
def get_common_network_config(context, iface, config):
|
||||
def get_common_network_config(context, iface, config, network_id=None):
|
||||
"""
|
||||
Augments a basic config dictionary with the attributes specific to an upper
|
||||
layer interface (i.e., an interface that is used to terminate IP traffic).
|
||||
"""
|
||||
traffic_classifier = get_interface_traffic_classifier(context, iface)
|
||||
if traffic_classifier:
|
||||
config['options']['post_up'] = traffic_classifier
|
||||
LOG.debug("get_common_network_config %s %s network_id=%s" %
|
||||
(iface.ifname, iface.networks, network_id))
|
||||
if network_id is None:
|
||||
traffic_classifier = get_interface_traffic_classifier(context, iface)
|
||||
if traffic_classifier:
|
||||
config['options']['post_up'] = traffic_classifier
|
||||
|
||||
method = get_interface_address_method(context, iface)
|
||||
if method == 'static':
|
||||
address = get_interface_primary_address(context, iface)
|
||||
address = get_interface_primary_address(context, iface, network_id)
|
||||
if address is None:
|
||||
networktype = utils.get_primary_network_type(iface)
|
||||
# control interfaces are not required to have an IP address
|
||||
if networktype == constants.NETWORK_TYPE_CONTROL:
|
||||
return config
|
||||
LOG.error("Interface %s has no primary address" % iface['ifname'])
|
||||
assert address is not None
|
||||
|
||||
config['ipaddress'] = address['address']
|
||||
config['netmask'] = address['netmask']
|
||||
|
||||
gateway = get_interface_gateway_address(context, iface)
|
||||
if gateway:
|
||||
config['gateway'] = gateway
|
||||
if network_id is None and len(iface.networks) > 0:
|
||||
networktype = find_networktype_by_network_id(
|
||||
context, int(iface.networks[0]))
|
||||
gateway = get_interface_gateway_address(context, networktype)
|
||||
if gateway:
|
||||
config['gateway'] = gateway
|
||||
return config
|
||||
|
||||
|
||||
def get_interface_network_config(context, iface):
|
||||
def get_interface_network_config(context, iface, network_id=None):
|
||||
"""
|
||||
Builds a network_config resource dictionary for a given interface
|
||||
"""
|
||||
|
@ -972,7 +895,7 @@ def get_interface_network_config(context, iface):
|
|||
os_ifname, method=method, family=family, mtu=mtu)
|
||||
|
||||
# Add options common to all top level interfaces
|
||||
config = get_common_network_config(context, iface, config)
|
||||
config = get_common_network_config(context, iface, config, network_id)
|
||||
|
||||
# Add type specific options
|
||||
if iface['iftype'] == constants.INTERFACE_TYPE_VLAN:
|
||||
|
@ -1018,11 +941,19 @@ def generate_network_config(context, config, iface):
|
|||
bridge, or to add additional route resources.
|
||||
"""
|
||||
network_config = get_interface_network_config(context, iface)
|
||||
|
||||
config[NETWORK_CONFIG_RESOURCE].update({
|
||||
network_config['ifname']: format_network_config(network_config)
|
||||
})
|
||||
|
||||
if len(iface.networks) > 1:
|
||||
for net_id in iface.networks:
|
||||
net_config = get_interface_network_config(context, iface,
|
||||
int(net_id))
|
||||
ifname = net_config['ifname'] + ':' + net_id
|
||||
config[NETWORK_CONFIG_RESOURCE].update({
|
||||
ifname: format_network_config(net_config)
|
||||
})
|
||||
|
||||
# Add additional configs for special interfaces
|
||||
if is_bridged_interface(context, iface):
|
||||
avp_config, bridge_config = get_bridged_network_config(context, iface)
|
||||
|
@ -1039,6 +970,25 @@ def generate_network_config(context, config, iface):
|
|||
})
|
||||
|
||||
|
||||
def find_network_by_pool_uuid(context, pool_uuid):
|
||||
for networktype, network in six.iteritems(context['networks']):
|
||||
if network.pool_uuid == pool_uuid:
|
||||
return network
|
||||
return None
|
||||
|
||||
|
||||
def find_network_id_by_networktype(context, networktype):
|
||||
for net_type, network in six.iteritems(context['networks']):
|
||||
if networktype == net_type:
|
||||
return network.id
|
||||
|
||||
|
||||
def find_networktype_by_network_id(context, network_id):
|
||||
for networktype, network in six.iteritems(context['networks']):
|
||||
if network.id == network_id:
|
||||
return networktype
|
||||
|
||||
|
||||
def find_interface_by_type(context, networktype):
|
||||
"""
|
||||
Lookup an interface based on networktype. This is only intended for
|
||||
|
@ -1046,8 +996,10 @@ def find_interface_by_type(context, networktype):
|
|||
mgmt, infra, pxeboot, bmc).
|
||||
"""
|
||||
for ifname, iface in six.iteritems(context['interfaces']):
|
||||
if networktype == utils.get_primary_network_type(iface):
|
||||
return iface
|
||||
for net_id in iface.networks:
|
||||
net_type = find_networktype_by_network_id(context, int(net_id))
|
||||
if networktype == net_type:
|
||||
return iface
|
||||
|
||||
|
||||
def find_address_by_type(context, networktype):
|
||||
|
@ -1074,23 +1026,12 @@ def find_sriov_interfaces_by_driver(context, driver):
|
|||
if iface['iftype'] != constants.INTERFACE_TYPE_ETHERNET:
|
||||
continue
|
||||
port = get_interface_port(context, iface)
|
||||
networktype = utils.get_primary_network_type(iface)
|
||||
if (port['driver'] == driver and
|
||||
networktype == constants.NETWORK_TYPE_PCI_SRIOV):
|
||||
iface['ifclass'] == constants.INTERFACE_CLASS_PCI_SRIOV):
|
||||
ifaces.append(iface)
|
||||
return ifaces
|
||||
|
||||
|
||||
def count_interfaces_by_type(context, networktypes):
|
||||
"""
|
||||
Count the number of interfaces with a matching network type.
|
||||
"""
|
||||
for ifname, iface in six.iteritems(context['interfaces']):
|
||||
networktypelist = utils.get_network_type_list(iface)
|
||||
if any(n in networktypelist for n in networktypes):
|
||||
return iface
|
||||
|
||||
|
||||
def interface_sort_key(iface):
|
||||
"""
|
||||
Sort interfaces by interface type placing ethernet interfaces ahead of
|
||||
|
|
|
@ -170,8 +170,6 @@ class NetworkingPuppet(base.BasePuppet):
|
|||
controller0_address,
|
||||
'platform::network::%s::params::controller1_address' % networktype:
|
||||
controller1_address,
|
||||
'platform::network::%s::params::mtu' % networktype:
|
||||
network.mtu,
|
||||
}
|
||||
|
||||
def _get_pxeboot_interface_config(self):
|
||||
|
@ -195,14 +193,15 @@ class NetworkingPuppet(base.BasePuppet):
|
|||
if network_interface:
|
||||
interface_name = interface.get_interface_os_ifname(
|
||||
self.context, network_interface)
|
||||
|
||||
network_id = interface.find_network_id_by_networktype(
|
||||
self.context, networktype)
|
||||
config.update({
|
||||
'platform::network::%s::params::interface_name' % networktype:
|
||||
interface_name
|
||||
})
|
||||
|
||||
interface_address = interface.get_interface_primary_address(
|
||||
self.context, network_interface)
|
||||
self.context, network_interface, network_id)
|
||||
if interface_address:
|
||||
config.update({
|
||||
'platform::network::%s::params::interface_address' %
|
||||
|
|
|
@ -162,8 +162,7 @@ class NeutronPuppet(openstack.OpenstackBasePuppet):
|
|||
|
||||
device_mappings = []
|
||||
for iface in self.context['interfaces'].values():
|
||||
if (utils.get_primary_network_type(iface) ==
|
||||
constants.NETWORK_TYPE_PCI_SRIOV):
|
||||
if (iface['ifclass'] in [constants.INTERFACE_CLASS_PCI_SRIOV]):
|
||||
port = interface.get_interface_port(self.context, iface)
|
||||
providernets = interface.get_interface_providernets(iface)
|
||||
for net in providernets:
|
||||
|
|
|
@ -12,7 +12,6 @@ import subprocess
|
|||
|
||||
from sysinv.common import constants
|
||||
from sysinv.common import exception
|
||||
from sysinv.common import utils
|
||||
|
||||
from . import openstack
|
||||
from . import interface
|
||||
|
@ -585,10 +584,7 @@ class NovaPuppet(openstack.OpenstackBasePuppet):
|
|||
# the list of devices to whitelist
|
||||
devices = []
|
||||
for iface in self.context['interfaces'].values():
|
||||
network_type = utils.get_primary_network_type(iface)
|
||||
networktypes = utils.get_network_type_list(iface)
|
||||
if (network_type == constants.NETWORK_TYPE_PCI_PASSTHROUGH or
|
||||
utils.is_pci_network_types(networktypes)):
|
||||
if iface['ifclass'] in [constants.INTERFACE_CLASS_PCI_PASSTHROUGH]:
|
||||
port = interface.get_interface_port(self.context, iface)
|
||||
device = {
|
||||
'address': port['pciaddr'],
|
||||
|
@ -617,8 +613,7 @@ class NovaPuppet(openstack.OpenstackBasePuppet):
|
|||
# the list of devices to whitelist
|
||||
devices = []
|
||||
for iface in self.context['interfaces'].values():
|
||||
network_type = utils.get_primary_network_type(iface)
|
||||
if network_type == constants.NETWORK_TYPE_PCI_SRIOV:
|
||||
if iface['ifclass'] in [constants.INTERFACE_CLASS_PCI_SRIOV]:
|
||||
port = interface.get_interface_port(self.context, iface)
|
||||
device = {
|
||||
'address': port['pciaddr'],
|
||||
|
|
|
@ -478,7 +478,6 @@ class PlatformPuppet(base.BasePuppet):
|
|||
drbdconfig = self.dbapi.drbdconfig_get_one()
|
||||
return {
|
||||
'platform::drbd::params::link_util': str(drbdconfig.link_util),
|
||||
'platform::drbd::params::link_speed': self._get_drbd_link_speed(),
|
||||
'platform::drbd::params::num_parallel': str(drbdconfig.num_parallel),
|
||||
'platform::drbd::params::rtt_ms': str(drbdconfig.rtt_ms),
|
||||
}
|
||||
|
@ -738,31 +737,24 @@ class PlatformPuppet(base.BasePuppet):
|
|||
|
||||
return config
|
||||
|
||||
def _get_drbd_link_speed(self):
|
||||
# return infra link speed if provisioned, otherwise mgmt
|
||||
try:
|
||||
infra_network = self.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_INFRA)
|
||||
drbd_link_speed = infra_network.link_capacity
|
||||
except exception.NetworkTypeNotFound:
|
||||
mgmt_network = self.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
drbd_link_speed = mgmt_network.link_capacity
|
||||
|
||||
return drbd_link_speed
|
||||
|
||||
def _get_nfs_config(self):
|
||||
|
||||
# Calculate the optimal NFS r/w size based on the network mtu based
|
||||
# on the configured network(s)
|
||||
mtu = constants.DEFAULT_MTU
|
||||
try:
|
||||
infra_network = self.dbapi.network_get_by_type(
|
||||
interfaces = self.dbapi.iinterface_get_by_network(
|
||||
constants.NETWORK_TYPE_INFRA)
|
||||
mtu = infra_network.mtu
|
||||
except exception.NetworkTypeNotFound:
|
||||
mgmt_network = self.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
mtu = mgmt_network.mtu
|
||||
for interface in interfaces:
|
||||
mtu = interface.imtu
|
||||
except exception.InvalidParameterValue:
|
||||
try:
|
||||
interfaces = self.dbapi.iinterface_get_by_network(
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
for interface in interfaces:
|
||||
mtu = interface.imtu
|
||||
except exception.InvalidParameterValue:
|
||||
pass
|
||||
|
||||
if self._get_address_by_name(
|
||||
constants.CONTROLLER_PLATFORM_NFS,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -327,10 +327,7 @@ def get_test_network(**kw):
|
|||
'id': kw.get('id'),
|
||||
'uuid': kw.get('uuid'),
|
||||
'type': kw.get('type'),
|
||||
'mtu': kw.get('mtu', 1500),
|
||||
'link_capacity': kw.get('link_capacity'),
|
||||
'dynamic': kw.get('dynamic', True),
|
||||
'vlan_id': kw.get('vlan_id'),
|
||||
'address_pool_id': kw.get('address_pool_id', None)
|
||||
}
|
||||
return inv
|
||||
|
@ -617,7 +614,9 @@ def post_get_test_interface(**kw):
|
|||
'iftype': kw.get('iftype', 'ethernet'),
|
||||
'imac': kw.get('imac', '11:22:33:44:55:66'),
|
||||
'imtu': kw.get('imtu', 1500),
|
||||
'ifclass': kw.get("ifclass"),
|
||||
'networktype': kw.get('networktype'),
|
||||
'networks': kw.get('networks', []),
|
||||
'aemode': kw.get('aemode', 'balanced'),
|
||||
'txhashpolicy': kw.get('txhashpolicy', 'layer2'),
|
||||
'providernetworks': kw.get('providernetworks'),
|
||||
|
@ -643,7 +642,9 @@ def get_test_interface(**kw):
|
|||
'iftype': kw.get('iftype', 'ethernet'),
|
||||
'imac': kw.get('imac', '11:22:33:44:55:66'),
|
||||
'imtu': kw.get('imtu', 1500),
|
||||
'ifclass': kw.get('ifclass', 'none'),
|
||||
'networktype': kw.get('networktype'),
|
||||
'networks': kw.get('networks', []),
|
||||
'aemode': kw.get('aemode'),
|
||||
'txhashpolicy': kw.get('txhashpolicy', None),
|
||||
'providernetworks': kw.get('providernetworks'),
|
||||
|
@ -674,6 +675,30 @@ def create_test_interface(**kw):
|
|||
return dbapi.iinterface_create(forihostid, interface)
|
||||
|
||||
|
||||
def create_test_interface_network(**kw):
|
||||
"""Create test network interface entry in DB and return Network DB
|
||||
object. Function to be used to create test Network objects in the database.
|
||||
:param kw: kwargs with overriding values for network's attributes.
|
||||
:returns: Test Network DB object.
|
||||
"""
|
||||
network_interface = get_test_interface_network(**kw)
|
||||
if 'id' not in kw:
|
||||
del network_interface['id']
|
||||
dbapi = db_api.get_instance()
|
||||
return dbapi.network_interface_create(network_interface)
|
||||
|
||||
|
||||
def get_test_interface_network(**kw):
|
||||
inv = {
|
||||
'id': kw.get('id'),
|
||||
'uuid': kw.get('uuid'),
|
||||
'forihostid': kw.get('forihostid'),
|
||||
'interface_id': kw.get('interface_id'),
|
||||
'network_id': kw.get('network_id'),
|
||||
}
|
||||
return inv
|
||||
|
||||
|
||||
def get_test_storage_tier(**kw):
|
||||
tier = {
|
||||
'id': kw.get('id', 321),
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue