Ejemplo n.º 1
0
 def _check_dir(self, path, create_dir=False, remove_dir=False):
     try:
         if remove_dir:
             self.check_remove_dir(path)
         if create_dir:
             self.check_create_dir(path)
     except WindowsError as ex:
         if ex.winerror == ERROR_INVALID_NAME:
             raise exception.AdminRequired(
                 _("Cannot access \"%(path)s\", make sure the "
                   "path exists and that you have the proper permissions. "
                   "In particular Nova-Compute must not be executed with the "
                   "builtin SYSTEM account or other accounts unable to "
                   "authenticate on a remote host.") % {'path': path})
         raise
 def _get_instances_sub_dir(self, dir_name, remote_server=None,
                            create_dir=True, remove_dir=False):
     instances_path = self.get_instances_dir(remote_server)
     path = os.path.join(instances_path, dir_name)
     try:
         if remove_dir:
             self.check_remove_dir(path)
         if create_dir:
             self.check_create_dir(path)
         return path
     except WindowsError as ex:
         if ex.winerror == ERROR_INVALID_NAME:
             raise exception.AdminRequired(_(
                 "Cannot access \"%(instances_path)s\", make sure the "
                 "path exists and that you have the proper permissions. "
                 "In particular Nova-Compute must not be executed with the "
                 "builtin SYSTEM account or other accounts unable to "
                 "authenticate on a remote host.") %
                 {'instances_path': instances_path})
         raise
Ejemplo n.º 3
0
 def _check_admin(self, context):
     """We cannot depend on the db layer to check for admin access
        for the auth manager, so we do it here"""
     if not context.is_admin:
         raise exception.AdminRequired()
Ejemplo n.º 4
0
def require_admin_context(ctxt):
    """Raise exception.AdminRequired() if context is an admin context."""
    if not ctxt.is_admin:
        raise exception.AdminRequired()