<commit_before>"""
Beacon that fires events on vm state changes

.. code-block:: yaml

    ## minimal
    # - check for vm changes every 1 second (salt default)
    # - does not send events at startup
    beacons:
      vmadm: []

    ## standard
    # - check for vm changes every 60 seconds
    # - send create event at startup for all vms
    beacons:
      vmadm:
        - interval: 60
        - startup_create_event: True
"""
import logging

import salt.utils.beacons

__virtualname__ = "vmadm"

VMADM_STATE = {
    "first_run": True,
    "vms": [],
}

log = logging.getLogger(__name__)


def __virtual__():
    """
    Provides vmadm beacon on SmartOS
    """
    if "imgadm.list" in __salt__:
        return True
    else:
        err_msg = "Only available on SmartOS compute nodes."
        log.error("Unable to load %s beacon: %s", __virtualname__, err_msg)
        return False, err_msg


def validate(config):
    """
    Validate the beacon configuration
    """<commit_msg>Fix function to check during smartos_vmadm beacon virtual<commit_after>"""
Beacon that fires events on vm state changes

.. code-block:: yaml

    ## minimal
    # - check for vm changes every 1 second (salt default)
    # - does not send events at startup
    beacons:
      vmadm: []

    ## standard
    # - check for vm changes every 60 seconds
    # - send create event at startup for all vms
    beacons:
      vmadm:
        - interval: 60
        - startup_create_event: True
"""
import logging

import salt.utils.beacons

__virtualname__ = "vmadm"

VMADM_STATE = {
    "first_run": True,
    "vms": [],
}

log = logging.getLogger(__name__)


def __virtual__():
    """
    Provides vmadm beacon on SmartOS
    """
    if "vmadm.list" in __salt__:
        return True
    else:
        err_msg = "Only available on SmartOS compute nodes."
        log.error("Unable to load %s beacon: %s", __virtualname__, err_msg)
        return False, err_msg


def validate(config):
    """
    Validate the beacon configuration
    """
{'fraction_non_alphanumeric': 0.09717402082300446, 'fraction_numerical': 0.00495785820525533, 'mean_word_length': 2.5034722222222223, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1336924', 'n_tokens_mistral': 650, 'n_tokens_neox': 609, 'n_words': 209}