Add fetching of qe deployments in config tool
This commit is contained in:
parent
2c61c87712
commit
3d4e43c8d1
24 changed files with 484 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
import logging
|
||||
|
||||
from flask import Blueprint, request
|
||||
from flask import Blueprint, request, abort
|
||||
from flask_restful import Resource, Api
|
||||
from flask_restful.utils.cors import crossdomain
|
||||
from email.utils import formatdate
|
||||
|
@ -8,7 +8,7 @@ from calendar import timegm
|
|||
from functools import partial, wraps
|
||||
from jsonschema import validate, ValidationError
|
||||
|
||||
from config_app.c_app import app
|
||||
from config_app.c_app import app, IS_KUBERNETES
|
||||
from config_app.config_endpoints.exception import InvalidResponse, InvalidRequest
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -128,6 +128,14 @@ def validate_json_request(schema_name, optional=False):
|
|||
return wrapped
|
||||
return wrapper
|
||||
|
||||
def kubernetes_only(f):
|
||||
@wraps(f)
|
||||
def abort_if_not_kube(*args, **kwargs):
|
||||
if not IS_KUBERNETES:
|
||||
abort(400)
|
||||
|
||||
return f(*args, **kwargs)
|
||||
return abort_if_not_kube
|
||||
|
||||
nickname = partial(add_method_metadata, 'nickname')
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@ import logging
|
|||
from flask import abort, request
|
||||
|
||||
from config_app.config_endpoints.api.suconfig_models_pre_oci import pre_oci_model as model
|
||||
from config_app.config_endpoints.api import resource, ApiResource, nickname, validate_json_request
|
||||
from config_app.config_endpoints.api import resource, ApiResource, nickname, validate_json_request, kubernetes_only
|
||||
from config_app.c_app import (app, config_provider, superusers, ip_resolver,
|
||||
instance_keys, INIT_SCRIPTS_LOCATION)
|
||||
instance_keys, INIT_SCRIPTS_LOCATION, IS_KUBERNETES)
|
||||
from config_app.config_util.k8sinterface import KubernetesAccessInterface
|
||||
|
||||
from data.database import configure
|
||||
from data.runmigration import run_alembic_migration
|
||||
|
@ -259,6 +260,24 @@ class SuperUserConfigValidate(ApiResource):
|
|||
return validate_service_for_config(service, validator_context)
|
||||
|
||||
|
||||
@resource('/v1/kubernetes/deployments/')
|
||||
class SuperUserKubernetesDeployment(ApiResource):
|
||||
""" Resource for fetching the status of config files and overriding them. """
|
||||
@kubernetes_only
|
||||
@nickname('scGetNumDeployments')
|
||||
def get(self):
|
||||
accessor = KubernetesAccessInterface()
|
||||
res = accessor.get_num_qe_pods()
|
||||
return res
|
||||
|
||||
@resource('/v1/superuser/config/kubernetes')
|
||||
class SuperUserKubernetesConfiguration(ApiResource):
|
||||
""" Resource for fetching the status of config files and overriding them. """
|
||||
@kubernetes_only
|
||||
@nickname('scSaveConfigToKube')
|
||||
def post(self):
|
||||
return config_provider.save_configuration_to_kubernetes()
|
||||
|
||||
|
||||
@resource('/v1/superuser/config/file/<filename>')
|
||||
class SuperUserConfigFile(ApiResource):
|
||||
|
|
Reference in a new issue