Skip to content

Instantly share code, notes, and snippets.

View petrblaho's full-sized avatar

Petr Blaho petrblaho

  • Brno, Czech Republic
View GitHub Profile
@petrblaho
petrblaho / virip
Created September 3, 2012 08:44
Simple script for detecting IP address of running virtual machine
#!/bin/bash
DOMAIN=$1
XML=`sudo virsh dumpxml $DOMAIN`
MAC=`echo "$XML" | grep 'mac address' | awk -F\' '{print $2}'`
VIRNETWORK=`echo "$XML" | grep 'source network' | awk -F\' '{print $2}'`
VIRBRIDGE=`sudo virsh net-info $VIRNETWORK | grep Bridge | awk '{print $2}'`
VIRNET=`ifconfig $VIRBRIDGE | grep inet | awk '{print $2}' | awk -F. '{print $1"."$2"."$3".*"}'`
nmap -sn $VIRNET &> /dev/null
@petrblaho
petrblaho / primes.rb
Created October 16, 2012 16:36
simple script for prime numbers
#!/usr/bin/env ruby
class Reminder
def initialize(bound, current = 0)
@bound = bound.to_i
@current = current.to_i
end
def +(number)
@current += number
@petrblaho
petrblaho / ukpost-tracker.rb
Created March 6, 2013 22:49
Dirty and simple scrapper for tracking UK post package
#! /usr/bin/env ruby
require 'uri'
require 'net/http'
require 'nokogiri'
track_id = ARGV.first
form_url = URI.parse('http://www.postoffice.co.uk/track-trace')
response = Net::HTTP.get_response(form_url)
ScriptAlias /nagios/cgi-bin/ "/usr/lib64/nagios/cgi-bin/"
<Directory "/usr/lib64/nagios/cgi-bin/">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/passwd
libvirt: XML-RPC error : authentication failed: polkit: polkit\56retains_authorization_after_challenge=1
Authorization requires authentication but no agent is available.
Traceback (most recent call last):
File "scripts/../bootstrap/configure-bootstrap-vm", line 48, in <module>
main()
File "scripts/../bootstrap/configure-bootstrap-vm", line 43, in main
conn=libvirt.open("qemu:///system")
File "/usr/lib64/python2.7/site-packages/libvirt.py", line 236, in open
if ret is None:raise libvirtError('virConnectOpen() failed')
libvirt.libvirtError: authentication failed: polkit: polkit\56retains_authorization_after_challenge=1
2013-06-07 11:15:06.058+0000: starting up
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin QEMU_AUDIO_DRV=none /usr/bin/qemu-kvm -name bootstrap -S -machine pc-1.0,accel=kvm,usb=off -cpu qemu32 -m 1536 -smp 2,sockets=2,cores=1,threads=1 -uuid b5171d6b-0964-4700-a12c-d7defb6f5a5b -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/bootstrap.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/bootstrap.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=24,id=hostnet0 -device e1000,netdev=hostnet0,id=net0,mac=52:54:00:1a:ad:6d,bus=pci.0,addr=0x3 -netdev tap,fd=25,id=hostnet1 -device e1000,netdev=hostnet1,id=net1,mac=52:54:00:74:35:7e,bus=pci.0,addr=0x4 -vnc 127.0.0.1:0 -vga cirrus -device virtio-ballo
@petrblaho
petrblaho / gist:5749399
Created June 10, 2013 14:59
Error message when starting bootstrap node VM on Fedora 19 VM host
error: Failed to start domain bootstrap
error: monitor socket did not show up: Connection refused
@petrblaho
petrblaho / gist:5796854
Created June 17, 2013 13:27
Error when building fedora image via tripleo
Processing triggers for man-db ...
Processing triggers for install-info ...
dib-run-parts Mon Jun 17 06:30:47 EDT 2013 00-remove-grub completed
dib-run-parts Mon Jun 17 06:30:47 EDT 2013 Running /tmp/in_target.d/pre-install.d/00-usr-local-bin-secure-path
dib-run-parts Mon Jun 17 06:30:47 EDT 2013 00-usr-local-bin-secure-path completed
dib-run-parts Mon Jun 17 06:30:47 EDT 2013 Running /tmp/in_target.d/pre-install.d/01-install-bin
dib-run-parts Mon Jun 17 06:30:47 EDT 2013 01-install-bin completed
dib-run-parts Mon Jun 17 06:30:47 EDT 2013 Running /tmp/in_target.d/pre-install.d/01-override-yum-arch
dib-run-parts Mon Jun 17 06:30:47 EDT 2013 01-override-yum-arch completed
dib-run-parts Mon Jun 17 06:30:47 EDT 2013 Running /tmp/in_target.d/pre-install.d/02-lsb
@petrblaho
petrblaho / part_of_tests.py
Created July 29, 2013 14:19
Tuskar tests - Racks 400 test for creating rack with invalid data pecan controller
def test_it_returns_400_when_posting_bad_data(self):
json = {
'bad-data-key': 'bad-data-value',
}
response = self.post_json('/racks', params=json, status=400, expect_errors=True)
self.assertEqual(response.status_int, 400)
import Test.HUnit (Assertion, (@=?), runTestTT, Test(..))
import Control.Monad (void)
import Bob (responseFor)
testCase :: String -> Assertion -> Test
testCase label assertion = TestLabel label (TestCase assertion)
test_respondsToSomething :: Assertion
test_respondsToSomething =
"Whatever." @=? responseFor "Tom-ay-to, tom-aaaah-to."