<commit_before>#
# Cookbook Name:: bcpc
# Recipe:: graphite
#
# Copyright 2013, Bloomberg Finance L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

if node['bcpc']['enabled']['metrics'] then

    include_recipe "bcpc::default"
    include_recipe "bcpc::apache2"

    # We need python-django >= 1.4, hence pinning to Trusty
    apt_preference 'python-django' do
        pin          'release n=trusty'
        pin_priority '999'
    end

    template "/etc/apt/apt.conf.d/00defaultrelease" do
        source "apt-conf-defaultrelease.erb"
        owner "root"
        group "root"
        mode 00644
    end

    apt_repository "trusty" do
        uri node['ubuntu']['archive_url']
        distribution 'trusty'
        components ["main"]
    end

    ruby_block "initialize-graphite-config" do
        block do
            make_config('mysql-graphite-user', "graphite")
            make_config('mysql-graphite-password', secure_password)
            make_config('graphite-secret-key', secure_password)
        end
    end

    %w{python-whisper_0.9.13_all.deb python-carbon_0.9.13_all.deb python-graphite-web_0.9.13_all.deb}.each do |pkg|
        cookbook_file "/tmp/#{pkg}" do
            source "bins/#{pkg}"
            owner "root"
            mode 00444
        end

        package pkg do
            provider Chef::Provider::Package::Dpkg
            source "/tmp/#{pkg}"
            action :install
        end
    end

    %w{python-pip python-cairo python-django python-django-tagging python-ldap python-twisted python-memcache memcached python-mysqldb}.each do |pkg|
        package pkg do
            action :upgrade
        end
    end

    #  _   _  ____ _  __   __  ____   _  _____ ____ _   _
    # | | | |/ ___| | \ \ / / |  _ \ / \|_   _/ ___| | | |
    # | | | | |  _| |  \ V /  | |_) / _ \ | || |   | |_| |
    # | |_| | |_| | |___| |   |  __/ ___ \| || |___|  _  |<commit_msg>python-tz is required for Graphite webapp<commit_after>#
# Cookbook Name:: bcpc
# Recipe:: graphite
#
# Copyright 2013, Bloomberg Finance L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

if node['bcpc']['enabled']['metrics'] then

    include_recipe "bcpc::default"
    include_recipe "bcpc::apache2"

    # We need python-django >= 1.4, hence pinning to Trusty
    apt_preference 'python-django' do
        pin          'release n=trusty'
        pin_priority '999'
    end

    template "/etc/apt/apt.conf.d/00defaultrelease" do
        source "apt-conf-defaultrelease.erb"
        owner "root"
        group "root"
        mode 00644
    end

    apt_repository "trusty" do
        uri node['ubuntu']['archive_url']
        distribution 'trusty'
        components ["main"]
    end

    ruby_block "initialize-graphite-config" do
        block do
            make_config('mysql-graphite-user', "graphite")
            make_config('mysql-graphite-password', secure_password)
            make_config('graphite-secret-key', secure_password)
        end
    end

    %w{python-whisper_0.9.13_all.deb python-carbon_0.9.13_all.deb python-graphite-web_0.9.13_all.deb}.each do |pkg|
        cookbook_file "/tmp/#{pkg}" do
            source "bins/#{pkg}"
            owner "root"
            mode 00444
        end

        package pkg do
            provider Chef::Provider::Package::Dpkg
            source "/tmp/#{pkg}"
            action :install
        end
    end

    %w{python-pip python-cairo python-django python-django-tagging python-ldap python-twisted python-memcache memcached python-mysqldb python-tz}.each do |pkg|
        package pkg do
            action :upgrade
        end
    end

    #  _   _  ____ _  __   __  ____   _  _____ ____ _   _
    # | | | |/ ___| | \ \ / / |  _ \ / \|_   _/ ___| | | |
    # | | | | |  _| |  \ V /  | |_) / _ \ | || |   | |_| |
    # | |_| | |_| | |___| |   |  __/ ___ \| || |___|  _  |
{'fraction_non_alphanumeric': 0.11469979296066253, 'fraction_numerical': 0.015734989648033125, 'mean_word_length': 2.2575859743762643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6418886', 'n_tokens_mistral': 1577, 'n_tokens_neox': 1477, 'n_words': 392}