• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python log.debug函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中salt.log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了debug函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: grain_match

 def grain_match(self, tgt):
     '''
     Reads in the grains glob match
     '''
     log.debug('grains target: {0}'.format(tgt))
     comps = tgt.rsplit(':', 1)
     if len(comps) != 2:
         log.error('Got insufficient arguments for grains match '
                   'statement from master')
         return False
     match = self._traverse_dict(self.opts['grains'], comps[0])
     if match == {}:
         log.error('Targeted grain "{0}" not found'.format(comps[0]))
         return False
     if isinstance(match, dict):
         log.error('Targeted grain "{0}" must correspond to a list, '
                   'string, or numeric value'.format(comps[0]))
         return False
     if isinstance(match, list):
         # We are matching a single component to a single list member
         for member in match:
             if fnmatch.fnmatch(str(member).lower(), comps[1].lower()):
                 return True
         return False
     return bool(fnmatch.fnmatch(str(match).lower(), comps[1].lower()))
开发者ID:11craft,项目名称:salt,代码行数:25,代码来源:minion.py


示例2: _handle_aes

 def _handle_aes(self, load):
     '''
     Takes the aes encrypted load, decrypts is and runs the encapsulated
     instructions
     '''
     try:
         data = self.crypticle.loads(load)
     except AuthenticationError:
         self.authenticate()
         data = self.crypticle.loads(load)
     # Verify that the publication is valid
     if 'tgt' not in data or 'jid' not in data or 'fun' not in data \
        or 'arg' not in data:
         return
     # Verify that the publication applies to this minion
     if 'tgt_type' in data:
         if not getattr(self.matcher,
                        '{0}_match'.format(data['tgt_type']))(data['tgt']):
             return
     else:
         if not self.matcher.glob_match(data['tgt']):
             return
     # If the minion does not have the function, don't execute,
     # this prevents minions that could not load a minion module
     # from returning a predictable exception
     #if data['fun'] not in self.functions:
     #    return
     if 'user' in data:
         log.info(('User {0[user]} Executing command {0[fun]} with jid '
                   '{0[jid]}'.format(data)))
     else:
         log.info(('Executing command {0[fun]} with jid {0[jid]}'
                   .format(data)))
     log.debug('Command details {0}'.format(data))
     self._handle_decoded_payload(data)
开发者ID:11craft,项目名称:salt,代码行数:35,代码来源:minion.py


示例3: load_config

def load_config(opts, path, env_var):
    '''
    Attempts to update ``opts`` dict by parsing either the file described by
    ``path`` or the environment variable described by ``env_var`` as YAML.
    '''
    if not path or not os.path.isfile(path):
        path = os.environ.get(env_var, path)
    # If the configuration file is missing, attempt to copy the template,
    # after removing the first header line.
    if not os.path.isfile(path):
        template = '{0}.template'.format(path)
        if os.path.isfile(template):
            with open(path, 'w') as out:
                with open(template, 'r') as f:
                    f.readline()  # skip first line
                    out.write(f.read())

    if os.path.isfile(path):
        try:
            opts.update(_read_conf_file(path))
            opts['conf_file'] = path
        except Exception as e:
            import salt.log
            msg = 'Error parsing configuration file: {0} - {1}'
            if salt.log.is_console_configured():
                log.warn(msg.format(path, e))
            else:
                print(msg.format(path, e))
    else:
        log.debug('Missing configuration file: {0}'.format(path))
开发者ID:fatbox,项目名称:salt,代码行数:30,代码来源:config.py


示例4: _dism

def _dism(action,
          image=None):
    '''
    Run a DISM servicing command on the given image.
    '''
    command='dism {0} {1}'.format(
        '/Image:{0}'.format(image) if image else '/Online',
        action
    )
    ret = {'action': action,
           'image': image,
           'result': True,
           'message': ''}
    output = __salt__['cmd.run'](command, ignore_retcode=True)
    if not re.search('The operation completed successfully.', output):
        ret['result'] = False
        ret['message'] = re.search(
            '(Error: \d+\r?\n\r?\n([^\r\n]+\r?\n)+\r?\nThe DISM log file can be found at [^\r\n]\r?\n)',
            output,
            re.MULTILINE
        ).group(1)
        log.exception('DISM command \'{0}\' on image {1} failed: {2}'.format(action, image, ret['message']))
    else:
        ret['message'] = output
        log.debug('DISM command \'{0}\' on image {1} completed with the following output: {2}'.format(action, image, output))
    return ret
开发者ID:ibrsp,项目名称:active-directory-formula,代码行数:26,代码来源:windows_servicing.py


