xentaur

changeset 61:6471afbee150

*** empty log message ***
author igor
date Mon Dec 03 08:36:13 2007 +0200 (2007-12-03)
parents e7b9761c03e8
children e838c1223b89
files build-xenomips-image files/xenomips.sh xendomain.py xentaur.py
line diff
     1.1 --- a/build-xenomips-image	Sun Nov 11 20:57:50 2007 +0200
     1.2 +++ b/build-xenomips-image	Mon Dec 03 08:36:13 2007 +0200
     1.3 @@ -30,9 +30,11 @@
     1.4  
     1.5  DEBIAN_MIRROR=ftp://debian.org.ua/debian
     1.6  DISTRO=etch
     1.7 -PACKAGES="openssh-server libc6-xen libelf1 libpcap0.8 screen nfs-common quagga tcpdump telnet ntpdate hping3 ntpd nmap netcat socat"
     1.8 +PACKAGES="openssh-server libc6-xen libelf1 libpcap0.8 screen nfs-common quagga tcpdump telnet ntpdate hping3 ntp nmap netcat socat"
     1.9  DYNAMIPS_SOURCES=http://www.ipflow.utc.fr/dynamips/dynamips-0.2.7.tar.gz
    1.10  DYNAMIPS_BUILD_DIR=dynamips/
    1.11 +PIXEMU_SOURCES=http://xgu.ru/download/pemu_public2007-07-02.tar.bz2
    1.12 +PIXEMU_BUILD_DIR=dynamips/
    1.13  KERNEL_VERSION=`uname -r`
    1.14  
    1.15  
    1.16 @@ -68,6 +70,14 @@
    1.17      cd ${OLD_PWD}
    1.18  }
    1.19  
    1.20 +build_and_install_pixemu()
    1.21 +{
    1.22 +    DESTDIR=${WORK_DIR}/usr/local/pixemu
    1.23 +    mkdir -p $DESTDIR
    1.24 +    cp /home/igor/pemu/pemu/* $DESTDIR
    1.25 +}
    1.26 +
    1.27 +
    1.28  if [ $(id -u) != 0 ]
    1.29  then
    1.30      echo You are not root.
    1.31 @@ -126,7 +136,7 @@
    1.32  mv /etc/quagga /etc/quagga.ORIG
    1.33  ln -s /xenomips/config/etc/quagga /etc/quagga
    1.34  
    1.35 -mkdir -p /xenomips/{ios,config,dynamips} /var/lib/xenomips /root/.ssh
    1.36 +mkdir -p /xenomips/{ios,config} /var/lib/xenomips /root/.ssh
    1.37  
    1.38  cat <<PROFILE >> /root/.profile
    1.39  TERM=linux
    1.40 @@ -147,6 +157,9 @@
    1.41      chmod 600  ${WORK_DIR}/root/.ssh/authorized_keys
    1.42  
    1.43      build_and_install_dynamips
    1.44 +    build_and_install_pixemu
    1.45 +    kill $(lsof +D ${WORK_DIR} | awk '{print $2}' | grep -v PID)
    1.46 +    pkill ntpd
    1.47      umount ${WORK_DIR}
    1.48  fi
    1.49  
    1.50 @@ -159,6 +172,7 @@
    1.51      cp -a ${WORK_DIR}/etc/quagga.ORIG ${WORK_DIR2}/quagga
    1.52      perl -i -p -e 's/=no/=yes/' ${WORK_DIR2}/quagga/daemons
    1.53      touch ${WORK_DIR2}/quagga/{zebra,bgpd,ospfd,ripd,ripngd,ospf6d,isisd}.conf
    1.54 +    cp -a ${WORK_DIR}/usr/local/pixemu ${WORK_DIR2}/pixemu
    1.55      umount ${WORK_DIR}
    1.56  
    1.57      myecho Preparing the Xenomips config filesystem
    1.58 @@ -166,12 +180,14 @@
    1.59      mkfs.ext3 -F ${CONFIG_FS_NAME}
    1.60  
    1.61      mount -o loop ${CONFIG_FS_NAME} ${WORK_DIR}
    1.62 -    mkdir -p ${WORK_DIR}/etc
    1.63 +    mkdir -p ${WORK_DIR}/{dynamips,etc}
    1.64      mv ${WORK_DIR2}/quagga ${WORK_DIR}/etc
    1.65 +    mv ${WORK_DIR2}/pixemu ${WORK_DIR}/
    1.66 +    dd if=/dev/zero of=${WORK_DIR}/pixemu/FLASH bs=1k count=16k
    1.67      umount ${WORK_DIR}
    1.68  
    1.69      myecho Creating $CONFIG_FS_NUMBER copies of the Xenomips config filesystem
    1.70 -    for i in `seq 1 $CONFIG_FS_NUMBER`
    1.71 +    for i in `seq 0 $CONFIG_FS_NUMBER`
    1.72      do
    1.73          cp ${CONFIG_FS_NAME} `echo ${CONFIG_FS_NAME} | sed s/XXX/$i/`
    1.74      done
     2.1 --- a/files/xenomips.sh	Sun Nov 11 20:57:50 2007 +0200
     2.2 +++ b/files/xenomips.sh	Mon Dec 03 08:36:13 2007 +0200
     2.3 @@ -1,13 +1,23 @@
     2.4  #!/bin/sh
     2.5  
     2.6 +XENOMIPS=''
     2.7 +grep -qi xenomips /proc/cmdline && XENOMIPS=`cat /proc/cmdline | sed 's/.*xenomips="//; s/".*//'`
     2.8 +
     2.9  case $1 in
    2.10      start)
    2.11          if grep -qi xenomips /proc/cmdline
    2.12          then 
    2.13 -            DYNAMIPS_WORKDIR="/xenomips/config"
    2.14 -            DYNAMIPS_ARGS=`cat /proc/cmdline | sed 's/.*xenomips="//; s/".*//'`
    2.15 -            cd "$DYNAMIPS_WORKDIR"
    2.16 -            screen -e '^xx' -d -m sh -c "while true; do dynamips $DYNAMIPS_ARGS ; done"
    2.17 +            WORKDIR="/xenomips/config/dynamips"
    2.18 +            if echo $XENOMIPS | grep -q ^./pemu
    2.19 +            then
    2.20 +                WORKDIR="/xenomips/config/pixemu"
    2.21 +                PIXOS=`echo $XENOMIPS | sed 's/.* //'`
    2.22 +                XENOMIPS=`echo $XENOMIPS | sed 's/ [^ ]*$//'`
    2.23 +                cp /xenomips/config/pixemu/pemu.ini.ORIG /xenomips/config/pixemu/pemu.ini
    2.24 +                sed -i -e "s@FLASH@$PIXOS@" /xenomips/config/pixemu/pemu.ini
    2.25 +            fi
    2.26 +            cd "$WORKDIR"
    2.27 +            screen -e '^xx' -d -m sh -c "while true; do $XENOMIPS ; done"
    2.28          else
    2.29              /etc/init.d/quagga start
    2.30              screen -e '^xx' -d -m sh -c 'while true; do vtysh; done'
    2.31 @@ -16,7 +26,7 @@
    2.32      stop)
    2.33          if grep -qi xenomips /proc/cmdline
    2.34          then 
    2.35 -            kill $(ps aux | grep  dynamips | awk '{print $2}')
    2.36 +            kill $(ps aux | egrep "pemu|dynamips" |  awk '{print $2}')
    2.37          else
    2.38              /etc/init.d/quagga stop
    2.39          fi
     3.1 --- a/xendomain.py	Sun Nov 11 20:57:50 2007 +0200
     3.2 +++ b/xendomain.py	Mon Dec 03 08:36:13 2007 +0200
     3.3 @@ -4,7 +4,6 @@
     3.4  # * network 
     3.5  # * domain
     3.6  
     3.7 -
     3.8  try: 
     3.9      domain
    3.10  except NameError:
    3.11 @@ -12,7 +11,8 @@
    3.12      network=sys.modules['__main__'].network
    3.13      domain=sys.modules['__main__'].domain
    3.14  
    3.15 -import os,re
    3.16 +import os
    3.17 +
    3.18  sys.path.append(os.environ['HOME']+"/xentaur")
    3.19  os.environ['xendomain']=domain
    3.20  
    3.21 @@ -26,48 +26,56 @@
    3.22  bridge_bridge_table = {
    3.23  }
    3.24  
    3.25 +#try:
    3.26 +#    domains
    3.27 +#except:
    3.28 +#    domains=[]
    3.29 +
    3.30 +
    3.31  domains_brief=[]
    3.32 -domains=[]
    3.33  domain_types=[]
    3.34  domain_notes=[]
    3.35  domain_subtypes=[]
    3.36 -
    3.37  hidden_bridges = []
    3.38  broken_links = []
    3.39  temporary_links = []
    3.40  cross_bridges=[]
    3.41 -
    3.42  real_bridges=[]
    3.43  real_nodes=[]
    3.44 +connection_table={}
    3.45 +
    3.46 +exec 'from %s import *' % (network)
    3.47 +
    3.48  # overriden by network config
    3.49  ############################
    3.50  
    3.51  def process_domains_brief():
    3.52 -    global domains, domain_types, real_nodes, domain_notes, domain_subtypes
    3.53 -    node_brief_re=re.compile('([a-zA-Z_0-9-]*)(?::([a-zA-Z_0-9-]*))?(?::([a-zA-Z_0-9-]*))?(\*?)(?:#(.*))?')
    3.54 -    if len(domains)==0:
    3.55 -        domains=map(lambda x:node_brief_re.search(x).groups()[0] or '', domains_brief)
    3.56 -    if len(domain_types)==0:
    3.57 -        domain_types=map(lambda x:node_brief_re.search(x).groups()[1] or '', domains_brief)
    3.58 -    if len(domain_subtypes)==0:
    3.59 -        domain_subtypes=map(lambda x:node_brief_re.search(x).groups()[2] or '', domains_brief)
    3.60 -    if len(real_nodes)==0:
    3.61 -        i=0
    3.62 -        for brief in domains_brief:
    3.63 -            if node_brief_re.search(brief).groups()[3] == '*':
    3.64 -                real_nodes.append(domains[i])
    3.65 -            i+=1
    3.66 -    if len(domain_notes)==0:
    3.67 -        domain_notes=map(lambda x:node_brief_re.search(x).groups()[4] or '', domains_brief)
    3.68 +#    import sre
    3.69 +    #global domains_brief, domains, domain_types, real_nodes, domain_notes, domain_subtypes
    3.70 +    if len(domains_brief) >0 :
    3.71 +        node_brief_re=sre.compile('([a-zA-Z_0-9-]*)(?::([a-zA-Z_0-9-]*))?(?::([a-zA-Z_0-9-]*))?(\*?)(?:#(.*))?')
    3.72 +        if len(domains)==0:
    3.73 +            domains=map(lambda x:node_brief_re.search(x).groups()[0] or '', domains_brief)
    3.74 +        if len(domain_types)==0:
    3.75 +            domain_types=map(lambda x:node_brief_re.search(x).groups()[1] or '', domains_brief)
    3.76 +        if len(domain_subtypes)==0:
    3.77 +            domain_subtypes=map(lambda x:node_brief_re.search(x).groups()[2] or '', domains_brief)
    3.78 +        if len(real_nodes)==0:
    3.79 +            i=0
    3.80 +            for brief in domains_brief:
    3.81 +                if node_brief_re.search(brief).groups()[3] == '*':
    3.82 +                    real_nodes.append(domains[i])
    3.83 +                i+=1
    3.84 +        if len(domain_notes)==0:
    3.85 +            domain_notes=map(lambda x:node_brief_re.search(x).groups()[4] or '', domains_brief)
    3.86  
    3.87  ############################
    3.88  #try:
    3.89 -exec 'from %s import *' % (network)
    3.90  #except:
    3.91  #    print "Can't find or interpret module %s with topology description" %(network)
    3.92  #    sys.exit(1)
    3.93  
    3.94 -process_domains_brief()
    3.95 +#process_domains_brief()
    3.96  
    3.97  N = domains.index(domain)
    3.98  name=domain
    3.99 @@ -110,49 +118,51 @@
   3.100  else:
   3.101      memory = 400
   3.102  
   3.103 -if domain_subtypes[N] != '' and platform == '':
   3.104 +if len(domain_subtypes) >0 and domain_subtypes[N] != '' and platform == '':
   3.105      platform=domain_subtypes[N]
   3.106  
   3.107  if platform == '': 
   3.108      platform='7200'
   3.109 -platform_option=""
   3.110 -if platform != '7200':
   3.111 -    platform_option=' -P '+platform
   3.112  
   3.113 -npe_option=""
   3.114 -if platform == '7200':
   3.115 -    npe_option=" -t "+npe_type
   3.116 -
   3.117 -mac_option=' -m 00:16:3e:01:'+hex(N)[2:]+':01'
   3.118 -if platform != '7200':
   3.119 -    mac_option =''
   3.120 -
   3.121 -xenomips='/xenomips/ios/'+ios_name+platform_option+npe_option+mac_option
   3.122 -
   3.123 -default_network_module={
   3.124 -    '7200' : 'PA-FE-TX',
   3.125 -    '3600' : 'NM-1FE-TX',
   3.126 -    '3725' : 'NM-1FE-TX',
   3.127 -    '3745' : 'NM-1FE-TX',
   3.128 -    '2691' : 'NM-1FE-TX',
   3.129 -}
   3.130 -network_module=default_network_module[platform]
   3.131 -
   3.132 -if platform== '7200':
   3.133 -    for i in range(len(vbridges)-1):
   3.134 -        xenomips += ' -p '+str(i+1)+':'+network_module
   3.135 -else:
   3.136 -    for i in range(len(vbridges)-1):
   3.137 -        xenomips += ' -p '+str(i+1)+':'+network_module
   3.138 -
   3.139 -
   3.140 -for i in range(len(vbridges)):
   3.141 - xenomips += ' -s '+str(i)+':0:gen_eth:eth'+str(i)
   3.142  
   3.143  if domain_types[N] == 'quagga':
   3.144      extra = "quagga"
   3.145 +elif domain_types[N] == 'dynamips':
   3.146 +    default_network_module={
   3.147 +        '7200' : 'PA-FE-TX',
   3.148 +        '3600' : 'NM-1FE-TX',
   3.149 +        '3725' : 'NM-1FE-TX',
   3.150 +        '3745' : 'NM-1FE-TX',
   3.151 +        '2691' : 'NM-1FE-TX',
   3.152 +    }
   3.153 +
   3.154 +    platform_option=""
   3.155 +    if platform != '7200':
   3.156 +        platform_option=' -P '+platform
   3.157 +    npe_option=""
   3.158 +    if platform == '7200':
   3.159 +        npe_option=" -t "+npe_type
   3.160 +    mac_option=' -m 00:16:3e:01:'+hex(N)[2:]+':01'
   3.161 +    if platform != '7200':
   3.162 +        mac_option =''
   3.163 +
   3.164 +    network_module=default_network_module[platform]
   3.165 +
   3.166 +    xenomips='dynamips /xenomips/ios/'+ios_name+platform_option+npe_option+mac_option
   3.167 +    if platform== '7200':
   3.168 +        for i in range(len(vbridges)-1):
   3.169 +            xenomips += ' -p '+str(i+1)+':'+network_module
   3.170 +    else:
   3.171 +        for i in range(len(vbridges)-1):
   3.172 +            xenomips += ' -p '+str(i+1)+':'+network_module
   3.173 +    for i in range(len(vbridges)):
   3.174 +        xenomips += ' -s '+str(i)+':0:gen_eth:eth'+str(i)
   3.175 +    extra = "xenomips=\""+xenomips+"\""
   3.176 +elif domain_types[N] == 'pixemu':
   3.177 +    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
   3.178 +    extra = "xenomips=\""+xenomips+"\""
   3.179  else:
   3.180 -    extra = "xenomips=\""+xenomips+"\""
   3.181 +    raise "Unknown domain type %s of domain %s " % (domain_types[N], domains[N])
   3.182  
   3.183  on_poweroff = 'destroy'
   3.184  on_reboot   = 'restart'
     4.1 --- a/xentaur.py	Sun Nov 11 20:57:50 2007 +0200
     4.2 +++ b/xentaur.py	Mon Dec 03 08:36:13 2007 +0200
     4.3 @@ -13,8 +13,10 @@
     4.4  link_object={}
     4.5  bridge_object={}
     4.6  
     4.7 -network='icnd2'
     4.8 -domain='sw1'
     4.9 +network='mini'
    4.10 +domain='dyn1'
    4.11 +#network='snrs'
    4.12 +#domain='dyn1'
    4.13  from xendomain import *
    4.14  
    4.15  bridges_turned_down=[]
    4.16 @@ -236,20 +238,30 @@
    4.17      ipshell()
    4.18  
    4.19  def version():
    4.20 -    print "Xentaur 0.1-PRE"
    4.21 -    print "(Godzilla-mutant)  _"
    4.22 -    print "                 / * \\"
    4.23 -    print "                /   .-"
    4.24 -    print "               /   |"
    4.25 -    print "              | \\ \\\\ \\"
    4.26 -    print "     _ -------|  \\ \\\\ \\"
    4.27 -    print " / /              \\_\\ -"
    4.28 -    print "/ |\\           |   |"
    4.29 -    print "| |  \\ .-----. | \\ |"
    4.30 -    print "  |  /        \\ \\ \\ \\"
    4.31 -    print "  \\/|.\\        \\ \\ \\ \\"
    4.32 -    print "   \\| - .       \\_\\ \\_\\"
    4.33 -    print "-----------------------------------------------"
    4.34 +    print """
    4.35 +Xentaur 0.1-PRE
    4.36 +
    4.37 +             ,--,
    4.38 +       _ ___/ /\\|
    4.39 +   ,;`( )__, )  ~
    4.40 +  // .//   '--;
    4.41 +  ' / \     |
    4.42 +
    4.43 +    """
    4.44 +#    print "Xentaur 0.1-PRE"
    4.45 +#    print "(Godzilla-mutant)  _"
    4.46 +#    print "                 / * \\"
    4.47 +#    print "                /   .-"
    4.48 +#    print "               /   |"
    4.49 +#    print "              | \\ \\\\ \\"
    4.50 +#    print "     _ -------|  \\ \\\\ \\"
    4.51 +#    print " / /              \\_\\ -"
    4.52 +#    print "/ |\\           |   |"
    4.53 +#    print "| |  \\ .-----. | \\ |"
    4.54 +#    print "  |  /        \\ \\ \\ \\"
    4.55 +#    print "  \\/|.\\        \\ \\ \\ \\"
    4.56 +#    print "   \\| - .       \\_\\ \\_\\"
    4.57 +#    print "-----------------------------------------------"
    4.58  
    4.59  
    4.60  def info():