def test_ethernet_manual_ipv4_address(self): """Check that we can manually set IPv4 address on ethernet.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection(connection, "plinth_test_eth_new", "eth0", "external", "manual", "169.254.0.1") connection = network.get_connection(self.ethernet_uuid) settings_ipv4 = connection.get_setting_ip4_config() self.assertEqual(settings_ipv4.get_method(), "manual") address = settings_ipv4.get_address(0) self.assertEqual(address.get_address(), "169.254.0.1")
def test_edit_ethernet_connection(self): """Check that we can update an ethernet connection.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection(connection, 'plinth_test_eth_new', 'external', 'manual', '169.254.0.1') connection = network.get_connection(self.ethernet_uuid) settings = connection.GetSettings() self.assertEqual(settings['connection']['id'], 'plinth_test_eth_new') self.assertEqual(settings['connection']['zone'], 'external') self.assertEqual(settings['ipv4']['method'], 'manual') self.assertEqual(settings['ipv4']['addresses'], [['169.254.0.1', 24, '0.0.0.0']])
def test_ethernet_manual_ipv4_address(self): """Check that we can manually set IPv4 address on ethernet.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection(connection, 'plinth_test_eth_new', 'eth0', 'external', 'manual', '169.254.0.1') connection = network.get_connection(self.ethernet_uuid) settings_ipv4 = connection.get_setting_ip4_config() self.assertEqual(settings_ipv4.get_method(), 'manual') address = settings_ipv4.get_address(0) self.assertEqual(address.get_address(), '169.254.0.1')
def test_edit_ethernet_connection(self): """Check that we can update an ethernet connection.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection(connection, "plinth_test_eth_new", "eth0", "external", "auto", "") connection = network.get_connection(self.ethernet_uuid) self.assertEqual(connection.get_id(), "plinth_test_eth_new") settings_connection = connection.get_setting_connection() self.assertEqual(settings_connection.get_zone(), "external") settings_ipv4 = connection.get_setting_ip4_config() self.assertEqual(settings_ipv4.get_method(), "auto")
def test_edit_ethernet_connection(self): """Check that we can update an ethernet connection.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection( connection, 'plinth_test_eth_new', 'external', 'manual', '169.254.0.1') connection = network.get_connection(self.ethernet_uuid) settings = connection.GetSettings() self.assertEqual(settings['connection']['id'], 'plinth_test_eth_new') self.assertEqual(settings['connection']['zone'], 'external') self.assertEqual(settings['ipv4']['method'], 'manual') self.assertEqual(settings['ipv4']['addresses'], [['169.254.0.1', 24, '0.0.0.0']])
def test_edit_ethernet_connection(self): """Check that we can update an ethernet connection.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection(connection, 'plinth_test_eth_new', 'eth1', 'external', 'auto', '') connection = network.get_connection(self.ethernet_uuid) self.assertEqual(connection.get_id(), 'plinth_test_eth_new') settings_connection = connection.get_setting_connection() self.assertEqual(settings_connection.get_interface_name(), 'eth1') self.assertEqual(settings_connection.get_zone(), 'external') settings_ipv4 = connection.get_setting_ip4_config() self.assertEqual(settings_ipv4.get_method(), 'auto')
def test_edit_ethernet_connection(self): """Check that we can update an ethernet connection.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection( connection, 'plinth_test_eth_new', 'eth1', 'external', 'auto', '') connection = network.get_connection(self.ethernet_uuid) self.assertEqual(connection.get_id(), 'plinth_test_eth_new') settings_connection = connection.get_setting_connection() self.assertEqual(settings_connection.get_interface_name(), 'eth1') self.assertEqual(settings_connection.get_zone(), 'external') settings_ipv4 = connection.get_setting_ip4_config() self.assertEqual(settings_ipv4.get_method(), 'auto')
def test_edit_ethernet_connection(self): """Check that we can update an ethernet connection.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection( connection, 'plinth_test_eth_new', 'external', 'manual', '169.254.0.1') connection = network.get_connection(self.ethernet_uuid) self.assertEqual(connection.get_id(), 'plinth_test_eth_new') settings_connection = connection.get_setting_connection() self.assertEqual(settings_connection.get_zone(), 'external') settings_ipv4 = connection.get_setting_ip4_config() self.assertEqual(settings_ipv4.get_method(), 'manual') address = settings_ipv4.get_address(0) self.assertEqual(address.get_address(), '169.254.0.1')
def test_ethernet_manual_ipv4_address(self): """Check that we can manually set IPv4 address on ethernet.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection( connection, 'plinth_test_eth_new', 'eth0', 'external', 'manual', '169.254.0.1', '255.255.254.0', '169.254.0.254', '1.2.3.4', '1.2.3.5') connection = network.get_connection(self.ethernet_uuid) settings_ipv4 = connection.get_setting_ip4_config() self.assertEqual(settings_ipv4.get_method(), 'manual') address = settings_ipv4.get_address(0) self.assertEqual(address.get_address(), '169.254.0.1') self.assertEqual(address.get_prefix(), 23) self.assertEqual(settings_ipv4.get_gateway(), '169.254.0.254') self.assertEqual(settings_ipv4.get_num_dns(), 2) self.assertEqual(settings_ipv4.get_dns(0), '1.2.3.4') self.assertEqual(settings_ipv4.get_dns(1), '1.2.3.5')
def test_ethernet_manual_ipv4_address(self): """Check that we can manually set IPv4 address on ethernet.""" connection = network.get_connection(self.ethernet_uuid) network.edit_ethernet_connection(connection, 'plinth_test_eth_new', 'eth0', 'external', 'manual', '169.254.0.1', '255.255.254.0', '169.254.0.254', '1.2.3.4', '1.2.3.5') connection = network.get_connection(self.ethernet_uuid) settings_ipv4 = connection.get_setting_ip4_config() self.assertEqual(settings_ipv4.get_method(), 'manual') address = settings_ipv4.get_address(0) self.assertEqual(address.get_address(), '169.254.0.1') self.assertEqual(address.get_prefix(), 23) self.assertEqual(settings_ipv4.get_gateway(), '169.254.0.254') self.assertEqual(settings_ipv4.get_num_dns(), 2) self.assertEqual(settings_ipv4.get_dns(0), '1.2.3.4') self.assertEqual(settings_ipv4.get_dns(1), '1.2.3.5')
def edit(request, uuid): """Serve connection editing form.""" try: connection = network.get_connection(uuid) except network.ConnectionNotFound: messages.error(request, _('Cannot edit connection: ' 'Connection not found.')) return redirect(reverse_lazy('networks:index')) if connection.get_connection_type() not in network.CONNECTION_TYPE_NAMES: messages.error(request, _('This type of connection is not yet understood.')) return redirect(reverse_lazy('networks:index')) form = None form_data = {'name': connection.get_id()} if request.method == 'POST': if connection.get_connection_type() == '802-11-wireless': form = AddWifiForm(request.POST) elif connection.get_connection_type() == '802-3-ethernet': form = AddEthernetForm(request.POST) elif connection.get_connection_type() == 'pppoe': form = AddPPPoEForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] interface = form.cleaned_data['interface'] zone = form.cleaned_data['zone'] if connection.get_connection_type() == 'pppoe': username = form.cleaned_data['username'] password = form.cleaned_data['password'] else: ipv4_method = form.cleaned_data['ipv4_method'] ipv4_address = form.cleaned_data['ipv4_address'] if connection.get_connection_type() == '802-3-ethernet': network.edit_ethernet_connection( connection, name, interface, zone, ipv4_method, ipv4_address) elif connection.get_connection_type() == '802-11-wireless': ssid = form.cleaned_data['ssid'] mode = form.cleaned_data['mode'] auth_mode = form.cleaned_data['auth_mode'] passphrase = form.cleaned_data['passphrase'] network.edit_wifi_connection( connection, name, interface, zone, ssid, mode, auth_mode, passphrase, ipv4_method, ipv4_address) elif connection.get_connection_type() == 'pppoe': network.edit_pppoe_connection( connection, name, interface, zone, username, password) return redirect(reverse_lazy('networks:index')) else: return TemplateResponse(request, 'connections_edit.html', {'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form}) else: settings_connection = connection.get_setting_connection() form_data['interface'] = connection.get_interface_name() try: form_data['zone'] = settings_connection.get_zone() except KeyError: form_data['zone'] = 'external' if settings_connection.get_connection_type() != 'pppoe': settings_ipv4 = connection.get_setting_ip4_config() form_data['ipv4_method'] = settings_ipv4.get_method() address = network.get_first_ip_address_from_connection(connection) if address: form_data['ipv4_address'] = address if settings_connection.get_connection_type() == '802-11-wireless': settings_wireless = connection.get_setting_wireless() form_data['ssid'] = settings_wireless.get_ssid().get_data() form_data['mode'] = settings_wireless.get_mode() try: wifi_sec = connection.get_setting_wireless_security() if wifi_sec: if wifi_sec.get_key_mgmt() == 'wpa-psk': form_data['auth_mode'] = 'wpa' secrets = connection.get_secrets( '802-11-wireless-security') psk = secrets['802-11-wireless-security']['psk'] form_data['passphrase'] = psk else: form_data['auth_mode'] = 'open' except KeyError: form_data['auth_mode'] = 'open' form = AddWifiForm(form_data) elif settings_connection.get_connection_type() == '802-3-ethernet': form = AddEthernetForm(form_data) elif settings_connection.get_connection_type() == 'pppoe': settings_pppoe = connection.get_setting_pppoe() form_data['username'] = settings_pppoe.get_username() secrets = connection.get_secrets('pppoe') form_data['password'] = secrets['pppoe']['password'] form = AddPPPoEForm(form_data) return TemplateResponse(request, 'connections_edit.html', {'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form})
def edit(request, uuid): """Serve connection editing form.""" try: connection = network.get_connection(uuid) except network.ConnectionNotFound: messages.error(request, _('Cannot edit connection: ' 'Connection not found.')) return redirect(reverse_lazy('networks:index')) if connection.get_connection_type() not in network.CONNECTION_TYPE_NAMES: messages.error(request, _('This type of connection is not yet understood.')) return redirect(reverse_lazy('networks:index')) form = None form_data = {'name': connection.get_id()} if request.method == 'POST': if connection.get_connection_type() == '802-11-wireless': form = AddWifiForm(request.POST) elif connection.get_connection_type() == '802-3-ethernet': form = AddEthernetForm(request.POST) elif connection.get_connection_type() == 'pppoe': form = AddPPPoEForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] interface = form.cleaned_data['interface'] zone = form.cleaned_data['zone'] if connection.get_connection_type() == 'pppoe': username = form.cleaned_data['username'] password = form.cleaned_data['password'] else: 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'] if connection.get_connection_type() == '802-3-ethernet': network.edit_ethernet_connection( connection, name, interface, zone, ipv4_method, ipv4_address, ipv4_netmask, ipv4_gateway, ipv4_dns, ipv4_second_dns) elif connection.get_connection_type() == '802-11-wireless': ssid = form.cleaned_data['ssid'] mode = form.cleaned_data['mode'] auth_mode = form.cleaned_data['auth_mode'] passphrase = form.cleaned_data['passphrase'] network.edit_wifi_connection( connection, name, interface, zone, ssid, mode, auth_mode, passphrase, ipv4_method, ipv4_address, ipv4_netmask, ipv4_gateway, ipv4_dns, ipv4_second_dns) elif connection.get_connection_type() == 'pppoe': network.edit_pppoe_connection( connection, name, interface, zone, username, password) return redirect(reverse_lazy('networks:index')) else: return TemplateResponse(request, 'connections_edit.html', {'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form}) else: settings_connection = connection.get_setting_connection() form_data['interface'] = connection.get_interface_name() try: form_data['zone'] = settings_connection.get_zone() except KeyError: form_data['zone'] = 'external' if settings_connection.get_connection_type() != 'pppoe': settings_ipv4 = connection.get_setting_ip4_config() form_data['ipv4_method'] = settings_ipv4.get_method() address, netmask = network.get_first_ip_address_from_connection( connection) gateway = settings_ipv4.get_gateway() dns = settings_ipv4.get_dns(0) second_dns = settings_ipv4.get_dns(1) if address: form_data['ipv4_address'] = address if netmask: form_data['ipv4_netmask'] = netmask if gateway: form_data['ipv4_gateway'] = gateway if dns: form_data['ipv4_dns'] = dns if second_dns: form_data['ipv4_second_dns'] = second_dns if settings_connection.get_connection_type() == '802-11-wireless': settings_wireless = connection.get_setting_wireless() form_data['ssid'] = settings_wireless.get_ssid().get_data() form_data['mode'] = settings_wireless.get_mode() try: wifi_sec = connection.get_setting_wireless_security() if wifi_sec: if wifi_sec.get_key_mgmt() == 'wpa-psk': form_data['auth_mode'] = 'wpa' secrets = connection.get_secrets( '802-11-wireless-security') psk = secrets['802-11-wireless-security']['psk'] form_data['passphrase'] = psk else: form_data['auth_mode'] = 'open' except KeyError: form_data['auth_mode'] = 'open' form = AddWifiForm(form_data) elif settings_connection.get_connection_type() == '802-3-ethernet': form = AddEthernetForm(form_data) elif settings_connection.get_connection_type() == 'pppoe': settings_pppoe = connection.get_setting_pppoe() form_data['username'] = settings_pppoe.get_username() secrets = connection.get_secrets('pppoe') form_data['password'] = secrets['pppoe']['password'] form = AddPPPoEForm(form_data) return TemplateResponse(request, 'connections_edit.html', {'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form})
def edit(request, uuid): """Serve connection editing form.""" try: connection = network.get_connection(uuid) except network.ConnectionNotFound: messages.error(request, _('Cannot edit connection: ' 'Connection not found.')) return redirect(reverse_lazy('networks:index')) form = None form_data = {'name': connection.get_id()} if request.method == 'POST': if connection.get_connection_type() == '802-11-wireless': form = AddWifiForm(request.POST) else: form = AddEthernetForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] interface = form.cleaned_data['interface'] zone = form.cleaned_data['zone'] ipv4_method = form.cleaned_data['ipv4_method'] ipv4_address = form.cleaned_data['ipv4_address'] if connection.get_connection_type() == '802-3-ethernet': network.edit_ethernet_connection( connection, name, interface, zone, ipv4_method, ipv4_address) elif connection.get_connection_type() == '802-11-wireless': ssid = form.cleaned_data['ssid'] mode = form.cleaned_data['mode'] auth_mode = form.cleaned_data['auth_mode'] passphrase = form.cleaned_data['passphrase'] network.edit_wifi_connection( connection, name, interface, zone, ssid, mode, auth_mode, passphrase, ipv4_method, ipv4_address) return redirect(reverse_lazy('networks:index')) else: return TemplateResponse(request, 'connections_edit.html', {'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form}) else: settings_connection = connection.get_setting_connection() settings_ipv4 = connection.get_setting_ip4_config() form_data['interface'] = connection.get_interface_name() try: form_data['zone'] = settings_connection.get_zone() except KeyError: form_data['zone'] = 'external' form_data['ipv4_method'] = settings_ipv4.get_method() if settings_ipv4.get_num_addresses(): # XXX: Plinth crashes here. Possibly because a double free bug # address = settings_ipv4.get_address(0) # form_data['ipv4_address'] = address.get_address() pass if settings_connection.get_connection_type() == '802-11-wireless': settings_wireless = connection.get_setting_wireless() form_data['ssid'] = settings_wireless.get_ssid().get_data() form_data['mode'] = settings_wireless.get_mode() try: wifi_sec = connection.get_setting_wireless_security() if wifi_sec: if wifi_sec.get_key_mgmt() == 'wpa-psk': form_data['auth_mode'] = 'wpa' secrets = connection.get_secrets( '802-11-wireless-security') psk = secrets['802-11-wireless-security']['psk'] form_data['passphrase'] = psk else: form_data['auth_mode'] = 'open' except KeyError: form_data['auth_mode'] = 'open' form = AddWifiForm(form_data) else: form = AddEthernetForm(form_data) return TemplateResponse(request, 'connections_edit.html', {'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form})
def edit(request, uuid): """Serve connection editing form.""" try: connection = network.get_connection(uuid) except network.ConnectionNotFound: messages.error(request, _("Cannot edit connection: " "Connection not found.")) return redirect(reverse_lazy("networks:index")) form = None form_data = {"name": connection.get_id()} if request.method == "POST": if connection.get_connection_type() == "802-11-wireless": form = AddWifiForm(request.POST) else: form = AddEthernetForm(request.POST) if form.is_valid(): name = form.cleaned_data["name"] zone = form.cleaned_data["zone"] ipv4_method = form.cleaned_data["ipv4_method"] ipv4_address = form.cleaned_data["ipv4_address"] if connection.get_connection_type() == "802-3-ethernet": network.edit_ethernet_connection(connection, name, zone, ipv4_method, ipv4_address) elif connection.get_connection_type() == "802-11-wireless": ssid = form.cleaned_data["ssid"] mode = form.cleaned_data["mode"] auth_mode = form.cleaned_data["auth_mode"] passphrase = form.cleaned_data["passphrase"] network.edit_wifi_connection( connection, name, zone, ssid, mode, auth_mode, passphrase, ipv4_method, ipv4_address ) return redirect(reverse_lazy("networks:index")) else: return TemplateResponse( request, "connections_edit.html", {"title": _("Edit Connection"), "subsubmenu": subsubmenu, "form": form}, ) else: settings_connection = connection.get_setting_connection() settings_ipv4 = connection.get_setting_ip4_config() try: form_data["zone"] = settings_connection.get_zone() except KeyError: form_data["zone"] = "external" form_data["ipv4_method"] = settings_ipv4.get_method() if settings_ipv4.get_num_addresses(): # XXX: Plinth crashes here. Possibly because a double free bug # address = settings_ipv4.get_address(0) # form_data['ipv4_address'] = address.get_address() pass if settings_connection.get_connection_type() == "802-11-wireless": settings_wireless = connection.get_setting_wireless() form_data["ssid"] = settings_wireless.get_ssid().get_data() form_data["mode"] = settings_wireless.get_mode() try: wifi_sec = connection.get_setting_wireless_security() if wifi_sec: if wifi_sec.get_key_mgmt() == "wpa-psk": form_data["auth_mode"] = "wpa" secrets = connection.get_secrets("802-11-wireless-security") psk = secrets["802-11-wireless-security"]["psk"] form_data["passphrase"] = psk else: form_data["auth_mode"] = "open" except KeyError: form_data["auth_mode"] = "open" form = AddWifiForm(form_data) else: form = AddEthernetForm(form_data) return TemplateResponse( request, "connections_edit.html", {"title": _("Edit Connection"), "subsubmenu": subsubmenu, "form": form} )
def edit(request, uuid): """Serve connection editing form.""" try: connection = network.get_connection(uuid) except network.ConnectionNotFound: messages.error(request, _('Cannot edit connection: ' 'Connection not found.')) return redirect(reverse_lazy('networks:index')) form = None settings = connection.GetSettings() form_data = {'name': settings['connection']['id']} if request.method == 'POST': if settings['connection']['type'] == '802-11-wireless': form = AddWifiForm(request.POST) else: form = AddEthernetForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] zone = form.cleaned_data['zone'] ipv4_method = form.cleaned_data['ipv4_method'] ipv4_address = form.cleaned_data['ipv4_address'] if settings['connection']['type'] == '802-3-ethernet': network.edit_ethernet_connection( connection, name, zone, ipv4_method, ipv4_address) elif settings['connection']['type'] == '802-11-wireless': ssid = form.cleaned_data['ssid'] mode = form.cleaned_data['mode'] auth_mode = form.cleaned_data['auth_mode'] passphrase = form.cleaned_data['passphrase'] network.edit_wifi_connection( connection, name, zone, ssid, mode, auth_mode, passphrase, ipv4_method, ipv4_address) return redirect(reverse_lazy('networks:index')) else: return TemplateResponse(request, 'connections_edit.html', {'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form}) else: try: form_data['zone'] = settings['connection']['zone'] except KeyError: form_data['zone'] = 'external' form_data['ipv4_method'] = settings['ipv4']['method'] if settings['ipv4']['addresses']: form_data['ipv4_address'] = settings['ipv4']['addresses'][0][0] if settings['connection']['type'] == '802-11-wireless': settings_wifi = settings['802-11-wireless'] form_data['ssid'] = settings_wifi['ssid'] form_data['mode'] = settings_wifi['mode'] try: if settings_wifi['security'] == '802-11-wireless-security': wifi_sec = settings['802-11-wireless-security'] if wifi_sec['key-mgmt'] == 'wpa-psk': form_data['auth_mode'] = 'wpa' secret = connection.GetSecrets() psk = secret['802-11-wireless-security']['psk'] form_data['passphrase'] = psk else: form_data['auth_mode'] = 'open' except KeyError: form_data['auth_mode'] = 'open' form = AddWifiForm(form_data) else: form = AddEthernetForm(form_data) return TemplateResponse(request, 'connections_edit.html', {'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form})
def edit(request, uuid): """Serve connection editing form.""" try: connection = network.get_connection(uuid) except network.ConnectionNotFound: messages.error(request, _('Cannot edit connection: ' 'Connection not found.')) return redirect(reverse_lazy('networks:index')) form = None settings = connection.GetSettings() form_data = {'name': settings['connection']['id']} if request.method == 'POST': if settings['connection']['type'] == '802-11-wireless': form = AddWifiForm(request.POST) else: form = AddEthernetForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] zone = form.cleaned_data['zone'] ipv4_method = form.cleaned_data['ipv4_method'] ipv4_address = form.cleaned_data['ipv4_address'] if settings['connection']['type'] == '802-3-ethernet': network.edit_ethernet_connection(connection, name, zone, ipv4_method, ipv4_address) elif settings['connection']['type'] == '802-11-wireless': ssid = form.cleaned_data['ssid'] mode = form.cleaned_data['mode'] auth_mode = form.cleaned_data['auth_mode'] passphrase = form.cleaned_data['passphrase'] network.edit_wifi_connection(connection, name, zone, ssid, mode, auth_mode, passphrase, ipv4_method, ipv4_address) return redirect(reverse_lazy('networks:index')) else: return TemplateResponse( request, 'connections_edit.html', { 'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form }) else: try: form_data['zone'] = settings['connection']['zone'] except KeyError: form_data['zone'] = 'external' form_data['ipv4_method'] = settings['ipv4']['method'] if settings['ipv4']['addresses']: form_data['ipv4_address'] = settings['ipv4']['addresses'][0][0] if settings['connection']['type'] == '802-11-wireless': settings_wifi = settings['802-11-wireless'] form_data['ssid'] = settings_wifi['ssid'] form_data['mode'] = settings_wifi['mode'] try: if settings_wifi['security'] == '802-11-wireless-security': wifi_sec = settings['802-11-wireless-security'] if wifi_sec['key-mgmt'] == 'wpa-psk': form_data['auth_mode'] = 'wpa' secret = connection.GetSecrets() psk = secret['802-11-wireless-security']['psk'] form_data['passphrase'] = psk else: form_data['auth_mode'] = 'open' except KeyError: form_data['auth_mode'] = 'open' form = AddWifiForm(form_data) else: form = AddEthernetForm(form_data) return TemplateResponse(request, 'connections_edit.html', { 'title': _('Edit Connection'), 'subsubmenu': subsubmenu, 'form': form })