Пример #1
0
 def convert_reservation_to_euinstance(self, reservation, keypath=None):
     euinstance_list = []
     for instance in reservation.instances:
         try:
             euinstance_list.append( EuInstance.make_euinstance_from_instance( instance, self, keypath=keypath ))
         except Exception, e:
             self.critical("Unable to create Euinstance from " + str(instance))
             euinstance_list.append(instance)
Пример #2
0
 def convert_reservation_to_euinstance(self, reservation, username="******", password=None, keyname=None):
     euinstance_list = []
     for instance in reservation.instances:
         keypair = self.get_keypair(keyname)
         try:
             euinstance_list.append( EuInstance.make_euinstance_from_instance( instance, self, keypair=keypair, username = username, password=password ))
         except Exception, e:
             self.critical("Unable to create Euinstance from " + str(instance))
             euinstance_list.append(instance)
Пример #3
0
 def __init__(self):
     self.setuptestcase()
     self.setup_parser(description="Test EBS on BFEBS during restart", testlist=False)
     self.parser.add_argument('--count',
                              help='Number of times to start/stop instance', default=5)
     self.parser.add_argument('--pause',
                              help='Number of seconds to pause between tests',default=5)
     self.parser.add_argument('--size',
                              help='Size of volume to create', default=1)
     self.get_args()
     self.set_arg('azone', self.args.zone)
     try:
         self.do_with_args(self.checkargs)
     except Exception:
         raise Exception("Mandotory arguments missing: emi and zone and (credpath or (config and password))")
     self.tester = self.do_with_args(Eucaops)
     self.volume = None
     self.instance = EuInstance()
Пример #4
0
class Check_vol_on_stop_start(EutesterTestCase):
        # init with argument list that makes these mandatory, but can fetch them from special 'args' later. 
        def __init__(self):
            self.setuptestcase()
            self.setup_parser(description="Test EBS on BFEBS during restart", testlist=False)
            self.parser.add_argument('--count',
                                     help='Number of times to start/stop instance', default=5)
            self.parser.add_argument('--pause',
                                     help='Number of seconds to pause between tests',default=5)
            self.parser.add_argument('--size',
                                     help='Size of volume to create', default=1)
            self.get_args()
            self.set_arg('azone', self.args.zone)
            try:
                self.do_with_args(self.checkargs)
            except Exception:
                raise Exception("Mandotory arguments missing: emi and zone and (credpath or (config and password))")
            self.tester = self.do_with_args(Eucaops)
            self.volume = None
            self.instance = EuInstance()
            #self.tester = Eucaops()
            
        def checkargs(self,emi,zone, credpath=None, config=None, password=None):
            if emi and zone and (credpath or (config and password)):
                return
            raise Exception("Mandotory arguments missing: emi and zone and (credpath or (config and password))")
        
        def get_keypair(self,keypair=None):
            self.keypair = None
            if keypair:
                self.keypair=self.tester.add_keypair(keypair)
        
    
            
        def run_instance(self):
            image = self.do_with_args(self.tester.get_emi)
            reservation = self.do_with_args(self.tester.run_instance, image=image, username='******')
            self.instance = reservation.instances[0]
            
        def create_volume(self):
            self.volume = self.do_with_args(self.tester.create_volume)
        
        def attach_volume_to_instance(self):
            self.instance.attach_volume(self.volume)
        
        def stop_start_check(self,pause=5):
            self.instance.stop_instance_and_verify()
            self.volume.update()
            self.instance.start_instance_and_verify(checkvolstatus=True)
            time.sleep(pause)
        
            
        def run_list(self):
            list=[]
            list.append(self.create_testunit_from_method(self.run_instance, eof=True))
            list.append(self.create_testunit_from_method(self.create_volume, eof=True))
            list.append(self.create_testunit_from_method(self.attach_volume_to_instance, eof=True))
            for x in xrange(1,int(self.args.count)):
                list.append(self.create_testunit_by_name('stop_start_check'))
            self.run_test_case_list(list)
Пример #5
0
 def convert_reservation_to_euinstance(self, reservation, username="******", password=None, keyname=None, timeout=120):
     euinstance_list = []
     keypair = None
     if keyname is not None:
             keypair = self.get_keypair(keyname)
     for instance in reservation.instances:
         if keypair is not None or (password is not None and username is not None):
             try:
                 euinstance_list.append( EuInstance.make_euinstance_from_instance( instance, self, keypair=keypair, username = username, password=password, timeout=timeout ))
             except Exception, e:
                 self.critical("Unable to create Euinstance from " + str(instance)+str(e))
                 euinstance_list.append(instance)
         else:
             euinstance_list.append(instance)
Пример #6
0
 def get_connectable_euinstances(self,path=None,connect=True):
     """
     convenience method returns a list of all running instances, for the current creduser
     for which there are local keys at 'path'
     """
     try:
         euinstances = []
         keys = self.get_all_current_local_keys(path=path)
         if keys:
             for keypair in keys:
                 self.debug('looking for instances using keypair:'+keypair.name)
                 instances = self.get_instances(state='running',key=keypair.name)
                 if instances:
                     for instance in instances:
                         if not connect:
                             keypair=None
                         euinstances.append(EuInstance.make_euinstance_from_instance( instance, self, keypair=keypair))
                   
         return euinstances
     except Exception, e:
         self.debug("Failed to find a pre-existing isntance we can connect to:"+str(e))
         pass
Пример #7
0
     pmsg("Remote file size: "+ str(rfsize) + "g")
     conn.close() 
 except Exception, e:
     pmsg("Failed to get remote file size...")
     raise e
 try:
     instance = None    
     keys = tester.get_all_current_local_keys()
     
     if keys != []:
         pmsg("Looks like we had some local keys looking through them now...")
         for keypair in keys:
             pmsg('looking for instances using keypair:'+keypair.name)
             instances = tester.get_instances(state='running',key=keypair.name)
             if instances != []:
                 instance = EuInstance(instances[0])
                 pmsg('Found usable instance:'+instance.id+'using key:'+keypair.name)
                 break
 except Exception, e:
     pmsg("Failed to find a pre-existing isntance we can connect to:"+str(e))
     pass
 
         
 if instance is None:   
     #Create a new keypair to use for this test if we didn't find one
     if keypair is None:
         try:
             keypair = tester.add_keypair(prefix + "-" + str(time.time()))
         except Exception, e:
             raise Exception("Error when adding keypair. Error:"+str(e))