Just a convenience function for ``__salt__['cmd.run_all'](cmd)``
351826
def _run(cmd):
    '''
    
    '''
    return __salt__['cmd.run_all'](cmd, env={'HOME': os.path.expanduser('~{0}'.format(__opts__['user']))})
388354
def run_wfunc(self):
        '''
        
        '''
        # Ensure that opts/grains are up to date
        # Execute routine
        data_cache = False
        data = None
        cdir = os.path.join(self.opts['cachedir'], 'minions', self.id)
        if not os.path.isdir(cdir):
            os.makedirs(cdir)
        datap = os.path.join(cdir, 'ssh_data.p')
        refresh = False
        if not os.path.isfile(datap):
            refresh = True
        else:
            passed_time = (time.time() - os.stat(datap).st_mtime) / 60
            if passed_time > self.opts.get('cache_life', 60):
                refresh = True

        if self.opts.get('refresh_cache'):
            refresh = True
        conf_grains = {}
        # Save conf file grains before they get clobbered
        if 'ssh_grains' in self.opts:
            conf_grains = self.opts['ssh_grains']
        if not data_cache:
            refresh = True
        if refresh:
            # Make the datap
            # TODO: Auto expire the datap
            pre_wrapper = salt.client.ssh.wrapper.FunctionWrapper(
                self.opts,
                self.id,
                fsclient=self.fsclient,
                minion_opts=self.minion_opts,
                **self.target)
            opts_pkg = pre_wrapper['test.opts_pkg']()  # pylint: disable=E1102
            if '_error' in opts_pkg:
                #Refresh failed
                retcode = opts_pkg['retcode']
                ret = salt.utils.json.dumps({'local': opts_pkg})
                return ret, retcode

            opts_pkg['file_roots'] = self.opts['file_roots']
            opts_pkg['pillar_roots'] = self.opts['pillar_roots']
            opts_pkg['ext_pillar'] = self.opts['ext_pillar']
            opts_pkg['extension_modules'] = self.opts['extension_modules']
            opts_pkg['module_dirs'] = self.opts['module_dirs']
            opts_pkg['_ssh_version'] = self.opts['_ssh_version']
            opts_pkg['__master_opts__'] = self.context['master_opts']
            if 'known_hosts_file' in self.opts:
                opts_pkg['known_hosts_file'] = self.opts['known_hosts_file']
            if '_caller_cachedir' in self.opts:
                opts_pkg['_caller_cachedir'] = self.opts['_caller_cachedir']
            else:
                opts_pkg['_caller_cachedir'] = self.opts['cachedir']
            # Use the ID defined in the roster file
            opts_pkg['id'] = self.id

            retcode = 0

            # Restore master grains
            for grain in conf_grains:
                opts_pkg['grains'][grain] = conf_grains[grain]
            # Enable roster grains support
            if 'grains' in self.target:
                for grain in self.target['grains']:
                    opts_pkg['grains'][grain] = self.target['grains'][grain]

            popts = {}
            popts.update(opts_pkg)

            # Master centric operations such as mine.get must have master option loaded.
            # The pillar must then be compiled by passing master opts found in opts_pkg['__master_opts__']
            # which causes the pillar renderer to loose track of salt master options
            #
            # Depending on popts merge order, it will overwrite some options found in opts_pkg['__master_opts__']
            master_centric_funcs = [
              "pillar.items",
              "mine.get"
            ]

            # Pillar compilation is a master centric operation.
            # Master options take precedence during Pillar compilation
            popts.update(opts_pkg['__master_opts__'])

            pillar = salt.pillar.Pillar(
                    popts,
                    opts_pkg['grains'],
                    opts_pkg['id'],
                    opts_pkg.get('saltenv', 'base')
                    )
            pillar_data = pillar.compile_pillar()

            # Once pillar has been compiled, restore priority of minion opts
            if self.fun not in master_centric_funcs:
                log.debug('%s is a minion function', self.fun)
                popts.update(opts_pkg)
            else:
                log.debug('%s is a master function', self.fun)

            # TODO: cache minion opts in datap in master.py
            data = {'opts': opts_pkg,
                    'grains': opts_pkg['grains'],
                    'pillar': pillar_data}
            if data_cache:
                with salt.utils.files.fopen(datap, 'w+b') as fp_:
                    fp_.write(
                            self.serial.dumps(data)
                            )
        if not data and data_cache:
            with salt.utils.files.fopen(datap, 'rb') as fp_:
                data = self.serial.load(fp_)
        opts = data.get('opts', {})
        opts['grains'] = data.get('grains')

        # Restore master grains
        for grain in conf_grains:
            opts['grains'][grain] = conf_grains[grain]
        # Enable roster grains support
        if 'grains' in self.target:
            for grain in self.target['grains']:
                opts['grains'][grain] = self.target['grains'][grain]

        opts['pillar'] = data.get('pillar')
        wrapper = salt.client.ssh.wrapper.FunctionWrapper(
            opts,
            self.id,
            fsclient=self.fsclient,
            minion_opts=self.minion_opts,
            **self.target)
        self.wfuncs = salt.loader.ssh_wrapper(opts, wrapper, self.context)
        wrapper.wfuncs = self.wfuncs

        # We're running in the mine, need to fetch the arguments from the
        # roster, pillar, master config (in that order)
        if self.mine:
            mine_args = None
            mine_fun_data = None
            mine_fun = self.fun

            if self.mine_functions and self.fun in self.mine_functions:
                mine_fun_data = self.mine_functions[self.fun]
            elif opts['pillar'] and self.fun in opts['pillar'].get('mine_functions', {}):
                mine_fun_data = opts['pillar']['mine_functions'][self.fun]
            elif self.fun in self.context['master_opts'].get('mine_functions', {}):
                mine_fun_data = self.context['master_opts']['mine_functions'][self.fun]

            if isinstance(mine_fun_data, dict):
                mine_fun = mine_fun_data.pop('mine_function', mine_fun)
                mine_args = mine_fun_data
            elif isinstance(mine_fun_data, list):
                for item in mine_fun_data[:]:
                    if isinstance(item, dict) and 'mine_function' in item:
                        mine_fun = item['mine_function']
                        mine_fun_data.pop(mine_fun_data.index(item))
                mine_args = mine_fun_data
            else:
                mine_args = mine_fun_data

            # If we found mine_args, replace our command's args
            if isinstance(mine_args, dict):
                self.args = []
                self.kwargs = mine_args
            elif isinstance(mine_args, list):
                self.args = mine_args
                self.kwargs = {}

        try:
            if self.mine:
                result = wrapper[mine_fun](*self.args, **self.kwargs)
            else:
                result = self.wfuncs[self.fun](*self.args, **self.kwargs)
        except TypeError as exc:
            result = 'TypeError encountered executing {0}: {1}'.format(self.fun, exc)
            log.error(result, exc_info_on_loglevel=logging.DEBUG)
            retcode = 1
        except Exception as exc:
            result = 'An Exception occurred while executing {0}: {1}'.format(self.fun, exc)
            log.error(result, exc_info_on_loglevel=logging.DEBUG)
            retcode = 1
        # Mimic the json data-structure that "salt-call --local" will
        # emit (as seen in ssh_py_shim.py)
        if isinstance(result, dict) and 'local' in result:
            ret = salt.utils.json.dumps({'local': result['local']})
        else:
            ret = salt.utils.json.dumps({'local': {'return': result}})
        return ret, retcode