示例5: _get_cached_minion_data

 def _get_cached_minion_data(self, *minion_ids):
     # Return two separate dicts of cached grains and pillar data of the minions
     grains = dict([(minion_id, {}) for minion_id in minion_ids])
     pillars = grains.copy()
     if not self.opts.get('minion_data_cache', False):
         log.debug('Skipping cached data because minion_data_cache is not enabled.')
         return grains, pillars
     serial = salt.payload.Serial(self.opts)
     mdir = os.path.join(self.opts['cachedir'], 'minions')
     # salt.utils.verify.valid_id has changed in git development to require opts arg
     valid_id_args = inspect.getargspec(salt.utils.verify.valid_id).args
     log.debug('salt.utils.verify.valid_id accepts args: {0}'.format(valid_id_args))
     try:
         for minion_id in minion_ids:
             if 'opts' in valid_id_args:
                 if not salt.utils.verify.valid_id(self.opts, minion_id):
                     continue
             else:
                 if not salt.utils.verify.valid_id(self.opts, minion_id):
                     continue
             path = os.path.join(mdir, minion_id, 'data.p')
             if os.path.isfile(path):
                 with salt.utils.fopen(path) as fp_:
                     mdata = serial.loads(fp_.read())
                     if mdata.get('grains', False):
                         grains[minion_id] = mdata['grains']
                     if mdata.get('pillar', False):
                         pillars[minion_id] = mdata['pillar']
     except (OSError, IOError):
         return grains, pillars
     return grains, pillars
开发者ID:jslatts,项目名称:salt,代码行数:31,代码来源:master.py


示例6: ext_pillar

def ext_pillar(minion_id,  # pylint: disable=W0613
               pillar,  # pylint: disable=W0613
               config_file):
    '''
    Execute LDAP searches and return the aggregated data
    '''
    if os.path.isfile(config_file):
        try:
            #open(config_file, 'r') as raw_config:
            config = _render_template(config_file) or {}
            opts = yaml.safe_load(config) or {}
            opts['conf_file'] = config_file
        except Exception as err:
            import salt.log
            msg = 'Error parsing configuration file: {0} - {1}'
            if salt.log.is_console_configured():
                log.warn(msg.format(config_file, err))
            else:
                print(msg.format(config_file, err))
    else:
        log.debug('Missing configuration file: {0}'.format(config_file))

    data = {}
    for source in opts['search_order']:
        config = opts[source]
        result = _do_search(config)
        print('source {0} got result {1}'.format(source, result))
        if result:
            data = _result_to_dict(data, result, config)
    return data
开发者ID:DavideyLee,项目名称:salt,代码行数:30,代码来源:pillar_ldap.py


示例7: __init__

    def __init__(self, opts, log_queue=None):
        '''
        starts the timer and inits the cache itself
        '''
        super(ConnectedCache, self).__init__(log_queue=log_queue)
        log.debug('ConCache initializing...')

        # the possible settings for the cache
        self.opts = opts

        # the actual cached minion ids
        self.minions = []

        self.cache_sock = os.path.join(self.opts['sock_dir'], 'con_cache.ipc')
        self.update_sock = os.path.join(self.opts['sock_dir'], 'con_upd.ipc')
        self.upd_t_sock = os.path.join(self.opts['sock_dir'], 'con_timer.ipc')
        self.cleanup()

        # the timer provides 1-second intervals to the loop in run()
        # to make the cache system most responsive, we do not use a loop-
        # delay which makes it hard to get 1-second intervals without a timer
        self.timer_stop = Event()
        self.timer = CacheTimer(self.opts, self.timer_stop)
        self.timer.start()
        self.running = True
开发者ID:bryson,项目名称:salt,代码行数:25,代码来源:master.py


示例8: stop

    def stop(self,
             signal,
             frame):
        '''
        we override stop() to brake our main loop
        and have a pretty log message
        '''
        log.info("received signal {0}".format(signal))

        # if we have running workers, run through all and join() the ones
        # that have finished. if we still have running workers after that,
        # wait 5 secs for the rest and then exit. Maybe we should improv
        # this a litte bit more
        if( len(self.running_workers) > 0 ):
            clean_workers = []

            for count in range(0, 2):
                for worker in self.running_workers:
                    if worker.isAlive():
                        clean_workers.append(worker)
                    else:
                        worker.join()
                        log.debug("joined worker #{0}".format(worker.getName()))

                if( len(clean_workers) > 0 ):
                    log.info("waiting 5secs for remaining workers..")
                    time.sleep(5)
                else:
                    break

        log.info("salt-eventsd has shut down")

        # leave the cleanup to the supers stop
        super(SaltEventsDaemon, self).stop(signal, frame)
开发者ID:ekristen,项目名称:salt-eventsd,代码行数:34,代码来源:__init__.py


