class get_bst_thresholds_api_ct(object):

    def __init__(self,ip,port,params="",debug=False):
        self.obj = BstRestService(ip,port)
        self.debug = debug
        self.params = params

    def step1(self,jsonData):
        """Get BST Thresholds"""
        try:
            resp = self.obj.postResponse(jsonData)
            if resp[0] == "INVALID":
                return "FAIL","Connection refused/Invalid JSON request... Please check the ip address provided in 'ini' file/BroadViewAgent is running or not/JSON data is valid or not ..."
        except Exception,e:
            return "FAIL","Unable to perform the rest call with given JSON data, Occured Exception ... "+str(e)

        try:
            self.obj.debugJsonPrint(self.debug,jsonData,resp)
        except:
            return "FAIL","Invalid JSON Response data received"

        if returnStatus(resp[0], 200)[0] == "FAIL": return "FAIL","Obtained {0}".format(resp[0])
        if not resp[1]: return "FAIL","Got null response"
        resp_ = resp[1].replace('Content-Type: text/json', '')
        data_dict = json.loads(resp_)
        if not "report" in data_dict: return "FAIL","No Report key in Response JSON Data"
        result = data_dict['report']
        realms = [ r['realm'] for r in result if 'data' in r and 'realm' in r ]
        jsonDict = json.loads(jsonData)
        paramsDict=jsonDict['params']
        plist = [ k.replace('include-', '') for k, v in paramsDict.items() if v == 1 ]
        msg="Expected realm(s) " + " ".join(plist) + " not present"
        return returnStatus(sorted(plist),sorted(realms),"",msg)
class get_bst_feature_api_ct(object):
    def __init__(self, ip, port, params="", debug=False):
        self.obj = BstRestService(ip, port)
        self.debug = debug
        self.params = params

    def step1(self, jsonData):
        """Get BST Feature Status"""
        try:
            resp = self.obj.postResponse(jsonData)
            if resp[0] == "INVALID":
                return "FAIL", "Connection refused/Invalid JSON request... Please check the ip address provided in 'ini' file/BroadViewAgent is running or not/JSON data is valid or not ..."
        except Exception, e:
            return "FAIL", "Unable to perform the rest call with given JSON data, Occured Exception ... " + str(
                e)

        try:
            self.obj.debugJsonPrint(self.debug, jsonData, resp)
        except:
            return "FAIL", "Invalid JSON Response data received"

        if returnStatus(resp[0], 200)[0] == "FAIL":
            return "FAIL", "Obtained {0}".format(resp[0])
        if not resp[1]: return "FAIL", "Got null response"
        resp_ = resp[1].replace('Content-Type: text/json', '')
        data_dict = json.loads(resp_)
        if not "result" in data_dict:
            return "FAIL", "No Result key in Response JSON Data"
        result = data_dict['result']
        plist = self.params.split(",")
        plist = [p.strip() for p in plist]
        return returnStatus(
            sorted(plist), sorted(result.keys()), "",
            "get_bst_feature params lists contains invalid param keys")
예제 #3
0
class configure_bst_tracking_api_ct(object):
    def __init__(self, ip, port, params="", debug=False):
        self.obj = BstRestService(ip, port)
        self.debug = debug
        self.params = params

    def step1(self, jsonData):
        """Configure BST tracking"""
        try:
            resp = self.obj.postResponse(jsonData)
            if resp[0] == "INVALID":
                return "FAIL", "Connection refused/Invalid JSON request... Please check the ip address provided in 'ini' file/BroadViewAgent is running or not/JSON data is valid or not ..."
        except Exception, e:
            return "FAIL", "Unable to perform the rest call with given JSON data, Occured Exception ... " + str(
                e)

        try:
            self.obj.debugJsonPrint(self.debug, jsonData, resp)
        except:
            return "FAIL", "Invalid JSON Response data received"

        self.nextStepCheckParams = jsonData
        if returnStatus(resp[0], 200)[0] == "FAIL":
            return "FAIL", "Obtained {0}".format(resp[0])
        return returnStatus(
            resp[0], 200, "",
            "Unable to get the 200 OK response, got reponse " + str(resp[0]))
