Beispiel #1
0
    def execute(self, options_dict, non_option_args):
        if len(non_option_args) < 1:
            self.usage()

        manager = self.Manager()

        aps = self.find_aps(manager.get_devices(), non_option_args)
            
        found = 0
        table_headers = ("Property", "Value")

        for ssid in non_option_args:
            ap = aps[ssid]
            if not ap:
                nmtalk.error("Can not find AP %s" % ssid)
                continue

            found += 1
            props = ap.get_properties()
            nmformat.tabular(table_headers, props)

        if found == 0:
            return 1

        return 0
Beispiel #2
0
    def execute(self, options_dict, non_option_args):
        if len(non_option_args) < 1:
            self.usage()

        manager = self.Manager()
        table_headers = ("Property", "Value")

        for device_iface in non_option_args:
            device = manager.get_device_by_iface(device_iface)
            if not device:
                nmtalk.error("Invalid device %s" % device_iface)
                continue

            config = device.get_ip4_config()
            if not config:
                nmtalk.error("Device has no IP4 config")
                continue

            props = config.get_properties()
            if len(non_option_args) > 1:
                print
                print "Device %s" % device_iface
                print
            nmformat.tabular(table_headers, props)

        return 0
Beispiel #3
0
    def execute(self, options_dict, non_option_args):
        if len(non_option_args) < 1:
            self.usage()

        manager = self.Manager()
        table_headers = ("Property", "Value")

        for device_iface in non_option_args:
            device = manager.get_device_by_iface(device_iface)
            if not device:
                nmtalk.error("Invalid device %s" % device_iface)
                continue

            config = device.get_ip4_config()
            if not config:
                nmtalk.error("Device has no IP4 config")
                continue

            props = config.get_properties()
            if len(non_option_args) > 1:
                print
                print "Device %s" % device_iface
                print
            nmformat.tabular(table_headers, props)

        return 0
Beispiel #4
0
    def execute(self, options_dict, non_option_args):
        manager = self.Manager()
        devices = []

        if len(non_option_args) < 1:
            # Get all wireless devices
            for device in manager.get_devices():
                if isinstance(device, nmwirelessdevicecmds.WirelessDevice):
                    devices.append(device)

        else:
            for device in manager.get_devices():
                for arg in non_option_args:
                    if device.get_interface() == arg:
                        if isinstance(device, nmwirelessdevicecmds.WirelessDevice):
                            devices.append(device)
                        else:
                            nmtalk.error("Wireless device expected, got %s" % str(device))

        got_devices = len(devices)

        if got_devices < 1:
            nmtalk.error("No wireless devices found.")
            return 1

        for device in devices:
            if got_devices > 1:
                nmtalk.message("Access Points for device '%s':" % device.get_interface())

            aps = device.get_access_points()

            if not aps:
                nmtalk.message("No access points found.")
                continue

            rows = []
            active_ap = device.get_active_access_point()
            if active_ap:
                active_ssid = active_ap.get_ssid()
            else:
                active_ssid = None

            for ap in aps:
                if active_ssid == ap.get_ssid():
                    active = "*"
                else:
                    active = ""

                rows.append ((str(ap), active))

            rows.sort(lambda x,y:cmp(x[0].lower(), y[0].lower()))
            nmformat.tabular(("SSID", "Active"), rows)

        return 0
Beispiel #5
0
    def execute(self, options_dict, non_option_args):
        manager = nmsettings.ConnectionManager()

        if options_dict.has_key("system"):
            connections = manager.get_connections(
                nmsettings.DBUS_SERVICE_SYSTEM_SETTINGS, "vpn")
            print_service = False
        elif options_dict.has_key("user"):
            connections = manager.get_connections(
                nmsettings.DBUS_SERVICE_USER_SETTINGS, "vpn")
            print_service = False
        else:
            connections = manager.get_connections(
                nmsettings.DBUS_SERVICE_SYSTEM_SETTINGS, "vpn")
            connections += manager.get_connections(
                nmsettings.DBUS_SERVICE_USER_SETTINGS, "vpn")
            print_service = True

        vpn_manager = nmvpn.VpnManager()
        active_map = {}
        for c in vpn_manager.list_active_connections():
            active_map[c.get_name()] = nmvpn.vpn_connection_state_to_str(
                c.get_state())

        rows = []
        for connection in connections:
            name = connection.get_id()
            r = [name, active_map.get(name, "")]
            if print_service:
                if connection.service == nmsettings.DBUS_SERVICE_USER_SETTINGS:
                    r.append("User")
                else:
                    r.append("System")

            rows.append(r)

        if rows:
            headers = ["Name", "Status"]
            if print_service:
                headers.append("Service type")

            rows.sort(lambda x, y: cmp(x[0].lower(), y[0].lower()))
            nmformat.tabular(headers, rows)
        else:
            nmtalk.message("No VPN connections found.")

        return 0
