group_add name, restrict, repos
359436
def group_add(self, name, restrict, repos, lces=[], assets=[], queries=[],
                  policies=[], dashboards=[], credentials=[], description=''):
        '''
        '''
        return self.raw_query('group', 'add', data={
            'lces': [{'id': i} for i in lces],
            'assets': [{'id': i} for i in assets],
            'queries': [{'id': i} for i in queries],
            'policies': [{'id': i} for i in policies],
            'dashboardTabs': [{'id': i} for i in dashboards],
            'credentials': [{'id': i} for i in credentials],
            'repositories': [{'id': i} for i in repos],
            'definingAssets': [{'id': i} for i in restrict],
            'name': name,
            'description': description,
            'users': [],
            'context': ''
        })
177995
def permit_gitrepo(config_fpath, writeback=False):
    
    # Define search replace patterns
    username_regex = utool.named_field('username', utool.REGEX_VARNAME)
    username_repl = utool.backref_field('username')
    regexpat = r'https://github.com/' + username_regex + '/'
    replpat = r'git@github.com:' + username_repl + '/'
    # Read and replace
    lines = utool.read_from(config_fpath, aslines=True)
    newlines = utool.regex_replace_lines(lines, regexpat, replpat)
    # Writeback or print
    if not WRITEBACK:
        print(''.join(newlines))
    else:
        utool.write_to(config_fpath, newlines, aslines=True)
1333988
def cli(env, group_id, name, description):
    """"""
    mgr = SoftLayer.NetworkManager(env.client)
    data = {}
    if name:
        data['name'] = name
    if description:
        data['description'] = description

    if not mgr.edit_securitygroup(group_id, **data):
        raise exceptions.CLIAbort("Failed to edit security group")
723039
def add_user_to_group(username, group):
    """"""
    cmd = ['gpasswd', '-a', username, group]
    log("Adding user {} to group {}".format(username, group))
    subprocess.check_call(cmd)
751041
def add(self, group_name, session):
        ''''''
        request = TOPRequest('taobao.crm.group.add')
        request['group_name'] = group_name
        self.create(self.execute(request, session), fields=['is_success', 'group_id'])
        return self.is_success, self.group_id
