Commit f2618505 by source_reader

added nilm module

parent a54d93b1
# == Class: joule
#
# Full description of class joule here.
#
# === Parameters
#
# Document parameters here.
#
# [*sample_parameter*]
# Explanation of what this parameter affects and what it defaults to.
# e.g. "Specify one or more upstream ntp servers as an array."
#
# === Variables
#
# Here you should define a list of variables that this module would require.
#
# [*sample_variable*]
# Explanation of how this variable affects the funtion of this class and if
# it has a default. e.g. "The parameter enc_ntp_servers must be set by the
# External Node Classifier as a comma separated list of hostnames." (Note,
# global variables should be avoided in favor of class parameters as
# of Puppet 2.6.)
#
# === Examples
#
# class { 'joule':
# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
# }
# Install the joule framework
# doc.wattsworth.net/joule
#
# === Authors
#
# Author Name <author@domain.com>
# John Donnal <donnal@usna.edu>
#
# === Copyright
#
# Copyright 2017 Your name here, unless otherwise noted.
# Copyright 2017 John Donnal, unless otherwise noted.
#
class joule {
$pip_url="http://puppet:wX27zvbA@pypi.wattsworth.net:8080/"
$pip_cmd="pip3 install --extra-index-url ${pip_url} --trusted-host pypi.wattsworth.net"
......@@ -59,6 +34,6 @@ class joule {
creates => "/etc/joule/main.conf",
require => Exec['install_joule']
}
}
source 'https://rubygems.org'
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 0.3.2'
gem 'facter', '>= 1.7.0'
# nilm
#### Table of Contents
1. [Overview](#overview)
2. [Module Description - What the module does and why it is useful](#module-description)
3. [Setup - The basics of getting started with nilm](#setup)
* [What nilm affects](#what-nilm-affects)
* [Setup requirements](#setup-requirements)
* [Beginning with nilm](#beginning-with-nilm)
4. [Usage - Configuration options and additional functionality](#usage)
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)
## Overview
A one-maybe-two sentence summary of what the module does/what problem it solves.
This is your 30 second elevator pitch for your module. Consider including
OS/Puppet version it works with.
## Module Description
If applicable, this section should have a brief description of the technology
the module integrates with and what that integration enables. This section
should answer the questions: "What does this module *do*?" and "Why would I use
it?"
If your module has a range of functionality (installation, configuration,
management, etc.) this is the time to mention it.
## Setup
### What nilm affects
* A list of files, packages, services, or operations that the module will alter,
impact, or execute on the system it's installed on.
* This is a great place to stick any warnings.
* Can be in list or paragraph form.
### Setup Requirements **OPTIONAL**
If your module requires anything extra before setting up (pluginsync enabled,
etc.), mention it here.
### Beginning with nilm
The very basic steps needed for a user to get the module up and running.
If your most recent release breaks compatibility or requires particular steps
for upgrading, you may wish to include an additional section here: Upgrading
(For an example, see http://forge.puppetlabs.com/puppetlabs/firewall).
## Usage
Put the classes, types, and resources for customizing, configuring, and doing
the fancy stuff with your module here.
## Reference
Here, list the classes, types, providers, facts, etc contained in your module.
This section should include all of the under-the-hood workings of your module so
people know what the module is touching on their system but don't need to mess
with things. (We are working on automating this section!)
## Limitations
This is where you list OS compatibility, version compatibility, etc.
## Development
Since your module is awesome, other users will want to play with it. Let them
know what the ground rules for contributing are.
## Release Notes/Contributors/Etc **Optional**
If you aren't using changelog, put your release notes here (though you should
consider using changelog). You may also add any additional sections you feel are
necessary or important to include here. Please use the `## ` header.
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
desc "Validate manifests, templates, and ruby files"
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
No preview for this file type
## Example meter file
# See configuration details at
# https://www.wattsworth.net/help/software
#
# Example contact meter
meter1:
type: contact
enabled: true # set to false to disable this meter
ip_address: 192.168.1.209 # default LabJack address
phases: 2 # 1 - 3
sensors:
voltage:
sensor_indices: [3,4] # maps to phase A,B,C
sensor_scales: 0.0919 # built-in constant
sinefit_phase: A # [A,B,C] voltage used by sinefit
nominal_rms_voltage: 120 # used to scale prep to watts
current:
sensor_indices: [1,2] # maps to phase A,B,C
sensor_scales: XX # set by resistors and LEM, see hardware help page
sinefit_rotations: [0,0] # relative to sinefit_phase voltage
streams:
sinefit:
decimate: true # if [false] only the base stream will be saved
keep: 1d # how much data to keep as [amount][units]
iv: # h: hours, d: days, w: weeks
decimate: true # m: months, y: years
keep: 1h # if [false] no data will be saved
prep:
decimate: true
keep: 1w
# Example non-contact meter
meter2:
type: noncontact
enabled: true # set to false to disable this meter
serial_number: meterXXXX # found on the meter case
phases: 3 # 1 - 3
sensors:
voltage:
sensor_index: 0 # electric field sensor
digitally_integrate: true # if true, integrate using FIR filter
nominal_rms_voltage: 120 # used to scale the electric field
current:
sensor_indices: [1,3,5,7] # D-Board with 4 A-Boards
#sensor_indices: [1,2,3,4,5] # Flex Board
calibration:
duration: 9 # length of calibration in seconds
watts: 200 # power consumed by calibration load
has_neutral: true # [false] if the system has no neutral bus
streams:
sinefit:
decimate: true # if [false] only the base stream will be saved
keep: 2d # how much data to keep as [amount][units]
iv: # h: hours, d: days, w: weeks,
decimate: true # m: months, y: years
keep: 2h # if [false] no data will be saved
prep:
decimate: true
keep: 2w
sensor:
keep: 3d
decimate: true
# == Class: nilm
# Joule modules for nilm data capture and processing
#
# === Authors
#
# John Donnal <donnal@usna.edu>
#
# === Copyright
#
# Copyright 2017 John Donnal, unless otherwise noted.
#
class nilm {
$pip_url="http://puppet:wX27zvbA@pypi.wattsworth.net:8080/"
$pip_cmd="pip3 install --extra-index-url ${pip_url} --trusted-host pypi.wattsworth.net"
exec{'install_nilm':
command => "${pip_cmd} nilm",
timeout => 0,
path => ["/usr/local/bin","/usr/bin"]
}
file{'/opt/configs':
ensure => directory,
owner => root,
group => root
}
file{'/opt/configs/meters.example.yml':
owner => root,
group => root,
source => 'puppet:///modules/nilm/meters.yml'
}
file{'/usr/local/bin/ethstream':
owner => root,
group => root,
mode => 0755,
source => 'puppet:///modules/nilm/ethstream'
}
}
{
"name": "jdonnal-nilm",
"version": "0.1.0",
"author": "John Donnal",
"summary": "install nilm joule modules",
"license": "Apache 2.0",
"source": "git.wattsworth.net",
"project_page": "git.wattsworth.net",
"issues_url": "git.wattsworth.net",
"dependencies": [
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}
]
}
require 'spec_helper'
describe 'nilm' do
context 'with defaults for all parameters' do
it { should contain_class('nilm') }
end
end
require 'puppetlabs_spec_helper/module_spec_helper'
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation
# errors and view a log of events) or by fully applying the test in a virtual
# environment (to compare the resulting system state to the desired state).
#
# Learn more about module testing here:
# http://docs.puppetlabs.com/guides/tests_smoke.html
#
include nilm
<VirtualHost *:80>
WSGIScriptAlias /nilmdb /opt/data/nilmdb.wsgi
WSGIScriptAlias /nilmdb /etc/nilmdb/nilmdb.wsgi
WSGIDaemonProcess nilmdb-procgroup threads=32 user=nilmdb group=nilmdb
<Location /nilmdb>
WSGIProcessGroup nilmdb-procgroup
......
......@@ -60,13 +60,17 @@ class nilmdb {
group => nilmdb,
require => User['nilmdb']
}
file{'/opt/data/nilmdb.wsgi':
file{'/etc/nilmdb':
ensure => directory,
owner => root,
group => root,
}
file{'/etc/nilmdb/nilmdb.wsgi':
ensure => present,
owner => nilmdb,
group => nilmdb,
owner => root,
group => root,
mode => 644,
source => 'puppet:///modules/nilmdb/nilmdb.wsgi',
require => User['nilmdb'],
notify => Exec['apache2ctl restart']
}
#mod_wsgi tries to access user home directory
......
......@@ -3,4 +3,5 @@ node 'raspberrypi' {
include joule
include raspi
include nilmdb
include nilm
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment