Ejemplo n.º 1
0
class DriverError(Exception):
    """Catch all exception that drivers can raise.

    This exception includes two strings: The user fault string and the
    optional operator fault string. The user fault string,
    "user_fault_string", will be provided to the API requester. The operator
    fault string, "operator_fault_string",  will be logged in the Octavia API
    log file for the operator to use when debugging.

    :param user_fault_string: String provided to the API requester.
    :type user_fault_string: string
    :param operator_fault_string: Optional string logged by the Octavia API
      for the operator to use when debugging.
    :type operator_fault_string: string
    """
    user_fault_string = _("An unknown driver error occurred.")
    operator_fault_string = _("An unknown driver error occurred.")

    def __init__(self, *args, **kwargs):
        self.user_fault_string = kwargs.pop('user_fault_string',
                                            self.user_fault_string)
        self.operator_fault_string = kwargs.pop('operator_fault_string',
                                                self.operator_fault_string)
        super(DriverError, self).__init__(self.user_fault_string,
                                          *args, **kwargs)
Ejemplo n.º 2
0
class UnsupportedOptionError(Exception):
    """Exception raised when a driver does not support an option.

    Provider drivers will validate that they can complete the request -- that
    all options are supported by the driver. If the request fails validation,
    drivers will raise an UnsupportedOptionError exception. For example, if a
    driver does not support a flavor passed as an option to load balancer
    create(), the driver will raise an UnsupportedOptionError and include a
    message parameter providing an explanation of the failure.

    :param user_fault_string: String provided to the API requester.
    :type user_fault_string: string
    :param operator_fault_string: Optional string logged by the Octavia API
      for the operator to use when debugging.
    :type operator_fault_string: string
    """
    user_fault_string = _("A specified option is not supported by this "
                          "provider.")
    operator_fault_string = _("A specified option is not supported by this "
                              "provider.")

    def __init__(self, *args, **kwargs):
        self.user_fault_string = kwargs.pop('user_fault_string',
                                            self.user_fault_string)
        self.operator_fault_string = kwargs.pop('operator_fault_string',
                                                self.operator_fault_string)
        super(UnsupportedOptionError, self).__init__(self.user_fault_string,
                                                     *args, **kwargs)
Ejemplo n.º 3
0
class UpdateStatusError(Exception):
    """Exception raised when a status update fails.

    Each exception will include a message field that describes the
    error and references to the failed record if available.
    :param fault_string: String describing the fault.
    :type fault_string: string
    :param status_object: The object the fault occurred on.
    :type status_object: string
    :param status_object_id: The ID of the object that failed status update.
    :type status_object_id: string
    :param status_record: The status update record that caused the fault.
    :type status_record: string
    """
    fault_string = _("The status update had an unknown error.")
    status_object = None
    status_object_id = None
    status_record = None

    def __init__(self, *args, **kwargs):
        self.fault_string = kwargs.pop('fault_string', self.fault_string)
        self.status_object = kwargs.pop('status_object', None)
        self.status_object_id = kwargs.pop('status_object_id', None)
        self.status_record = kwargs.pop('status_record', None)

        super(UpdateStatusError, self).__init__(self.fault_string,
                                                *args, **kwargs)
Ejemplo n.º 4
0
class NotImplementedError(Exception):
    """Exception raised when a driver does not implement an API function.

    :param user_fault_string: String provided to the API requester.
    :type user_fault_string: string
    :param operator_fault_string: Optional string logged by the Octavia API
      for the operator to use when debugging.
    :type operator_fault_string: string
    """
    user_fault_string = _("This feature is not implemented by the provider.")
    operator_fault_string = _("This feature is not implemented by this "
                              "provider.")

    def __init__(self, *args, **kwargs):
        self.user_fault_string = kwargs.pop('user_fault_string',
                                            self.user_fault_string)
        self.operator_fault_string = kwargs.pop('operator_fault_string',
                                                self.operator_fault_string)
        super().__init__(self.user_fault_string, *args, **kwargs)
Ejemplo n.º 5
0
class DriverAgentNotFound(Exception):
    """Exception raised when the driver agent cannot be reached.

    Each exception will include a message field that describes the
    error.
    :param fault_string: String describing the fault.
    :type fault_string: string
    """
    fault_string = _("The driver-agent process was not found or not ready.")

    def __init__(self, *args, **kwargs):
        self.fault_string = kwargs.pop('fault_string', self.fault_string)
        super().__init__(self.fault_string, *args, **kwargs)
