Skip to content

Commit

Permalink
show registration
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir committed Oct 11, 2021
1 parent 3cc0dc2 commit c8a41b9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
22 changes: 19 additions & 3 deletions scripts/client/list-alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ def get_row(msg):
row = [key, None]
else:
row = [key,
value.state.name, value.overrides, value.effective_registration]
value.state.name]

if params.overrides:
row.append(value.overrides)

if params.effective:
row.append(value.effective_registration)

row_header = get_row_header(headers, timestamp)

Expand All @@ -42,9 +48,15 @@ def get_row(msg):


def disp_table(records):
head = ["Alarm Name", "State", "Overrides", "Effective Registration"]
head = ["Alarm Name", "State"]
table = []

if params.overrides:
head.append("Overrides")

if params.effective:
head.append("Effective Registration")

head = ["Timestamp", "User", "Host", "Produced By"] + head

for msg in records.values():
Expand Down Expand Up @@ -79,12 +91,16 @@ def list_records():

@click.command()
@click.option('--monitor', is_flag=True, help="Monitor indefinitely")
def cli(monitor):
@click.option('--overrides', is_flag=True, help="Show overrides")
@click.option('--effective', is_flag=True, help="Show effective registration")
def cli(monitor, overrides, effective):
global params

params = types.SimpleNamespace()

params.monitor = monitor
params.overrides = overrides
params.effective = effective

list_records()

Expand Down
22 changes: 20 additions & 2 deletions scripts/client/set-alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from confluent_kafka.serialization import StringSerializer
from jlab_jaws.avro.entities import Alarm, AlarmState, AlarmOverrideSet, ProcessorTransitions, OverriddenAlarmType, \
DisabledOverride, FilteredOverride, LatchedOverride, MaskedOverride, OnDelayedOverride, OffDelayedOverride, \
ShelvedOverride, ShelvedReason
ShelvedOverride, ShelvedReason, AlarmRegistration, AlarmLocation, AlarmCategory, AlarmPriority, SimpleProducer
from jlab_jaws.avro.serde import AlarmSerde

from common import delivery_report
Expand Down Expand Up @@ -63,6 +63,23 @@ def get_overrides(override):
return overrides


def get_effective_registration():
return AlarmRegistration(AlarmLocation.INJ,
AlarmCategory.RF,
AlarmPriority.P4_INCIDENTAL,
"testing",
"fix it",
"tester",
True,
True,
5,
5,
"alarm1",
"/tmp",
"base",
SimpleProducer())


@click.command()
@click.option('--unset', is_flag=True, help="present to clear state, missing to set state")
@click.option('--state', required=True, type=click.Choice(AlarmState._member_names_), help="The state")
Expand All @@ -79,10 +96,11 @@ def cli(unset, state, override, name):
params.value = None
else:
overrides = get_overrides(override)
effective_registration = get_effective_registration()

params.value = Alarm(None,
None,
None,
effective_registration,
None,
overrides,
ProcessorTransitions(False, False, False, False,
Expand Down

0 comments on commit c8a41b9

Please sign in to comment.