938314
def repo_name
      unless @repo_name
        url = config["remote.#{name}.url"]
        raise GitProcessError.new("There is no #{name} url set up.") if url.nil? or url.empty?
        uri = Addressable::URI.parse(url)
        @repo_name = uri.path.sub(/\.git/, '').sub(/^\//, '')
      end
      @repo_name
    end
898934
def set(self, repo):
        
        name = repo.name
        if name in self.__repositories \
           and self.__repositories[name].is_initialized:
            raise ValueError('Can not replace repositories that have been '
                             'initialized.')
        self.__repositories[name] = repo
118790
def add_to_group(self, devices):
        """"""
        ids = {d.id for d in self.devices_in_group()}
        ids.update(self._device_ids(devices))
        self._set_group(ids)
1249649
public function groupAdd($group_name){
        $params=array(
            'group_name'=>$group_name
        );
        $rst = $this->_request->post($this->_url . 'group/add', $params);
        return $this->_client->rst($rst);
    }
954760
function rename_group($group_id, $new_name, &$new_gid)
    {
        $group_cache = $this->_fetch_groups();
        $old_dn      = $group_cache[$group_id]['dn'];
        $new_rdn     = "cn=" . rcube_ldap_generic::quote_string($new_name, true);
        $new_gid     = self::dn_encode($new_rdn . ',' . $this->groups_base_dn);

        if (!$this->ldap->rename($old_dn, $new_rdn, null, true)) {
            $this->set_error(self::ERROR_SAVING, 'errorsaving');
            return false;
        }

        if ($this->cache) {
            $this->cache->remove('groups');
        }

        return $new_name;
    }
599122
def create(self, group_view=False):
        
        self.add_handlers({'^T': self.quit, '^Q': self.quit})
        self.add(npyscreen.TitleText,
                 name='Select which tools to ' + self.action['action'] + ':',
                 editable=False)
        togglable = ['remove']
        if self.action['action_name'] in togglable:
            self.cur_view = self.add(npyscreen.TitleText,
                                     name='Group view:',
                                     value='all groups', editable=False,
                                     rely=3)
            self.add_handlers({'^V': self.toggle_view})
            i = 5
        else:
            i = 4

        if self.action['action_name'] == 'start':
            response = self.tools_inst.inventory(choices=['repos',
                                                          'tools',
                                                          'built',
                                                          'running'])
        else:
            response = self.tools_inst.inventory(choices=['repos', 'tools'])
        if response[0]:
            inventory = response[1]

            repos = inventory['repos']

            # dict has repo as key and list of core/non-core tools as values
            has_core = {}
            has_non_core = {}

            # find all tools that are in this repo
            # and list them if they are core
            for repo in repos:
                core_list = []
                ncore_list = []

                # splice the repo names for processing
                if (repo.startswith('http')):
                    repo_name = repo.rsplit('/', 2)[1:]
                else:
                    repo_name = repo.split('/')

                for tool in inventory['tools']:
                    tool_repo_name = tool.split(':')

                    # cross reference repo names
                    if (repo_name[0] == tool_repo_name[0] and
                            repo_name[1] == tool_repo_name[1]):
                        # check to ensure tool not set to locally active = no
                        # in vent.cfg
                        externally_active = False
                        vent_cfg_file = self.api_action.vent_config
                        vent_cfg = Template(vent_cfg_file)
                        tool_pairs = vent_cfg.section('external-services')[1]
                        for ext_tool in tool_pairs:
                            if ext_tool[0].lower() == inventory['tools'][tool]:
                                try:
                                    ext_tool_options = json.loads(ext_tool[1])
                                    loc = 'locally_active'
                                    if (loc in ext_tool_options and
                                            ext_tool_options[loc] == 'no'):
                                        externally_active = True
                                except Exception as e:
                                    self.logger.error("Couldn't check ext"
                                                      ' because: ' + str(e))
                                    externally_active = False
                        manifest = Template(self.api_action.manifest)
                        if not externally_active:
                            instance_num = re.search(r'\d+$',
                                                     manifest.option(
                                                         tool, 'name')[1])
                            if not instance_num:
                                ncore_list.append(tool)
                            # multiple instances share same image
                            elif self.action['action_name'] not in self.no_instance:
                                ncore_list.append(tool)

                has_core[repo] = core_list
                has_non_core[repo] = ncore_list

            for repo in repos:
                self.tools_tc[repo] = {}

                if self.action['cores']:
                    # make sure only repos with core tools are displayed
                    if has_core.get(repo):
                        self.repo_widgets[repo] = self.add(npyscreen.TitleText,
                                                           name='Plugin: '+repo,
                                                           editable=False,
                                                           rely=i, relx=5)

                        for tool in has_core[repo]:
                            tool_name = tool.split(':', 2)[2].split('/')[-1]
                            if tool_name == '':
                                tool_name = '/'
                            self.tools_tc[repo][tool] = self.add(
                                npyscreen.CheckBox, name=tool_name,
                                value=True, relx=10)
                            i += 1
                        i += 3
                else:
                    # make sure only repos with non-core tools are displayed
                    if has_non_core.get(repo):
                        self.repo_widgets[repo] = self.add(npyscreen.TitleText,
                                                           name='Plugin: '+repo,
                                                           editable=False,
                                                           rely=i, relx=5)

                        for tool in has_non_core[repo]:
                            tool_name = tool.split(':', 2)[2].split('/')[-1]
                            if tool_name == '':
                                tool_name = '/'
                            self.tools_tc[repo][tool] = self.add(
                                npyscreen.CheckBox, name=tool_name,
                                value=True, relx=10)
                            i += 1
                        i += 3
        return
81608
def edit!(**kwords)
      response = connection.send(:put,
                                 "/repos/#{self.Name}",
                                 body: JSON.generate(kwords))
      hash = JSON.parse(response.body, symbolize_names: true)
      return nil if hash == marshal_dump
      marshal_load(hash)
      self
    end
1301433
def pull_all_repos():
    """"""
    repos = ClonedRepo.objects.all()
    for repo in repos:
        if repo.origin is not None:
            pull_repo.delay(repo_name=repo.name)
1087095
def _api_group_for_type(cls):
    
    _groups = {
        (u"v1beta1", u"Deployment"): u"extensions",
        (u"v1beta1", u"DeploymentList"): u"extensions",
        (u"v1beta1", u"ReplicaSet"): u"extensions",
        (u"v1beta1", u"ReplicaSetList"): u"extensions",
    }
    key = (
        cls.apiVersion,
        cls.__name__.rsplit(u".")[-1],
    )
    group = _groups.get(key, None)
    return group
1023871
def add(name,
        uid=None,
        gid=None,
        groups=None,
        home=None,
        shell=None,
        unique=True,
        fullname='',
        roomnumber='',
        workphone='',
        homephone='',
        createhome=True,
        loginclass=None,
        **kwargs):
    '''
    
    '''
    kwargs = salt.utils.args.clean_kwargs(**kwargs)
    if salt.utils.data.is_true(kwargs.pop('system', False)):
        log.warning('pw_user module does not support the \'system\' argument')
    if kwargs:
        log.warning('Invalid kwargs passed to user.add')

    if isinstance(groups, six.string_types):
        groups = groups.split(',')
    cmd = ['pw', 'useradd']
    if uid:
        cmd.extend(['-u', uid])
    if gid:
        cmd.extend(['-g', gid])
    if groups:
        cmd.extend(['-G', ','.join(groups)])
    if home is not None:
        cmd.extend(['-d', home])
    if createhome is True:
        cmd.append('-m')
    if loginclass:
        cmd.extend(['-L', loginclass])
    if shell:
        cmd.extend(['-s', shell])
    if not salt.utils.data.is_true(unique):
        cmd.append('-o')
    gecos_field = _build_gecos({'fullname': fullname,
                                'roomnumber': roomnumber,
                                'workphone': workphone,
                                'homephone': homephone})
    cmd.extend(['-c', gecos_field])
    cmd.extend(['-n', name])
    return __salt__['cmd.retcode'](cmd, python_shell=False) == 0
56983
def get_gid(group_name)
      Etc.group { |g| return g.gid if g.name == group_name }
    end
152858
def add(name, gid=None, **kwargs):
    '''
    
    '''
    kwargs = salt.utils.args.clean_kwargs(**kwargs)
    if salt.utils.data.is_true(kwargs.pop('system', False)):
        log.warning('pw_group module does not support the \'system\' argument')
    if kwargs:
        log.warning('Invalid kwargs passed to group.add')

    cmd = 'pw groupadd '
    if gid:
        cmd += '-g {0} '.format(gid)
    cmd = '{0} -n {1}'.format(cmd, name)
    ret = __salt__['cmd.run_all'](cmd, python_shell=False)

    return not ret['retcode']