示例9: start

 def start(self):
     log.debug("starting monitor with {} task{}".format(len(self.tasks), "" if len(self.tasks) == 1 else "s"))
     if self.tasks:
         for task in self.tasks:
             threading.Thread(target=task.run).start()
     else:
         log.error("no monitor tasks to run")
开发者ID:perlchild,项目名称:salt-monitor,代码行数:7,代码来源:monitor.py


示例10: _get_cached_minion_data

 def _get_cached_minion_data(self, *minion_ids):
     # Return two separate dicts of cached grains and pillar data of the
     # minions
     grains = dict([(minion_id, {}) for minion_id in minion_ids])
     pillars = grains.copy()
     if not self.opts.get('minion_data_cache', False):
         log.debug('Skipping cached data because minion_data_cache is not '
                   'enabled.')
         return grains, pillars
     mdir = os.path.join(self.opts['cachedir'], 'minions')
     try:
         for minion_id in minion_ids:
             if not salt.utils.verify.valid_id(self.opts, minion_id):
                 continue
             path = os.path.join(mdir, minion_id, 'data.p')
             if os.path.isfile(path):
                 with salt.utils.fopen(path, 'rb') as fp_:
                     mdata = self.serial.loads(fp_.read())
                     if mdata.get('grains', False):
                         grains[minion_id] = mdata['grains']
                     if mdata.get('pillar', False):
                         pillars[minion_id] = mdata['pillar']
     except (OSError, IOError):
         return grains, pillars
     return grains, pillars
开发者ID:wikimedia,项目名称:operations-debs-salt,代码行数:25,代码来源:master.py


示例11: get_minion_grains

    def get_minion_grains(self):
        '''
        Get grains data for the targeted minions, either by fetching the
        cached minion data on the master, or by fetching the grains
        directly on the minion.

        By default, this function tries hard to get the pillar data:
            - Try to get the cached minion grains if the master
                has minion_data_cache: True
            - If the grains data for the minion is cached, use it.
            - If there is no cached grains data for a minion,
                then try to get the minion grains directly from the minion.
        '''
        minion_grains = {}
        minion_ids = self._tgt_to_list()
        if any(arg for arg in [self.use_cached_grains, self.grains_fallback]):
            log.debug('Getting cached minion data.')
            cached_minion_grains, cached_minion_pillars = self._get_cached_minion_data(*minion_ids)
        else:
            cached_minion_grains = {}
        log.debug('Getting minion grain data for: {0}'.format(minion_ids))
        minion_grains = self._get_minion_grains(
                                        *minion_ids,
                                        cached_grains=cached_minion_grains)
        return minion_grains
开发者ID:wikimedia,项目名称:operations-debs-salt,代码行数:25,代码来源:master.py


示例12: __init__

 def __init__(self,
              tgt='',
              expr_form='glob',
              env=None,
              use_cached_grains=True,
              use_cached_pillar=True,
              grains_fallback=True,
              pillar_fallback=True,
              opts=None):
     log.debug('New instance of {0} created.'.format(
         self.__class__.__name__))
     if opts is None:
         log.error('{0}: Missing master opts init arg.'.format(
             self.__class__.__name__))
         raise SaltException('{0}: Missing master opts init arg.'.format(
             self.__class__.__name__))
     else:
         self.opts = opts
     self.tgt = tgt
     self.expr_form = expr_form
     self.env = env
     self.use_cached_grains = use_cached_grains
     self.use_cached_pillar = use_cached_pillar
     self.grains_fallback = grains_fallback
     self.pillar_fallback = pillar_fallback
     log.debug('Init settings: tgt: \"{0}\", expr_form: \"{1}\", env: \"{2}\", use_cached_grains: {3}, use_cached_pillar: {4}, grains_fallback: {5}, pillar_fallback: {6}'.format(tgt, expr_form, env, use_cached_grains, use_cached_pillar, grains_fallback, pillar_fallback))
开发者ID:jslatts,项目名称:salt,代码行数:26,代码来源:master.py


示例13: __init__

    def __init__(self, parser):
        self.parser = parser

        log.debug("TODO: load more manager here")
        self.manager = LibvirtManager()
        self.image = ImageService()
        self.flavor = FlavorService()
开发者ID:crook,项目名称:hellostack,代码行数:7,代码来源:shell.py


示例14: immutable_encoder

 def immutable_encoder(obj):
     log.debug('IMMUTABLE OBJ: {0}'.format(obj))
     if isinstance(obj, immutabletypes.ImmutableDict):
         return dict(obj)
     if isinstance(obj, immutabletypes.ImmutableList):
         return list(obj)
     if isinstance(obj, immutabletypes.ImmutableSet):
         return set(obj)
