def create_test(self, values): # ensure defaults are present for new tests if not values.get('uuid'): values['uuid'] = utils.generate_uuid() cpulse = models.cpulse() cpulse.update(values) # TODO(VINOD) try: cpulse.save() except db_exc.DBDuplicateEntry: raise exception.TestAlreadyExists(uuid=values['uuid']) return cpulse
def create_test(self, values): # ensure that the test name is valid discover.import_modules_from_package("cloudpulse.scenario.plugins") plugins = discover.itersubclasses(base.Scenario) if not any(values['name'] in dir(scenario) for scenario in plugins): raise exception.TestInvalid(test=values['name']) # ensure defaults are present for new tests if not values.get('uuid'): values['uuid'] = utils.generate_uuid() cpulse = models.cpulse() cpulse.update(values) # TODO(VINOD) try: cpulse.save() except db_exc.DBDuplicateEntry: raise exception.TestAlreadyExists(uuid=values['uuid']) return cpulse