Merge "TVD: support housekeeper for TVD"

This commit is contained in:
Zuul 2018-01-03 10:27:06 +00:00 committed by Gerrit Code Review
commit dcb75b97ec
4 changed files with 46 additions and 1 deletions

View File

@ -25,12 +25,24 @@ LOG = log.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class BaseJob(object):
_core_plugin = None
def __init__(self, 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()
@property
def plugin(self):
if not self._core_plugin:
self._core_plugin = directory.get_plugin()
if self._core_plugin.is_tvd_plugin() is True:
# get the plugin that match this driver
self._core_plugin = self.get_project_plugin(
self._core_plugin)
return self._core_plugin
@abc.abstractmethod
def get_name(self):
@ -43,3 +55,7 @@ class BaseJob(object):
@abc.abstractmethod
def run(self, context):
pass
@abc.abstractmethod
def get_project_plugin(self, plugin):
pass

View File

@ -685,3 +685,23 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
"""
plugin_type = self.get_plugin_type_from_project(context, project_id)
return self.plugins[plugin_type]
def get_housekeeper(self, context, name, fields=None):
p = self._get_plugin_from_project(context, context.project_id)
if hasattr(p, 'housekeeper'):
return p.housekeeper.get(name)
msg = _("Housekeeper %s not found") % name
raise nsx_exc.NsxPluginException(err_msg=msg)
def get_housekeepers(self, context, filters=None, fields=None, sorts=None,
limit=None, marker=None, page_reverse=False):
p = self._get_plugin_from_project(context, context.project_id)
if hasattr(p, 'housekeeper'):
return p.housekeeper.list()
return []
def update_housekeeper(self, context, name, housekeeper):
p = self._get_plugin_from_project(context, context.project_id)
if hasattr(p, 'housekeeper'):
p.housekeeper.run(context, name)
return p.housekeeper.get(name)

View File

@ -20,6 +20,7 @@ from sqlalchemy.orm import exc as sa_exc
from vmware_nsx.common import locking
from vmware_nsx.common import nsxv_constants
from vmware_nsx.db import nsxv_db
from vmware_nsx.extensions import projectpluginmap
from vmware_nsx.plugins.common.housekeeper import base_job
from vmware_nsx.plugins.nsx_v import availability_zones as nsx_az
from vmware_nsx.plugins.nsx_v.vshield.common import constants as vcns_const
@ -32,6 +33,9 @@ class ErrorBackupEdgeJob(base_job.BaseJob):
super(ErrorBackupEdgeJob, self).__init__(readonly)
self.azs = nsx_az.NsxVAvailabilityZones()
def get_project_plugin(self, plugin):
return plugin.get_plugin_by_type(projectpluginmap.NsxPlugins.NSX_V)
def get_name(self):
return 'error_backup_edge'

View File

@ -19,6 +19,7 @@ from oslo_utils import uuidutils
from vmware_nsx.common import locking
from vmware_nsx.db import nsxv_db
from vmware_nsx.extensions import projectpluginmap
from vmware_nsx.plugins.common.housekeeper import base_job
from vmware_nsx.plugins.nsx_v.vshield.common import constants as vcns_const
@ -26,6 +27,10 @@ LOG = log.getLogger(__name__)
class ErrorDhcpEdgeJob(base_job.BaseJob):
def get_project_plugin(self, plugin):
return plugin.get_plugin_by_type(projectpluginmap.NsxPlugins.NSX_V)
def get_name(self):
return 'error_dhcp_edge'