开发者ID:bryson,项目名称:salt,代码行数:8,代码来源:payload.py


示例15: get_cached_mine_data

 def get_cached_mine_data(self):
     '''
     Get cached mine data for the targeted minions.
     '''
     mine_data = {}
     minion_ids = self._tgt_to_list()
     log.debug('Getting cached mine data for: {0}'.format(minion_ids))
     mine_data = self._get_cached_mine_data(*minion_ids)
     return mine_data
开发者ID:wikimedia,项目名称:operations-debs-salt,代码行数:9,代码来源:master.py


示例16: run

 def run(self):
     '''
     Gather currently connected minions and update the cache
     '''
     new_mins = list(salt.utils.minions.CkMinions(self.opts).connected_ids())
     cc = cache_cli(self.opts)
     cc.get_cached()
     cc.put_cache([new_mins])
     log.debug('ConCache CacheWorker update finished')
开发者ID:bryson,项目名称:salt,代码行数:9,代码来源:master.py


示例17: _linux_gpu_data

def _linux_gpu_data():
    '''
    num_gpus: int
    gpus:
      - vendor: nvidia|amd|ati|...
        model: string
    '''
    # dominant gpu vendors to search for (MUST be lowercase for matching below)
    known_vendors = ['nvidia', 'amd', 'ati', 'intel']

    devs = []
    try:
        lspci_out = __salt__['cmd.run']('lspci -vmm')

        cur_dev = {}
        error = False
        for line in lspci_out.splitlines():
            # check for record-separating empty lines
            if line == '':
                if cur_dev.get('Class', '') == 'VGA compatible controller':
                    devs.append(cur_dev)
                # XXX; may also need to search for "3D controller"
                cur_dev = {}
                continue
            if re.match(r'^\w+:\s+.*', line):
                key, val = line.split(':', 1)
                cur_dev[key.strip()] = val.strip()
            else:
                error = True
                log.debug('Unexpected lspci output: \'{0}\''.format(line))

        if error:
            log.warn(
                'Error loading grains, unexpected linux_gpu_data output, '
                'check that you have a valid shell configured and '
                'permissions to run lspci command'
            )
    except OSError:
        pass

    gpus = []
    for gpu in devs:
        vendor_strings = gpu['Vendor'].lower().split()
        # default vendor to 'unknown', overwrite if we match a known one
        vendor = 'unknown'
        for name in known_vendors:
            # search for an 'expected' vendor name in the list of strings
            if name in vendor_strings:
                vendor = name
                break
        gpus.append({'vendor': vendor, 'model': gpu['Device']})

    grains = {}
    grains['num_gpus'] = len(gpus)
    grains['gpus'] = gpus
    return grains
开发者ID:herlo,项目名称:salt,代码行数:56,代码来源:core.py


示例18: renew

 def renew(self):
     '''
     compares the current minion list against the ips
     connected on the master publisher port and updates
     the minion list accordingly
     '''
     log.debug('ConCache renewing minion cache')
     new_mins = list(salt.utils.minions.CkMinions(self.opts).connected_ids())
     self.minions = new_mins
     log.debug('ConCache received {0} minion ids'.format(len(new_mins)))
开发者ID:qzchenwl,项目名称:saltstack-verify,代码行数:10,代码来源:master.py


示例19: _tgt_to_list

 def _tgt_to_list(self):
     # Return a list of minion ids that match the target and expr_form
     minion_ids = []
     ckminions = salt.utils.minions.CkMinions(self.opts)
     minion_ids = ckminions.check_minions(self.tgt, self.expr_form)
     if len(minion_ids) == 0:
         log.debug('No minions matched for tgt="{0}" and expr_form="{1}"'.format(self.tgt, self.expr_form))
         return {}
     log.debug('Matching minions for tgt="{0}" and expr_form="{1}": {2}'.format(self.tgt, self.expr_form, minion_ids))
     return minion_ids
开发者ID:wikimedia,项目名称:operations-debs-salt,代码行数:10,代码来源:master.py


示例20: _get_live_minion_grains

 def _get_live_minion_grains(self, minion_ids):
     # Returns a dict of grains fetched directly from the minions
     log.debug('Getting live grains for minions: "{0}"'.format(minion_ids))
     client = salt.client.get_local_client(self.opts['conf_file'])
     ret = client.cmd(
                    ','.join(minion_ids),
                     'grains.items',
                     timeout=self.opts['timeout'],
                     expr_form='list')
     return ret
开发者ID:wikimedia,项目名称:operations-debs-salt,代码行数:10,代码来源:master.py



注:本文中的salt.log.debug函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python log.error函数代码示例发布时间:2022-05-27
下一篇:
Python moves.zip函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap