def notify(_context, message): """Notifies the recipient of the desired event given the model. Log notifications using OpenStack's default logging system. """ priority = message.get('priority', CONF.default_notification_level) priority = priority.lower() logger = logging.getLogger( 'helloworld.openstack.common.notification.%s' % message['event_type']) getattr(logger, priority)(jsonutils.dumps(message))
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. '''messaging based notification driver, with message envelopes''' from oslo.config import cfg from helloworld.openstack.common import context as req_context from helloworld.openstack.common.gettextutils import _ from helloworld.openstack.common import log as logging from helloworld.openstack.common import rpc LOG = logging.getLogger(__name__) notification_topic_opt = cfg.ListOpt( 'topics', default=['notifications', ], help='AMQP topic(s) used for OpenStack notifications') opt_group = cfg.OptGroup(name='rpc_notifier2', title='Options for rpc_notifier2') CONF = cfg.CONF CONF.register_group(opt_group) CONF.register_opt(notification_topic_opt, opt_group) def notify(context, message): """Sends a notification via RPC."""