Esempio n. 1
0
def check(indent="", shellError=False):
	print indent + "checking OpenVZ element type..." 
	indent += "\t"
	try:
		id = checkCreate(indent=indent)

		id1 = checkCreateInterface(id, indent=indent)
		
		checkAction(id, "prepare", assertState="prepared", indent=indent)
		
		id2 = checkCreateInterface(id, indent=indent)

		print indent + "checking attribute changes in state prepared..."
		element_modify(id, {"ram": 128, "diskspace": 10000, "template": None})
		
		checkAction(id, "start", assertState="started", indent=indent)
		
		print indent + "checking VNC server..."
		info = element_info(id)
		assert "attrs" in info and "vncport" in info["attrs"]
		assert lib.tcpPortOpen(__hostname__, info["attrs"]["vncport"]), "VNC Port not open"
		
		print indent + "checking execute..."
		res = element_action(id, "execute", {"cmd":"whoami"})
		assert res.strip() == "root", "Result of whoami was %s" % res
		
		print indent + "checking attribute changes in state started..."
		element_modify(id1, {"ip4address": "10.0.0.1/24", "ip6address": "fdb2:a935:f0f5:b82b::1/64"})
		element_modify(id, {"rootpassword": "******", "hostname": "test", "gateway4": "10.0.0.254", "gateway6": "fdb2:a935:f0f5:b82b::ffff"})
		element_modify(id1, {"use_dhcp": True})
		
		checkAction(id, "stop", assertState="prepared", indent=indent)
		
		print indent + "checking disk download and upload..."
		fileserver_port = host_info()["fileserver_port"]
		assert fileserver_port	
		grant = element_action(id, "download_grant")
		assert grant
		lib.download("http://%s:%d/%s/download" % (__hostname__, fileserver_port, grant), "disk.tar.gz")
		assert os.path.exists("disk.tar.gz")
		grant = element_action(id, "upload_grant")
		assert grant
		lib.upload("http://%s:%d/%s/upload" % (__hostname__, fileserver_port, grant), "disk.tar.gz")
		element_action(id, "upload_use")
		
		checkRemove(id1, indent=indent)		
		
		checkAction(id, "destroy", assertState="created", indent=indent)
		
		checkRemove(id, indent=indent)
	except:
		import traceback
		traceback.print_exc()
		if shellError:
			shell()
	finally:
		if os.path.exists("disk.tar.gz"):
			os.remove("disk.tar.gz")
		tearDown(id, indent)
Esempio n. 2
0
def check(indent="", shellError=False):
	print indent + "checking KVMQM element type..." 
	indent += "\t"
	try:
		id = checkCreate(indent=indent)

		id1 = checkCreateInterface(id, indent=indent)
		
		checkAction(id, "prepare", assertState="prepared", indent=indent)
		
		id2 = checkCreateInterface(id, indent=indent)

		print indent + "checking attribute changes in state prepared..."
		element_modify(id, {"cpus": 2, "ram": 128, "usbtablet": False, "kblang": "de", "template": None})
		
		checkAction(id, "start", assertState="started", indent=indent)
		
		print indent + "checking VNC server..."
		info = element_info(id)
		assert "attrs" in info and "vncport" in info["attrs"]
		assert lib.tcpPortOpen(__hostname__, info["attrs"]["vncport"]), "VNC Port not open"
		
		checkAction(id, "stop", assertState="prepared", indent=indent)
		
		print indent + "checking disk download and upload..."
		fileserver_port = host_info()["fileserver_port"]
		assert fileserver_port	
		grant = element_action(id, "download_grant")
		assert grant
		lib.download("http://%s:%d/%s/download" % (__hostname__, fileserver_port, grant), "disk.qcow2")
		assert os.path.exists("disk.qcow2")
		grant = element_action(id, "upload_grant")
		assert grant
		lib.upload("http://%s:%d/%s/upload" % (__hostname__, fileserver_port, grant), "disk.qcow2")
		element_action(id, "upload_use")
		
		checkRemove(id1, indent=indent)		
		
		checkAction(id, "destroy", assertState="created", indent=indent)
		
		checkRemove(id, indent=indent)
	except:
		import traceback
		traceback.print_exc()
		if shellError:
			shell()
	finally:
		if os.path.exists("disk.qcow2"):
			os.remove("disk.qcow2")
		tearDown(id, indent)
