def configure_schema(cls): return RwlogMgmtYang.get_schema()
def post_startup(self, mgmt_session): """ Converts the config data to Yang model and applies the config. """ parsed_filters = [] for filter_name, severity in self.filters.items(): parsed_filters.append({ "name": filter_name, "severity": severity}) category = {"category": parsed_filters} sink_config = { "sink" : [ { "name": self.name, "server_address": self.ip, "port": self.port, "filter": category } ]} model = gi.repository.RwYang.Model.create_libncx() model.load_schema_ypbc(rwlogmgmt.get_schema()) model.load_schema_ypbc(rwlog.get_schema()) proxy = mgmt_session.proxy(rwlogmgmt) logging = proxy.get_config("/rwlog-mgmt:logging") if logging is not None: # rwrest doesn't do PATCH (RIFT-9036) so we can't blow away the current config # when we add the syslog information. so do a GET and fill in the extra we # need for syslog before "blowing away" the old container. This is an obvious # race condition at boot time. # there is possibly already config in place for the syslog viewer from the reload # operations. so don't blow away the config that already exists. update_count = 2 if not logging.has_field("syslog_viewer"): logging.syslog_viewer = self.syslog_url else: update_count -= 1 if not logging.has_field("sink"): sink = rwlogmgmt.Logging.from_dict(sink_config) for e in sink.sink: new = logging.sink.add() new.from_dict(e.as_dict()) else: update_count -= 1 if update_count == 0: return else: # no config exists logging = rwlogmgmt.Logging() sink = rwlogmgmt.Logging.from_dict(sink_config) for e in sink.sink: new = logging.sink.add() new.from_dict(e.as_dict()) logging.syslog_viewer = self.syslog_url proxy.replace_config(xpath="/rwlog-mgmt:logging", obj=logging)
def post_startup(self, mgmt_session): """ Converts the config data to Yang model and applies the config. """ parsed_filters = [] for filter_name, severity in self.filters.items(): parsed_filters.append({"name": filter_name, "severity": severity}) category = {"category": parsed_filters} sink_config = { "sink": [{ "name": self.name, "server_address": self.ip, "port": self.port, "filter": category }] } model = gi.repository.RwYang.Model.create_libncx() model.load_schema_ypbc(rwlogmgmt.get_schema()) model.load_schema_ypbc(rwlog.get_schema()) proxy = mgmt_session.proxy(rwlogmgmt) logging = proxy.get_config("/rwlog-mgmt:logging") if logging is not None: # rwrest doesn't do PATCH (RIFT-9036) so we can't blow away the current config # when we add the syslog information. so do a GET and fill in the extra we # need for syslog before "blowing away" the old container. This is an obvious # race condition at boot time. # there is possibly already config in place for the syslog viewer from the reload # operations. so don't blow away the config that already exists. update_count = 2 if not logging.has_field("syslog_viewer"): logging.syslog_viewer = self.syslog_url else: update_count -= 1 if not logging.has_field("sink"): sink = rwlogmgmt.Logging.from_dict(sink_config) for e in sink.sink: new = logging.sink.add() new.from_dict(e.as_dict()) else: update_count -= 1 if update_count == 0: return else: # no config exists logging = rwlogmgmt.Logging() sink = rwlogmgmt.Logging.from_dict(sink_config) for e in sink.sink: new = logging.sink.add() new.from_dict(e.as_dict()) logging.syslog_viewer = self.syslog_url proxy.replace_config(xpath="/rwlog-mgmt:logging", obj=logging)