Exemple #1
0
 def setUp(self):
     self.context = mock.Mock()
     self.pool = 'default_pool'
     self.executor = mock.Mock()
     self.task = zone.ZoneAction(self.executor, self.context, self.pool,
                                 mock.Mock(), 'CREATE')
     self.task._wait_for_nameservers = mock.Mock()
Exemple #2
0
 def test_wait_for_nameservers(self, mock_time):
     # It is just a time.sleep :(
     task = zone.ZoneAction(
         self.executor, self.context, self.pool, mock.Mock(), 'CREATE'
     )
     task._wait_for_nameservers()
     mock_time.sleep.assert_called_with(task.delay)
Exemple #3
0
    def test_call_on_delete(self):
        myzone = mock.Mock()
        task = zone.ZoneAction(self.executor, self.context, self.pool, myzone,
                               'DELETE')
        task._zone_action_on_targets = mock.Mock(return_value=True)
        task._poll_for_zone = mock.Mock(return_value=True)
        task._wait_for_nameservers = mock.Mock()

        assert task()

        assert myzone.serial == 0
Exemple #4
0
    def _do_zone_action(self, context, zone):
        pool = self.get_pool(zone.pool_id)
        all_tasks = []
        all_tasks.append(
            zonetasks.ZoneAction(self.executor, context, pool, zone,
                                 zone.action))

        # Send a NOTIFY to each also-notifies
        for also_notify in pool.also_notifies:
            notify_target = AlsoNotifyTask()
            notify_target.options = {
                'host': also_notify.host,
                'port': also_notify.port
            }
            all_tasks.append(
                zonetasks.SendNotify(self.executor, zone, notify_target))
        return self.executor.run(all_tasks)
Exemple #5
0
 def _do_zone_action(self, context, zone):
     pool = self.get_pool(zone.pool_id)
     task = zonetasks.ZoneAction(self.executor, context, pool, zone,
                                 zone.action)
     return self.executor.run(task)