834598
def _cmd(binary, *args):
    '''
    
    '''
    binary = salt.utils.path.which(binary)
    if not binary:
        raise CommandNotFoundError('{0}: command not found'.format(binary))
    cmd = [binary] + list(args)
    return __salt__['cmd.run_stdout']([binary] + list(args),
                                      python_shell=False)
1189385
def run(self):
        '''
        
        '''
        # Parse shell arguments
        self.parse_args()

        salt_master_user = self.config.get('user')
        if salt_master_user is None:
            salt_master_user = salt.utils.user.get_user()

        if not check_user(salt_master_user):
            self.error(
                'If salt-cloud is running on a master machine, salt-cloud '
                'needs to run as the same user as the salt-master, \'{0}\'. '
                'If salt-cloud is not running on a salt-master, the '
                'appropriate write permissions must be granted to \'{1}\'. '
                'Please run salt-cloud as root, \'{0}\', or change '
                'permissions for \'{1}\'.'.format(
                    salt_master_user,
                    syspaths.CONFIG_DIR
                )
            )

        try:
            if self.config['verify_env']:
                verify_env(
                    [os.path.dirname(self.config['conf_file'])],
                    salt_master_user,
                    root_dir=self.config['root_dir'],
                )
                logfile = self.config['log_file']
                if logfile is not None and not logfile.startswith('tcp://') \
                        and not logfile.startswith('udp://') \
                        and not logfile.startswith('file://'):
                    # Logfile is not using Syslog, verify
                    verify_files([logfile], salt_master_user)
        except (IOError, OSError) as err:
            log.error('Error while verifying the environment: %s', err)
            sys.exit(err.errno)

        # Setup log file logging
        self.setup_logfile_logger()
        verify_log(self.config)

        if self.options.update_bootstrap:
            ret = salt.utils.cloud.update_bootstrap(self.config)
            salt.output.display_output(ret,
                                       self.options.output,
                                       opts=self.config)
            self.exit(salt.defaults.exitcodes.EX_OK)

        log.info('salt-cloud starting')
        try:
            mapper = salt.cloud.Map(self.config)
        except SaltCloudSystemExit as exc:
            self.handle_exception(exc.args, exc)
        except SaltCloudException as exc:
            msg = 'There was an error generating the mapper.'
            self.handle_exception(msg, exc)

        names = self.config.get('names', None)
        if names is not None:
            filtered_rendered_map = {}
            for map_profile in mapper.rendered_map:
                filtered_map_profile = {}
                for name in mapper.rendered_map[map_profile]:
                    if name in names:
                        filtered_map_profile[name] = mapper.rendered_map[map_profile][name]
                if filtered_map_profile:
                    filtered_rendered_map[map_profile] = filtered_map_profile
            mapper.rendered_map = filtered_rendered_map

        ret = {}

        if self.selected_query_option is not None:
            if self.selected_query_option == 'list_providers':
                try:
                    ret = mapper.provider_list()
                except (SaltCloudException, Exception) as exc:
                    msg = 'There was an error listing providers: {0}'
                    self.handle_exception(msg, exc)

            elif self.selected_query_option == 'list_profiles':
                provider = self.options.list_profiles
                try:
                    ret = mapper.profile_list(provider)
                except(SaltCloudException, Exception) as exc:
                    msg = 'There was an error listing profiles: {0}'
                    self.handle_exception(msg, exc)

            elif self.config.get('map', None):
                log.info('Applying map from \'%s\'.', self.config['map'])
                try:
                    ret = mapper.interpolated_map(
                        query=self.selected_query_option
                    )
                except (SaltCloudException, Exception) as exc:
                    msg = 'There was an error with a custom map: {0}'
                    self.handle_exception(msg, exc)
            else:
                try:
                    ret = mapper.map_providers_parallel(
                        query=self.selected_query_option
                    )
                except (SaltCloudException, Exception) as exc:
                    msg = 'There was an error with a map: {0}'
                    self.handle_exception(msg, exc)

        elif self.options.list_locations is not None:
            try:
                ret = mapper.location_list(
                    self.options.list_locations
                )
            except (SaltCloudException, Exception) as exc:
                msg = 'There was an error listing locations: {0}'
                self.handle_exception(msg, exc)

        elif self.options.list_images is not None:
            try:
                ret = mapper.image_list(
                    self.options.list_images
                )
            except (SaltCloudException, Exception) as exc:
                msg = 'There was an error listing images: {0}'
                self.handle_exception(msg, exc)

        elif self.options.list_sizes is not None:
            try:
                ret = mapper.size_list(
                    self.options.list_sizes
                )
            except (SaltCloudException, Exception) as exc:
                msg = 'There was an error listing sizes: {0}'
                self.handle_exception(msg, exc)

        elif self.options.destroy and (self.config.get('names', None) or
                                       self.config.get('map', None)):
            map_file = self.config.get('map', None)
            names = self.config.get('names', ())
            if map_file is not None:
                if names != ():
                    msg = 'Supplying a mapfile, \'{0}\', in addition to instance names {1} ' \
                          'with the \'--destroy\' or \'-d\' function is not supported. ' \
                          'Please choose to delete either the entire map file or individual ' \
                          'instances.'.format(map_file, names)
                    self.handle_exception(msg, SaltCloudSystemExit)

                log.info('Applying map from \'%s\'.', map_file)
                matching = mapper.delete_map(query='list_nodes')
            else:
                matching = mapper.get_running_by_names(
                    names,
                    profile=self.options.profile
                )

            if not matching:
                print('No machines were found to be destroyed')
                self.exit(salt.defaults.exitcodes.EX_OK)

            msg = 'The following virtual machines are set to be destroyed:\n'
            names = set()
            for alias, drivers in six.iteritems(matching):
                msg += '  {0}:\n'.format(alias)
                for driver, vms in six.iteritems(drivers):
                    msg += '    {0}:\n'.format(driver)
                    for name in vms:
                        msg += '      {0}\n'.format(name)
                        names.add(name)
            try:
                if self.print_confirm(msg):
                    ret = mapper.destroy(names, cached=True)
            except (SaltCloudException, Exception) as exc:
                msg = 'There was an error destroying machines: {0}'
                self.handle_exception(msg, exc)

        elif self.options.action and (self.config.get('names', None) or
                                      self.config.get('map', None)):
            if self.config.get('map', None):
                log.info('Applying map from \'%s\'.', self.config['map'])
                try:
                    names = mapper.get_vmnames_by_action(self.options.action)
                except SaltCloudException as exc:
                    msg = 'There was an error actioning virtual machines.'
                    self.handle_exception(msg, exc)
            else:
                names = self.config.get('names', None)

            kwargs = {}
            machines = []
            msg = (
                'The following virtual machines are set to be actioned with '
                '"{0}":\n'.format(
                    self.options.action
                )
            )
            for name in names:
                if '=' in name:
                    # This is obviously not a machine name, treat it as a kwarg
                    key, value = name.split('=', 1)
                    kwargs[key] = value
                else:
                    msg += '  {0}\n'.format(name)
                    machines.append(name)
            names = machines

            try:
                if self.print_confirm(msg):
                    ret = mapper.do_action(names, kwargs)
            except (SaltCloudException, Exception) as exc:
                msg = 'There was an error actioning machines: {0}'
                self.handle_exception(msg, exc)

        elif self.options.function:
            kwargs = {}
            args = self.args[:]
            for arg in args[:]:
                if '=' in arg:
                    key, value = arg.split('=', 1)
                    kwargs[key] = value
                    args.remove(arg)

            if args:
                self.error(
                    'Any arguments passed to --function need to be passed '
                    'as kwargs. Ex: image=ami-54cf5c3d. Remaining '
                    'arguments: {0}'.format(args)
                )
            try:
                ret = mapper.do_function(
                    self.function_provider, self.function_name, kwargs
                )
            except (SaltCloudException, Exception) as exc:
                msg = 'There was an error running the function: {0}'
                self.handle_exception(msg, exc)

        elif self.options.profile and self.config.get('names', False):
            try:
                ret = mapper.run_profile(
                    self.options.profile,
                    self.config.get('names')
                )
            except (SaltCloudException, Exception) as exc:
                msg = 'There was a profile error: {0}'
                self.handle_exception(msg, exc)

        elif self.options.set_password:
            username = self.credential_username
            provider_name = "salt.cloud.provider.{0}".format(self.credential_provider)
            # TODO: check if provider is configured
            # set the password
            salt.utils.cloud.store_password_in_keyring(provider_name, username)
        elif self.config.get('map', None) and \
                self.selected_query_option is None:
            if not mapper.rendered_map:
                sys.stderr.write('No nodes defined in this map')
                self.exit(salt.defaults.exitcodes.EX_GENERIC)
            try:
                ret = {}
                run_map = True

                log.info('Applying map from \'%s\'.', self.config['map'])
                dmap = mapper.map_data()

                msg = ''
                if 'errors' in dmap:
                    # display profile errors
                    msg += 'Found the following errors:\n'
                    for profile_name, error in six.iteritems(dmap['errors']):
                        msg += '  {0}: {1}\n'.format(profile_name, error)
                    sys.stderr.write(msg)
                    sys.stderr.flush()

                msg = ''
                if 'existing' in dmap:
                    msg += ('The following virtual machines already exist:\n')
                    for name in dmap['existing']:
                        msg += '  {0}\n'.format(name)

                if dmap['create']:
                    msg += ('The following virtual machines are set to be '
                            'created:\n')
                    for name in dmap['create']:
                        msg += '  {0}\n'.format(name)

                if 'destroy' in dmap:
                    msg += ('The following virtual machines are set to be '
                            'destroyed:\n')
                    for name in dmap['destroy']:
                        msg += '  {0}\n'.format(name)

                if not dmap['create'] and not dmap.get('destroy', None):
                    if not dmap.get('existing', None):
                        # nothing to create or destroy & nothing exists
                        print(msg)
                        self.exit(1)
                    else:
                        # nothing to create or destroy, print existing
                        run_map = False

                if run_map:
                    if self.print_confirm(msg):
                        ret = mapper.run_map(dmap)

                    if self.config.get('parallel', False) is False:
                        log.info('Complete')

                if dmap.get('existing', None):
                    for name in dmap['existing']:
                        if 'ec2' in dmap['existing'][name]['provider']:
                            msg = 'Instance already exists, or is terminated and has the same name.'
                        else:
                            msg = 'Already running.'
                        ret[name] = {'Message': msg}

            except (SaltCloudException, Exception) as exc:
                msg = 'There was a query error: {0}'
                self.handle_exception(msg, exc)

        elif self.options.bootstrap:
            host = self.options.bootstrap
            if self.args and '=' not in self.args[0]:
                minion_id = self.args.pop(0)
            else:
                minion_id = host

            vm_ = {
                'driver': '',
                'ssh_host': host,
                'name': minion_id,
            }
            args = self.args[:]
            for arg in args[:]:
                if '=' in arg:
                    key, value = arg.split('=', 1)
                    vm_[key] = value
                    args.remove(arg)

            if args:
                self.error(
                    'Any arguments passed to --bootstrap need to be passed as '
                    'kwargs. Ex: ssh_username=larry. Remaining arguments: {0}'.format(args)
                )

            try:
                ret = salt.utils.cloud.bootstrap(vm_, self.config)
            except (SaltCloudException, Exception) as exc:
                msg = 'There was an error bootstrapping the minion: {0}'
                self.handle_exception(msg, exc)

        else:
            self.error('Nothing was done. Using the proper arguments?')

        salt.output.display_output(ret,
                                   self.options.output,
                                   opts=self.config)
        self.exit(salt.defaults.exitcodes.EX_OK)
