예제 #1
0
def add_wifi(request, ssid=None, interface_name=None):
    """Serve wifi connection create form."""
    form = None
    form_data = None

    if ssid:
        device = network.get_device_by_interface_name(interface_name)
        form_data = {'name': ssid,
                     'interface': interface_name if device else None,
                     'zone': 'external',
                     'ssid': ssid,
                     'mode': 'infrastructure',
                     'auth_mode': 'wpa',
                     'ipv4_method': 'auto'}

    if request.method == 'POST':
        form = AddWifiForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            interface = form.cleaned_data['interface']
            zone = form.cleaned_data['zone']
            ssid = form.cleaned_data['ssid']
            mode = form.cleaned_data['mode']
            auth_mode = form.cleaned_data['auth_mode']
            passphrase = form.cleaned_data['passphrase']
            ipv4_method = form.cleaned_data['ipv4_method']
            ipv4_address = form.cleaned_data['ipv4_address']
            ipv4_netmask = form.cleaned_data['ipv4_netmask']
            ipv4_gateway = form.cleaned_data['ipv4_gateway']
            ipv4_dns = form.cleaned_data['ipv4_dns']
            ipv4_second_dns = form.cleaned_data['ipv4_second_dns']

            network.add_wifi_connection(
                name, interface, zone, ssid, mode, auth_mode, passphrase,
                ipv4_method, ipv4_address, ipv4_netmask, ipv4_gateway,
                ipv4_dns, ipv4_second_dns)
            return redirect(reverse_lazy('networks:index'))
    else:
        if form_data:
            form = AddWifiForm(form_data)
        else:
            form = AddWifiForm()

    return TemplateResponse(request, 'connections_create.html',
                            {'title': _('Adding New Wi-Fi Connection'),
                             'subsubmenu': subsubmenu,
                             'form': form})
예제 #2
0
 def setUp(cls):
     cls.ethernet_uuid = network.add_ethernet_connection(
         'plinth_test_eth', 'internal',
         'auto', '')
     cls.wifi_uuid = network.add_wifi_connection(
         'plinth_test_wifi', 'external',
         'plinthtestwifi', 'adhoc', 'open', '',
         'auto', '')
예제 #3
0
 def setUp(cls):
     connection = network.add_ethernet_connection('plinth_test_eth',
                                                  'internal', 'auto', '')
     cls.ethernet_uuid = connection['connection']['uuid']
     connection = network.add_wifi_connection('plinth_test_wifi',
                                              'external', 'plinthtestwifi',
                                              'adhoc', 'open', '', 'auto',
                                              '')
     cls.wifi_uuid = connection['connection']['uuid']
예제 #4
0
 def setUp(cls):
     cls.ethernet_uuid = network.add_ethernet_connection(
         'plinth_test_eth', 'eth0', 'internal', 'auto', '')
     cls.wifi_uuid = network.add_wifi_connection('plinth_test_wifi',
                                                 'wlan0', 'external',
                                                 'plinthtestwifi', 'adhoc',
                                                 'open', '', 'auto', '')
     cls.pppoe_uuid = network.add_pppoe_connection('plinth_test_pppoe',
                                                   'eth1', 'internal',
                                                   'x-user', 'x-password')
예제 #5
0
 def setUp(cls):
     cls.ethernet_uuid = network.add_ethernet_connection(
         'plinth_test_eth', 'eth0', 'internal',
         'auto', '', '', '', '', '')
     cls.wifi_uuid = network.add_wifi_connection(
         'plinth_test_wifi', 'wlan0', 'external',
         'plinthtestwifi', 'adhoc', 'open', '',
         'auto', '', '', '', '', '')
     cls.pppoe_uuid = network.add_pppoe_connection(
         'plinth_test_pppoe', 'eth1', 'internal',
         'x-user', 'x-password')
예제 #6
0
파일: networks.py 프로젝트: NickDaly/Plinth
def add_wifi(request, ssid=None):
    """Serve wifi connection create form."""
    form = None
    form_data = None

    if ssid:
        form_data = {
            "name": ssid,
            "zone": "external",
            "ssid": ssid,
            "mode": "infrastructure",
            "auth_mode": "wpa",
            "ipv4_method": "auto",
        }

    if request.method == "POST":
        form = AddWifiForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data["name"]
            zone = form.cleaned_data["zone"]
            ssid = form.cleaned_data["ssid"]
            mode = form.cleaned_data["mode"]
            auth_mode = form.cleaned_data["auth_mode"]
            passphrase = form.cleaned_data["passphrase"]
            ipv4_method = form.cleaned_data["ipv4_method"]
            ipv4_address = form.cleaned_data["ipv4_address"]

            network.add_wifi_connection(name, zone, ssid, mode, auth_mode, passphrase, ipv4_method, ipv4_address)
            return redirect(reverse_lazy("networks:index"))
    else:
        if form_data:
            form = AddWifiForm(form_data)
        else:
            form = AddWifiForm()

    return TemplateResponse(
        request,
        "connections_create.html",
        {"title": _("Adding New Wi-Fi Connection"), "subsubmenu": subsubmenu, "form": form},
    )
예제 #7
0
 def setUp(cls):
     cls.ethernet_uuid = network.add_ethernet_connection("plinth_test_eth", "eth0", "internal", "auto", "")
     cls.wifi_uuid = network.add_wifi_connection(
         "plinth_test_wifi", "wlan0", "external", "plinthtestwifi", "adhoc", "open", "", "auto", ""
     )