blob: f51855c53834866d59a30bc690f8e9a0950910ff [file] [log] [blame]
Takahiro Suzuki2b66b942020-12-17 11:58:14 +09001# Copyright 2020-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import json
16from xossynchronizer.event_steps.eventstep import EventStep
17from helpers import NttHelpers
18
19
20class SubscriberAuthEventStep(EventStep):
21 topics = ["authentication.events"]
22 technology = "kafka"
23
24 def __init__(self, *args, **kwargs):
25 super(SubscriberAuthEventStep, self).__init__(*args, **kwargs)
26
27 def process_event(self, event):
28 value = json.loads(event.value)
29 self.log.info("authentication.events: Got event for subscriber", event_value=value)
30
31 si = NttHelpers.find_or_create_ntt_si(self.model_accessor, self.log, value)
32 self.log.debug("authentication.events: Updating service instance", si=si)
33 si.authentication_state = value["authenticationState"]
34 si.save_changed_fields(always_update_timestamp=True)