Beispiel #6
0
    def execute(self, options_dict, non_option_args):
        manager = self.Manager()
        device_list = manager.get_devices()

        if len(device_list) < 1:
            nmtalk.message("No devices found.")
            return 0

        table_rows = []

        for device in device_list:
            row = (device.get_interface(), str(device), nmdevice.device_state_to_str(device.get_state()))
            table_rows.append(row)

        nmformat.tabular(("Interface", "Type", "State"), table_rows)

        return 0
Beispiel #7
0
    def execute(self, options_dict, non_option_args):
        manager = self.Manager()
        device_list = manager.get_devices()

        if len(device_list) < 1:
            nmtalk.message("No devices found.")
            return 0

        table_rows = []

        for device in device_list:
            row = (device.get_interface(), str(device),
                   nmdevice.device_state_to_str(device.get_state()))
            table_rows.append(row)

        nmformat.tabular(("Interface", "Type", "State"), table_rows)

        return 0
Beispiel #8
0
    def execute(self, options_dict, non_option_args):
        manager = nmsettings.ConnectionManager()

        if options_dict.has_key("system"):
            connections = manager.get_connections(nmsettings.DBUS_SERVICE_SYSTEM_SETTINGS, "vpn")
            print_service = False
        elif options_dict.has_key("user"):
            connections = manager.get_connections(nmsettings.DBUS_SERVICE_USER_SETTINGS, "vpn")
            print_service = False
        else:
            connections = manager.get_connections(nmsettings.DBUS_SERVICE_SYSTEM_SETTINGS, "vpn")
            connections += manager.get_connections(nmsettings.DBUS_SERVICE_USER_SETTINGS, "vpn")
            print_service = True

        vpn_manager = nmvpn.VpnManager()
        active_map = {}
        for c in vpn_manager.list_active_connections():
            active_map[c.get_name()] = nmvpn.vpn_connection_state_to_str(c.get_state())

        rows = []
        for connection in connections:
            name = connection.get_id()
            r = [name, active_map.get(name, "")]
            if print_service:
                if connection.service == nmsettings.DBUS_SERVICE_USER_SETTINGS:
                    r.append("User")
                else:
                    r.append("System")

            rows.append(r)

        if rows:
            headers = ["Name", "Status"]
            if print_service:
                headers.append("Service type")

            rows.sort(lambda x,y:cmp(x[0].lower(), y[0].lower()))
            nmformat.tabular(headers, rows)
        else:
            nmtalk.message("No VPN connections found.")

        return 0
Beispiel #9
0
    def execute(self, options_dict, non_option_args):
        manager = nmsettings.ConnectionManager()

        if options_dict.has_key("system"):
            connections = manager.get_connections(nmsettings.DBUS_SERVICE_SYSTEM_SETTINGS)
            print_service = False
        elif options_dict.has_key("user"):
            connections = manager.get_connections(nmsettings.DBUS_SERVICE_USER_SETTINGS)
            print_service = False
        else:
            connections = manager.get_connections(nmsettings.DBUS_SERVICE_SYSTEM_SETTINGS)
            connections += manager.get_connections(nmsettings.DBUS_SERVICE_USER_SETTINGS)
            print_service = True

        rows = []
        for connection in connections:
            r = [connection.get_id(), connection.get_type()]
            if print_service:
                if connection.service == nmsettings.DBUS_SERVICE_USER_SETTINGS:
                    r.append("User")
                else:
                    r.append("System")

            rows.append(r)

        if rows:
            if options_dict.has_key("sort-by-type"):
                rows.sort(lambda x,y:cmp(x[1].lower(), y[1].lower()))
            else:
                rows.sort(lambda x,y:cmp(x[0].lower(), y[0].lower()))

            headers = ["Name", "Type"]
            if print_service:
                headers.append("Service type")

            nmformat.tabular(headers, rows)
        else:
            nmtalk.message("No connections found.")

        return 0