From ecfe878c1a6ef0c55bb05a91be12809250ab8df8 Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Mon, 1 Jan 2018 14:02:42 +0200 Subject: [PATCH] Housekeeper: Per-job readonly option Add readonly mode support per each job Change-Id: I803cbdcae71f5dbf2d025016171e08c05e633393 --- vmware_nsx/common/config.py | 4 ++++ vmware_nsx/plugins/common/housekeeper/base_job.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/vmware_nsx/common/config.py b/vmware_nsx/common/config.py index da31be99d7..4fb959994f 100644 --- a/vmware_nsx/common/config.py +++ b/vmware_nsx/common/config.py @@ -709,6 +709,10 @@ nsxv_opts = [ cfg.ListOpt('housekeeping_jobs', default=['error_dhcp_edge', 'error_backup_edge'], help=_("List of the enabled housekeeping jobs")), + cfg.ListOpt('housekeeping_readonly_jobs', + default=[], + help=_("List of housekeeping jobs which are enabled in read " + "only mode")), cfg.BoolOpt('housekeeping_readonly', default=True, help=_("Housekeeping will only warn about breakage.")), diff --git a/vmware_nsx/plugins/common/housekeeper/base_job.py b/vmware_nsx/plugins/common/housekeeper/base_job.py index 3973357cf5..b2a519f1f2 100644 --- a/vmware_nsx/plugins/common/housekeeper/base_job.py +++ b/vmware_nsx/plugins/common/housekeeper/base_job.py @@ -16,6 +16,7 @@ import abc from neutron_lib.plugins import directory +from oslo_config import cfg from oslo_log import log import six @@ -25,7 +26,10 @@ LOG = log.getLogger(__name__) @six.add_metaclass(abc.ABCMeta) class BaseJob(object): def __init__(self, readonly): - self.readonly = readonly + self.readonly = readonly or (self.get_name() in + cfg.CONF.nsxv.housekeeping_readonly_jobs) + LOG.info('Housekeeping: %s job initialized in %s mode', + self.get_name(), 'RO' if self.readonly else 'RW') self.plugin = directory.get_plugin() @abc.abstractmethod