# Path: hardware/cmdb.py
# LOG = logging.getLogger('hardware.cmdb')
# class CmdbError(Exception):
# def cmdb_filename(cfg_dir, name):
# def load_cmdb(cfg_dir, name):
# def save_cmdb(cfg_dir, name, cmdb):
# def update_cmdb(cmdb, var, pref, forced_find):
#     def update_entry(entry, cmdb, idx):
# 
# Path: hardware/matcher.py
# LOG = logging.getLogger('hardware.matcher')
# _FUNC_REGEXP = re.compile(r'^([^(]+)'          # function name
#                           r'\(\s*([^,]+)'      # first argument
#                           r'(?:\s*,\s*(.+))?'  # remaining optional arguments
#                           r'\)$')              # last parenthesis
# def _adder(array, index, value):
# def _appender(array, index, value):
# def _range(elt, minval, maxval):
# def _gt(left, right):
# def _ge(left, right):
# def _lt(left, right):
# def _le(left, right):
# def _not(_, right):
# def _and(_, left, right):
# def _or(_, left, right):
# def _network(left, right):
# def _regexp(left, right):
# def _in(elt, *lst):
# def _call_func(func, implicit, res):
# def _extract_result(implicit, expr):
# def match_spec(spec, lines, arr, adder=_adder):
# def match_all(lines, specs, arr, arr2, debug=False, level=0):
# def match_multiple(lines, spec, arr):
# def generate_filename_and_macs(items):


import errno
import logging
import os
import pprint
import time
from hardware import cmdb
from hardware import matcher
If a profiles matches, its count is decremented.

Returns the name of the matching profile.
'''
        idx = 0
        times = '*'
        name = None
        valid_roles = []
        for name, times in self._data:
            LOG.info('testing %s' % name)
            if times == '*' or int(times) > 0:
                valid_roles.append(name)
                specs = self._load_specs(name)
                var = {}
                var2 = {}
                if matcher.match_all(hw_items, specs, var, var2):
                    LOG.info('Specs %s matches' % name)

                    forced = (var2 != {})

                    if var2 == {}:
                        var2 = var

                    if times != '*':
                        self._data[idx] = (name, int(times) - 1)
                        LOG.info('Decrementing %s to %d' %
                                 (name, int(times) - 1))

                    dbase = cmdb.load_cmdb(self._cfg_dir, name)
                    if dbase:

# Path: hardware/cmdb.py
# LOG = logging.getLogger('hardware.cmdb')
# class CmdbError(Exception):
# def cmdb_filename(cfg_dir, name):
# def load_cmdb(cfg_dir, name):
# def save_cmdb(cfg_dir, name, cmdb):
# def update_cmdb(cmdb, var, pref, forced_find):
#     def update_entry(entry, cmdb, idx):
# 
# Path: hardware/matcher.py
# LOG = logging.getLogger('hardware.matcher')
# _FUNC_REGEXP = re.compile(r'^([^(]+)'          # function name
#                           r'\(\s*([^,]+)'      # first argument
#                           r'(?:\s*,\s*(.+))?'  # remaining optional arguments
#                           r'\)$')              # last parenthesis
# def _adder(array, index, value):
# def _appender(array, index, value):
# def _range(elt, minval, maxval):
# def _gt(left, right):
# def _ge(left, right):
# def _lt(left, right):
# def _le(left, right):
# def _not(_, right):
# def _and(_, left, right):
# def _or(_, left, right):
# def _network(left, right):
# def _regexp(left, right):
# def _in(elt, *lst):
# def _call_func(func, implicit, res):
# def _extract_result(implicit, expr):
# def match_spec(spec, lines, arr, adder=_adder):
# def match_all(lines, specs, arr, arr2, debug=False, level=0):
# def match_multiple(lines, spec, arr):
# def generate_filename_and_macs(items):


# Path: hardware/state.py
import errno
import logging
import os
import pprint
import time
from hardware import cmdb
from hardware import matcher

If a profiles matches, its count is decremented.

Returns the name of the matching profile.
'''
        idx = 0
        times = '*'
        name = None
        valid_roles = []
        for name, times in self._data:
            LOG.info('testing %s' % name)
            if times == '*' or int(times) > 0:
                valid_roles.append(name)
                specs = self._load_specs(name)
                var = {}
                var2 = {}
                if matcher.match_all(hw_items, specs, var, var2):
                    LOG.info('Specs %s matches' % name)

                    forced = (var2 != {})

                    if var2 == {}:
                        var2 = var

                    if times != '*':
                        self._data[idx] = (name, int(times) - 1)
                        LOG.info('Decrementing %s to %d' %
                                 (name, int(times) - 1))

                    dbase = cmdb.load_cmdb(self._cfg_dir, name)
                    if dbase:

                        if cmdb.update_cmdb(dbase, var, var2, forced):