Housekeeper: Per-job readonly option

Add readonly mode support per each job

Change-Id: I803cbdcae71f5dbf2d025016171e08c05e633393
This commit is contained in:
Kobi Samoray 2018-01-01 14:02:42 +02:00
parent 6c26c0124a
commit ecfe878c1a
2 changed files with 9 additions and 1 deletions

View File

@ -709,6 +709,10 @@ nsxv_opts = [
cfg.ListOpt('housekeeping_jobs', cfg.ListOpt('housekeeping_jobs',
default=['error_dhcp_edge', 'error_backup_edge'], default=['error_dhcp_edge', 'error_backup_edge'],
help=_("List of the enabled housekeeping jobs")), 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', cfg.BoolOpt('housekeeping_readonly',
default=True, default=True,
help=_("Housekeeping will only warn about breakage.")), help=_("Housekeeping will only warn about breakage.")),

View File

@ -16,6 +16,7 @@
import abc import abc
from neutron_lib.plugins import directory from neutron_lib.plugins import directory
from oslo_config import cfg
from oslo_log import log from oslo_log import log
import six import six
@ -25,7 +26,10 @@ LOG = log.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
class BaseJob(object): class BaseJob(object):
def __init__(self, readonly): 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() self.plugin = directory.get_plugin()
@abc.abstractmethod @abc.abstractmethod