Exemple #1
0
    def __init__(self, callbacks):
        super(VcnsDriver, self).__init__()

        self.callbacks = callbacks
        self.vcns_uri = cfg.CONF.vcns.manager_uri
        self.vcns_user = cfg.CONF.vcns.user
        self.vcns_passwd = cfg.CONF.vcns.password
        self.datacenter_moid = cfg.CONF.vcns.datacenter_moid
        self.deployment_container_id = cfg.CONF.vcns.deployment_container_id
        self.resource_pool_id = cfg.CONF.vcns.resource_pool_id
        self.datastore_id = cfg.CONF.vcns.datastore_id
        self.external_network = cfg.CONF.vcns.external_network
        interval = cfg.CONF.vcns.task_status_check_interval
        self.task_manager = tasks.TaskManager(interval)
        self.task_manager.start()
        self.vcns = vcns.Vcns(self.vcns_uri, self.vcns_user, self.vcns_passwd)
Exemple #2
0
    def _test_task_manager_stop(self,
                                exec_wait=False,
                                result_wait=False,
                                stop_wait=0):
        def _exec(task):
            if exec_wait:
                greenthread.sleep(0.01)
            return TaskStatus.PENDING

        def _status(task):
            greenthread.sleep(0.01)
            return TaskStatus.PENDING

        def _result(task):
            if result_wait:
                greenthread.sleep(0)
            pass

        manager = ts.TaskManager().start(100)
        manager.stop()
        # Task manager should not leave running threads around
        # if _thread is None it means it was killed in stop()
        self.assertIsNone(manager._thread)
        manager.start(100)

        alltasks = {}
        for i in range(100):
            res = 'res-%d' % i
            tasks = []
            for i in range(100):
                task = ts.Task('name', res, _exec, _status, _result)
                manager.add(task)
                tasks.append(task)
            alltasks[res] = tasks

        greenthread.sleep(stop_wait)
        manager.stop()
        # Task manager should not leave running threads around
        # if _thread is None it means it was killed in stop()
        self.assertIsNone(manager._thread)

        for res, tasks in alltasks.iteritems():
            for task in tasks:
                self.assertEqual(task.status, TaskStatus.ABORT)
Exemple #3
0
    def test_task_pending_task(self):
        def _exec(task):
            task.userdata['executing'] = True
            while not task.userdata['tested']:
                greenthread.sleep(0)
            task.userdata['executing'] = False
            return TaskStatus.COMPLETED

        userdata = {'executing': False, 'tested': False}
        manager = ts.TaskManager().start(100)
        task = ts.Task('name', 'res', _exec, userdata=userdata)
        manager.add(task)

        while not userdata['executing']:
            greenthread.sleep(0)
        self.assertTrue(manager.has_pending_task())

        userdata['tested'] = True
        while userdata['executing']:
            greenthread.sleep(0)
        self.assertFalse(manager.has_pending_task())
Exemple #4
0
 def setUp(self):
     super(VcnsDriverTaskManagerTestCase, self).setUp()
     self.manager = ts.TaskManager()
     self.manager.start(100)