def _get_service_info(service):
    '''
    return details about given connman service
    '''
    service_info = pyconnman.ConnService(os.path.join(SERVICE_PATH, service))
    data = {
        'label': service,
        'wireless': service_info.get_property('Type') == 'wifi',
        'connectionid': six.text_type(service_info.get_property('Ethernet')['Interface']),
        'hwaddr': six.text_type(service_info.get_property('Ethernet')['Address'])
    }

    state = service_info.get_property('State')
    if state == 'ready' or state == 'online':
        data['up'] = True
        data['ipv4'] = {
            'gateway': '0.0.0.0'
        }
        ipv4 = 'IPv4'
        if service_info.get_property('IPv4')['Method'] == 'manual':
            ipv4 += '.Configuration'
        ipv4_info = service_info.get_property(ipv4)
        for info in ['Method', 'Address', 'Netmask', 'Gateway']:
            value = ipv4_info.get(info)
            if value is None:
                log.warning('Unable to get IPv4 %s for service %s\n', info, service)
                continue
            if info == 'Method':
                info = 'requestmode'
                if value == 'dhcp':
                    value = 'dhcp_linklocal'
                elif value in ('manual', 'fixed'):
                    value = 'static'
            data['ipv4'][info.lower()] = six.text_type(value)

        ipv6_info = service_info.get_property('IPv6')
        for info in ['Address', 'Prefix', 'Gateway']:
            value = ipv6_info.get(info)
            if value is None:
                log.warning('Unable to get IPv6 %s for service %s\n', info, service)
                continue
            if 'ipv6' not in data:
                data['ipv6'] = {}
            data['ipv6'][info.lower()] = [six.text_type(value)]

        nameservers = []
        for nameserver_prop in service_info.get_property('Nameservers'):
            nameservers.append(six.text_type(nameserver_prop))
        data['ipv4']['dns'] = nameservers
    else:
        data['up'] = False
        data['ipv4'] = {
            'requestmode': 'disabled'
        }

    data['ipv4']['supportedrequestmodes'] = [
        'static',
        'dhcp_linklocal',
        'disabled'
    ]
    return data
def _get_service_info ( service ) : service_info = pyconnman . ConnService ( os . path . join ( SERVICE_PATH , service ) ) data = { 'label' : service , 'wireless' : service_info . get_property ( 'Type' ) == 'wifi' , 'connectionid' : six . text_type ( service_info . get_property ( 'Ethernet' ) [ 'Interface' ] ) , 'hwaddr' : six . text_type ( service_info . get_property ( 'Ethernet' ) [ 'Address' ] ) } state = service_info . get_property ( 'State' ) if state == 'ready' or state == 'online' : data [ 'up' ] = True data [ 'ipv4' ] = { 'gateway' : '0.0.0.0' } ipv4 = 'IPv4' if service_info . get_property ( 'IPv4' ) [ 'Method' ] == 'manual' : ipv4 += '.Configuration' ipv4_info = service_info . get_property ( ipv4 ) for info in [ 'Method' , 'Address' , 'Netmask' , 'Gateway' ] : value = ipv4_info . get ( info ) if value is None : log . warning ( 'Unable to get IPv4 %s for service %s\n' , info , service ) continue if info == 'Method' : info = 'requestmode' if value == 'dhcp' : value = 'dhcp_linklocal' elif value in ( 'manual' , 'fixed' ) : value = 'static' data [ 'ipv4' ] [ info . lower ( ) ] = six . text_type ( value ) ipv6_info = service_info . get_property ( 'IPv6' ) for info in [ 'Address' , 'Prefix' , 'Gateway' ] : value = ipv6_info . get ( info ) if value is None : log . warning ( 'Unable to get IPv6 %s for service %s\n' , info , service ) continue if 'ipv6' not in data : data [ 'ipv6' ] = { } data [ 'ipv6' ] [ info . lower ( ) ] = [ six . text_type ( value ) ] nameservers = [ ] for nameserver_prop in service_info . get_property ( 'Nameservers' ) : nameservers . append ( six . text_type ( nameserver_prop ) ) data [ 'ipv4' ] [ 'dns' ] = nameservers else : data [ 'up' ] = False data [ 'ipv4' ] = { 'requestmode' : 'disabled' } data [ 'ipv4' ] [ 'supportedrequestmodes' ] = [ 'static' , 'dhcp_linklocal' , 'disabled' ] return data
return details about given connman service