def test_state(self): trans, client = get_client(saas.VPS) print "test state" trans.open() try: vps = client.vps(65) print VPSMgr.dump_vps_info(vps) finally: trans.close()
def test_state (self): trans, client = get_client (saas.VPS) print "test state" trans.open () try: vps = client.vps (65) print VPSMgr.dump_vps_info (vps) finally: trans.close ()
def test_invalid(self): trans, client = get_client(saas.VPS) trans.open() print "connected" try: vps = client.vps(0) print VPSMgr.dump_vps_info(vps) self.assert_(not VPSMgr.vps_is_valid(vps)) vps = client.vps(100000000) print VPSMgr.dump_vps_info(vps) self.assert_(not VPSMgr.vps_is_valid(vps)) finally: trans.close()
def test_invalid (self): trans, client = get_client (saas.VPS) trans.open () print "connected" try: vps = client.vps (0) print VPSMgr.dump_vps_info (vps) self.assert_ (not VPSMgr.vps_is_valid (vps)) vps = client.vps (100000000) print VPSMgr.dump_vps_info (vps) self.assert_ (not VPSMgr.vps_is_valid (vps)) finally: trans.close ()
def run_server (queue_dict): # server = zthrift.server.get_server_nonblock (saas.VPS, DummyHandler (queue_dict)) # return server.serve () zthrift.server.server (saas.VPS, DummyHandler (queue_dict), port=conf.SAAS_PORT + 1, allowed_ips=["119.254.32.166", "127.0.0.1"]) print "server exit ?" if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) queue_dict = get_queue_dict () th = threading.Thread(target=run_server, args=(queue_dict,)) th.setDaemon(1) th.start () time.sleep (2) transport, client = get_client (saas.VPS, host="127.0.0.1", port=conf.SAAS_PORT + 1) transport.open () try: vps = client.vps (1) print "id", vps.id, "os", vps.os, "cpu", vps.cpu, "ram", vps.ram, "hd", vps.hd, \ "ip", int2ip (vps.ipv4), "netmask", int2ip (vps.ipv4_netmask), "gateway", int2ip (vps.ipv4_gateway), \ "pw", vps.password finally: transport.close () # unittest.main () # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 :
def get_client(self): return get_client(VPS)
def get_client (self): return get_client (VPS)