Exemple #1
0
def deviceValidate(device, version):
    '''This function validates if the device matches one of the versions
    supported by the device package. This function should do a compare (regular
    expression match) the version fetched from the device with version
    string passed in the param.

    @param device: dict
        a device dictionary
    @param version: str
         a regular expression for the supported versions of the device.
         e.g: '1.0'
     @return: dict
        {'state': <state>, 'version': <version>}
    '''
    env.debug("[Version argument]\n%s" % version)

    result = {}
    asa_version, error = read_asa_version(device)
    if asa_version:
        result['version'] = asa_version
        match = re.compile(version).match(asa_version)
        result['state'] = Status.SUCCESS if match else Status.PERMANENT
        if not match:
            result['faults'] = [
                (get_config_root_key({}), 0,
                 'Device running un-supported ASA version %s' % asa_version)
            ]
    else:  #not able to connect
        result['state'] = Status.TRANSIENT
        result['faults'] = [(get_config_root_key({}), 0, error)]
    return result
def deviceValidate(device,
                   version):
    '''This function validates if the device matches one of the versions
    supported by the device package. This function should do a compare (regular
    expression match) the version fetched from the device with version
    string passed in the param.

    @param device: dict
        a device dictionary
    @param version: str
         a regular expression for the supported versions of the device.
         e.g: '1.0'
     @return: dict
        {'state': <state>, 'version': <version>}
    '''
    env.debug("[Version argument]\n%s" % version)

    result = {}
    asa_version, error = read_asa_version(device)
    if asa_version:
        result['version'] = asa_version
        match =  re.compile(version).match(asa_version)
        result['state'] = Status.SUCCESS if match else Status.PERMANENT
        if not match:
            result['faults'] = [(get_config_root_key({}), 0, 'Device running un-supported ASA version %s' % asa_version)]
    else: #not able to connect
        result['state'] = Status.TRANSIENT
        result['faults'] = [(get_config_root_key({}), 0, error)]
    return result
Exemple #3
0
 def get_fault_path():
     root = util.get_config_root_key('')
     fault_path = []
     if not root:
         fault_path.append(root)
     fault_path.append((4, 'ClusterConfig', ''))
     return fault_path
Exemple #4
0
 def handler(*argv, **kwargs):
     config = get_config_dict(argv[1:])
     root = get_config_root_key(config)
     result = {'state': Status.SUCCESS, 'faults': []}
     try:
         f(*argv, **kwargs)
     except ConnectionError as e:
         result['faults'] = [(root, 0, e.message)]
         result['state'] = Status.AUDIT
     except IFCConfigError as e:
         result['faults'] = e.fault_list
         result['state'] = Status.PERMANENT
     except ASACommandError as e:
         result['faults'] = e.fault_list
         result['state'] = Status.PERMANENT
     except Exception as e:
         result['faults'] = [(root, 0, "Unexpected exception: " +
                              e.message + '\n' + traceback.format_exc())]
         result['state'] = Status.PERMANENT
     finally:
         return result
 def handler(*argv, **kwargs):
     config  = get_config_dict(argv[1:])
     root = get_config_root_key(config)
     result = {'state': Status.SUCCESS, 'faults': []}
     try:
         f(*argv, **kwargs)
     except ConnectionError as e:
         result['faults'] = [(root, 0, e.message)]
         result['state'] = Status.AUDIT
     except IFCConfigError as e:
         result['faults'] = e.fault_list
         result['state'] = Status.PERMANENT
     except ASACommandError as e:
         result['faults'] = e.fault_list
         result['state'] = Status.PERMANENT
     except Exception as e:
         result['faults'] = [(root, 0, "Unexpected exception: " + e.message +
                             '\n' + traceback.format_exc())]
         result['state'] = Status.PERMANENT
     finally:
         return result
Exemple #6
0
def serviceHealth(device, configuration):
    '''This function is called periodically to report health of the service function
    on the device.

    @param device:
        a device dictionary
    @param configuration: dict
        It contains device configuration, group configuration for a particular
        graph instance and function configuration. The configuration dictionary follows
        the format described above.
    @return: dict
        It is dictionary of function health represented as an integer within (0-100) range.
        Format of the dictionary is as follows

          { (path): health,  ...}

          path: Is a list identifying a function within the graph. Example
          [ vdev, vgrp, vfunc ]

          vdev - Device Name. Passed in the configuration dictionary
          vgrp - Function Group name passed in the configuration dictionary
          vfunc - function name passed in configuration dictionary

        The health dictionary will contain an entry for each function rendered on the
        device for the given graph
    '''
    result = {}
    version, error = read_asa_version(device)
    if not version:  #fail to connect
        result['faults'] = [(get_config_root_key(configuration), 0, error)]
        result[
            'state'] = Status.TRANSIENT  #same as that from xxxxAudit and xxxxModify
    else:
        result['health'] = []
        result['state'] = Status.SUCCESS
        for f in get_config_firewall_keys(configuration):
            result['health'].append((f, 100))
    return result
def serviceHealth(device,
                  configuration):
    '''This function is called periodically to report health of the service function
    on the device.

    @param device:
        a device dictionary
    @param configuration: dict
        It contains device configuration, group configuration for a particular
        graph instance and function configuration. The configuration dictionary follows
        the format described above.
    @return: dict
        It is dictionary of function health represented as an integer within (0-100) range.
        Format of the dictionary is as follows

          { (path): health,  ...}

          path: Is a list identifying a function within the graph. Example
          [ vdev, vgrp, vfunc ]

          vdev - Device Name. Passed in the configuration dictionary
          vgrp - Function Group name passed in the configuration dictionary
          vfunc - function name passed in configuration dictionary

        The health dictionary will contain an entry for each function rendered on the
        device for the given graph
    '''
    result = {}
    version, error = read_asa_version(device)
    if not version: #fail to connect
        result['faults'] = [(get_config_root_key(configuration), 0, error)]
        result['state'] = Status.TRANSIENT #same as that from xxxxAudit and xxxxModify
    else:
        result['health'] = []
        result['state'] = Status.SUCCESS
        for f in get_config_firewall_keys(configuration):
            result['health'].append((f, 100))
    return result