<commit_before>#!/usr/bin/python3
# Copyright (c) 2016, <NAME> <<EMAIL>>

import os
import shutil

from charms.reactive import when
from charms.reactive import when_not
from charms.reactive import set_state
from charms.reactive import when_any
from charms.reactive import when_none

from charmhelpers.core import hookenv

from charms.layer.puppet import PuppetConfigs
config = hookenv.config()


@when('config.set.puppet-server')
@when_not('puppet-agent.installed')
def install_puppet_agent():

    '''Install puppet agent
    '''
    p = PuppetConfigs()
    # Download and install trusty puppet deb
    hookenv.status_set('maintenance',
                       'Installing puppet agent')
    p.install_puppet()
    p.puppet_active()
    set_state('puppet-agent.installed')


@when_not('config.set.puppet-server', 'puppet.available')
def masterless_puppet():
    '''
    Set the `puppet.available` state so that other layers can
    gate puppet operations for masterless puppet state (unconfigured)
    '''
    hookenv.status_set('active',
                       'Masterless puppet configued')
    set_state('puppet.available')

@when_none('apt.installed.puppet-common', 'apt.installed.puppet-agent')
@when('puppet.available')
def masterless_avail():
    hookenv.status_set('active',
                       'Masterless puppet configued')

@when('config.set.puppet-server')
@when_not('puppet-agent.configured', 'apt.queued_installs')
def configure_puppet_agent():
    '''Since the server is set we render
    the puppet config files and ensure puppet service running
    '''
    p = PuppetConfigs()
    p.configure_puppet()

    set_state('puppet-agent.configured')
    p.puppet_active()


@when('puppet-agent.installed', 'puppet-agent.configured')
@when_not('puppet-agent.available')<commit_msg>Add bits for masterless puppet pkg installs<commit_after>#!/usr/bin/python3
# Copyright (c) 2016, <NAME> <<EMAIL>>

import os
import shutil

from charms.reactive import when
from charms.reactive import when_not
from charms.reactive import set_state
from charms.reactive import when_any
from charms.reactive import when_none

from charmhelpers.core import hookenv

from charms.layer.puppet import PuppetConfigs
import charms.apt

config = hookenv.config()


@when('config.set.puppet-server')
@when_not('puppet-agent.installed')
def install_puppet_agent():

    '''Install puppet agent
    '''
    p = PuppetConfigs()
    # Download and install trusty puppet deb
    hookenv.status_set('maintenance',
                       'Installing puppet agent')
    p.install_puppet()
    p.puppet_active()
    set_state('puppet-agent.installed')


@when_not('config.set.puppet-server', 'puppet.available')
@when_not('apt.installed.puppet-common')
def masterless_puppet():
    '''
    Set the `puppet.available` state so that other layers can
    gate puppet operations for masterless puppet state (unconfigured)
    '''
    hookenv.status_set('active',
                       'Masterless puppet configued')
    charms.apt.queue_install(['puppet-common'])
    charms.apt.install_queued()
    set_state('puppet.available')


@when_none('puppet-agent.installed', 'config.set.puppet-server')
@when('puppet.available', 'apt.installed.puppet-common')
def masterless_avail():
    hookenv.status_set('active',
                       'Masterless puppet configued')


@when('config.set.puppet-server')
@when_not('puppet-agent.configured', 'apt.queued_installs')
def configure_puppet_agent():
    '''Since the server is set we render
    the puppet config files and ensure puppet service running
    '''
    p = PuppetConfigs()
    p.configure_puppet()

    set_state('puppet-agent.configured')
    p.puppet_active()


@when('puppet-agent.installed', 'puppet-agent.configured')
@when_not('puppet-agent.available')
{'fraction_non_alphanumeric': 0.11812896405919662, 'fraction_numerical': 0.002642706131078224, 'mean_word_length': 4.039946737683089, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1274555', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1209, 'n_words': 263}