Skip to content

Instantly share code, notes, and snippets.

View niedbalski's full-sized avatar
👋
Be humble. Stay focused.

Jorge Niedbalski niedbalski

👋
Be humble. Stay focused.
View GitHub Profile
@niedbalski
niedbalski / rabbit-output.txt
Created August 26, 2015 20:12
rabbit-output.txt
ubuntu@niedbalski-bastion:~/charms$ juju run --service rabbitmq-server "sudo cat /etc/hosts"
- MachineId: "4"
Stdout: |
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
@niedbalski
niedbalski / spf.py
Last active August 29, 2015 13:56
chess-solver.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import networkx as nx
import matplotlib.pyplot as plt
__author__ = 'Jorge Niedbalski R. <jnr@pyrosome.org>'
class SPF:
valid_moves = [(-1, -2),
=== modified file 'deployer/action/importer.py'
--- deployer/action/importer.py 2014-05-29 17:03:15 +0000
+++ deployer/action/importer.py 2014-05-29 20:45:52 +0000
@@ -60,7 +60,7 @@
self.log.debug("Getting charms...")
self.deployment.fetch_charms(
update=self.options.update_charms,
- no_local_mods=self.options.no_local_mods)
+ local_mods=self.options.local_mods)
=== modified file 'charmtools/templates/python/files/scripts/charm_helpers_sync.py'
--- charmtools/templates/python/files/scripts/charm_helpers_sync.py 2014-05-23 20:10:24 +0000
+++ charmtools/templates/python/files/scripts/charm_helpers_sync.py 2014-05-30 20:19:55 +0000
@@ -30,7 +30,7 @@
def clone_helpers(work_dir, branch):
dest = os.path.join(work_dir, 'charm-helpers')
logging.info('Checking out %s to %s.' % (branch, dest))
- cmd = ['bzr', 'branch', branch, dest]
+ cmd = ['bzr', 'checkout', '--lightweight', branch, dest]
subprocess.check_call(cmd)
@niedbalski
niedbalski / juju-get-grep.py
Created July 24, 2014 09:07
Get a specific entry on juju get
#!/usr/bin/env python
"""
Usage:
$ juju get-grep service config_entry
"""
__author__ == "Jorge Niedbalski R. <jorge.niedbalski@canonical.com>"
import subprocess
import sys
import yaml
@niedbalski
niedbalski / service_is_running.py
Last active August 29, 2015 14:05
Ensure that a particular service keeps running, event on an exception
import subprocess
logger = logging.getLogger(__name__)
def ensure_service_is_running(service):
def wrapper(callback):
def wrapped_f(self, *args, **kwargs):
try:
subprocess.check_call(["service", service, "stop"])
callback(self, *args, **kwargs)
@niedbalski
niedbalski / config.go
Last active August 29, 2015 14:05
config.go
//NewConfigFromFile function loads a YAML file and returns
//a pointer to a newly create Configuration struct
func NewConfigFromFile(path string) (*Config, error) {
cfg := New(Config)
if _, err := os.Stat(path); os.IsNotExist(err) {
return nil, errors.New("Cannot open configuration file")
}
readed, err := ioutil.ReadFile(path)
@niedbalski
niedbalski / remote-pdb.md
Last active August 29, 2015 14:06
Using rpdb charmhelpers

Usage

On your charms code, put a trace exception

from charmhelpers.contrib.python import pdb

@hooks.hook()
def install():
   pdb.set_trace()
 ...
@niedbalski
niedbalski / status.py
Created September 26, 2014 20:06
juju status
def juju_status(juju_env=None):
cmd = ['juju', 'status']
if juju_env:
cmd.append(['-e', juju_env])
status_raw = subprocess.check_output(cmd)
return yaml.safe_load(status_raw)
19<28@19niedbalski> neutron port-create --fixed-ip ip_address=10.5.0.x --security-group default wolsen_admin_net
19<28@19niedbalski> then, for each port ( neutron port-list )
19<28@19niedbalski> neutron port-update 0d750378-8850-4bfb-9a9c-62bf3f69af8f --allowed_address_pairs list=true type=dict ip_address=10.5.0.x