Beispiel #1
0
    def getGui(self, type_):
        try:
            return self.addField(
                    self.addField(
                        self.addField(self.addDefaultFields(factory().lookup(type_).guiDescription(), ['name', 'comments', 'tags', 'priority']), {
                            'name': 'nets_positive',
                            'value': True,
                            'label': ugettext('Network access'),
                            'tooltip': ugettext('If checked, the transport will be enabled for the selected networks.If unchecked, transport will be disabled for selected networks'),
                            'type': 'checkbox',
                            'order': 100,  # At end
                        }), {
                        'name': 'networks',
                        'value': [],
                        'values': sorted([{'id': x.id, 'text': x.name} for x in Network.objects.all()], key=lambda x: x['text'].lower()),  # TODO: We will fix this behavior after current admin client is fully removed
                        'label': ugettext('Networks'),
                        'tooltip': ugettext('Networks associated with this transport. If No network selected, will mean "all networks"'),
                        'type': 'multichoice',
                        'order': 101
                    }), {
                    'name': 'allowed_oss',
                    'value': [],
                    'values': sorted([{'id': x, 'text': x} for x in OsDetector.knownOss], key=lambda x: x['text'].lower()),  # TODO: We will fix this behavior after current admin client is fully removed
                    'label': ugettext('Allowed Devices'),
                    'tooltip': ugettext('If empty, any kind of device compatible with this transport will be allowed. Else, only devices compatible with selected values will be allowed'),
                    'type': 'multichoice',
                    'order': 102
                })

        except Exception:
            self.invalidItemException()
Beispiel #2
0
    def getType(self) -> typing.Type['transports.Transport']:
        """
        Get the type of the object this record represents.

        The type is Python type, it obtains this type from ServiceProviderFactory and associated record field.

        Returns:
            The python type for this record object

        :note: We only need to get info from this, not access specific data (class specific info)
        """
        return transports.factory().lookup(self.data_type)
Beispiel #3
0
    def getType(self):
        '''
        Get the type of the object this record represents.

        The type is Python type, it obtains this type from ServiceProviderFactory and associated record field.

        Returns:
            The python type for this record object

        :note: We only need to get info from this, not access specific data (class specific info)
        '''
        from uds.core import transports

        return transports.factory().lookup(self.data_type)
Beispiel #4
0
def __init__():
    """
    This imports all packages that are descendant of this package, and, after that,
    it register all subclases of service provider as
    """
    from uds.core import transports

    # Dinamycally import children of this package. The __init__.py files of each module must import classes so they can get registered
    pkgpath = os.path.dirname(sys.modules[__name__].__file__)
    for _, name, _ in pkgutil.iter_modules([pkgpath]):
        # __import__(name, globals(), locals(), [], 1)
        importlib.import_module('.' + name, __name__)  # import module
        
    importlib.invalidate_caches()

    # This is marked as error in IDE, but it's not (__subclasses__)
    for cls in transports.Transport.__subclasses__():
        clsSubCls = cls.__subclasses__()
        if len(clsSubCls) == 0:
            transports.factory().insert(cls)
        else:
            for l2 in clsSubCls:
                transports.factory().insert(l2)
Beispiel #5
0
def __init__():
    """
    This imports all packages that are descendant of this package, and, after that,
    it register all subclases of service provider as
    """
    import os.path
    import pkgutil
    import sys
    from uds.core import transports

    # Dinamycally import children of this package. The __init__.py files must import classes
    pkgpath = os.path.dirname(sys.modules[__name__].__file__)
    for _, name, _ in pkgutil.iter_modules([pkgpath]):
        __import__(name, globals(), locals(), [], 1)

    p = transports.Transport
    # This is marked as error in IDE, but it's not (__subclasses__)
    for cls in p.__subclasses__():
        clsSubCls = cls.__subclasses__()
        if len(clsSubCls) == 0:
            transports.factory().insert(cls)
        else:
            for l2 in clsSubCls:
                transports.factory().insert(l2)
Beispiel #6
0
def __init__():
    """
    This imports all packages that are descendant of this package, and, after that,
    it register all subclases of service provider as
    """
    import os.path
    import pkgutil
    import sys
    from uds.core import transports

    # Dinamycally import children of this package. The __init__.py files must import classes
    pkgpath = os.path.dirname(sys.modules[__name__].__file__)
    for _, name, _ in pkgutil.iter_modules([pkgpath]):
        __import__(name, globals(), locals(), [], 1)

    p = transports.Transport
    # This is marked as error in IDE, but it's not (__subclasses__)
    for cls in p.__subclasses__():
        clsSubCls = cls.__subclasses__()
        if len(clsSubCls) == 0:
            transports.factory().insert(cls)
        else:
            for l2 in clsSubCls:
                transports.factory().insert(l2)
Beispiel #7
0
    def getGui(self, type_: str) -> typing.List[typing.Any]:
        transport = transports.factory().lookup(type_)

        if not transport:
            raise self.invalidItemException()

        field = self.addDefaultFields(transport.guiDescription(),
                                      ['name', 'comments', 'tags', 'priority'])
        field = self.addField(
            field,
            {
                'name':
                'nets_positive',
                'value':
                True,
                'label':
                ugettext('Network access'),
                'tooltip':
                ugettext(
                    'If checked, the transport will be enabled for the selected networks. If unchecked, transport will be disabled for selected networks'
                ),
                'type':
                'checkbox',
                'order':
                100,  # At end
            })
        field = self.addField(
            field, {
                'name':
                'networks',
                'value': [],
                'values':
                sorted([{
                    'id': x.uuid,
                    'text': x.name
                } for x in Network.objects.all()],
                       key=lambda x: x['text'].lower()),
                'label':
                ugettext('Networks'),
                'tooltip':
                ugettext(
                    'Networks associated with this transport. If No network selected, will mean "all networks"'
                ),
                'type':
                'multichoice',
                'order':
                101
            })
        field = self.addField(
            field, {
                'name':
                'allowed_oss',
                'value': [],
                'values':
                sorted([{
                    'id': x,
                    'text': x.replace('CrOS', 'Chrome OS')
                } for x in OsDetector.knownOss],
                       key=lambda x: x['text'].lower()),
                'label':
                ugettext('Allowed Devices'),
                'tooltip':
                ugettext(
                    'If empty, any kind of device compatible with this transport will be allowed. Else, only devices compatible with selected values will be allowed'
                ),
                'type':
                'multichoice',
                'order':
                102
            })
        field = self.addField(
            field, {
                'name':
                'pools',
                'value': [],
                'values':
                [{
                    'id': x.uuid,
                    'text': x.name
                } for x in ServicePool.objects.all().order_by('name')
                 if transport.protocol in x.service.getType().allowedProtocols
                 ],
                'label':
                ugettext('Service Pools'),
                'tooltip':
                ugettext('Currently assigned services pools'),
                'type':
                'multichoice',
                'order':
                103
            })

        return field
Beispiel #8
0
 def enum_types(self) -> typing.Iterable[typing.Type[transports.Transport]]:
     return transports.factory().providers().values()
Beispiel #9
0
 def enum_types(self):
     return factory().providers().values()