def post(self, runtime): params = runtime.to_dict() LOG.info("Creating runtime. [runtime=%s]", params) params.update({'status': 'creating'}) db_model = db_api.create_runtime(params) self.engine_client.create_runtime(db_model.id) return resources.Runtime.from_dict(db_model.to_dict())
def create_runtime(self): runtime = db_api.create_runtime( { 'name': self.rand_name('runtime', prefix=self.prefix), 'image': self.rand_name('image', prefix=self.prefix), # 'auth_enable' is disabled by default, we create runtime for # default tenant. 'project_id': DEFAULT_PROJECT_ID, 'status': status.AVAILABLE, 'trusted': True } ) return runtime
def post(self, runtime): params = runtime.to_dict() if not POST_REQUIRED.issubset(set(params.keys())): raise exc.InputException( 'Required param is missing. Required: %s' % POST_REQUIRED) LOG.info("Creating %s, params: %s", self.type, params) params.update({'status': status.CREATING}) db_model = db_api.create_runtime(params) self.engine_client.create_runtime(db_model.id) return resources.Runtime.from_dict(db_model.to_dict())
def test_put_image_runtime_not_available(self): db_runtime = db_api.create_runtime({ 'name': self.rand_name('runtime', prefix='TestRuntimeController'), 'image': self.rand_name('image', prefix='TestRuntimeController'), 'project_id': test_base.DEFAULT_PROJECT_ID, 'status': status.CREATING }) runtime_id = db_runtime.id resp = self.app.put_json('/v1/runtimes/%s' % runtime_id, {'image': 'new_image'}, expect_errors=True) self.assertEqual(409, resp.status_int)
def post(self, runtime): acl.enforce('runtime:create', context.get_ctx()) params = runtime.to_dict() if 'trusted' not in params: params['trusted'] = True if not POST_REQUIRED.issubset(set(params.keys())): raise exc.InputException( 'Required param is missing. Required: %s' % POST_REQUIRED) LOG.info("Creating %s, params: %s", self.type, params) params.update({'status': status.CREATING}) db_model = db_api.create_runtime(params) self.engine_client.create_runtime(db_model.id) return resources.Runtime.from_db_obj(db_model)