class get_bst_thresholds_api_ct(object):

    def __init__(self,ip,port,params="",debug=False):
        self.obj = BstRestService(ip,port)
        self.debug = debug
        self.params = params

    def step1(self,jsonData):
        """Get BST Thresholds"""
        try:
            resp = self.obj.postResponse(jsonData)
            if resp[0] == "INVALID":
                return "FAIL","Connection refused/Invalid JSON request... Please check the ip address provided in 'ini' file/BroadViewAgent is running or not/JSON data is valid or not ..."
        except Exception,e:
            return "FAIL","Unable to perform the rest call with given JSON data, Occured Exception ... "+str(e)

        try:
            self.obj.debugJsonPrint(self.debug,jsonData,resp)
        except:
            return "FAIL","Invalid JSON Response data received"

        if returnStatus(resp[0], 200)[0] == "FAIL": return "FAIL","Obtained {0}".format(resp[0])
        if not resp[1]: return "FAIL","Got null response"
        resp_ = resp[1].replace('Content-Type: text/json', '')
        data_dict = json.loads(resp_)
        if not "report" in data_dict: return "FAIL","No Report key in Response JSON Data"
        result = data_dict['report']
        realms = [ r['realm'] for r in result if 'data' in r and 'realm' in r ]
        jsonDict = json.loads(jsonData)
        paramsDict=jsonDict['params']
        plist = [ k.replace('include-', '') for k, v in paramsDict.items() if v == 1 ]
        msg="Expected realm(s) " + " ".join(plist) + " not present"
        return returnStatus(sorted(plist),sorted(realms),"",msg)
class configure_bst_feature_api_ct(object):

    def __init__(self,ip,port,params="",debug=False):
        self.obj = BstRestService(ip,port)
        self.debug = debug
        self.params = params

    def step1(self,jsonData):
        """Configure BST feature"""
        try:
            pprint.pprint(jsonData)
            resp = self.obj.postResponse(jsonData)
            if resp[0] == "INVALID":
                return "FAIL","Connection refused/Invalid JSON request... Please check the ip address provided in 'ini' file/BroadViewAgent is running or not/JSON data is valid or not ..."
        except Exception,e:
            return "FAIL","Unable to perform the rest call with given JSON data, Occured Exception ... "+str(e)

        try:
            self.obj.debugJsonPrint(self.debug,jsonData,resp)
        except:
            return "FAIL","Invalid JSON Response data received"

        self.nextStepCheckParams=jsonData
        if returnStatus(resp[0], 200)[0] == "FAIL": return "FAIL","Obtained {0}".format(resp[0])
        return returnStatus(resp[0], 200,"","Unable to get the 200 OK response, got reponse "+str(resp[0]))
class get_bst_feature_api_ct(object):
    def __init__(self, ip, port, params="", debug=False):
        self.obj = BstRestService(ip, port)
        self.debug = debug
        self.params = params

    def step1(self, jsonData):
        """Get BST Feature Status"""
        try:
            resp = self.obj.postResponse(jsonData)
            if resp[0] == "INVALID":
                return (
                    "FAIL",
                    "Connection refused/Invalid JSON request... Please check the ip address provided in 'ini' file/BroadViewAgent is running or not/JSON data is valid or not ...",
                )
        except Exception, e:
            return "FAIL", "Unable to perform the rest call with given JSON data, Occured Exception ... " + str(e)

        try:
            self.obj.debugJsonPrint(self.debug, jsonData, resp)
        except:
            return "FAIL", "Invalid JSON Response data received"

        if returnStatus(resp[0], 200)[0] == "FAIL":
            return "FAIL", "Obtained {0}".format(resp[0])
        if not resp[1]:
            return "FAIL", "Got null response"
        resp_ = resp[1].replace("Content-Type: text/json", "")
        data_dict = json.loads(resp_)
        if not "result" in data_dict:
            return "FAIL", "No Result key in Response JSON Data"
        result = data_dict["result"]
        plist = self.params.split(",")
        plist = [p.strip() for p in plist]
        return returnStatus(
            sorted(plist), sorted(result.keys()), "", "get_bst_feature params lists contains invalid param keys"
        )
 def __init__(self, ip, port, params="", debug=False):
     self.obj = BstRestService(ip, port)
     self.debug = debug
     self.params = params
 def __init__(self,ip,port,params="",debug=False):
     self.obj = BstRestService(ip,port)
     self.debug = debug
     self.params = params