Beispiel #1
0
 def _boot_and_test (self, vps, is_new=True):
     assert isinstance (vps, XenVPS)
     self.loginfo (vps, "booting")
     status = None
     out = None
     err = None
     vps.start ()
     if not vps.wait_until_reachable (60):
         raise Exception ("the vps started, seems not reachable")
     if is_new:
         _e = None
         for i in xrange (0, 5):
             self.loginfo (vps, "started and reachable, wait for ssh connection")
             time.sleep (5)
             try:
                 status, out, err = vps_common.call_cmd_via_ssh (vps.ip, user="******", password=vps.root_pw, cmd="free|grep Swap")
                 self.loginfo (vps, "ssh login ok")
                 if status == 0:
                     if vps.swap_store.size_g > 0:
                         swap_size = int (out.split ()[1])
                         if swap_size == 0:
                             raise Exception ("it seems swap has not properly configured, please check") 
                         self.loginfo (vps, "checked swap size is %d" % (swap_size))
                 else:
                     raise Exception ("cmd 'free' on via returns %s %s" % (out, err))
                 return
             except socket.error, e:
                 _e = e
                 continue
         if _e:
             raise _e
Beispiel #2
0
 def test_ssh(self):
     from ops.vps_common import call_cmd_via_ssh
     status, out, err = call_cmd_via_ssh("10.10.2.2",
                                         user="******",
                                         password="******",
                                         cmd="free|grep Swap")
     self.assertEqual(status, 0)
     print out
Beispiel #3
0
 def _boot_and_test(self, xv, is_new=True):
     assert isinstance(xv, XenVPS)
     self.loginfo(xv, "booting")
     status = None
     out = None
     err = None
     xv.start()
     if not xv.wait_until_reachable(120):
         if not is_new:
             if not scan_port_open(xv.ip):
                 raise Exception("the vps started, seems not reachable")
         else:
             raise Exception("the vps started, seems not reachable")
     if is_new:
         _e = None
         for i in xrange(0, 5):
             self.loginfo(xv,
                          "started and reachable, wait for ssh connection")
             time.sleep(5)
             try:
                 status, out, err = vps_common.call_cmd_via_ssh(
                     xv.ip,
                     user="******",
                     password=xv.root_pw,
                     cmd="free|grep Swap")
                 self.loginfo(xv, "ssh login ok")
                 if status == 0:
                     if xv.swap_store.size_g > 0:
                         swap_size = int(out.split()[1])
                         if swap_size == 0:
                             raise Exception(
                                 "it seems swap has not properly configured, please check"
                             )
                         self.loginfo(
                             xv, "checked swap size is %d" % (swap_size))
                 else:
                     raise Exception("cmd 'free' on via returns %s %s" %
                                     (out, err))
                 return
             except socket.error, e:
                 _e = e
                 continue
         if _e:
             raise Exception(_e)
Beispiel #4
0
 def test_ssh (self):
     from ops.vps_common import call_cmd_via_ssh
     status, out, err = call_cmd_via_ssh ("10.10.2.2", user="******", password="******", cmd="free|grep Swap")
     self.assertEqual(status, 0)
     print out
Beispiel #5
0
     raise e
 self.assert_(xv.is_running())
 try:
     logger.debug("close vps0")
     vpsops.close_vps(xv.vps_id, xv)
 except Exception, e:
     logger.exception(e)
     raise e
 self.assert_(not xv.is_running())
 self.assert_(xv.root_store.trash_exists())
 self.assert_(xv.data_disks['xvdc1'].trash_exists())
 self.assert_(not xv.root_store.exists())
 try:
     logger.debug("reopen vps0")
     vpsops.reopen_vps(xv.vps_id, xv)
     status, out, err = vps_common.call_cmd_via_ssh(
         xv.ip, user="******", password=xv.root_pw, cmd="free|grep Swap")
     if status == 0:
         if xv.swap_store.size_g > 0:
             swap_size = int(out.split()[1])
             if swap_size == 0:
                 raise Exception(
                     "it seems swap has not properly configured, please check"
                 )
     else:
         self.fail("ssh test failed %s, %s" % (out, err))
 except Exception, e:
     logger.exception(e)
     raise e
 self.assert_(xv.is_running())
 self.assert_(xv.root_store.exists())
 self.assert_(xv.data_disks['xvdc1'].exists())
Beispiel #6
0
     raise e
 self.assert_ (xv.is_running ())
 try:
     logger.debug ("close vps0")
     vpsops.close_vps (xv.vps_id, xv)
 except Exception, e:
     logger.exception (e)
     raise e
 self.assert_ (not xv.is_running ())
 self.assert_ (xv.root_store.trash_exists ())
 self.assert_ (xv.data_disks['xvdc1'].trash_exists ())
 self.assert_ (not xv.root_store.exists ())
 try:
     logger.debug ("reopen vps0")
     vpsops.reopen_vps (xv.vps_id, xv)
     status, out, err = vps_common.call_cmd_via_ssh (xv.ip, user="******", password=xv.root_pw, cmd="free|grep Swap")
     if status == 0:
         if xv.swap_store.size_g > 0:
             swap_size = int (out.split ()[1])
             if swap_size == 0:
                 raise Exception ("it seems swap has not properly configured, please check") 
     else:
         self.fail ("ssh test failed %s, %s" % (out, err))
 except Exception, e:
     logger.exception (e)
     raise e
 self.assert_ (xv.is_running ())
 self.assert_ (xv.root_store.exists ())
 self.assert_ (xv.data_disks['xvdc1'].exists ())
 try:
     logger.debug ("delete vps0")