def _adjust_lbvserver_state_for_update(self, loadBalancerId, new_state):
        """ First, we'll get from Netscaler the current lbvserver state """
        """ XXX - In Netscaler, we haven't got IDs for resources so our assumption: loadBalancerId == loadBalancer.name """

        resource_type = "lbvserver"
        resource_name = NitroUtils.get_lbvservername_from_loadbalancerid(
            loadBalancerId)

        self.logger.debug(
            "adjusting the lbvserver state to submit for an update operation. For this we need to get the existing lbvserver"
        )
        current_state = self.nitrowrapper.get_netscaler_entity(
            resource_type, resource_name)

        if "servicetype" in new_state.keys():
            if new_state["servicetype"] != current_state["servicetype"]:
                """ XXX - Netscaler doesn't support changing the servicetype of an lbvserver. """
                raise NotImplementedException(
                    "Sorry, changing the protocol of the loadBalancer in the current implementation is not supported."
                )

            else:
                """ Just remove it since it is the same """
                del new_state["servicetype"]

        if "port" in new_state.keys():
            if type(current_state["port"]) is int:
                new_state["port"] = int(new_state["port"])

            if new_state["port"] != current_state["port"]:
                """ XXX - Netscaler doesn't support changing the port of an lbvserver. """
                raise NotImplementedException(
                    "Sorry, changing the port of the loadBalancer in the current implementation is not supported."
                )

            else:
                del new_state["port"]

        if "lbmethod" in new_state.keys():
            if new_state["lbmethod"] == current_state["lbmethod"]:
                del new_state["lbmethod"]

        if self.extensions_enabled:
            """ XXX - Also check for extended properties in the new_state dictionary """


        self.logger.debug("Adjusted state for Updating lbvserver %s is: %s" %
                          (resource_name, str(new_state)))

        return new_state
    def _netscaler_check_can_rename_entity(self, entitytype):

        if entitytype == "lbvserver":
            return

        if entitytype == "service":
            return

        """ XXX - TODO: We need to check all the entities that we can rename
                  and add them here
        """

        raise NotImplementedException("Sorry, renaming of some objects is currently not supported")
    def _get_netscaler_addconnectionthrottle_tasks(self,
                                                   loadBalancerId,
                                                   loadBalancer,
                                                   newLoadBalancerId=None):

        task_list = []

        if not "connectionThrottle" in loadBalancer:
            return task_list

        raise NotImplementedException(
            "connectionThrottle property is not currently supported for loadBalancer."
        )
    def _allocate_loadBalancer_vips(self, loadBalancer, tenant_id,
                                    loadBalancerId):

        if not loadBalancer.virtualIps:
            raise BadRequestException("validation fault",
                                      "object is not valid",
                                      "No virtual IP field specified.")

        if len(loadBalancer.virtualIps) > 1:
            raise NotImplementedException(
                "Not Implemented. " +
                "Sorry, this loadBalancer service currently allow only for one virtual Ip per loadBalancer"
            )

        for virtualIP in loadBalancer.virtualIps:
            self._allocate_loadBalancer_vip(virtualIP, tenant_id,
                                            loadBalancerId)
Example #5
0
    def get_lbmethod_from_algorithm(algorithm):

        if algorithm == "LEAST_CONNECTIONS":
            return "LEASTCONNECTION"

        if algorithm == "WEIGHTED_LEAST_CONNECTIONS":
            return "LEASTCONNECTION"

        if algorithm == "ROUND_ROBIN":
            return "ROUNDROBIN"

        if algorithm == "WEIGHTED_ROUND_ROBIN":
            return "ROUNDROBIN"

        if algorithm == "RANDOM":
            raise NotImplementedException(
                "Sorry, this loadBalancer service currently doesn't implement the LB algorithm %s"
                % algorithm)
        """ We should never get another lbmethod than the above values """
        raise ImplementationErrorException("programming error")
Example #6
0
    def get_servicetype_from_protocol(protocol):

        protocol = protocol.upper()

        if protocol == "HTTP":
            return "HTTP"

        if protocol == "HTTPS":
            return "SSL"

        if protocol == "FTP":
            return "FTP"

        if protocol == "SMTP":
            return "TCP"

        if protocol == "POP3":
            return "TCP"

        if protocol == "IMAPv4":
            return "TCP"

        if protocol == "LDAP":
            return "TCP"

        if protocol == "TCP":
            return "TCP"

        if protocol == "POPS":
            return "TCP-SSL"

        if protocol == "IMAPS":
            return "TCP-SSL"

        if protocol == "LDAPS":
            return "TCP-SSL"

        raise NotImplementedException(
            "Sorry, this protocol is not implemented")
Example #7
0
    def get_entity_payload_from_dictobj(resource_type, resource_state):

        if resource_type == "lbvserver":
            return NitroUtils._get_lbvserver_payload_from_dictobj(
                resource_state)

        if resource_type == "service":
            return NitroUtils._get_service_payload_from_dictobj(resource_state)

        if resource_type == "lbvserver_service_binding":
            return NitroUtils._get_servicebinding_payload_from_dictobj(
                resource_state)

        if resource_type == "lbmonitor":
            return NitroUtils._get_monitor_payload_from_dictobj(resource_state)

        if resource_type == "lbmonitor_service_binding":
            return NitroUtils._get_monitorbinding_payload_from_dictobj(
                resource_state)

        raise NotImplementedException(
            "Adding some entities is not supported yet through this API.")