def resolve_dpdk_bonds(): ''' Resolve local PCI devices from configured mac addresses using the dpdk-bond-mappings configuration option @return: OrderDict indexed by PCI device address. ''' bonds = config('dpdk-bond-mappings') devices = PCINetDevices() resolved_devices = collections.OrderedDict() db = kv() if bonds: # NOTE: ordered dict of format {[mac]: bond} bondmap = parse_data_port_mappings(bonds) for mac, bond in bondmap.items(): pcidev = devices.get_device_from_mac(mac) if pcidev: # NOTE: store mac->pci allocation as post binding # to dpdk, it disappears from PCIDevices. db.set(mac, pcidev.pci_address) db.flush() pci_address = db.get(mac) if pci_address: resolved_devices[pci_address] = bond return resolved_devices
def resolve_dpdk_ports(): ''' Resolve local PCI devices from configured mac addresses using the data-port configuration option @return: OrderDict indexed by PCI device address. ''' ports = config('data-port') devices = PCINetDevices() resolved_devices = {} db = kv() if ports: # NOTE: ordered dict of format {[mac]: bridge} portmap = parse_data_port_mappings(ports) for mac, bridge in portmap.iteritems(): pcidev = devices.get_device_from_mac(mac) if pcidev: # NOTE: store mac->pci allocation as post binding # to dpdk, it disappears from PCIDevices. db.set(mac, pcidev.pci_address) db.flush() pci_address = db.get(mac) if pci_address: resolved_devices[pci_address] = bridge return resolved_devices
def configure_sriov(): '''Configure SR-IOV devices based on provided configuration options''' charm_config = config() enable_sriov = charm_config.get('enable-sriov') if enable_sriov and charm_config.changed('sriov-numvfs'): devices = PCINetDevices() sriov_numvfs = charm_config.get('sriov-numvfs') # automatic configuration of all SR-IOV devices if sriov_numvfs == 'auto': log('Configuring SR-IOV device VF functions in auto mode') for device in devices.pci_devices: if device and device.sriov: log("Configuring SR-IOV device" " {} with {} VF's".format(device.interface_name, device.sriov_totalvfs)) device.set_sriov_numvfs(device.sriov_totalvfs) else: # Single int blanket configuration try: sriov_numvfs = int(sriov_numvfs) log('Configuring SR-IOV device VF functions' ' with blanket setting') for device in devices.pci_devices: if device and device.sriov: log("Configuring SR-IOV device" " {} with {} VF's".format(device.interface_name, sriov_numvfs)) device.set_sriov_numvfs(sriov_numvfs) except ValueError: # <device>:<numvfs>[ <device>:numvfs] configuration sriov_numvfs = sriov_numvfs.split() for device_config in sriov_numvfs: log('Configuring SR-IOV device VF functions per interface') interface_name, numvfs = device_config.split(':') device = devices.get_device_from_interface_name( interface_name) if device and device.sriov: log("Configuring SR-IOV device" " {} with {} VF's".format(device.interface_name, numvfs)) device.set_sriov_numvfs(int(numvfs)) # Trigger remote restart in parent application remote_restart('neutron-plugin', 'nova-compute')
def configure_sriov(): '''Configure SR-IOV devices based on provided configuration options NOTE(fnordahl): Boot time configuration is done by init script intalled by this charm. This function only does runtime configuration! ''' charm_config = config() if not enable_sriov(): return # make sure init script has correct mode and that boot time execution # is enabled os.chmod(NEUTRON_SRIOV_INIT_SCRIPT, 0o755) service('enable', 'neutron-openvswitch-networking-sriov') devices = PCINetDevices() sriov_numvfs = charm_config.get('sriov-numvfs') # automatic configuration of all SR-IOV devices if sriov_numvfs == 'auto': log('Configuring SR-IOV device VF functions in auto mode') for device in devices.pci_devices: if device and device.sriov: log("Configuring SR-IOV device" " {} with {} VF's".format(device.interface_name, device.sriov_totalvfs)) device.set_sriov_numvfs(device.sriov_totalvfs) else: # Single int blanket configuration try: log('Configuring SR-IOV device VF functions' ' with blanket setting') for device in devices.pci_devices: if device and device.sriov: numvfs = min(int(sriov_numvfs), device.sriov_totalvfs) if int(sriov_numvfs) > device.sriov_totalvfs: log('Requested value for sriov-numvfs ({}) too ' 'high for interface {}. Falling back to ' 'interface totalvfs ' 'value: {}'.format(sriov_numvfs, device.interface_name, device.sriov_totalvfs)) log("Configuring SR-IOV device {} with {} " "VFs".format(device.interface_name, numvfs)) device.set_sriov_numvfs(numvfs) except ValueError: # <device>:<numvfs>[ <device>:numvfs] configuration sriov_numvfs = sriov_numvfs.split() for device_config in sriov_numvfs: log('Configuring SR-IOV device VF functions per interface') interface_name, numvfs = device_config.split(':') device = devices.get_device_from_interface_name( interface_name) if device and device.sriov: if int(numvfs) > device.sriov_totalvfs: log('Requested value for sriov-numfs ({}) too ' 'high for interface {}. Falling back to ' 'interface totalvfs ' 'value: {}'.format(numvfs, device.interface_name, device.sriov_totalvfs)) numvfs = device.sriov_totalvfs log("Configuring SR-IOV device {} with {} " "VF's".format(device.interface_name, numvfs)) device.set_sriov_numvfs(int(numvfs)) # Trigger remote restart in parent application remote_restart('neutron-plugin', 'nova-compute') # Restart of SRIOV agent is required after changes to system runtime # VF configuration cmp_release = CompareOpenStackReleases( os_release('neutron-common', base='icehouse')) if cmp_release >= 'mitaka': service_restart('neutron-sriov-agent') else: service_restart('neutron-plugin-sriov-agent')
def configure_sriov(): '''Configure SR-IOV devices based on provided configuration options NOTE(fnordahl): Boot time configuration is done by init script intalled by this charm. This function only does runtime configuration! ''' charm_config = config() if not enable_sriov(): return # make sure init script has correct mode and that boot time execution # is enabled os.chmod(NEUTRON_SRIOV_INIT_SCRIPT, 0o755) service('enable', 'neutron-openvswitch-networking-sriov') if charm_config.changed('sriov-numvfs'): devices = PCINetDevices() sriov_numvfs = charm_config.get('sriov-numvfs') # automatic configuration of all SR-IOV devices if sriov_numvfs == 'auto': log('Configuring SR-IOV device VF functions in auto mode') for device in devices.pci_devices: if device and device.sriov: log("Configuring SR-IOV device" " {} with {} VF's".format(device.interface_name, device.sriov_totalvfs)) # NOTE(fnordahl): run-time change of numvfs is disallowed # without resetting to 0 first. device.set_sriov_numvfs(0) device.set_sriov_numvfs(device.sriov_totalvfs) else: # Single int blanket configuration try: log('Configuring SR-IOV device VF functions' ' with blanket setting') for device in devices.pci_devices: if device and device.sriov: numvfs = min(int(sriov_numvfs), device.sriov_totalvfs) if int(sriov_numvfs) > device.sriov_totalvfs: log('Requested value for sriov-numvfs ({}) too ' 'high for interface {}. Falling back to ' 'interface totalvfs ' 'value: {}'.format(sriov_numvfs, device.interface_name, device.sriov_totalvfs)) log("Configuring SR-IOV device {} with {} " "VFs".format(device.interface_name, numvfs)) # NOTE(fnordahl): run-time change of numvfs is # disallowed without resetting to 0 first. device.set_sriov_numvfs(0) device.set_sriov_numvfs(numvfs) except ValueError: # <device>:<numvfs>[ <device>:numvfs] configuration sriov_numvfs = sriov_numvfs.split() for device_config in sriov_numvfs: log('Configuring SR-IOV device VF functions per interface') interface_name, numvfs = device_config.split(':') device = devices.get_device_from_interface_name( interface_name) if device and device.sriov: if int(numvfs) > device.sriov_totalvfs: log('Requested value for sriov-numfs ({}) too ' 'high for interface {}. Falling back to ' 'interface totalvfs ' 'value: {}'.format(numvfs, device.interface_name, device.sriov_totalvfs)) numvfs = device.sriov_totalvfs log("Configuring SR-IOV device {} with {} " "VF's".format(device.interface_name, numvfs)) # NOTE(fnordahl): run-time change of numvfs is # disallowed without resetting to 0 first. device.set_sriov_numvfs(0) device.set_sriov_numvfs(int(numvfs)) # Trigger remote restart in parent application remote_restart('neutron-plugin', 'nova-compute') # Restart of SRIOV agent is required after changes to system runtime # VF configuration cmp_release = CompareOpenStackReleases( os_release('neutron-common', base='icehouse')) if cmp_release >= 'mitaka': service_restart('neutron-sriov-agent') else: service_restart('neutron-plugin-sriov-agent')