Beispiel #1
0
 def test_remote_restart(self, mock_relation_ids, mock_relation_set,
                         mock_related_units, mock_uuid4):
     mock_relation_ids.return_value = ['neutron-plugin-api-subordinate:8']
     mock_related_units.return_value = ['neutron-api/0']
     mock_uuid4.return_value = 'uuid4'
     utils.remote_restart('neutron-plugin-api-subordinate')
     mock_relation_set.assert_called_with(
         relation_id='neutron-plugin-api-subordinate:8',
         relation_settings={'restart-trigger': 'uuid4'})
Beispiel #2
0
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')