X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ricsdl-package%2Fexamples%2Fsync.py;h=618586d1846430bba8d1b96cecd3a3cc2138b0b5;hb=7104c62d1e3846e75519245c5593438881e9657f;hp=24c8fe8498c4f42f98857468a41640f14f211375;hpb=276ed3c833c81a4142d7c4607474ee95a7f01355;p=ric-plt%2Fsdlpy.git diff --git a/ricsdl-package/examples/sync.py b/ricsdl-package/examples/sync.py old mode 100644 new mode 100755 index 24c8fe8..618586d --- a/ricsdl-package/examples/sync.py +++ b/ricsdl-package/examples/sync.py @@ -25,11 +25,11 @@ Execution of these examples requires: * Following Redis extension commands have been installed to runtime environment: - MSETPUB - SETIE - - SETIEPUB - - SETNXPUB - - DELPUB + - SETIEMPUB + - SETNXMPUB + - DELMPUB - DELIE - - DELIEPUB + - DELIEMPUB Redis v4.0 or greater is required. Older versions do not support extension modules. Implementation of above commands is produced by RIC DBaaS: https://gerrit.o-ran-sc.org/r/admin/repos/ric-plt/dbaas @@ -39,11 +39,19 @@ Execution of these examples requires: running Redis. * Following environment variables are needed to set to the pod/container where the application utilizing SDL is going to be run. - DBAAS_SERVICE_HOST = [redis server address] - DBAAS_SERVICE_PORT= [redis server port] - DBAAS_MASTER_NAME = [master Redis sentinel name]. Needed to set only if sentinel is in use. - DBAAS_SERVICE_SENTINEL_PORT = [Redis sentinel port number]. Needed to set only if sentinel - is in use. + DBAAS_SERVICE_HOST = [DB service address] + DBAAS_SERVICE_PORT= [DB service port] + DBAAS_MASTER_NAME = [DB name]. Needed to set only if Redis sentinel is used to provide high + availability for Redis DB solution. + DBAAS_SERVICE_SENTINEL_PORT = [Redis sentinel port number]. Needed to set only if Redis + sentinel is in use. + DBASS_CLUSTER_ADDR_LIST = [list of DB service addresses]. Is set only if more than one + Redis sentinel groups are in use. + In official RIC deployments four first environment variables are defined in Helm configMaps + of the DBaaS and these configurations can be loaded automatically as environment variables + into application pods via `envFrom dbaas-appconfig` statement in an application Helm Charts. + The last environment variable is not for time being in use in official RIC deployments, only + in Nokia SEP deployments. """ from ricsdl.syncstorage import SyncStorage from ricsdl.exceptions import RejectedByBackend, NotConnected, BackendError @@ -73,6 +81,16 @@ def _try_func_return(func): # Creates SDL instance. The call creates connection to the SDL database backend. mysdl = _try_func_return(SyncStorage) +# Creates SDL instance what utilizes a fake database backend. Fake database is meant to +# be used only at development phase of SDL clients. It does not provide more advanced +# database services. +# mysdl = _try_func_return(lambda: SyncStorage(fake_db_backend='dict')) + +# Checks if SDL is operational. Note that it is not necessary to call `is_active()` after each +# SDL instance creation. Below example is here just to show how to call it spontaneously +# when SDL healthiness is needed to check. +is_active = mysdl.is_active() +assert is_active is True # Sets a value 'my_value' for a key 'my_key' under given namespace. Note that value # type must be bytes and multiple key values can be set in one set function call.