Skip to content

Instantly share code, notes, and snippets.

View whitmo's full-sized avatar
💭
state 26

Whit Morriss whitmo

💭
state 26
View GitHub Profile
def growth(peryear, rate=0.08, years=4, princ=0):
"""
>>> growth(24450)
Year: 0 $0
Year: 1 $26406.0
Year: 2 $54924.48
Year: 3 $85724.4384
Total: $118988.393472
"""
sub = peryear / 12.0
@whitmo
whitmo / tox.ini
Created May 8, 2014 22:32
charmhelper w/ tox
coverage==3.7.1
Jinja2==2.7.2
MarkupSafe==0.19
mock==1.0.1
netaddr==0.7.11
netifaces==0.8
nose==1.3.1
python-mimeparse==0.1.4
PyYAML==3.11
Tempita==0.5.2
environment: local
machines:
"29":
agent-state: started
agent-version: 1.18.3.1
dns-name: 10.0.3.117
instance-id: whit-local-machine-29
series: trusty
hardware: arch=amd64
services:
@whitmo
whitmo / hooks.py
Last active August 29, 2015 14:01
service hook ideas
from charmhelpers import Service
from charmhelpers import hooks
from charmhelpers import ExternalService as es
class Mysql(es):
@property
def dsn(self):
return "msql:{host}:{port}".format(self)
class Relation(object):
def __init__(self, name):
self.name = name
def joined(self):
return self.relation_get(error=False)
def context(self):
return self.relation_get()
@whitmo
whitmo / bosh-fail.txt
Created May 28, 2014 21:22
bosh-failing-to-deploy-bosh
Director task 7
# Logfile created on 2014-05-28 18:53:21 +0000 by logger.rb/31641
I, [2014-05-28T18:53:21.563384 #2558] INFO -- : Director Version : 1.2579.0
I, [2014-05-28T18:53:21.563469 #2558] INFO -- : Enqueuing task: 7
I, [2014-05-28T18:53:24.674043 #31551] [0xca187c] INFO -- : Looking for task with task id 7
D, [2014-05-28T18:53:24.675479 #31551] [0xca187c] DEBUG -- : Acquired connection: 24052980
D, [2014-05-28T18:53:24.676566 #31551] [0xca187c] DEBUG -- : (0.000735s) SELECT * FROM "tasks" WHERE "id" = 7
D, [2014-05-28T18:53:24.681127 #31551] [0xca187c] DEBUG -- : Released connection: 24052980
I, [2014-05-28T18:53:24.681295 #31551] [0xca187c] INFO -- : Starting task: 7
I, [2014-05-28T18:53:24.681442 #31551] [task:7] INFO -- : Creating job

ERB renderer proposal

bosh renders templates in its director (rather than the agent) using ruby's ERB. We would like to reuse the templates (found in the jobs) so will need a small self contained rendering utility.

Packaging

It would be preferable to not have every cf charm require a ruby install. Jruby seems like it should be able to create a jar that would allow for containment

job-renderer executable

@whitmo
whitmo / template_vars.json
Created June 10, 2014 14:40
ERB statemements from cf job templates
{
"cloud_controller_ng": [
[
"stacks.yml.erb",
[
"= p(\"ccng.stacks\", []).to_yaml.gsub(\"---\", \"\")"
]
],
[
"handle_nfs_or_local_blobstore.sh.erb",
database:
url: jdbc:<%= properties.uaadb.db_scheme %>://<%= properties.uaadb.address %>:<%= properties.uaadb.port %>/<%= uaa_db.name %>
username: <%= uaa_role.name %>
password: "<%= uaa_role.password %>"
---
name: uaa
templates:
uaa_ctl.erb: bin/uaa_ctl
cf-registrar_ctl: bin/uaa_cf-registrar_ctl
cf-registrar.config.yml.erb: config/cf-registrar/config.yml
uaa.yml.erb: config/uaa.yml
varz.yml.erb: config/varz.yml
log4j.properties.erb: config/log4j.properties