def add_ip_address(ns, setting, address, prefix, gateway=None):
    address, version = util.address_check(address)
    prefix = util.prefix_check(prefix, version)
    gateway = _gateway_check(gateway, version)

    protocol = ns.LMI_IPAssignmentSettingData.ProtocolIFTypeValues.values_dict()["IPv%s" % version]
    found = False
    for settingData in setting.associators(AssocClass="LMI_OrderedIPAssignmentComponent"):
        if (settingData.ProtocolIFType is not None and
                int(settingData.ProtocolIFType) == protocol and
                hasattr(settingData, "IPAddresses")):

            # lmishell doesn't handle in-place editing of array parameters properly,
            # we need to create new arrays and then copy them back
            settingData.IPAddresses = settingData.IPAddresses + [address]
            if version == 4:
                settingData.SubnetMasks = settingData.SubnetMasks + [util.netmask_from_prefix(prefix)]
            else:
                settingData.IPv6SubnetPrefixLengths = settingData.IPv6SubnetPrefixLengths + [str(prefix)]
            if gateway:
                settingData.GatewayAddresses = settingData.GatewayAddresses + [gateway]
            else:
                settingData.GatewayAddresses = settingData.GatewayAddresses + [""]
            found = True
            settingData.push()
    if not found:
        raise LmiInvalidOptions("Can't add IP address to setting: invalid setting type.")
    LOG().info("IP address %s/%d added to setting %s", address, prefix, setting.Caption)
    return 0
check author or email
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/networking/lmi/scripts/networking/__init__.py/add_ip_address--crossover with--dataset/ETHPy150Open douban/ellen/ellen/git/rev_list.py/_check_author