Generate schemas dynamically from pieces provided by each object class
This way we benefit from:
* knowing which attributes are used/required by each object class and
subclass
* Having validation function definitions near the class going to use them
Change-Id: I8fd6773c51d19405a585977af4ed72cad2b21db1
diff --git a/src/osmo_gsm_tester/obj/ms.py b/src/osmo_gsm_tester/obj/ms.py
index 3dcea7b..b72333a 100644
--- a/src/osmo_gsm_tester/obj/ms.py
+++ b/src/osmo_gsm_tester/obj/ms.py
@@ -19,6 +19,21 @@
from abc import ABCMeta, abstractmethod
from ..core import log
+from ..core import schema
+
+def on_register_schemas():
+ resource_schema = {
+ 'type': schema.STR,
+ 'label': schema.STR,
+ 'path': schema.STR,
+ 'imsi': schema.IMSI,
+ 'ki': schema.KI,
+ 'auth_algo': schema.AUTH_ALGO,
+ 'apn_ipaddr': schema.IPV4,
+ 'ciphers[]': schema.CIPHER,
+ 'features[]': schema.MODEM_FEATURE
+ }
+ schema.register_resource_schema('modem', resource_schema)
class MS(log.Origin, metaclass=ABCMeta):
"""Base for everything about mobile/modem and SIMs."""