Esempio n. 1
0
    def get_loadbalancer_objects_from_request(self, req):

        dict_obj = Utils.get_dictionary_from_request(req, self.request_format)

        dict_keys = dict_obj.keys()

        if "loadBalancers" in dict_keys:
            state = dict_obj["loadBalancers"]
            loadbalancers = self.get_loadbalancer_objects_from_dictionary(
                state)
            return loadbalancers

        elif "loadBalancer" in dict_keys:
            state = dict_obj["loadBalancer"]
            loadbalancer = self.get_loadbalancer_object_from_dictionary(state)
            return loadbalancer

        else:
            self.logger.debug(
                "Bad Request: The root element in the request is neither \"loadBalancers\", nor \"loadBalancer\""
            )
            raise BadRequestException(
                "Validation fault", "the object is not valid",
                "malformed request body. object to add is not one loadBalancer or a list of loadBalancers"
            )
Esempio n. 2
0
    def get_lbhealthmonitor_object_from_request(self, req):
        dict_obj = Utils.get_dictionary_from_request(req, self.request_format)

        if not isinstance(dict_obj, dict):
            self.logger.debug(
                "Bad Request: The root element is not a dictionary")
            raise BadRequestException("Validation fault",
                                      "the object is not valid",
                                      "malformed request body.")

        dict_keys = dict_obj.keys()

        if "healthMonitor" in dict_keys:
            state = dict_obj["healthMonitor"]
            lbhealthmonitor = self.get_lbhealthmonitor_object_from_dictionary(
                state)
            return lbhealthmonitor

        else:
            self.logger.debug(
                "Bad Request: The root element in the request is not \"healthMonitor\""
            )
            raise BadRequestException(
                "Validation fault", "the object is not valid",
                "malformed request body. expecting a healthMonitor object")
Esempio n. 3
0
    def get_lbnode_objects_from_request(self, req):

        dict_obj = Utils.get_dictionary_from_request(req, self.request_format)

        dict_keys = dict_obj.keys()

        if "nodes" in dict_keys:
            state = dict_obj["nodes"]
            lbnodes = self.get_lbnode_objects_from_dictionary(state)
            return lbnodes

        elif "node" in dict_keys:
            state = dict_obj["node"]
            lbnode = self.get_lbnode_object_from_dictionary(state)
            return lbnode

        else:
            self.logger.debug(
                "Bad Request: The root element in the request is neither \"loadBalancers\", nor \"loadBalancer\""
            )
            raise BadRequestException("Validation fault",
                                      "the object is not valid",
                                      "malformed request body.")