1266780
def run(self):
        '''
        
        '''
        import salt.key
        self.parse_args()

        self.setup_logfile_logger()
        verify_log(self.config)

        key = salt.key.KeyCLI(self.config)
        if check_user(self.config['user']):
            key.run()
246753
def map_run(self, path=None, **kwargs):
        '''
        
        '''
        kwarg = {}
        if path:
            kwarg['map'] = path
        kwarg.update(kwargs)
        mapper = salt.cloud.Map(self._opts_defaults(**kwarg))
        dmap = mapper.map_data()
        return salt.utils.data.simple_types_filter(
            mapper.run_map(dmap)
        )
413442
def mod_run_check(cmd_kwargs, onlyif, unless):
    '''
    
    '''
    cmd_kwargs = copy.deepcopy(cmd_kwargs)
    cmd_kwargs.update({
        'use_vt': False,
        'bg': False,
        'ignore_retcode': True,
        'python_shell': True,
    })

    if onlyif is not None:
        if not isinstance(onlyif, list):
            onlyif = [onlyif]

        for command in onlyif:
            if not isinstance(command, six.string_types) and command:
                # Boolean or some other non-string which resolves to True
                continue
            try:
                if __salt__['cmd.retcode'](command, **cmd_kwargs) == 0:
                    # Command exited with a zero retcode
                    continue
            except Exception as exc:
                log.exception(
                    'The following onlyif command raised an error: %s',
                    command
                )
                return {
                    'comment': 'onlyif raised error ({0}), see log for '
                               'more details'.format(exc),
                    'result': False
                }

            return {'comment': 'onlyif condition is false',
                    'skip_watch': True,
                    'result': True}

    if unless is not None:
        if not isinstance(unless, list):
            unless = [unless]

        for command in unless:
            if not isinstance(command, six.string_types) and not command:
                # Boolean or some other non-string which resolves to False
                break
            try:
                if __salt__['cmd.retcode'](command, **cmd_kwargs) != 0:
                    # Command exited with a non-zero retcode
                    break
            except Exception as exc:
                log.exception(
                    'The following unless command raised an error: %s',
                    command
                )
                return {
                    'comment': 'unless raised error ({0}), see log for '
                               'more details'.format(exc),
                    'result': False
                }
        else:
            return {'comment': 'unless condition is true',
                    'skip_watch': True,
                    'result': True}

    return True
