Skip to content

Instantly share code, notes, and snippets.

@nvgoldin
nvgoldin / vms.py
Created March 19, 2017 11:11
getting nets
In [1]: class vm(object):
...: def __init__(self, nets):
...: self.nets = nets
...:
In [2]: vms = [ vm(nets=['1', '2']), vm(nets=['2', '9']), vm(nets=['3', '2']) ]
In [3]: set((net for vm in vms for net in vm.nets))
Out[3]: {'1', '2', '3', '9'}
@nvgoldin
nvgoldin / jenkins_perf.py
Created February 22, 2017 19:31
Compare jenkins job average execution time relative to a build
import numpy as np
import jenkins
import getpass
import time
"""
compare a jenkins job average execution time relative to a build
advisable to have: https://wiki.jenkins-ci.org/display/JENKINS/Metrics+Plugin
"""
@nvgoldin
nvgoldin / gist:c040ec0ebfa143dcf523939e5a8475c9
Created January 30, 2017 14:20 — forked from djmattyg007/gist:6b5e845ad1140c8a0fa66b64f953bf9a
Example of allowing management of individual systemd units with polkit
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.systemd1.manage-units") {
if (action.lookup("unit") == "myservice.service") {
var verb = action.lookup("verb");
if (verb == "start" || verb == "stop" || verb == "restart") {
return polkit.Result.YES;
}
}
}
});
@nvgoldin
nvgoldin / lago-api.py
Created January 23, 2017 13:37
lago api idea(integration with pytest)
import lago
from pytest import fixture
@fixture(scope="module")
def prefix():
prefix = lago.api.init(conf='../LagoInitFile')
prefix.start()
yield prefix
prefix.destroy()
#!/bin/bash -ex
SUITE=$1
JENKINS="/home/ngoldin/src/gerrit.ovirt.org/jenkins"
LAGO="/home/ngoldin/src/nvgoldin.github.com/lago"
REPODIR="/tmp/lago-export"
OST="/home/ngoldin/src/gerrit.ovirt.org/ovirt-system-tests"
BUILD_CONF="/home/ngoldin/src/nvgoldin.github.com/lago-build-scripts"
echo "BUILDING LAGO RPM"
pushd "$LAGO"
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
@nvgoldin
nvgoldin / asyncio_shutdown_loop.py
Created July 27, 2016 13:34
Python 3.5 asyncio - shutdown all tasks safely using signal handler
import signal
import functools
async def looping_task(loop, task_num):
try:
while True:
print('{0}:in looping_task'.format(task_num))
await asyncio.sleep(5.0, loop=loop)
except asyncio.CancelledError:
return "{0}: I was cancelled!".format(task_num)
#!/bin/bash
FILE=$1
USER=$2
EMAIL=$3
realfile=$(readlink -f $FILE)
cat << EOF | augtool -Ast "Xml incl ${realfile}"
# Remove #empty node