示例#1
0
 def test_notification_systemd(self):
     with mock.patch('novaagent.utils.systemd_status') as mock_status:
         try:
             utils.send_notification('systemd', 'notify')
             self.assertTrue(mock_status.called)
         except Exception:
             assert False, 'systemd notification failed to complete'
示例#2
0
 def test_notification_upstart(self):
     try:
         with mock.patch('os.kill') as mock_kill:
             utils.send_notification('upstart', None)
             self.assertTrue(mock_kill.called)
     except Exception:
         assert False, 'upstart notification failed to complete'
示例#3
0
def nova_agent_listen(server_type, server_os, notify, server_init):
    log.info('Starting actions for {0}'.format(server_type.__name__))
    log.info('Checking for existence of /dev/xen/xenbus')

    send_notification = True
    notify_init = False

    if os.path.exists('/dev/xen/xenbus'):
        with Client(router=XENBUS_ROUTER) as xenbus_client:
            check_provider(utils.get_provider(client=xenbus_client))
            while True:
                notify_init = action(server_os, client=xenbus_client)
                if send_notification and notify_init:
                    log.info('Sending notification startup is complete')
                    utils.send_notification(server_init, notify)
                    send_notification = False

                time.sleep(1)
    else:
        check_provider(utils.get_provider())
        while True:
            notify_init = action(server_os)
            if send_notification and notify_init:
                log.info('Sending notification startup is complete')
                utils.send_notification(server_init, notify)
                send_notification = False

            time.sleep(1)