1022411
def sync_all(name, **kwargs):
    '''
    
    '''
    ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}

    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = "saltutil.sync_all would have been run"
        return ret

    try:
        sync_status = __salt__['saltutil.sync_all'](**kwargs)
        for key, value in sync_status.items():
            if value:
                ret['changes'][key] = value
                ret['comment'] = "Sync performed"
    except Exception as e:
        log.error("Failed to run saltutil.sync_all: %s", e)
        ret['result'] = False
        ret['comment'] = "Failed to run sync_all: {0}".format(e)
        return ret

    if not ret['changes']:
        ret['comment'] = "No updates to sync"

    return ret
925426
def __run_post_all(self):
        """"""

        # if the list of delta dirs is [delta1, delta2] the post scripts of delta1 are
        # executed before the post scripts of delta2

        for d in self.dirs:
            post_all_py_path = os.path.join(d, 'post-all.py')
            if os.path.isfile(post_all_py_path):
                print('     Applying post-all.py...', end=' ')
                self.__run_py_file(post_all_py_path, 'post-all')
                print('OK')

            post_all_sql_path = os.path.join(d, 'post-all.sql')
            if os.path.isfile(post_all_sql_path):
                print('     Applying post-all.sql...', end=' ')
                self.__run_sql_file(post_all_sql_path)
                print('OK')
