Пример #1
0
    def upsert_wifi_slice(self, **kwargs):
        """Upsert new slice."""

        slc = WiFiSlice(**kwargs)

        for wtp in self.lvapp_manager.devices.values():
            for block in wtp.blocks.values():
                wtp.connection.send_set_slice(self, slc, block)

        self.wifi_slices[str(slc.slice_id)] = slc

        self.save()
        self.refresh_from_db()

        return slc.slice_id
Пример #2
0
    def to_python(self, value):

        try:

            out = {}

            for slc in value.values():

                if not isinstance(slc, WiFiSlice):
                    slc = WiFiSlice(**slc)

                out[str(slc.slice_id)] = slc

            return out

        except ValueError as ex:
            raise ValidationError(ex)