def activate(ns, setting, device=None):
    service = ns.LMI_IPConfigurationService.first_instance()
    if (setting.classname in ('LMI_BridgingMasterSettingData', 'LMI_BondingMasterSettingData')
            and device is None):

        if setting.classname == 'LMI_BridgingMasterSettingData':
            slave_class = 'LMI_BridgingSlaveSettingData'
        elif setting.classname == 'LMI_BondingMasterSettingData':
            slave_class = 'LMI_BondingSlaveSettingData'

        # Autodetect and activate slaves
        for slave_setting in setting.associators(AssocClass='LMI_OrderedIPAssignmentComponent', ResultClass=slave_class):
            device = slave_setting.first_associator(AssocClass="LMI_IPElementSettingData")
            LOG().debug('Activating setting %s on device %s', setting.Caption, device.ElementName)
            result = service.SyncApplySettingToIPNetworkConnection(SettingData=slave_setting,
                    IPNetworkConnection=device,
                    Mode=service.ApplySettingToIPNetworkConnection.ModeValues.Mode32768)
            if result.errorstr:
                raise LmiFailed("Unable to activate setting: %s" % result.errorstr)
        # TODO: rework using indications
        isCurrent = False
        while not isCurrent:
            for esd in setting.references(ResultClass="LMI_IPElementSettingData"):
                if esd.IsCurrent == ns.LMI_IPElementSettingData.IsCurrentValues.IsCurrent:
                    isCurrent = True
                    break
            time.sleep(1)
        LOG().info("Setting %s activated", setting.Caption)
        return 0

    devices = []
    if device is not None:
        devices.append(device)
    else:
        devices = get_applicable_devices(ns, setting)

    if len(devices) == 0:
        raise LmiFailed("No device is associated with given connection.")

    for device in devices:
        LOG().debug('Activating setting %s on device %s', setting.Caption, device.ElementName)
        result = service.SyncApplySettingToIPNetworkConnection(SettingData=setting,
                IPNetworkConnection=device,
                Mode=service.ApplySettingToIPNetworkConnection.ModeValues.Mode32768)
        if result.errorstr:
            raise LmiFailed("Unable to activate setting: %s" % result.errorstr)
    LOG().info("Setting %s activated", setting.Caption)
    return 0
img: bxhxwxc
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/networking/lmi/scripts/networking/__init__.py/activate--crossover with--dataset/ETHPy150Open ppwwyyxx/tensorpack/tensorpack/models/image_sample.py/sample