944966
def run(self, cmd):
        
        # TODO: can this be removed ?
        import __main__
        main_dict = __main__.__dict__
        return self.runctx(cmd, main_dict, main_dict)
586754
def mod_run_check_cmd(cmd, filename, **check_cmd_opts):
    '''
    
    '''

    log.debug('running our check_cmd')
    _cmd = '{0} {1}'.format(cmd, filename)
    cret = __salt__['cmd.run_all'](_cmd, **check_cmd_opts)
    if cret['retcode'] != 0:
        ret = {'comment': 'check_cmd execution failed',
               'skip_watch': True,
               'result': False}

        if cret.get('stdout'):
            ret['comment'] += '\n' + cret['stdout']
        if cret.get('stderr'):
            ret['comment'] += '\n' + cret['stderr']

        return ret

    # No reason to stop, return True
    return True
1087980
def _run_cmd(cmds):
    """"""
    if not isinstance(cmds, str):
        cmds = "".join(cmds)
    print("Execute \"%s\"" % cmds)
    try:
        subprocess.check_call(cmds, shell=True)
    except subprocess.CalledProcessError as err:
        print(err)
        raise err
1095274
def _run_cmd(cmd):
    """"""
    if not os.path.exists(cmd[0]):
        cmd[0] = shutil.which(cmd[0])
        assert cmd[0] is not None

    shebang_parts = parseshebang.parse(cmd[0])

    proc = subprocess.Popen(shebang_parts + cmd,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    stdout, stderr = proc.communicate()
    return {
        "stdout": stdout,
        "stderr": stderr,
        "code": proc.returncode
    }
1043013
def run(self, argv):
        """"""
        command = argv[0]
        handlers = { 
            'clean': self.clean,
            'create': self.create,
            'disable': self.disable,
            'enable': self.enable,
            'list': self.list,
            'update': self.update,
        }
        handler = handlers.get(command, None)
        if handler is None:
            error("Unrecognized command: %s" % command, 2)
        handler(argv[1:])
324729
def _cmd_run(cmd):
    '''
    
    '''
    cmd.insert(0, 'aptly')
    cmd_ret = __salt__['cmd.run_all'](cmd, ignore_retcode=True)

    if cmd_ret['retcode'] != 0:
        log.debug('Unable to execute command: %s\nError: %s', cmd,
                   cmd_ret['stderr'])

    return cmd_ret['stdout']
795133
def init(runlevel):
    '''
    
    '''
    cmd = ['init', '{0}'.format(runlevel)]
    ret = __salt__['cmd.run'](cmd, python_shell=False)
    return ret
1359017
def run(self, cmd):
        """"""
        import __main__
        dikt = __main__.__dict__
        return self.runctx(cmd, dikt, dikt)