Ejemplo n.º 6
0
class DriverAgentTimeout(Exception):
    """Exception raised when the driver agent does not respond.

    Raised when communication with the driver agent times out.
    Each exception will include a message field that describes the
    error.
    :param fault_string: String describing the fault.
    :type fault_string: string
    """
    fault_string = _("The driver-agent timeout.")

    def __init__(self, *args, **kwargs):
        self.fault_string = kwargs.pop('fault_string', self.fault_string)
        super().__init__(self.fault_string, *args, **kwargs)
Ejemplo n.º 7
0
class NotFound(Exception):
    """Exception raised when the driver cannot find a resource.

    This exception includes two strings: The user fault string and the
    optional operator fault string. The user fault string,
    "user_fault_string", will be provided to the API requester. The operator
    fault string, "operator_fault_string",  will be logged in the Octavia API
    log file for the operator to use when debugging.

    :param user_fault_string: String provided to the API requester.
    :type user_fault_string: string
    :param operator_fault_string: Optional string logged by the Octavia API
      for the operator to use when debugging.
    :type operator_fault_string: string
    """
    user_fault_string = _("The provider driver could not find a resource.")
    operator_fault_string = _("The provider driver could not find a resource.")

    def __init__(self, *args, **kwargs):
        self.user_fault_string = kwargs.pop('user_fault_string',
                                            self.user_fault_string)
        self.operator_fault_string = kwargs.pop('operator_fault_string',
                                                self.operator_fault_string)
        super().__init__(self.user_fault_string, *args, **kwargs)
Ejemplo n.º 8
0
def setup_logging(conf):
    """Sets up the logging options for a log with supplied name.

    :param conf: a cfg.ConfOpts object
    """
    product_name = "octavia_f5"
    logging.setup(conf, product_name)
    LOG.info("Logging enabled!")
    LOG.debug("command line: %s", " ".join(sys.argv))


f5_agent_opts = [
    cfg.BoolOpt('bigip_token',
                default=True,
                help=_('Use token authentication.')),
    cfg.BoolOpt('bigip_verify',
                default=False,
                help=_('Verify AS3 endpoint TLS cert.')),
    cfg.ListOpt('bigip_urls',
                item_type=cfg.types.URI(schemes=['http', 'https']),
                help=_('The URL to the bigip host device with AS3 endpoint')),
    cfg.StrOpt('esd_dir', help=_('Directory of the esd files')),
    cfg.StrOpt('tcp_service_type',
               default=constants.SERVICE_TCP,
               choices=[constants.SERVICE_L4, constants.SERVICE_TCP],
               help=_("Service type used for TCP listener")),
    cfg.StrOpt('profile_http',
               default=None,
               help=_("Path to default HTTP profile"
                      "(e.g. custom_http)")),
Ejemplo n.º 9
0
def setup_logging(conf):
    """Sets up the logging options for a log with supplied name.

    :param conf: a cfg.ConfOpts object
    """
    product_name = "octavia_f5"
    logging.setup(conf, product_name)
    LOG.info("Logging enabled!")
    LOG.debug("command line: %s", " ".join(sys.argv))


f5_agent_opts = [
    cfg.BoolOpt('bigip_token',
                default=True,
                help=_('Use token authentication.')),
    cfg.BoolOpt('bigip_verify',
                default=False,
                help=_('Verify AS3 endpoint TLS cert.')),
    cfg.ListOpt('bigip_urls',
                item_type=cfg.types.URI(schemes=['http', 'https']),
                help=_('The URL to the bigip host device with AS3 endpoint')),
    cfg.StrOpt('esd_dir', help=_('Directory of the esd files')),
    cfg.StrOpt('tcp_service_type',
               default=constants.SERVICE_TCP,
               choices=[constants.SERVICE_L4, constants.SERVICE_TCP],
               help=_("Service type used for TCP listener")),
    cfg.StrOpt('profile_l4',
               default=None,
               help=_("Path to default l4 acceleration profile"
                      "(e.g. /Common/custom_fastl4)")),