def POST(self): # Pull all the user data user_data = self.params() login = user_data.get('login', None) password = user_data.get('password', None) name = user_data.get('name', None) # Creation manager = managers.user_manager() args = [login] kwargs = {'password': password, 'name': name} weight = pulp_config.config.getint('tasks', 'create_weight') tags = [ resource_tag(dispatch_constants.RESOURCE_USER_TYPE, login), action_tag('create') ] call_request = CallRequest(manager.create_user, args, kwargs, weight=weight, tags=tags, kwarg_blacklist=['password']) call_request.creates_resource(dispatch_constants.RESOURCE_USER_TYPE, login) user = execution.execute_sync(call_request) user_link = serialization.link.child_link_obj(login) user.update(user_link) # Grant permissions permission_manager = managers.permission_manager() permission_manager.grant_automatic_permissions_for_resource( user_link['_href']) return self.created(login, user)
def POST(self): group_data = self.params() group_id = group_data.pop('id', None) if group_id is None: raise pulp_exceptions.MissingValue(['id']) display_name = group_data.pop('display_name', None) description = group_data.pop('description', None) consumer_ids = group_data.pop('consumer_ids', None) notes = group_data.pop('notes', None) if group_data: raise pulp_exceptions.InvalidValue(group_data.keys()) manager = managers_factory.consumer_group_manager() weight = pulp_config.config.getint('tasks', 'create_weight') tags = [ resource_tag(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, group_id) ] call_request = CallRequest( manager.create_consumer_group, [group_id, display_name, description, consumer_ids, notes], weight=weight, tags=tags) call_request.creates_resource( dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, group_id) group = execution.execute_sync(call_request) group.update(serialization.link.child_link_obj(group['id'])) return self.created(group['_href'], group)
def POST(self): body = self.params() id = body.get('id') display_name = body.get('display_name') description = body.get('description') notes = body.get('notes') manager = managers.consumer_manager() args = [id, display_name, description, notes] weight = pulp_config.config.getint('tasks', 'create_weight') tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, id), action_tag('create')] call_request = CallRequest(manager.register, args, weight=weight, tags=tags) call_request.creates_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, id) call_report = CallReport.from_call_request(call_request) call_report.serialize_result = False consumer = execution.execute_sync(call_request, call_report) consumer.update({'_href': serialization.link.child_link_obj(consumer['id'])}) return self.created(consumer['_href'], consumer)
def POST(self, repo_id): # Params (validation will occur in the manager) params = self.params() distributor_type = params.get('distributor_type_id', None) distributor_config = params.get('distributor_config', None) distributor_id = params.get('distributor_id', None) auto_publish = params.get('auto_publish', False) # Update the repo distributor_manager = manager_factory.repo_distributor_manager() weight = pulp_config.config.getint('tasks', 'create_weight') tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag('add_distributor')] if distributor_id is not None: tags.append(resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)) call_request = CallRequest(distributor_manager.add_distributor, [repo_id, distributor_type], {'repo_plugin_config': distributor_config, 'auto_publish': auto_publish, 'distributor_id': distributor_id}, weight=weight, tags=tags, kwarg_blacklist=['repo_plugin_config']) call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id) if distributor_id is not None: call_request.creates_resource(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id) return execution.execute_created(self, call_request, distributor_id)
def POST(self): # Pull all the roles data role_data = self.params() role_id = role_data.get('role_id', None) display_name = role_data.get('display_name', None) description = role_data.get('description', None) # Creation manager = managers.role_manager() args = [role_id, display_name, description] weight = pulp_config.config.getint('tasks', 'create_weight') tags = [resource_tag(dispatch_constants.RESOURCE_ROLE_TYPE, role_id), action_tag('create')] call_request = CallRequest(manager.create_role, args, weight=weight, tags=tags) call_request.creates_resource(dispatch_constants.RESOURCE_ROLE_TYPE, role_id) role = execution.execute_sync(call_request) role_link = serialization.link.child_link_obj(role_id) role.update(role_link) return self.created(role_id, role)
def POST(self): body = self.params() id = body.get('id') display_name = body.get('display_name') description = body.get('description') notes = body.get('notes') manager = managers.consumer_manager() args = [id, display_name, description, notes] weight = pulp_config.config.getint('tasks', 'create_weight') tags = [ resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, id), action_tag('create') ] call_request = CallRequest(manager.register, args, weight=weight, tags=tags) call_request.creates_resource( dispatch_constants.RESOURCE_CONSUMER_TYPE, id) call_report = CallReport.from_call_request(call_request) call_report.serialize_result = False consumer = execution.execute_sync(call_request, call_report) consumer.update( {'_href': serialization.link.child_link_obj(consumer['id'])}) return self.created(consumer['_href'], consumer)
def POST(self): group_data = self.params() group_id = group_data.pop('id', None) if group_id is None: raise pulp_exceptions.MissingValue(['id']) display_name = group_data.pop('display_name', None) description = group_data.pop('description', None) repo_ids = group_data.pop('repo_ids', None) notes = group_data.pop('notes', None) distributors = group_data.pop('distributors', None) if group_data: raise pulp_exceptions.InvalidValue(group_data.keys()) # Create the repo group manager = managers_factory.repo_group_manager() args = [group_id, display_name, description, repo_ids, notes] kwargs = {'distributor_list': distributors} weight = pulp_config.config.getint('tasks', 'create_weight') tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, group_id)] call_request = CallRequest(manager.create_and_configure_repo_group, args, kwargs, weight=weight, tags=tags) call_request.creates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, group_id) group = execution.execute_sync(call_request) group.update(serialization.link.child_link_obj(group['id'])) group['distributors'] = distributors or [] return self.created(group['_href'], group)
def POST(self): # Pull all the user data user_data = self.params() login = user_data.get('login', None) password = user_data.get('password', None) name = user_data.get('name', None) # Creation manager = managers.user_manager() args = [login] kwargs = {'password': password, 'name': name} weight = pulp_config.config.getint('tasks', 'create_weight') tags = [resource_tag(dispatch_constants.RESOURCE_USER_TYPE, login), action_tag('create')] call_request = CallRequest(manager.create_user, args, kwargs, weight=weight, tags=tags, kwarg_blacklist=['password']) call_request.creates_resource(dispatch_constants.RESOURCE_USER_TYPE, login) user = execution.execute_sync(call_request) user_link = serialization.link.child_link_obj(login) user.update(user_link) # Grant permissions permission_manager = managers.permission_manager() permission_manager.grant_automatic_permissions_for_resource(user_link['_href']) return self.created(login, user)
def POST(self): # Pull the repo data out of the request body (validation will occur # in the manager) repo_data = self.params() id = repo_data.get('id', None) display_name = repo_data.get('display_name', None) description = repo_data.get('description', None) notes = repo_data.get('notes', None) importer_type_id = repo_data.get('importer_type_id', None) importer_repo_plugin_config = repo_data.get('importer_config', None) distributors = repo_data.get('distributors', None) # Creation repo_manager = manager_factory.repo_manager() args = [id, display_name, description, notes] kwargs = { 'importer_type_id': importer_type_id, 'importer_repo_plugin_config': importer_repo_plugin_config, 'distributor_list': distributors } weight = pulp_config.config.getint('tasks', 'create_weight') tags = [ resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, id), action_tag('create') ] call_request = CallRequest(repo_manager.create_and_configure_repo, args, kwargs, weight=weight, tags=tags, kwarg_blacklist=[ 'importer_repo_plugin_config', 'distributor_list' ]) call_request.creates_resource( dispatch_constants.RESOURCE_REPOSITORY_TYPE, id) repo = execution.execute_sync(call_request) repo.update(serialization.link.child_link_obj(id)) return self.created(id, repo)
def POST(self): group_data = self.params() group_id = group_data.pop('id', None) if group_id is None: raise pulp_exceptions.MissingValue(['id']) display_name = group_data.pop('display_name', None) description = group_data.pop('description', None) consumer_ids = group_data.pop('consumer_ids', None) notes = group_data.pop('notes', None) if group_data: raise pulp_exceptions.InvalidValue(group_data.keys()) manager = managers_factory.consumer_group_manager() weight = pulp_config.config.getint('tasks', 'create_weight') tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, group_id)] call_request = CallRequest(manager.create_consumer_group, [group_id, display_name, description, consumer_ids, notes], weight=weight, tags=tags) call_request.creates_resource(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, group_id) group = execution.execute_sync(call_request) group.update(serialization.link.child_link_obj(group['id'])) return self.created(group['_href'], group)
def POST(self, repo_id): # Params (validation will occur in the manager) params = self.params() distributor_type = params.get('distributor_type_id', None) distributor_config = params.get('distributor_config', None) distributor_id = params.get('distributor_id', None) auto_publish = params.get('auto_publish', False) # Update the repo distributor_manager = manager_factory.repo_distributor_manager() weight = pulp_config.config.getint('tasks', 'create_weight') tags = [ resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag('add_distributor') ] if distributor_id is not None: tags.append( resource_tag( dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)) call_request = CallRequest( distributor_manager.add_distributor, [repo_id, distributor_type], { 'repo_plugin_config': distributor_config, 'auto_publish': auto_publish, 'distributor_id': distributor_id }, weight=weight, tags=tags, kwarg_blacklist=['repo_plugin_config']) call_request.updates_resource( dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id) if distributor_id is not None: call_request.creates_resource( dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id) return execution.execute_created(self, call_request, distributor_id)
def POST(self): # Pull the repo data out of the request body (validation will occur # in the manager) repo_data = self.params() id = repo_data.get('id', None) display_name = repo_data.get('display_name', None) description = repo_data.get('description', None) notes = repo_data.get('notes', None) importer_type_id = repo_data.get('importer_type_id', None) importer_repo_plugin_config = repo_data.get('importer_config', None) distributors = repo_data.get('distributors', None) # Creation repo_manager = manager_factory.repo_manager() args = [id, display_name, description, notes] kwargs = {'importer_type_id': importer_type_id, 'importer_repo_plugin_config': importer_repo_plugin_config, 'distributor_list': distributors} weight = pulp_config.config.getint('tasks', 'create_weight') tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, id), action_tag('create')] call_request = CallRequest(repo_manager.create_and_configure_repo, args, kwargs, weight=weight, tags=tags, kwarg_blacklist=['importer_repo_plugin_config', 'distributor_list']) call_request.creates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, id) repo = execution.execute_sync(call_request) repo.update(serialization.link.child_link_obj(id)) return self.created(id, repo)