def update(self, id): """ Update content (units) on a consumer. Expected body: {units:[], options:<dict>} where unit is: {type_id:<str>, unit_key={}} and the options is a dict of update options. @param id: A consumer ID. @type id: str @return: TBD @rtype: dict """ body = self.params() units = body.get('units') options = body.get('options') resources = { dispatch_constants.RESOURCE_CONSUMER_TYPE: {id:dispatch_constants.RESOURCE_READ_OPERATION}, } args = [ id, units, options, ] manager = managers.consumer_agent_manager() call_request = CallRequest( manager.update_content, args, resources=resources, weight=pulp_config.config.getint('tasks', 'consumer_content_weight'), asynchronous=True, archive=True,) result = execution.execute_async(self, call_request) return result
def POST(self): orphans = self.params() orphan_manager = factory.content_orphan_manager() tags = [action_tag('delete_orphans'), resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, 'orphans')] call_request = CallRequest(orphan_manager.delete_orphans_by_id, [orphans], tags=tags, archive=True) return execution.execute_async(self, call_request)
def POST(self, dest_repo_id): # Params params = self.params() source_repo_id = params.get('source_repo_id', None) overrides = params.get('override_config', None) if source_repo_id is None: raise exceptions.MissingValue(['source_repo_id']) criteria = params.get('criteria', None) if criteria is not None: try: criteria = UnitAssociationCriteria.from_client_input(criteria) except: _LOG.exception('Error parsing association criteria [%s]' % criteria) raise exceptions.PulpDataException(), None, sys.exc_info()[2] association_manager = manager_factory.repo_unit_association_manager() resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {source_repo_id: dispatch_constants.RESOURCE_READ_OPERATION, dest_repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION}} tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, dest_repo_id), resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, source_repo_id), action_tag('associate')] call_request = CallRequest(association_manager.associate_from_repo, [source_repo_id, dest_repo_id], {'criteria': criteria, 'import_config_override': overrides}, resources=resources, tags=tags, archive=True) return execution.execute_async(self, call_request)
def POST(self, repo_group_id): params = self.params() distributor_id = params.get('id', None) overrides = params.get('override_config', None) if distributor_id is None: raise MissingValue(['id']) publish_manager = managers_factory.repo_group_publish_manager() tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id), resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_DISTRIBUTOR_TYPE, distributor_id), action_tag('publish') ] weight = pulp_config.config.getint('tasks', 'publish_weight') call_request = CallRequest(publish_manager.publish, args=[repo_group_id, distributor_id], kwargs={'publish_config_override' : overrides}, tags=tags, weight=weight, archive=True) call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id) call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_DISTRIBUTOR_TYPE, distributor_id) call_request.add_life_cycle_callback(dispatch_constants.CALL_ENQUEUE_LIFE_CYCLE_CALLBACK, publish_manager.prep_publish) return execution.execute_async(self, call_request)
def POST(self): """ Creates an async task to regenerate content applicability data for given updated repositories. body {repo_criteria:<dict>} """ body = self.params() repo_criteria = body.get('repo_criteria', None) if repo_criteria is None: raise exceptions.MissingValue('repo_criteria') try: repo_criteria = Criteria.from_client_input(repo_criteria) except: raise exceptions.InvalidValue('repo_criteria') manager = manager_factory.applicability_regeneration_manager() regeneration_tag = action_tag('applicability_regeneration') call_request = CallRequest(manager.regenerate_applicability_for_repos, [repo_criteria], tags = [regeneration_tag]) # allow only one applicability regeneration task at a time call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_PROFILE_APPLICABILITY_TYPE, dispatch_constants.RESOURCE_ANY_ID) return execution.execute_async(self, call_request)
def POST(self, repo_id): params = self.params() criteria = params.get('criteria', None) if criteria is not None: try: criteria = UnitAssociationCriteria.from_client_input(criteria) except: _LOG.error('Error parsing unassociation criteria [%s]' % criteria) raise exceptions.PulpDataException(), None, sys.exc_info()[2] association_manager = manager_factory.repo_unit_association_manager() tags = [ resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag('unassociate') ] call_request = CallRequest( association_manager.unassociate_by_criteria, [ repo_id, criteria, RepoContentUnit.OWNER_TYPE_USER, manager_factory.principal_manager().get_principal()['login'] ], tags=tags, archive=True) call_request.updates_resource( dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id) return execution.execute_async(self, call_request)
def uninstall(self, consumer_group_id): """ Uninstall content (units) on a consumer. Expected body: {units:[], options:<dict>} where unit is: {type_id:<str>, unit_key={}} and the options is a dict of uninstall options. @param id: A consumer ID. @type id: str @return: TBD @rtype: dict """ body = self.params() units = body.get('units') options = body.get('options') resources = { dispatch_constants.RESOURCE_CONSUMER_TYPE: {consumer_group_id:dispatch_constants.RESOURCE_READ_OPERATION}, } args = [ consumer_group_id, units, options, ] manager = managers_factory.consumer_group_manager() call_request = CallRequest( manager.uninstall_content, args, resources=resources, weight=0, asynchronous=True, archive=True,) result = execution.execute_async(self, call_request) return result
def POST(self, repo_group_id): params = self.params() distributor_id = params.get('id', None) overrides = params.get('override_config', None) if distributor_id is None: raise MissingValue(['id']) publish_manager = managers_factory.repo_group_publish_manager() resources = { dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE : {repo_group_id : dispatch_constants.RESOURCE_UPDATE_OPERATION}, dispatch_constants.RESOURCE_REPOSITORY_GROUP_DISTRIBUTOR_TYPE : {distributor_id : dispatch_constants.RESOURCE_UPDATE_OPERATION}, } tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, repo_group_id), resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_DISTRIBUTOR_TYPE, distributor_id), action_tag('publish') ] weight = pulp_config.config.getint('tasks', 'publish_weight') call_request = CallRequest(publish_manager.publish, args=[repo_group_id, distributor_id], kwargs={'publish_config_override' : overrides}, resources=resources, tags=tags, weight=weight, archive=True) return execution.execute_async(self, call_request)
def DELETE(self, content_type, content_id): orphan_manager = factory.content_orphan_manager() orphan_manager.get_orphan(content_type, content_id) ids = [{'content_type_id': content_type, 'unit_id': content_id}] tags = [resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, 'orphans')] call_request = CallRequest(orphan_manager.delete_orphans_by_id, [ids], tags=tags, archive=True) return execution.execute_async(self, call_request)
def DELETE(self): orphan_manager = factory.content_orphan_manager() tags = [ resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, 'orphans') ] call_request = CallRequest(orphan_manager.delete_all_orphans, tags=tags, archive=True) return execution.execute_async(self, call_request)
def POST(self, repo_id): # Params params = self.params() distributor_id = params.get('id', None) overrides = params.get('override_config', None) call_request = publish_itinerary(repo_id, distributor_id, overrides)[0] return execution.execute_async(self, call_request)
def DELETE(self, content_type, content_id): orphan_manager = factory.content_orphan_manager() orphan_manager.get_orphan(content_type, content_id) ids = [{'content_type_id': content_type, 'unit_id': content_id}] tags = [ resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, 'orphans') ] call_request = CallRequest(orphan_manager.delete_orphans_by_id, [ids], tags=tags, archive=True) return execution.execute_async(self, call_request)
def POST(self, dest_repo_id): # Params params = self.params() source_repo_id = params.get('source_repo_id', None) overrides = params.get('override_config', None) if source_repo_id is None: raise exceptions.MissingValue(['source_repo_id']) # A 404 only applies to things in the URL, so the destination repo # check allows the MissingResource to bubble up, but if the source # repo doesn't exist, it's considered bad data. repo_query_manager = manager_factory.repo_query_manager() repo_query_manager.get_repository(dest_repo_id) try: repo_query_manager.get_repository(source_repo_id) except exceptions.MissingResource: raise exceptions.InvalidValue(['source_repo_id']) criteria = params.get('criteria', None) if criteria is not None: try: criteria = UnitAssociationCriteria.from_client_input(criteria) except: _LOG.error('Error parsing association criteria [%s]' % criteria) raise exceptions.PulpDataException(), None, sys.exc_info()[2] association_manager = manager_factory.repo_unit_association_manager() tags = [ resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, dest_repo_id), resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, source_repo_id), action_tag('associate') ] call_request = CallRequest( association_manager.associate_from_repo, [source_repo_id, dest_repo_id], { 'criteria': criteria, 'import_config_override': overrides }, tags=tags, archive=True, kwarg_blacklist=['criteria', 'import_config_override']) call_request.reads_resource( dispatch_constants.RESOURCE_REPOSITORY_TYPE, source_repo_id) call_request.updates_resource( dispatch_constants.RESOURCE_REPOSITORY_TYPE, dest_repo_id) return execution.execute_async(self, call_request)
def POST(self): orphans = self.params() orphan_manager = factory.content_orphan_manager() tags = [ action_tag('delete_orphans'), resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, 'orphans') ] call_request = CallRequest(orphan_manager.delete_orphans_by_id, [orphans], tags=tags, archive=True) return execution.execute_async(self, call_request)
def POST(self, repo_id): # validation manager = manager_factory.repo_query_manager() manager.get_repository(repo_id) # Params params = self.params() distributor_id = params.get('id', None) overrides = params.get('override_config', None) call_request = publish_itinerary(repo_id, distributor_id, overrides)[0] return execution.execute_async(self, call_request)
def update(self, id): """ Update content (units) on a consumer. Expected body: {units:[], options:<dict>} where unit is: {type_id:<str>, unit_key={}} and the options is a dict of update options. @param id: A consumer ID. @type id: str @return: TBD @rtype: dict """ body = self.params() units = body.get('units') options = body.get('options') call_request = consumer_content_update_itinerary(id, units, options)[0] result = execution.execute_async(self, call_request) return result
def uninstall(self, id): """ Uninstall content (units) on a consumer. Expected body: {units:[], options:<dict>} where unit is: {type_id:<str>, unit_key={}} and the options is a dict of uninstall options. @param id: A consumer ID. @type id: str @return: TBD @rtype: dict """ body = self.params() units = body.get('units') options = body.get('options') call_request = consumer_content_uninstall_itinerary(id, units, options)[0] result = execution.execute_async(self, call_request) return result
def POST(self, dest_repo_id): # Params params = self.params() source_repo_id = params.get('source_repo_id', None) overrides = params.get('override_config', None) if source_repo_id is None: raise exceptions.MissingValue(['source_repo_id']) # A 404 only applies to things in the URL, so the destination repo # check allows the MissingResource to bubble up, but if the source # repo doesn't exist, it's considered bad data. repo_query_manager = manager_factory.repo_query_manager() repo_query_manager.get_repository(dest_repo_id) try: repo_query_manager.get_repository(source_repo_id) except exceptions.MissingResource: raise exceptions.InvalidValue(['source_repo_id']) criteria = params.get('criteria', None) if criteria is not None: try: criteria = UnitAssociationCriteria.from_client_input(criteria) except: _LOG.error('Error parsing association criteria [%s]' % criteria) raise exceptions.PulpDataException(), None, sys.exc_info()[2] association_manager = manager_factory.repo_unit_association_manager() resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {source_repo_id: dispatch_constants.RESOURCE_READ_OPERATION, dest_repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION}} tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, dest_repo_id), resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, source_repo_id), action_tag('associate')] call_request = CallRequest(association_manager.associate_from_repo, [source_repo_id, dest_repo_id], {'criteria': criteria, 'import_config_override': overrides}, resources=resources, tags=tags, archive=True) return execution.execute_async(self, call_request)
def uninstall(self, consumer_group_id): """ Uninstall content (units) from the consumers in a consumer group. Expected body: {units:[], options:<dict>} where unit is: {type_id:<str>, unit_key={}} and the options is a dict of uninstall options. @param consumer_group_id: A consumer group ID. @type consumer_group_id: str @return: list of call requests @rtype: list """ body = self.params() units = body.get('units') options = body.get('options') call_request_list = consumer_group_content_uninstall_itinerary(consumer_group_id, units, options) results = [] for call_request in call_request_list: result = execution.execute_async(self, call_request) results.append(result) return results
def uninstall(self, consumer_group_id): """ Uninstall content (units) from the consumers in a consumer group. Expected body: {units:[], options:<dict>} where unit is: {type_id:<str>, unit_key={}} and the options is a dict of uninstall options. @param consumer_group_id: A consumer group ID. @type consumer_group_id: str @return: list of call requests @rtype: list """ body = self.params() units = body.get('units') options = body.get('options') call_request_list = consumer_group_content_uninstall_itinerary( consumer_group_id, units, options) results = [] for call_request in call_request_list: result = execution.execute_async(self, call_request) results.append(result) return results
def POST(self, repo_id): # Params params = self.params() distributor_id = params.get('id', None) overrides = params.get('override_config', None) # Execute the publish asynchronously repo_publish_manager = manager_factory.repo_publish_manager() weight = pulp_config.config.getint('tasks', 'publish_weight') tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag('publish')] call_request = CallRequest(repo_publish_manager.publish, [repo_id, distributor_id], {'publish_config_override': overrides}, weight=weight, tags=tags, archive=True) call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id) call_request.add_life_cycle_callback(dispatch_constants.CALL_ENQUEUE_LIFE_CYCLE_CALLBACK, repo_publish_manager.prep_publish) return execution.execute_async(self, call_request)
def POST(self, repo_id): params = self.params() criteria = params.get('criteria', None) if criteria is not None: try: criteria = UnitAssociationCriteria.from_client_input(criteria) except: _LOG.exception('Error parsing unassociation criteria [%s]' % criteria) raise exceptions.PulpDataException(), None, sys.exc_info()[2] association_manager = manager_factory.repo_unit_association_manager() tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag('unassociate')] call_request = CallRequest(association_manager.unassociate_by_criteria, [repo_id, criteria, RepoContentUnit.OWNER_TYPE_USER, manager_factory.principal_manager().get_principal()['login']], tags=tags, archive=True) call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id) return execution.execute_async(self, call_request)
def DELETE(self, content_type): orphan_manager = factory.content_orphan_manager() tags = [resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, 'orphans')] call_request = CallRequest(orphan_manager.delete_orphans_by_type, [content_type], tags=tags, archive=True) return execution.execute_async(self, call_request)