Merge "Re-factor Application class use of is_system_app"
This commit is contained in:
commit
32dc0ce0b4
|
@ -1887,11 +1887,6 @@ class AppOperator(object):
|
||||||
LOG.error("Application rollback aborted!")
|
LOG.error("Application rollback aborted!")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _is_system_app(self, name):
|
|
||||||
if name in self._helm.get_helm_applications():
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def perform_app_upload(self, rpc_app, tarfile):
|
def perform_app_upload(self, rpc_app, tarfile):
|
||||||
"""Process application upload request
|
"""Process application upload request
|
||||||
|
|
||||||
|
@ -1904,8 +1899,7 @@ class AppOperator(object):
|
||||||
:param tarfile: location of application tarfile
|
:param tarfile: location of application tarfile
|
||||||
"""
|
"""
|
||||||
|
|
||||||
app = AppOperator.Application(rpc_app,
|
app = AppOperator.Application(rpc_app)
|
||||||
self._is_system_app(rpc_app.get('name')))
|
|
||||||
LOG.info("Application %s (%s) upload started." % (app.name, app.version))
|
LOG.info("Application %s (%s) upload started." % (app.name, app.version))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -2078,8 +2072,7 @@ class AppOperator(object):
|
||||||
:return boolean: whether application apply was successful
|
:return boolean: whether application apply was successful
|
||||||
"""
|
"""
|
||||||
|
|
||||||
app = AppOperator.Application(rpc_app,
|
app = AppOperator.Application(rpc_app)
|
||||||
self._is_system_app(rpc_app.get('name')))
|
|
||||||
|
|
||||||
# If apply is called from update method, the app's abort status has
|
# If apply is called from update method, the app's abort status has
|
||||||
# already been registered.
|
# already been registered.
|
||||||
|
@ -2250,10 +2243,8 @@ class AppOperator(object):
|
||||||
:param reuse_user_overrides: (optional) True or False
|
:param reuse_user_overrides: (optional) True or False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from_app = AppOperator.Application(from_rpc_app,
|
from_app = AppOperator.Application(from_rpc_app)
|
||||||
from_rpc_app.get('name') in self._helm.get_helm_applications())
|
to_app = AppOperator.Application(to_rpc_app)
|
||||||
to_app = AppOperator.Application(to_rpc_app,
|
|
||||||
to_rpc_app.get('name') in self._helm.get_helm_applications())
|
|
||||||
|
|
||||||
self._register_app_abort(to_app.name)
|
self._register_app_abort(to_app.name)
|
||||||
self._raise_app_alarm(to_app.name, constants.APP_UPDATE_IN_PROGRESS,
|
self._raise_app_alarm(to_app.name, constants.APP_UPDATE_IN_PROGRESS,
|
||||||
|
@ -2354,8 +2345,7 @@ class AppOperator(object):
|
||||||
:return boolean: whether application remove was successful
|
:return boolean: whether application remove was successful
|
||||||
"""
|
"""
|
||||||
|
|
||||||
app = AppOperator.Application(rpc_app,
|
app = AppOperator.Application(rpc_app)
|
||||||
rpc_app.get('name') in self._helm.get_helm_applications())
|
|
||||||
self._register_app_abort(app.name)
|
self._register_app_abort(app.name)
|
||||||
|
|
||||||
self.clear_reapply(app.name)
|
self.clear_reapply(app.name)
|
||||||
|
@ -2410,29 +2400,21 @@ class AppOperator(object):
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
def activate(self, rpc_app):
|
def activate(self, rpc_app):
|
||||||
app = AppOperator.Application(
|
app = AppOperator.Application(rpc_app)
|
||||||
rpc_app,
|
|
||||||
rpc_app.get('name') in self._helm.get_helm_applications())
|
|
||||||
with self._lock:
|
with self._lock:
|
||||||
return app.update_active(True)
|
return app.update_active(True)
|
||||||
|
|
||||||
def deactivate(self, rpc_app):
|
def deactivate(self, rpc_app):
|
||||||
app = AppOperator.Application(
|
app = AppOperator.Application(rpc_app)
|
||||||
rpc_app,
|
|
||||||
rpc_app.get('name') in self._helm.get_helm_applications())
|
|
||||||
with self._lock:
|
with self._lock:
|
||||||
return app.update_active(False)
|
return app.update_active(False)
|
||||||
|
|
||||||
def get_appname(self, rpc_app):
|
def get_appname(self, rpc_app):
|
||||||
app = AppOperator.Application(
|
app = AppOperator.Application(rpc_app)
|
||||||
rpc_app,
|
|
||||||
rpc_app.get('name') in self._helm.get_helm_applications())
|
|
||||||
return app.name
|
return app.name
|
||||||
|
|
||||||
def is_app_active(self, rpc_app):
|
def is_app_active(self, rpc_app):
|
||||||
app = AppOperator.Application(
|
app = AppOperator.Application(rpc_app)
|
||||||
rpc_app,
|
|
||||||
rpc_app.get('name') in self._helm.get_helm_applications())
|
|
||||||
return app.active
|
return app.active
|
||||||
|
|
||||||
def perform_app_abort(self, rpc_app):
|
def perform_app_abort(self, rpc_app):
|
||||||
|
@ -2449,8 +2431,7 @@ class AppOperator(object):
|
||||||
:param rpc_app: application object in the RPC request
|
:param rpc_app: application object in the RPC request
|
||||||
"""
|
"""
|
||||||
|
|
||||||
app = AppOperator.Application(rpc_app,
|
app = AppOperator.Application(rpc_app)
|
||||||
rpc_app.get('name') in self._helm.get_helm_applications())
|
|
||||||
|
|
||||||
# Retrieve the latest app status from the database
|
# Retrieve the latest app status from the database
|
||||||
db_app = self._dbapi.kube_app_get(app.name)
|
db_app = self._dbapi.kube_app_get(app.name)
|
||||||
|
@ -2481,8 +2462,7 @@ class AppOperator(object):
|
||||||
:param rpc_app: application object in the RPC request
|
:param rpc_app: application object in the RPC request
|
||||||
"""
|
"""
|
||||||
|
|
||||||
app = AppOperator.Application(rpc_app,
|
app = AppOperator.Application(rpc_app)
|
||||||
rpc_app.get('name') in self._helm.get_helm_applications())
|
|
||||||
try:
|
try:
|
||||||
self._dbapi.kube_app_destroy(app.name)
|
self._dbapi.kube_app_destroy(app.name)
|
||||||
self._cleanup(app)
|
self._cleanup(app)
|
||||||
|
@ -2505,11 +2485,9 @@ class AppOperator(object):
|
||||||
support application related operations.
|
support application related operations.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, rpc_app, is_system_app):
|
def __init__(self, rpc_app):
|
||||||
self._kube_app = rpc_app
|
self._kube_app = rpc_app
|
||||||
|
|
||||||
self.system_app = is_system_app
|
|
||||||
|
|
||||||
self.tarfile = None
|
self.tarfile = None
|
||||||
self.downloaded_tarfile = False
|
self.downloaded_tarfile = False
|
||||||
|
|
||||||
|
@ -2558,6 +2536,17 @@ class AppOperator(object):
|
||||||
self.charts = []
|
self.charts = []
|
||||||
self.releases = []
|
self.releases = []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def system_app(self):
|
||||||
|
# TODO(rchurch): This will be refactored as plugins become bundled
|
||||||
|
# with applications. A system app can be determined if it has any
|
||||||
|
# installed plugins after being uploaded.
|
||||||
|
return ((self.name == constants.HELM_APP_OPENSTACK or
|
||||||
|
self.name == constants.HELM_APP_MONITOR or
|
||||||
|
self.name == constants.HELM_APP_PLATFORM) or
|
||||||
|
(True if (os.path.exists(self.sync_plugins_dir) and
|
||||||
|
os.listdir(self.sync_plugins_dir)) else False))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._kube_app.get('name')
|
return self._kube_app.get('name')
|
||||||
|
@ -2608,9 +2597,6 @@ class AppOperator(object):
|
||||||
def regenerate_application_info(self, new_name, new_version, new_patch_dependencies):
|
def regenerate_application_info(self, new_name, new_version, new_patch_dependencies):
|
||||||
self._kube_app.name = new_name
|
self._kube_app.name = new_name
|
||||||
self._kube_app.app_version = new_version
|
self._kube_app.app_version = new_version
|
||||||
self.system_app = \
|
|
||||||
(self.name == constants.HELM_APP_OPENSTACK or
|
|
||||||
self.name == constants.HELM_APP_MONITOR)
|
|
||||||
|
|
||||||
new_armada_dir = cutils.generate_synced_armada_dir(
|
new_armada_dir = cutils.generate_synced_armada_dir(
|
||||||
self.name, self.version)
|
self.name, self.version)
|
||||||
|
|
|
@ -10415,7 +10415,8 @@ class ConductorManager(service.PeriodicService):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
app = kubeapp_obj.get_by_name(context, app_name)
|
app = kubeapp_obj.get_by_name(context, app_name)
|
||||||
app = self._app.Application(app, True)
|
app = self._app.Application(app)
|
||||||
|
|
||||||
except exception.KubeAppNotFound:
|
except exception.KubeAppNotFound:
|
||||||
return
|
return
|
||||||
if app.status == constants.APP_APPLY_SUCCESS:
|
if app.status == constants.APP_APPLY_SUCCESS:
|
||||||
|
|
Loading…
Reference in New Issue