Ensure that a user is present.

    name
        Name of the user to remove.

    profile
        Configuration profile used to connect to the Grafana instance.
        Default is 'grafana'.
965776
def absent(name, profile='grafana'):
    '''
    
    '''
    if isinstance(profile, string_types):
        profile = __salt__['config.option'](profile)

    ret = {'name': name, 'result': None, 'comment': None, 'changes': {}}
    user = __salt__['grafana4.get_user'](name, profile)

    if user:
        if __opts__['test']:
            ret['comment'] = 'User {0} will be deleted'.format(name)
            return ret
        orgs = __salt__['grafana4.get_user_orgs'](user['id'], profile=profile)
        __salt__['grafana4.delete_user'](user['id'], profile=profile)
        for org in orgs:
            if org['name'] == user['email']:
                # Remove entire Org in the case where auto_assign_org=false:
                # When set to false, new users will automatically cause a new
                # organization to be created for that new user (the org name
                # will be the email)
                __salt__['grafana4.delete_org'](org['orgId'], profile=profile)
            else:
                __salt__['grafana4.delete_user_org'](
                    user['id'], org['orgId'], profile=profile)
    else:
        ret['result'] = True
        ret['comment'] = 'User {0} already absent'.format(name)
        return ret

    ret['result'] = True
    ret['changes'][name] = 'Absent'
    ret['comment'] = 'User {0} was deleted'.format(name)
    return ret
933842
def remove_profile(self, profile):
        
        self.remove_file(
            os.path.join(
                self.root_directory, 'minimum_needs', profile + '.json')
        )
856371
def profile_remove(name, **kwargs):
    
    ctx = Context(**kwargs)
    ctx.execute_action('profile:remove', **{
        'storage': ctx.repo.create_secure_service('storage'),
        'name': name,
    })
248445
def has_user(self, username):
        
        return self.model.objects.filter(
            **self._filter_user_by(username)
        ).exists()
436199
def suspend(instance_id, profile=None, **kwargs):
    '''
    

    '''
    conn = _auth(profile, **kwargs)
    return conn.suspend(instance_id)
748648
def removeProfile( self ):
        
        manager  = self.parent()
        prof     = manager.currentProfile()
        opts     = QMessageBox.Yes | QMessageBox.No
        question = 'Are you sure you want to remove "%s"?' % prof.name()
        answer   = QMessageBox.question( self, 'Remove Profile', question, opts)
        
        if ( answer == QMessageBox.Yes ):
            manager.removeProfile(prof)
490802
def delete_user(self, username):
        
        path = Client.urls['users_by_name'] % username
        return self._call(path, 'DELETE')
1090900
def profile_name
      # allow user to specify the path also
      if @options[:profile] && File.exist?(@options[:profile])
        filename_profile = File.basename(@options[:profile], '.yml')
      end

      name = derandomize(@name)
      if File.exist?(profile_file(name))
        name_profile = name
      end

      filename_profile ||
      @options[:profile] ||
      name_profile || # conventional profile is the name of the elb
      "default"
    end
1021380
def getProfile(self, profile=None):
    '''
    
    '''
    if profile is None:
      # todo: what if the configuration `profile.default` does not exist?
      profile = self.config.get('DEFAULT', 'profile.default')
    if profile in self.profiles:
      return self.profiles[profile].init()
    for prof in self.profiles.values():
      if prof.name == profile:
        return prof.init()
    for prof in self.profiles.values():
      if prof.name.lower() == profile.lower():
        return prof.init()
    raise KeyError(profile)
492701
def keypair_delete(name, profile=None, **kwargs):
    '''
    
    '''
    conn = _auth(profile, **kwargs)
    return conn.keypair_delete(name)
1340178
def user_remove(name, user=None, password=None, host=None, port=None,
                database='admin', authdb=None):
    '''
    
    '''
    conn = _connect(user, password, host, port)
    if not conn:
        return 'Failed to connect to mongo database'

    try:
        log.info('Removing user %s', name)
        mdb = pymongo.database.Database(conn, database)
        mdb.remove_user(name)
    except pymongo.errors.PyMongoError as err:
        log.error('Creating database %s failed with error: %s', name, err)
        return six.text_type(err)

    return True
462990
def validate_profile_exists(self):
        """"""

        if self.args.profile_name not in self.profiles:
            self.handle_error('Could not find profile "{}"'.format(self.args.profile_name))
244018
def User(self, Username=''):
        
        if not Username:
            Username = self.CurrentUserHandle
        o = User(self, Username)
        o.OnlineStatus # Test if such a user exists.
        return o
449802
def _configHasProfile(self):
        

        for i, config_file in enumerate(self.config_files):
            if os.path.exists(config_file):
                with open(config_file) as f:
                    config_string = f.read()
                if "[pyradio]" in config_string:
                    if i == 0:
                        self.PROFILE_FROM_USER = True
                    return 1
        return 0
990722
def delete_user(self, user_id, **kwargs):
        
        return DeleteUser(settings=self.settings, **kwargs).call(user_id=user_id, **kwargs)
273301
def tenant_present(name, description=None, enabled=True, profile=None,
                   **connection_args):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': 'Tenant / project "{0}" already exists'.format(name)}

    _api_version(profile=profile, **connection_args)

    # Check if tenant is already present
    tenant = __salt__['keystone.tenant_get'](name=name,
                                             profile=profile,
                                             **connection_args)

    if 'Error' not in tenant:
        if tenant[name].get('description', None) != description:
            if __opts__.get('test'):
                ret['result'] = None
                ret['comment'] = 'Tenant / project "{0}" will be updated'.format(name)
                ret['changes']['Description'] = 'Will be updated'
                return ret
            __salt__['keystone.tenant_update'](name=name,
                                               description=description,
                                               enabled=enabled,
                                               profile=profile,
                                               **connection_args)
            ret['comment'] = 'Tenant / project "{0}" has been updated'.format(name)
            ret['changes']['Description'] = 'Updated'
        if tenant[name].get('enabled', None) != enabled:
            if __opts__.get('test'):
                ret['result'] = None
                ret['comment'] = 'Tenant / project "{0}" will be updated'.format(name)
                ret['changes']['Enabled'] = 'Will be {0}'.format(enabled)
                return ret
            __salt__['keystone.tenant_update'](name=name,
                                               description=description,
                                               enabled=enabled,
                                               profile=profile,
                                               **connection_args)
            ret['comment'] = 'Tenant / project "{0}" has been updated'.format(name)
            ret['changes']['Enabled'] = 'Now {0}'.format(enabled)
    else:
        if __opts__.get('test'):
            ret['result'] = None
            ret['comment'] = 'Tenant / project "{0}" will be added'.format(name)
            ret['changes']['Tenant'] = 'Will be created'
            return ret
        # Create tenant
        if _OS_IDENTITY_API_VERSION > 2:
            created = __salt__['keystone.project_create'](name=name, domain='default', description=description,
                                                          enabled=enabled, profile=profile, **connection_args)
        else:
            created = __salt__['keystone.tenant_create'](name=name, description=description, enabled=enabled,
                                                         profile=profile, **connection_args)
        ret['changes']['Tenant'] = 'Created' if created is True else 'Failed'
        ret['result'] = created
        ret['comment'] = 'Tenant / project "{0}" has been added'.format(name)
    return ret
549062
def delete_unknown_user(_debug)
      @current_users.each do |cu|
        cu.drop unless @managed_users.any? do |mu|
          cu.user == mu.user && cu.host == mu.host
        end
      end
    end