Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
FILE=$1
USER=$2
EMAIL=$3
realfile=$(readlink -f $FILE)
cat << EOF | augtool -Ast "Xml incl ${realfile}"
# Remove #empty node
@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)
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
#!/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"
@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()
@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 / 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 / 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 / sdk4_types.py
Last active March 20, 2017 17:42
sdk4 types init
In [1]: import ovirtsdk4 as sdk4
In [2]: sdk4.types
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-3ecb0c730dda> in <module>()
----> 1 sdk4.types
AttributeError: 'module' object has no attribute 'types'
@nvgoldin
nvgoldin / ost_lago_runtest.sh
Created April 2, 2017 08:54
Re-run 'lago ovirt run-test' individual test
./run_suite.sh -o /dev/shm/ost basic-suite-master
# failure/stop
export LAGO_INITFILE_PATH="/home/ngoldin/src/gerrit.ovirt.org/ovirt-system-tests/basic-suite-master/"
export LAGO_WORKDIR_PATH="/dev/shm/ost"
export SUITE="basic-suite-master"
cd /dev/shm/ost
PYTHONPATH=$PYTHONPATH:/home/ngoldin/src/gerrit.ovirt.org/ovirt-system-tests/basic-suite-master/ lago ovirt runtest /home/ngoldin/src/gerrit.ovirt.org/ovirt-system-tests/basic-suite-master/test-scenarios/002_bootstrap.py