Commit 07759b7d authored by Carlos Natalino's avatar Carlos Natalino
Browse files

Merging changes from Lluis and adding a few cosmetic changes to the WebUI.

parents b4612ca5 081237d7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -18,8 +18,8 @@

K8S_NAMESPACE=${K8S_NAMESPACE:-'tf-dev'}

GRAFANA_IP=`kubectl get service/webuiservice -n ${K8S_NAMESPACE} -o jsonpath='{.spec.clusterIP}'`
GRAFANA_PORT=`kubectl get service/webuiservice -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[1].port}'`
GRAFANA_IP=$(kubectl get service/webuiservice -n ${K8S_NAMESPACE} -o jsonpath='{.spec.clusterIP}')
GRAFANA_PORT=$(kubectl get service webuiservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}')
URL=http://${GRAFANA_IP}:${GRAFANA_PORT}

echo Opening Dashboard on URL ${URL}
+9 −12
Original line number Diff line number Diff line
@@ -16,23 +16,20 @@

K8S_NAMESPACE=${K8S_NAMESPACE:-'tf-dev'}

WEBUI_SERVICE_NAME="service/webuiservice-public"
WEBUI_PROTO=`kubectl get ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[0].name}'`
WEBUI_IP=`kubectl get ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.clusterIP}'`
WEBUI_PORT=`kubectl get ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[0].port}'`
GRAFANA_PORT=`kubectl get ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[1].port}'`
URL=${WEBUI_PROTO}://${WEBUI_IP}:${WEBUI_PORT}
WEBUI_SERVICE_NAME="webuiservice-public"
WEBUI_PROTO=`kubectl get service ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[0].name}'`
WEBUI_IP=`kubectl get service ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.clusterIP}'`
WEBUI_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8004)].nodePort}')
GRAFANA_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}')

# Open WebUI
URL=${WEBUI_PROTO}://${WEBUI_IP}:${WEBUI_PORT}
echo Opening web UI on URL ${URL}

# curl -kL ${URL}

python3 -m webbrowser ${URL}

# Open Dashboard
URL=${WEBUI_PROTO}://${WEBUI_IP}:${GRAFANA_PORT}

echo Opening web UI on URL ${URL}

echo Opening Dashboard on URL ${URL}
# curl -kL ${URL}

python3 -m webbrowser ${URL}
+9 −4
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ from device.service.driver_api.Exceptions import UnsupportedResourceKeyException
from device.service.driver_api._Driver import _Driver
from device.service.driver_api.AnyTreeTools import TreeNode, dump_subtree, get_subnode, set_subnode_value
from device.service.drivers.openconfig.Tools import xml_pretty_print, xml_to_dict, xml_to_file
from device.service.drivers.openconfig.templates import ALL_RESOURCE_KEYS, compose_config, get_filter, parse
from device.service.drivers.openconfig.templates import ALL_RESOURCE_KEYS, EMPTY_CONFIG, compose_config, get_filter, parse

DEBUG_MODE = False
#logging.getLogger('ncclient.transport.ssh').setLevel(logging.DEBUG if DEBUG_MODE else logging.WARNING)
@@ -180,7 +180,9 @@ class OpenConfigDriver(_Driver):
                    chk_string(str_resource_name + '.key', resource_key, allow_empty=False)
                    str_config_message = compose_config(resource_key, resource_value)
                    if str_config_message is None: raise UnsupportedResourceKeyException(resource_key)
                    LOGGER.info('[SetConfig] str_config_message = {:s}'.format(str(str_config_message)))
                    LOGGER.info('[SetConfig] str_config_message[{:d}] = {:s}'.format(
                        len(str_config_message), str(str_config_message)))
                    if str_config_message != EMPTY_CONFIG:
                        self.__netconf_manager.edit_config(str_config_message, target='running')
                    results.append(True)
                except Exception as e: # pylint: disable=broad-except
@@ -204,7 +206,10 @@ class OpenConfigDriver(_Driver):
                    chk_string(str_resource_name + '.key', resource_key, allow_empty=False)
                    str_config_message = compose_config(resource_key, resource_value, delete=True)
                    if str_config_message is None: raise UnsupportedResourceKeyException(resource_key)
                    LOGGER.info('[DeleteConfig] str_config_message = {:s}'.format(str(str_config_message)))
                    LOGGER.info('[DeleteConfig] str_config_message[{:d}] = {:s}'.format(
                        len(str_config_message), str(str_config_message)))
                    if str_config_message != EMPTY_CONFIG:
                        self.__netconf_manager.edit_config(str_config_message, target='running')
                    self.__netconf_manager.edit_config(str_config_message, target='running')
                    results.append(True)
                except Exception as e: # pylint: disable=broad-except
+4 −2
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ RESOURCE_PARSERS = {
LOGGER = logging.getLogger(__name__)
RE_REMOVE_FILTERS = re.compile(r'\[[^\]]+\]')
RE_REMOVE_FILTERS_2 = re.compile(r'\/[a-z]+:')
EMPTY_CONFIG = '<config></config>'
EMPTY_FILTER = '<filter></filter>'
JINJA_ENV = Environment(loader=PackageLoader('device.service.drivers.openconfig'), autoescape=select_autoescape())

def get_filter(resource_key : str):
@@ -51,7 +53,7 @@ def get_filter(resource_key : str):
    resource_key = resource_key.replace('//', '')
    template_name = '{:s}/get.xml'.format(resource_key)
    template = JINJA_ENV.get_template(template_name)
    return '<filter>{:s}</filter>'.format(template.render())
    return '<filter>{:s}</filter>'.format(template.render().strip())

def parse(resource_key : str, xml_data : ET.Element):
    resource_key = RESOURCE_KEY_MAPPINGS.get(resource_key, resource_key)
@@ -71,4 +73,4 @@ def compose_config(resource_key : str, resource_value : str, delete : bool = Fal
    template = JINJA_ENV.get_template(template_name)
    data : Dict[str, Any] = json.loads(resource_value)
    operation = 'delete' if delete else 'merge'
    return '<config>{:s}</config>'.format(template.render(**data, operation=operation))
    return '<config>{:s}</config>'.format(template.render(**data, operation=operation).strip())
+1 −0
Original line number Diff line number Diff line
@@ -17,3 +17,4 @@
        {% endif %}
    </network-instance>
</network-instances>
Loading