Пример #1
0
    def add_device(self, device):
        assert isinstance(device, Device)
        self._make_up_to_date('/devices', device.id, device)

        # Ultimately, assign devices to device grpups.
        # see https://jira.opencord.org/browse/CORD-838

        dg = DeviceGroup(id='1')
        self._make_up_to_date('/device_groups', dg.id, dg)
Пример #2
0
    def add_device(self, device):
        assert isinstance(device, Device)
        self._make_up_to_date('/devices', device.id, device)

        # TODO for now, just map everything into a single device group
        # which we create if it does not yet exist

        dg = DeviceGroup(id='1')
        self._make_up_to_date('/device_groups', dg.id, dg)
Пример #3
0
    def GetDeviceGroup(self, request, context):
        log.info('grpc-request', request=request)

        depth = int(dict(context.invocation_metadata()).get('get-depth', 0))

        if '/' in request.id:
            context.set_details('Malformed device group id \'{}\''.format(
                request.id))
            context.set_code(StatusCode.INVALID_ARGUMENT)
            return DeviceGroup()

        # TODO is this mapped to tree or taken from coordinator?
        try:
            return self.root.get('/device_groups/' + request.id, depth=depth)
        except KeyError:
            context.set_details('Device group \'{}\' not found'.format(
                request.id))
            context.set_code(StatusCode.NOT_FOUND)
            return DeviceGroup()