Exemple #1
0
class NotificationPublisher(NotificationObject):
    # Version 1.0: Initial version
    #         2.0: The binary field has been renamed to source
    #         2.1: The type of the source field changed from string to enum.
    #              This only needs a minor bump as the enum uses the possible
    #              values of the previous string field
    #         2.2: New enum for source fields added
    VERSION = '2.2'

    fields = {
        'host': fields.StringField(nullable=False),
        'source': fields.NotificationSourceField(nullable=False),
    }

    def __init__(self, host, source):
        super(NotificationPublisher, self).__init__()
        self.host = host
        self.source = source

    @classmethod
    def from_service_obj(cls, service):
        # nova-osapi_compute binary name needs to be translated to nova-api
        # notification source enum value.
        source = ("nova-api"
                  if service.binary == "nova-osapi_compute"
                  else service.binary)
        return cls(host=service.host, source=source)
Exemple #2
0
class NotificationPublisher(NotificationObject):
    # Version 1.0: Initial version
    #         2.0: The binary field has been renamed to source
    #         2.1: The type of the source field changed from string to enum.
    #              This only needs a minor bump as the enum uses the possible
    #              values of the previous string field
    #         2.2: New enum for source fields added
    VERSION = '2.2'

    # TODO(stephenfin): Remove 'nova-cells' from 'NotificationSourceField' enum
    # when bumping this object to version 3.0
    fields = {
        'host': fields.StringField(nullable=False),
        'source': fields.NotificationSourceField(nullable=False),
    }

    def __init__(self, host, source):
        super(NotificationPublisher, self).__init__()
        self.host = host
        self.source = source

    @classmethod
    def from_service_obj(cls, service):
        source = fields.NotificationSource.get_source_by_binary(service.binary)
        return cls(host=service.host, source=source)
Exemple #3
0
class NotificationPublisher(NotificationObject):
    # Version 1.0: Initial version
    #         2.0: The binary field has been renamed to source
    #         2.1: The type of the source field changed from string to enum.
    #              This only needs a minor bump as the enum uses the possible
    #              values of the previous string field
    VERSION = '2.1'

    fields = {
        'host': fields.StringField(nullable=False),
        'source': fields.NotificationSourceField(nullable=False),
    }

    def __init__(self, host, source):
        super(NotificationPublisher, self).__init__()
        self.host = host
        self.source = source

    @classmethod
    def from_service_obj(cls, service):
        return cls(host=service.host, source=service.binary)