Esempio n. 3
0
def check(indent="", shellError=False):
	print indent + "checking Repy element type..." 
	indent += "\t"
	try:
		id = checkCreate(indent=indent)

		id1 = checkCreateInterface(id, indent=indent)
		
		id2 = checkCreateInterface(id, indent=indent)

		print indent + "checking attribute changes in state created..."
		element_modify(id, {"cpus": 0.5, "ram": 128, "bandwidth": 1000000, "args": ["id=1000"], "template": None})
		
		checkAction(id, "start", assertState="started", indent=indent)
		
		print indent + "checking VNC server..."
		info = element_info(id)
		assert "attrs" in info and "vncport" in info["attrs"]
		assert lib.tcpPortOpen(__hostname__, info["attrs"]["vncport"]), "VNC Port not open"
		
		checkAction(id, "stop", assertState="prepared", indent=indent)
		
		print indent + "checking disk download and upload..."
		fileserver_port = host_info()["fileserver_port"]
		assert fileserver_port	
		grant = element_action(id, "download_grant")
		assert grant
		lib.download("http://%s:%d/%s/download" % (__hostname__, fileserver_port, grant), "disk.repy")
		assert os.path.exists("disk.repy")
		grant = element_action(id, "upload_grant")
		assert grant
		lib.upload("http://%s:%d/%s/upload" % (__hostname__, fileserver_port, grant), "disk.repy")
		element_action(id, "upload_use")
		
		checkRemove(id1, indent=indent)		
				
		checkRemove(id, indent=indent)
	except:
		import traceback
		traceback.print_exc()
		if shellError:
			shell()
	finally:
		if os.path.exists("disk.repy"):
			os.remove("disk.repy")
		tearDown(id, indent)
Esempio n. 4
0
def check(indent="", shellError=False):
	print indent + "checking Bridge connection type..." 
	indent += "\t"
	try:
		print indent+"creating two openvz devices with one interface each..."
		dev0 = element_create("openvz")["id"]
		print indent+"\tID: %d" % dev0
		eth0 = element_create("openvz_interface", dev0, {"use_dhcp": False, "ip4address": "10.0.0.1/24"})["id"]		
		print indent+"\tID: %d" % eth0
		dev1 = element_create("openvz")["id"]
		print indent+"\tID: %d" % dev1
		eth1 = element_create("openvz_interface", dev1, {"use_dhcp": False, "ip4address": "10.0.0.2/24"})["id"]
		print indent+"\tID: %d" % eth1

		print indent+"creating bridge between interfaces..."
		id = checkCreate(eth0, eth1, indent=indent)

		print indent+"starting openvz devices..."
		element_action(dev0, "prepare")
		element_action(dev1, "prepare")
		element_action(dev0, "start")
		element_action(dev1, "start")
		
		print indent+"starting bridge..."
		checkAction(id, "start", assertState="started", indent=indent)
		
		print indent+"checking connectivity..."
		time.sleep(5)
		element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"})
		
		print indent+"changing link emulation values..."
		connection_modify(id, {"emulation": True, "delay_to": 5.0, "delay_from": 2.0, "jitter_to": 0.0,
			"jitter_from": 0.0, "distribution_to": "uniform", "distribution_from": "uniform", 
			"bandwidth_to": 10000, "bandwidth_from": 10000, "lossratio_to": 0.0, "lossratio_from": 0.0,
			"duplicate_to": 0.0, "duplicate_from": 0.0, "corrupt_to": 0.0, "corrupt_from": 0.0})
		
		print indent+"checking connectivity..."
		element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"})

		print indent+"checking file capture..."
		connection_modify(id, {"capturing": True, "capture_mode": "file", "capture_filter": "icmp"})
		
		element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"})
		
		print indent+"checking capture download..."
		fileserver_port = host_info()["fileserver_port"]
		assert fileserver_port	
		grant = connection_action(id, "download_grant")
		assert grant
		lib.download("http://%s:%d/%s/download" % (__hostname__, fileserver_port, grant), "capture.pcap")
		assert os.path.exists("capture.pcap")

		print indent+"checking live capture..."
		connection_modify(id, {"capture_mode": "net"})
		info = connection_info(id)
		assert "attrs" in info and "capture_port" in info["attrs"]
		assert lib.tcpPortOpen(__hostname__, info["attrs"]["capture_port"]), "Capture port not open"	
		
		print indent+"stopping bridge..."
		checkAction(id, "stop", assertState="created", indent=indent)

		print indent+"removing bridge..."
		checkRemove(id, indent=indent)

		print indent+"tearing down openvz devices..."
		openvzTearDown(dev0, indent=indent)
		openvzTearDown(dev1, indent=indent)
	except:
		import traceback
		traceback.print_exc()
		if shellError:
			shell()
	finally:
		if os.path.exists("capture.pcap"):
			os.remove("capture.pcap")
		tearDown(id, indent)
		openvzTearDown(dev0, indent=indent)
		openvzTearDown(dev1, indent=indent)
