Skip to content

Instantly share code, notes, and snippets.

View chrigl's full-sized avatar
🇺🇦

Christoph Glaubitz chrigl

🇺🇦
View GitHub Profile
Error: /Stage[main]/Cephdeploy/Concat[/home/cephdeploy/bootstrap/ceph.conf]/Exec[concat_/home/cephdeploy/bootstrap/
ceph.conf]: Could not evaluate: Could not find command '/var/lib/puppet/concat/bin/concatfragments.sh'
@chrigl
chrigl / ep14-db-random-ids.md
Last active August 29, 2015 14:04
This is why using random IDs is usually a bad idea

This is a comment on "Advanced Database Programming with Python"

For example in MySQL, the index is implemented as a balanced tree. Quite obvious. If your are inserting a new entry with a random number, the tree may have to be rebalanced again. Now imagine, you are running a master node with several hundreds of slave nodes, each one of it has to rebalance its index. Maybe there are some usecases, where random ID actually makes sense. But most of the times they result in hard to debug problems on a large scale environment.

Again in MySQL, they assume, you will need the recently inserted entry in short time again. They get this entry because of its location in the balanced tree. So, with random IDs, you break this mechanism as well.

However. All this stuff depends on the DBMS you are using, but auto_increment is a well known and well tested feature within decades. Do not try to solve problems that do not exist ;)

def issocket(fname):
""" Returns True if fname is a socket. """
if not os.path.exists(fname):
return False
return stat.S_ISSOCK(os.stat(fname).st_mode)
@chrigl
chrigl / gist:7a5989b02b850a14329a
Created November 27, 2014 14:06
does ssh-agent respond in time?
# get identities
_ssh_agent_msg = chr(11)
def check_ssh_agent(fname):
""" Check if ssh-agent works.
Returns True if ssh-agent got response from ssh-agent """
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
conn.connect(fname)
conn.settimeout(10)
@chrigl
chrigl / convert_html_to_rst.py
Last active August 29, 2015 14:16
convert html to rst POC
# -*- coding: utf-8 -*-
from io import StringIO
from lxml import etree
pre_str = """
.. code-block::
@chrigl
chrigl / upstartwatch.py
Created May 6, 2015 08:09
upstartwatch... not sure if this is a good idea.
#!/usr/bin/env python3
import sys
import dbus
import time
import json
import argparse
import threading
import functools
import http.server
from gi.repository import GObject
@chrigl
chrigl / gist:57f898f4e8df4fcf9c15
Created June 10, 2015 15:12
Provisioning of a floating ip network in OpenContrail
#!/usr/bin/env python
#
# Copyright 2015 c.glaubitz@syseleven.de
#
# 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
#
@chrigl
chrigl / check_duplicate_fips.py
Last active July 19, 2016 12:13
Detect duplicate floating ips in midonet zookeeper
#!/usr/bin/env python
from __future__ import print_function
from kazoo.client import KazooClient
from collections import Counter
# id of ext-net
DEFAULT_BRIDGE='caf8de33-1059-4473-a2c1-2a62d12294fa'
[DEFAULT]
[oslo_concurrency]
lock_path = /var/lib/tempest/run_lock
[auth]
test_accounts_file = /etc/tempest/accounts.yaml
use_dynamic_credentials = false
[identity]
heat_template_version: 2015-04-30
resources:
network:
type: OS::Neutron::Net
properties:
name: ceph_dev_net