This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import datetime | |
import time | |
from random import random | |
class ThreadClass(threading.Thread): | |
def set_id(self, id): | |
self.id=id | |
def dummy_delay(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try to execute the script in two different modes to see the difference | |
# | |
# $ python log.py | tee log | |
# <noting for a long time> | |
# | |
# $ python -u log.py | tee log | |
# my log message 0 | |
# | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cs_create(self, count, sample_nr): | |
name='test' + str(int(time.time())) | |
image=112 | |
flavor=1 | |
log("[%2d][%2d] creating image: " % (sample_nr, count) + pformat( {'name': name, 'image' : image, 'flavor' : flavor } ) ) | |
sm=self.cs.servers | |
server=sm.create(name, image, flavor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example code that creates cloud server and try not to hit the cloud API climits | |
cs_count=13 # number of cs to build | |
build_nr=1 | |
delayed_10s=False | |
while build_nr <= cs_count : | |
if 0==build_nr % 11 and not delayed_10s: | |
time.sleep(60+10) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XenAPI | |
s=XenAPI.Session('http://localhost/') | |
s.login_with_password('root', 'password') | |
s.xenapi.VM.get_all() | |
Out[30]: | |
['OpaqueRef:fed9f387-359c-5e34-04b3-7e9de0271e9b', | |
'OpaqueRef:f21c711b-5de7-fb1f-5320-ea4b8fbbdac2', | |
... | |
'OpaqueRef:0032adf3-04d3-6cf7-94fe-9d06af09bec7'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (1) | |
$ xe vm-copy vm=vm-10 new-name-label=gateway-vm | |
$ xe network-list | |
$ xe vif-create network-uuid=b211707c-0f56-b33e-22b0-ad1816914b8a device=3 vm-uuid=4fb0febb-5659-f9b5-abf6-21cd63632c5b | |
$ xe vif-plug uuid=02600ba0-b040-733f-bcce-e64661dcb352 | |
$ xe console vm=gateway-vm | |
# (2) | |
root@gateway-vm:/etc/network# cat interfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xe vm-export filename=vm-label1-export1.xva vm=vm-label | |
for i in $(seq 2 10); do | |
name="vm-$i" | |
echo -n "creating vm $name " | |
uuid=$(xe vm-import filename=vm-label1-export1.xva preserve=false) | |
xe vm-param-set name-label=$name uuid=$uuid | |
xe vm-start vm=$name | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
template=`xe template-list name-label="Ubuntu Lucid Lynx 10.04 (64-bit)" --minimal` | |
vm=`xe vm-install template=$template new-name-label=vm-label` | |
network=`xe network-list bridge=xenbr0 --minimal` | |
vif=`xe vif-create vm-uuid=$vm network-uuid=$network device=0` | |
xe vm-param-set uuid=$vm other-config:install-repository=http://archive.ubuntu.com/ubuntu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.encoding = "windows-1252" | |
config.version = "8" | |
virtualHW.version = "8" | |
numvcpus = "4" | |
scsi0.present = "TRUE" | |
scsi0.virtualDev = "lsilogic" | |
memsize = "4096" | |
scsi0:0.present = "TRUE" | |
scsi0:0.fileName = "xenserver5.vmdk" | |
ide1:0.present = "TRUE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <strings.h> | |
#include <string.h> | |
#include <sys/ioctl.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <termios.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> |