Esempio n. 5
0
def check(indent="", shellError=False):
    print indent + "checking Bridge connection type..."
    indent += "\t"
    try:
        print indent + "creating two openvz devices with one interface each..."
        dev0 = element_create("openvz")["id"]
        print indent + "\tID: %d" % dev0
        eth0 = element_create("openvz_interface", dev0, {
            "use_dhcp": False,
            "ip4address": "10.0.0.1/24"
        })["id"]
        print indent + "\tID: %d" % eth0
        dev1 = element_create("openvz")["id"]
        print indent + "\tID: %d" % dev1
        eth1 = element_create("openvz_interface", dev1, {
            "use_dhcp": False,
            "ip4address": "10.0.0.2/24"
        })["id"]
        print indent + "\tID: %d" % eth1

        print indent + "creating bridge between interfaces..."
        id = checkCreate(eth0, eth1, indent=indent)

        print indent + "starting openvz devices..."
        element_action(dev0, "prepare")
        element_action(dev1, "prepare")
        element_action(dev0, "start")
        element_action(dev1, "start")

        print indent + "starting bridge..."
        checkAction(id, "start", assertState="started", indent=indent)

        print indent + "checking connectivity..."
        time.sleep(5)
        element_action(dev0, "execute",
                       {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"})

        print indent + "changing link emulation values..."
        connection_modify(
            id, {
                "emulation": True,
                "delay_to": 5.0,
                "delay_from": 2.0,
                "jitter_to": 0.0,
                "jitter_from": 0.0,
                "distribution_to": "uniform",
                "distribution_from": "uniform",
                "bandwidth_to": 10000,
                "bandwidth_from": 10000,
                "lossratio_to": 0.0,
                "lossratio_from": 0.0,
                "duplicate_to": 0.0,
                "duplicate_from": 0.0,
                "corrupt_to": 0.0,
                "corrupt_from": 0.0
            })

        print indent + "checking connectivity..."
        element_action(dev0, "execute",
                       {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"})

        print indent + "checking file capture..."
        connection_modify(id, {
            "capturing": True,
            "capture_mode": "file",
            "capture_filter": "icmp"
        })

        element_action(dev0, "execute",
                       {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"})

        print indent + "checking capture download..."
        fileserver_port = host_info()["fileserver_port"]
        assert fileserver_port
        grant = connection_action(id, "download_grant")
        assert grant
        lib.download(
            "http://%s:%d/%s/download" %
            (__hostname__, fileserver_port, grant), "capture.pcap")
        assert os.path.exists("capture.pcap")

        print indent + "checking live capture..."
        connection_modify(id, {"capture_mode": "net"})
        info = connection_info(id)
        assert "attrs" in info and "capture_port" in info["attrs"]
        assert lib.tcpPortOpen(
            __hostname__,
            info["attrs"]["capture_port"]), "Capture port not open"

        print indent + "stopping bridge..."
        checkAction(id, "stop", assertState="created", indent=indent)

        print indent + "removing bridge..."
        checkRemove(id, indent=indent)

        print indent + "tearing down openvz devices..."
        openvzTearDown(dev0, indent=indent)
        openvzTearDown(dev1, indent=indent)
    except:
        import traceback
        traceback.print_exc()
        if shellError:
            shell()
    finally:
        if os.path.exists("capture.pcap"):
            os.remove("capture.pcap")
        tearDown(id, indent)
        openvzTearDown(dev0, indent=indent)
        openvzTearDown(dev1, indent=indent)