'configure', 'start', SEP,
'store_keys', 'clear_known_hosts', 'initscripts', SEP,
'sites', 'nodes', 'slices', 'nodegroups', SEP,
- 'init_node','bootcd', 'configure_qemu', SEP,
- 'kill_all_qemus', 'start_nodes', SEP,
+ 'init_node','bootcd', 'configure_qemu',
+ 'kill_all_qemus', 'reinstall_node','start_node', SEP,
'standby_20', SEP,
'nodes_booted', 'nodes_ssh', 'check_slices',
'check_initscripts', 'check_tcp',SEP,
options = []
if self.is_qemu():
options=['serial']
- encoded=self.test_plc.apiserver.GetBootMedium(self.test_plc.auth_root(), self.name(), 'node-iso', '', options)
+ encoded=self.test_plc.apiserver.GetBootMedium(self.test_plc.auth_root(),
+ self.name(), 'node-iso', '', options)
if (encoded == ''):
raise Exception, 'GetBootmedium failed'
else:
file(filename,'w').write(base64.b64decode(encoded))
return True
+
+ def reinstall_node (self):
+ self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(),
+ self.name(),{'boot_state':'rins'})
+ return True
def configure_qemu(self):
if not self.is_qemu():
return
mac=self.node_spec['network_fields']['mac']
hostname=self.node_spec['node_fields']['hostname']
+ ip=self.node_spec['network_fields']['ip']
auth=self.test_plc.auth_root()
target_arch=self.test_plc.apiserver.GetPlcRelease(auth)['build']['target-arch']
conf_filename="%s/qemu.conf"%(self.nodedir())
file.write('MACADDR=%s\n'%mac)
file.write('NODE_ISO=%s.iso\n'%self.name())
file.write('HOSTNAME=%s\n'%hostname)
+ file.write('IP=%s\n'%ip)
file.write('TARGET_ARCH=%s\n'%target_arch)
file.close()
utils.header ("Transferring configuration files for node %s onto %s"%(self.name(),self.host_box()))
return self.test_box().copy(self.nodedir(),recursive=True)==0
- def start_node (self,options):
+ def start_node (self):
model=self.node_spec['node_fields']['model']
#starting the Qemu nodes before
if self.is_qemu():
- self.start_qemu(options)
+ self.start_qemu()
else:
utils.header("TestNode.start_node : %s model %s taken as real node"%(self.name(),model))
- def start_qemu (self, options):
+ def start_qemu (self):
+ options = self.test_plc.options
test_box = self.test_box()
utils.header("Starting qemu node %s on %s"%(self.name(),test_box.hostname()))
def bootcd (self): pass
@node_mapper
def configure_qemu (self): pass
+ @node_mapper
+ def reinstall_node (self): pass
def do_check_initscripts(self):
overall = True
@node_mapper
def clear_known_hosts (self): pass
- def start_nodes (self):
- utils.header("Starting nodes")
- for site_spec in self.plc_spec['sites']:
- TestSite(self,site_spec).start_nodes (self.options)
- return True
+ @node_mapper
+ def start_node (self) : pass
def locate_first_sliver (self):
slice_spec = self.plc_spec['slices'][0]
return node
raise Exception,"Cannot locate node %s"%nodename
- def start_nodes (self,options):
- for node_spec in self.site_spec['nodes']:
- TestNode(self.test_plc, self, node_spec).start_node(options)
- return True
def run(self, command,background=False):
local_command = self.actual_command(command)
- if background:
- local_command += " &"
- return utils.system(local_command)
+ return utils.system(local_command,background)
def clean_dir (self,dirname):
if self.is_local():
--- /dev/null
+TestMain.py
\ No newline at end of file
--- /dev/null
+#!/usr/bin/python
+
+import sys
+import re
+
+def main ():
+ fin=open(sys.argv[1])
+ fou=open(sys.argv[2],"w")
+ ip=sys.argv[3]
+
+ found=False
+ lo_matcher=re.compile("\A(?P<left>.+)\s+-i\s+lo\s+-j\s+ACCEPT")
+ ip_matcher=re.compile("--(source|destination) %s"%ip)
+ for line in fin.readlines():
+ attempt=lo_matcher.match(line)
+ if attempt:
+ fou.write(line)
+ # open-up for this IP
+ fou.write("%s --source %s -j ACCEPT\n"%(attempt.group('left'),ip))
+ fou.write("%s --destination %s -j ACCEPT\n"%(attempt.group('left'),ip))
+ found=True
+ else:
+ attempt = ip_matcher.match(line)
+ # do not rewrite old lines for this ip
+ if not attempt:
+ fou.write(line)
+
+ fin.close()
+ fou.close()
+ if found : return 0
+ else : return 1
+
+if __name__ == '__main__':
+ main()
+
#
COMMAND=$(basename $0)
+cd $(dirname $0)
# constant
INTERFACE_BRIDGE=br0
echo "Configuring the IP Gateway @:" $gateway
route add default gw $gateway
- # xxx this is *wrong*
- # wipe the host firewall otherwise the guest qemu can't access the LAN
- # echo "Wiping the firewall..."
- # iptables -F
-
}
#Adding a new interface to the bridge: this is used by qemu-ifup
echo "Adding $INTERFACE_LAN to $INTERFACE_BRIDGE"
brctl addif $INTERFACE_BRIDGE $INTERFACE_LAN
+ # turn off filtering on this interface
+ ########## from the test environment
+ # expected vars are MACADDR, NODE_ISO, HOSTNAME, IP and TARGET_ARCH
+ CONFIG=qemu.conf
+ [ -f "$CONFIG" ] || { echo "Config file for qemu $CONFIG not found in $(pwd)" ; exit 1 ; }
+ . $CONFIG
+
+ echo "Tweaking iptables"
+ iptables-save > iptables.pre
+ # rewrite a new config - quick and dirty
+ ./iptables.py iptables.pre iptables.post $IP
+ iptables-restore < iptables.post
+
}
#Stop the bridge and restore the original setting
/sbin/ifconfig $INTERFACE_BRIDGE down
brctl delbr $INTERFACE_BRIDGE
/sbin/service network restart
+ /sbin/service iptables restart
}
#
# use the bridge as set up by qemu-bridge-init start
-qemu-bridge-init add $1
+cd $(dirname $0)
+./qemu-bridge-init add $1
kill_from_file $nodedir/qemu.pid
done
else
- echo "Killing all processes mathing $COMMANDS_TO_KILL"
- for command in $COMMANDS_TO_KILL ; do
- pkill -x $command
- done
+ pids=$(list_pids)
+ if [ -n "$pids" ] ; then
+ echo "Killing all processes matching $COMMANDS_TO_KILL"
+ for pid in $pids; do
+ echo Killing $pid
+ kill $pid
+ done
+ else
+ echo "No process found that match $COMMANDS_TO_KILL"
+ fi
fi
}
TAP="tap,script=$SCRIPT"
########## from the test environment
-# expected vars are MACADDR, NODE_ISO, HOSTNAME and TARGET_ARCH
+# expected vars are MACADDR, NODE_ISO, HOSTNAME, IP and TARGET_ARCH
CONFIG=qemu.conf
-if [ ! -e ${CONFIG} ];then
- echo "File for node_iso version not found"
- exit 1
-fi
+[ -f "$CONFIG" ] || { echo "Config file for qemu $CONFIG not found in $(pwd)" ; exit 1 ; }
. $CONFIG
# the launcher, depending on local/target archs