-#!/usr/bin/python3
# ============LICENSE_START===============================================
# Copyright (C) 2020 Nordix Foundation. All rights reserved.
# ========================================================================
import fileinput
import json
import sys
+import os
+import maincommon
+
+from pathlib import Path
from flask import Flask, escape, request, make_response
from jsonschema import validate
from var_declaration import policy_instances, policy_types, policy_status, policy_type_per_instance
+from maincommon import *
+
+
+check_apipath()
-app = connexion.App(__name__, specification_dir='.')
+app = connexion.App(__name__, specification_dir=apipath)
@app.route('/policytypes/<string:policyTypeId>', methods=['PUT','DELETE'])
def policy_type(policyTypeId):
@app.route('/counter/<string:countername>', methods=['GET'])
def getCounter(countername):
if (countername == "num_instances"):
- return str(len(policy_instances)),200
+ return str(len(policy_instances)),200
elif (countername == "num_types"):
- return str(len(policy_types)),200
+ return str(len(policy_types)),200
+ elif (countername == "interface"):
+ p=Path(os.getcwd())
+ pp=p.parts
+ return str(pp[len(pp)-1]),200
else:
- return "Counter name: "+countername+" not found.",404
+ return "Counter name: "+countername+" not found.",404
port_number = 8085
if isinstance(sys.argv[1], int):
port_number = sys.argv[1]
-app.add_api('../a1-openapi.yaml')
+app.add_api('a1-openapi.yaml')
app.run(port=port_number)