コード例 #1
0
ファイル: history.py プロジェクト: ehelms/pulp
    def _originator(self):
        '''
        Returns the value to use as the originator of the consumer event (either the
        consumer itself or an admin user).

        @return: login of the originator value to use in the event
        @rtype:  string
        '''
        return get_principal()['login']
コード例 #2
0
ファイル: user.py プロジェクト: stpierre/pulp
    def generate_user_certificate(self):
        """
        Generates a user certificate for the currently logged in user.

        @return: certificate and private key, combined into a single string,
                 that can be used to identify the current user on subsequent calls
        @rtype:  str
        """

        # Get the currently logged in user
        user = principal.get_principal()
        key, certificate = cert_generator.make_admin_user_cert(user)
        return key + certificate
コード例 #3
0
ファイル: authorization.py プロジェクト: stpierre/pulp
def grant_automatic_permissions_for_created_resource(resource):
    """
    Grant CRUDE permissions for a newly created resource to current principal.
    @type resource: str
    @param resource: resource path to grant permissions to
    @rtype: bool
    @return: True on success, False otherwise
    @raise RuntimeError: if the system principal has not been set
    """
    user = get_principal()
    if is_system_principal():
        raise RuntimeError(_('cannot grant auto permission on %s to %s') %
                           (resource, user))
    operations = [CREATE, READ, UPDATE, DELETE, EXECUTE]
    _permission_api.grant(resource, user, operations)
    return True
コード例 #4
0
ファイル: cud.py プロジェクト: ehelms/pulp
 def grant_automatic_permissions_for_resource(self, resource):
     """
     Grant CRUDE permissions for a newly created resource to current principal.
     
     @type resource: str
     @param resource: resource path to grant permissions to
     
     @rtype: bool
     @return: True on success, False otherwise
     
     @raise PulpExecutionException: if the system principal has not been set
     """
     user = get_principal()
     if is_system_principal():
         raise PulpExecutionException(_('Cannot grant automatic permissions for [%s] on resource [%s]') %
                            (user, resource))
         
     operations = [self.CREATE, self.READ, self.UPDATE, self.DELETE, self.EXECUTE]
     self.grant(resource, user['login'], operations)
     return True
コード例 #5
0
ファイル: repositories.py プロジェクト: ehelms/pulp
    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, 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)
コード例 #6
0
ファイル: upload.py プロジェクト: ehelms/pulp
    def import_uploaded_unit(self, repo_id, unit_type_id, unit_key, unit_metadata, upload_id):
        """
        Called to trigger the importer's handling of an uploaded unit. This
        should not be called until the bits have finished uploading. The
        importer is then responsible for moving the file to the correct location,
        adding it to the Pulp server's inventory, and associating it with the
        repository.

        This call will first call is_valid_upload to check the integrity of the
        destination repository. See that method's documentation for exception
        possibilities.

        @param repo_id: identifies the repository into which the unit is uploaded
        @type  repo_id: str

        @param unit_type_id: type of unit being uploaded
        @type  unit_type_id: str

        @param unit_key: unique identifier for the unit (user-specified)
        @type  unit_key: dict

        @param unit_metadata: any user-specified information about the unit
        @type  unit_metadata: dict

        @param upload_id: upload being imported
        @type  upload_id: str
        """

        # If it doesn't raise an exception, it's good to go
        self.is_valid_upload(repo_id, unit_type_id)

        repo_query_manager = manager_factory.repo_query_manager()
        importer_manager = manager_factory.repo_importer_manager()

        repo = repo_query_manager.find_by_id(repo_id)
        repo_importer = importer_manager.get_importer(repo_id)

        try:
            importer_instance, plugin_config = plugin_api.get_importer_by_id(repo_importer['importer_type_id'])
        except plugin_exceptions.PluginNotFound:
            raise MissingResource(repo_id), None, sys.exc_info()[2]

        # Assemble the data needed for the import
        conduit = UploadConduit(repo_id, repo_importer['id'], RepoContentUnit.OWNER_TYPE_USER, pulp_principal.get_principal()['login'])

        call_config = PluginCallConfiguration(plugin_config, repo_importer['config'], None)
        transfer_repo = repo_common_utils.to_transfer_repo(repo)
        transfer_repo.working_dir = repo_common_utils.importer_working_dir(repo_importer['importer_type_id'], repo_id, mkdir=True)

        file_path = self._upload_file_path(upload_id)

        # Invoke the importer
        try:
            # def upload_unit(self, type_id, unit_key, metadata, file_path, conduit, config):
            report = importer_instance.upload_unit(transfer_repo, unit_type_id, unit_key, unit_metadata, file_path, conduit, call_config)
        except Exception, e:
            _LOG.exception('Error from the importer while importing uploaded unit to repository [%s]' % repo_id)
            raise PulpExecutionException(e), None, sys.exc_info()[2]
コード例 #7
0
ファイル: root_actions.py プロジェクト: ehelms/pulp
 def POST(self):
     user = principal.get_principal()
     key, certificate = factory.cert_generation_manager().make_admin_user_cert(user)
     certificate = key + certificate
     return self.ok(certificate)
コード例 #8
0
ファイル: authorization.py プロジェクト: ehelms/pulp
 def __init__(self):
     self.user_name = get_principal()['login']