# HG changeset patch # User igor # Date 1196663773 -7200 # Node ID 6471afbee150e608b9c87e1fa13680ef9a39bfc8 # Parent e7b9761c03e8f2d095ed9ad887be68c57ab91c85 *** empty log message *** diff -r e7b9761c03e8 -r 6471afbee150 build-xenomips-image --- a/build-xenomips-image Sun Nov 11 20:57:50 2007 +0200 +++ b/build-xenomips-image Mon Dec 03 08:36:13 2007 +0200 @@ -30,9 +30,11 @@ DEBIAN_MIRROR=ftp://debian.org.ua/debian DISTRO=etch -PACKAGES="openssh-server libc6-xen libelf1 libpcap0.8 screen nfs-common quagga tcpdump telnet ntpdate hping3 ntpd nmap netcat socat" +PACKAGES="openssh-server libc6-xen libelf1 libpcap0.8 screen nfs-common quagga tcpdump telnet ntpdate hping3 ntp nmap netcat socat" DYNAMIPS_SOURCES=http://www.ipflow.utc.fr/dynamips/dynamips-0.2.7.tar.gz DYNAMIPS_BUILD_DIR=dynamips/ +PIXEMU_SOURCES=http://xgu.ru/download/pemu_public2007-07-02.tar.bz2 +PIXEMU_BUILD_DIR=dynamips/ KERNEL_VERSION=`uname -r` @@ -68,6 +70,14 @@ cd ${OLD_PWD} } +build_and_install_pixemu() +{ + DESTDIR=${WORK_DIR}/usr/local/pixemu + mkdir -p $DESTDIR + cp /home/igor/pemu/pemu/* $DESTDIR +} + + if [ $(id -u) != 0 ] then echo You are not root. @@ -126,7 +136,7 @@ mv /etc/quagga /etc/quagga.ORIG ln -s /xenomips/config/etc/quagga /etc/quagga -mkdir -p /xenomips/{ios,config,dynamips} /var/lib/xenomips /root/.ssh +mkdir -p /xenomips/{ios,config} /var/lib/xenomips /root/.ssh cat <> /root/.profile TERM=linux @@ -147,6 +157,9 @@ chmod 600 ${WORK_DIR}/root/.ssh/authorized_keys build_and_install_dynamips + build_and_install_pixemu + kill $(lsof +D ${WORK_DIR} | awk '{print $2}' | grep -v PID) + pkill ntpd umount ${WORK_DIR} fi @@ -159,6 +172,7 @@ cp -a ${WORK_DIR}/etc/quagga.ORIG ${WORK_DIR2}/quagga perl -i -p -e 's/=no/=yes/' ${WORK_DIR2}/quagga/daemons touch ${WORK_DIR2}/quagga/{zebra,bgpd,ospfd,ripd,ripngd,ospf6d,isisd}.conf + cp -a ${WORK_DIR}/usr/local/pixemu ${WORK_DIR2}/pixemu umount ${WORK_DIR} myecho Preparing the Xenomips config filesystem @@ -166,12 +180,14 @@ mkfs.ext3 -F ${CONFIG_FS_NAME} mount -o loop ${CONFIG_FS_NAME} ${WORK_DIR} - mkdir -p ${WORK_DIR}/etc + mkdir -p ${WORK_DIR}/{dynamips,etc} mv ${WORK_DIR2}/quagga ${WORK_DIR}/etc + mv ${WORK_DIR2}/pixemu ${WORK_DIR}/ + dd if=/dev/zero of=${WORK_DIR}/pixemu/FLASH bs=1k count=16k umount ${WORK_DIR} myecho Creating $CONFIG_FS_NUMBER copies of the Xenomips config filesystem - for i in `seq 1 $CONFIG_FS_NUMBER` + for i in `seq 0 $CONFIG_FS_NUMBER` do cp ${CONFIG_FS_NAME} `echo ${CONFIG_FS_NAME} | sed s/XXX/$i/` done diff -r e7b9761c03e8 -r 6471afbee150 files/xenomips.sh --- a/files/xenomips.sh Sun Nov 11 20:57:50 2007 +0200 +++ b/files/xenomips.sh Mon Dec 03 08:36:13 2007 +0200 @@ -1,13 +1,23 @@ #!/bin/sh +XENOMIPS='' +grep -qi xenomips /proc/cmdline && XENOMIPS=`cat /proc/cmdline | sed 's/.*xenomips="//; s/".*//'` + case $1 in start) if grep -qi xenomips /proc/cmdline then - DYNAMIPS_WORKDIR="/xenomips/config" - DYNAMIPS_ARGS=`cat /proc/cmdline | sed 's/.*xenomips="//; s/".*//'` - cd "$DYNAMIPS_WORKDIR" - screen -e '^xx' -d -m sh -c "while true; do dynamips $DYNAMIPS_ARGS ; done" + WORKDIR="/xenomips/config/dynamips" + if echo $XENOMIPS | grep -q ^./pemu + then + WORKDIR="/xenomips/config/pixemu" + PIXOS=`echo $XENOMIPS | sed 's/.* //'` + XENOMIPS=`echo $XENOMIPS | sed 's/ [^ ]*$//'` + cp /xenomips/config/pixemu/pemu.ini.ORIG /xenomips/config/pixemu/pemu.ini + sed -i -e "s@FLASH@$PIXOS@" /xenomips/config/pixemu/pemu.ini + fi + cd "$WORKDIR" + screen -e '^xx' -d -m sh -c "while true; do $XENOMIPS ; done" else /etc/init.d/quagga start screen -e '^xx' -d -m sh -c 'while true; do vtysh; done' @@ -16,7 +26,7 @@ stop) if grep -qi xenomips /proc/cmdline then - kill $(ps aux | grep dynamips | awk '{print $2}') + kill $(ps aux | egrep "pemu|dynamips" | awk '{print $2}') else /etc/init.d/quagga stop fi diff -r e7b9761c03e8 -r 6471afbee150 xendomain.py --- a/xendomain.py Sun Nov 11 20:57:50 2007 +0200 +++ b/xendomain.py Mon Dec 03 08:36:13 2007 +0200 @@ -4,7 +4,6 @@ # * network # * domain - try: domain except NameError: @@ -12,7 +11,8 @@ network=sys.modules['__main__'].network domain=sys.modules['__main__'].domain -import os,re +import os + sys.path.append(os.environ['HOME']+"/xentaur") os.environ['xendomain']=domain @@ -26,48 +26,56 @@ bridge_bridge_table = { } +#try: +# domains +#except: +# domains=[] + + domains_brief=[] -domains=[] domain_types=[] domain_notes=[] domain_subtypes=[] - hidden_bridges = [] broken_links = [] temporary_links = [] cross_bridges=[] - real_bridges=[] real_nodes=[] +connection_table={} + +exec 'from %s import *' % (network) + # overriden by network config ############################ def process_domains_brief(): - global domains, domain_types, real_nodes, domain_notes, domain_subtypes - node_brief_re=re.compile('([a-zA-Z_0-9-]*)(?::([a-zA-Z_0-9-]*))?(?::([a-zA-Z_0-9-]*))?(\*?)(?:#(.*))?') - if len(domains)==0: - domains=map(lambda x:node_brief_re.search(x).groups()[0] or '', domains_brief) - if len(domain_types)==0: - domain_types=map(lambda x:node_brief_re.search(x).groups()[1] or '', domains_brief) - if len(domain_subtypes)==0: - domain_subtypes=map(lambda x:node_brief_re.search(x).groups()[2] or '', domains_brief) - if len(real_nodes)==0: - i=0 - for brief in domains_brief: - if node_brief_re.search(brief).groups()[3] == '*': - real_nodes.append(domains[i]) - i+=1 - if len(domain_notes)==0: - domain_notes=map(lambda x:node_brief_re.search(x).groups()[4] or '', domains_brief) +# import sre + #global domains_brief, domains, domain_types, real_nodes, domain_notes, domain_subtypes + if len(domains_brief) >0 : + node_brief_re=sre.compile('([a-zA-Z_0-9-]*)(?::([a-zA-Z_0-9-]*))?(?::([a-zA-Z_0-9-]*))?(\*?)(?:#(.*))?') + if len(domains)==0: + domains=map(lambda x:node_brief_re.search(x).groups()[0] or '', domains_brief) + if len(domain_types)==0: + domain_types=map(lambda x:node_brief_re.search(x).groups()[1] or '', domains_brief) + if len(domain_subtypes)==0: + domain_subtypes=map(lambda x:node_brief_re.search(x).groups()[2] or '', domains_brief) + if len(real_nodes)==0: + i=0 + for brief in domains_brief: + if node_brief_re.search(brief).groups()[3] == '*': + real_nodes.append(domains[i]) + i+=1 + if len(domain_notes)==0: + domain_notes=map(lambda x:node_brief_re.search(x).groups()[4] or '', domains_brief) ############################ #try: -exec 'from %s import *' % (network) #except: # print "Can't find or interpret module %s with topology description" %(network) # sys.exit(1) -process_domains_brief() +#process_domains_brief() N = domains.index(domain) name=domain @@ -110,49 +118,51 @@ else: memory = 400 -if domain_subtypes[N] != '' and platform == '': +if len(domain_subtypes) >0 and domain_subtypes[N] != '' and platform == '': platform=domain_subtypes[N] if platform == '': platform='7200' -platform_option="" -if platform != '7200': - platform_option=' -P '+platform -npe_option="" -if platform == '7200': - npe_option=" -t "+npe_type - -mac_option=' -m 00:16:3e:01:'+hex(N)[2:]+':01' -if platform != '7200': - mac_option ='' - -xenomips='/xenomips/ios/'+ios_name+platform_option+npe_option+mac_option - -default_network_module={ - '7200' : 'PA-FE-TX', - '3600' : 'NM-1FE-TX', - '3725' : 'NM-1FE-TX', - '3745' : 'NM-1FE-TX', - '2691' : 'NM-1FE-TX', -} -network_module=default_network_module[platform] - -if platform== '7200': - for i in range(len(vbridges)-1): - xenomips += ' -p '+str(i+1)+':'+network_module -else: - for i in range(len(vbridges)-1): - xenomips += ' -p '+str(i+1)+':'+network_module - - -for i in range(len(vbridges)): - xenomips += ' -s '+str(i)+':0:gen_eth:eth'+str(i) if domain_types[N] == 'quagga': extra = "quagga" +elif domain_types[N] == 'dynamips': + default_network_module={ + '7200' : 'PA-FE-TX', + '3600' : 'NM-1FE-TX', + '3725' : 'NM-1FE-TX', + '3745' : 'NM-1FE-TX', + '2691' : 'NM-1FE-TX', + } + + platform_option="" + if platform != '7200': + platform_option=' -P '+platform + npe_option="" + if platform == '7200': + npe_option=" -t "+npe_type + mac_option=' -m 00:16:3e:01:'+hex(N)[2:]+':01' + if platform != '7200': + mac_option ='' + + network_module=default_network_module[platform] + + xenomips='dynamips /xenomips/ios/'+ios_name+platform_option+npe_option+mac_option + if platform== '7200': + for i in range(len(vbridges)-1): + xenomips += ' -p '+str(i+1)+':'+network_module + else: + for i in range(len(vbridges)-1): + xenomips += ' -p '+str(i+1)+':'+network_module + for i in range(len(vbridges)): + xenomips += ' -s '+str(i)+':0:gen_eth:eth'+str(i) + extra = "xenomips=\""+xenomips+"\"" +elif domain_types[N] == 'pixemu': + xenomips="./pemu -net nic,vlan=1,macaddr=00:aa:00:00:02:01 -net pcap,vlan=1,ifname=eth0 -net nic,vlan=2,macaddr=00:aa:00:00:02:02 -net pcap,vlan=2,ifname=eth1 -serial stdio -m 128 FLASH"+' /xenomips/ios/'+ios_name + extra = "xenomips=\""+xenomips+"\"" else: - extra = "xenomips=\""+xenomips+"\"" + raise "Unknown domain type %s of domain %s " % (domain_types[N], domains[N]) on_poweroff = 'destroy' on_reboot = 'restart' diff -r e7b9761c03e8 -r 6471afbee150 xentaur.py --- a/xentaur.py Sun Nov 11 20:57:50 2007 +0200 +++ b/xentaur.py Mon Dec 03 08:36:13 2007 +0200 @@ -13,8 +13,10 @@ link_object={} bridge_object={} -network='icnd2' -domain='sw1' +network='mini' +domain='dyn1' +#network='snrs' +#domain='dyn1' from xendomain import * bridges_turned_down=[] @@ -236,20 +238,30 @@ ipshell() def version(): - print "Xentaur 0.1-PRE" - print "(Godzilla-mutant) _" - print " / * \\" - print " / .-" - print " / |" - print " | \\ \\\\ \\" - print " _ -------| \\ \\\\ \\" - print " / / \\_\\ -" - print "/ |\\ | |" - print "| | \\ .-----. | \\ |" - print " | / \\ \\ \\ \\" - print " \\/|.\\ \\ \\ \\ \\" - print " \\| - . \\_\\ \\_\\" - print "-----------------------------------------------" + print """ +Xentaur 0.1-PRE + + ,--, + _ ___/ /\\| + ,;`( )__, ) ~ + // .// '--; + ' / \ | + + """ +# print "Xentaur 0.1-PRE" +# print "(Godzilla-mutant) _" +# print " / * \\" +# print " / .-" +# print " / |" +# print " | \\ \\\\ \\" +# print " _ -------| \\ \\\\ \\" +# print " / / \\_\\ -" +# print "/ |\\ | |" +# print "| | \\ .-----. | \\ |" +# print " | / \\ \\ \\ \\" +# print " \\/|.\\ \\ \\ \\ \\" +# print " \\| - . \\_\\ \\_\\" +# print "-----------------------------------------------" def info():