def sreg_convert(system, messages):
    bundles = []
    for name in generate_possible_names(system.hostname):
        bundles += generate_sreg_bundles(system, name)

    results = []
    for bundle in bundles:
        res = _combine(bundle, transaction_managed=True, use_reversion=False)
        messages.append("\t(Converted A/PTR to create '{0}')".format(res))
        results.append(res)
    return results
示例#2
0
def sreg_convert(system, messages):
    bundles = []
    for name in generate_possible_names(system.hostname):
        bundles += generate_sreg_bundles(system, name)

    results = []
    for bundle in bundles:
        res = _combine(bundle, transaction_managed=True, use_reversion=False)
        messages.append("\t(Converted A/PTR to create '{0}')".format(res))
        results.append(res)
    return results
示例#3
0
def combine_status_list(request):
    """
    This view is temporary. It can be used to convert a system using KV objects
    for dhcp into the new Sreg and HW scheme.
    """
    def get(thing, default):
        if thing in request.POST:
            return request.POST.get(thing)
        return request.GET.get(thing, default)

    qd = request.POST or request.GET
    if qd:
        convert_everything = get('convert-everything', False)
        search = get('search', '')
        records, error = search_type(search, 'SYS')
        if not search or error:
            records = []
            total = 0
        else:
            try:
                total = records.count()
                records = records
            except MySQLdb.OperationalError, e:
                if "Got error " in str(e) and " from regexp" in str(e):
                    # This is nasty. If the user is using an invalid regex
                    # patter, the db might shit a brick
                    total = 0
                    records = []
                else:
                    raise

        bundles = []
        for system in records:
            for name in generate_possible_names(system.hostname):
                bundles += generate_sreg_bundles(system, name)

        if convert_everything:
            combine_multiple(bundles, rollback=False)
            bundles = []
        else:
            combine_multiple(bundles, rollback=True)

        return render(request, 'static_reg/combine_status_list.html', {
            'bundles': bundles,
            'search': search,
            'total': total
        })
示例#4
0
def combine_status_list(request):
    """
    This view is temporary. It can be used to convert a system using KV objects
    for dhcp into the new Sreg and HW scheme.
    """
    def get(thing, default):
        if thing in request.POST:
            return request.POST.get(thing)
        return request.GET.get(thing, default)

    qd = request.POST or request.GET
    if qd:
        convert_everything = get('convert-everything', False)
        search = get('search', '')
        records, error = search_type(search, 'SYS')
        if not search or error:
            records = []
            total = 0
        else:
            try:
                total = records.count()
                records = records
            except MySQLdb.OperationalError, e:
                if "Got error " in str(e) and " from regexp" in str(e):
                    # This is nasty. If the user is using an invalid regex
                    # patter, the db might shit a brick
                    total = 0
                    records = []
                else:
                    raise

        bundles = []
        for system in records:
            for name in generate_possible_names(system.hostname):
                bundles += generate_sreg_bundles(system, name)

        if convert_everything:
            combine_multiple(bundles, rollback=False)
            bundles = []
        else:
            combine_multiple(bundles, rollback=True)

        return render(request, 'static_reg/combine_status_list.html', {
            'bundles': bundles,
            'search': search,
            'total': total
        })