Example #1
0
 def setup_windows_test_volumes(self):
     '''
     Description:
         Attempts to confirm that each zone provided has the minimum number of volumes in it. 
         If volumes were provided in __init__ then this method will attempt to sort those into the zone. 
         Volumes will be created if the testzones do not have the amount specified. 
     Failure:
         Failed to create volumes for use in windows test
     '''
     if len(self.zonelist) and len(self.zonelist[0].volumes):
         self.debug('setupWindowsTestVolumes has already been ran')
         return
     #sort any provided volumes into zone
     for volume in self.testvolumes:
         if volume.status == 'available':
             if type(volume) != EuVolume:
                 volume = EuVolume.make_euvol_from_vol(volume)
             for zone in self.zonelist:
                 if volume.zone == zone.name:
                     zone.volumes.append(volume)
     #make sure each zone has the correct amount of volumes to perform the tests
     for zone in self.zonelist:
         while len(zone.volumes) < self.testvolcount:
             volume = EuVolume.make_euvol_from_vol(self.tester.create_volume(zone,timepergig=180))
             zone.volumes.append(volume)
Example #2
0
 def setup_windows_test_volumes(self):
     '''
     Description:
         Attempts to confirm that each zone provided has the minimum number of volumes in it. 
         If volumes were provided in __init__ then this method will attempt to sort those into the zone. 
         Volumes will be created if the testzones do not have the amount specified. 
     Failure:
         Failed to create volumes for use in windows test
     '''
     if len(self.zonelist) and len(self.zonelist[0].volumes):
         self.debug('setupWindowsTestVolumes has already been ran')
         return
     #sort any provided volumes into zone
     for volume in self.testvolumes:
         if volume.status == 'available':
             if type(volume) != EuVolume:
                 volume = EuVolume.make_euvol_from_vol(volume)
             for zone in self.zonelist:
                 if volume.zone == zone.name:
                     zone.volumes.append(volume)
     #make sure each zone has the correct amount of volumes to perform the tests
     for zone in self.zonelist:
         while len(zone.volumes) < self.testvolcount:
             volume = EuVolume.make_euvol_from_vol(self.tester.create_volume(zone,timepergig=180))
             zone.volumes.append(volume)
Example #3
0
 def init_volume_list(self, reattach=False, detach=True):
     '''
     Method to detect volumes which the cloud believes this guest is using, and attempt to match up the cloud dev with the local guest dev.
     In the case the local dev can not be found the volume will be detached. If the local device is found a euvolume object is created and appended 
     the local attached_vols list. To confirm local state with the cloud state, the options 'reattach', or 'detach' can be used. 
     This should be used when first creating a euinstance from an instance to insure the euinstance volume state is in sync with the cloud. 
     '''
     self.attached_vols = []
     cloudlist = []
     cloudlist=self.tester.ec2.get_all_volumes()
     for vol in cloudlist:
         #check to see if the volume is attached to us, but is not involved with the bdm for this instance
         if (vol.attach_data.instance_id == self.id) and (self.block_device_mapping.current_name != vol.attach_data.device):
             dev = vol.attach_data.device
             try:
                 self.assertFilePresent(dev)
                 if not detach:
                     evol = EuVolume.make_euvol_from_vol(vol)
                     evol.guestdev = dev
                     evol.clouddev = dev
                     self.attached_vols.append(evol)
                 else:
                     self.tester.detach_volume(vol)
             except Exception,e:
                 if reattach or detach:
                     self.tester.detach_volume(vol)
                 if reattach:
                     dev = self.get_free_scsi_dev()
                     self.attach_volume(self, self, vol,dev )
Example #4
0
    def create_vols_per_zone(self,
                             zonelist=None,
                             volsperzone=2,
                             size=1,
                             snapshot=None,
                             timepergig=300):
        testmsg = """
                    Intention of this test is to verify creation of volume(s) per zone given.
                    Upon successful creation the volumes will be appended to a volumes list
                    for the zone it was created in. 
                    These volumes may be later used if in later ebstests suite tests. 
                    """
        testmsg = testmsg + "variables provided:\nzonelist:" + str(
            zonelist) + "\nvolsperzone:" + str(volsperzone) + "\nsize:" + str(
                size) + "\nsnapshot:" + str(snapshot)

        self.startmsg(testmsg)
        if zonelist is None:
            zonelist = self.zonelist
        for testzone in zonelist:
            zone = testzone.name
            for x in xrange(0, volsperzone):
                vol = EuVolume.make_euvol_from_vol(
                    self.tester.create_volume(zone,
                                              size=size,
                                              snapshot=snapshot,
                                              timepergig=timepergig))
                testzone.volumes.append(vol)
                self.debug('create_vols_per_zone created  vol(' + str(x) +
                           ') zone:' + str(zone) + ' vol:' + str(vol.id))

        self.endsuccess()
Example #5
0
 def init_volume_list(self, reattach=False, detach=True):
     '''
     Method to detect volumes which the cloud believes this guest is using, and attempt to match up the cloud dev with the local guest dev.
     In the case the local dev can not be found the volume will be detached. If the local device is found a euvolume object is created and appended 
     the local attached_vols list. To confirm local state with the cloud state, the options 'reattach', or 'detach' can be used. 
     This should be used when first creating a euinstance from an instance to insure the euinstance volume state is in sync with the cloud. 
     '''
     self.attached_vols = []
     cloudlist = []
     cloudlist=self.tester.ec2.get_all_volumes()
     for vol in cloudlist:
         #check to see if the volume is attached to us, but is not involved with the bdm for this instance
         if (vol.attach_data.instance_id == self.id) and (self.block_device_mapping.current_name != vol.attach_data.device):
             dev = vol.attach_data.device
             try:
                 self.assertFilePresent(dev)
                 if not detach:
                     evol = EuVolume.make_euvol_from_vol(vol)
                     evol.guestdev = dev
                     evol.clouddev = dev
                     self.attached_vols.append(evol)
                 else:
                     self.tester.detach_volume(vol)
             except Exception,e:
                 if reattach or detach:
                     self.tester.detach_volume(vol)
                 if reattach:
                     dev = self.get_free_scsi_dev()
                     self.attach_volume(self, self, vol,dev )
Example #6
0
 def attach_volume(self, volume,  dev=None, timeout=60, overwrite=False):
     '''
     Method used to attach a volume to an instance and track it's use by that instance
     required - euvolume - the euvolume object being attached
     required - tester - the eucaops/eutester object/connection for this cloud
     optional - dev - string to specify the dev path to 'request' when attaching the volume to
     optional - timeout - integer- time allowed before failing
     optional - overwrite - flag to indicate whether to overwrite head data of a non-zero filled volume upon attach for md5
     ''' 
     if not isinstance(volume, EuVolume):
         volume = EuVolume.make_euvol_from_vol(volume)
     return self.attach_euvolume(volume,  dev=dev, timeout=timeout, overwrite=overwrite)
Example #7
0
 def Reboot(self, zone=None):
     """Reboot instance ensure IP connectivity and volumes stay attached"""
     if zone is None:
         zone = self.zone
     self.reservation = self.tester.run_instance(self.image, keypair=self.keypair.name, group=self.group.name, zone=zone)
     for instance in self.reservation.instances:
         ### Create 1GB volume in first AZ
         self.volume = self.tester.create_volume(instance.placement, 1)
         euvolume = EuVolume.make_euvol_from_vol(self.volume)
         self.volume_device = instance.attach_euvolume(euvolume)
         ### Reboot instance
         instance.reboot_instance_and_verify(waitconnect=20)
         instance.detach_euvolume(euvolume)
     return self.reservation
Example #8
0
 def Reboot(self, zone=None):
     """Reboot instance ensure IP connectivity and volumes stay attached"""
     if zone is None:
         zone = self.zone
     self.reservation = self.tester.run_instance(self.image,
                                                 keypair=self.keypair.name,
                                                 group=self.group.name,
                                                 zone=zone)
     for instance in self.reservation.instances:
         ### Create 1GB volume in first AZ
         self.volume = self.tester.create_volume(instance.placement, 1)
         euvolume = EuVolume.make_euvol_from_vol(self.volume)
         self.volume_device = instance.attach_euvolume(euvolume)
         ### Reboot instance
         instance.reboot_instance_and_verify(waitconnect=20)
         instance.detach_euvolume(euvolume)
     return self.reservation
Example #9
0
 def create_vols_per_zone(self, zonelist=None, volsperzone=2, size=1, snapshot=None, timepergig=300):
     testmsg =   """
                 Intention of this test is to verify creation of volume(s) per zone given.
                 Upon successful creation the volumes will be appended to a volumes list
                 for the zone it was created in. 
                 These volumes may be later used if in later ebstests suite tests. 
                 """    
     testmsg = testmsg + "variables provided:\nzonelist:"+str(zonelist)+"\nvolsperzone:"+str(volsperzone)+"\nsize:"+str(size)+"\nsnapshot:"+str(snapshot)
     
     self.startmsg(testmsg)
     if zonelist is None:
         zonelist = self.zonelist
     for testzone in zonelist:
         zone = testzone.name
         for x in xrange(0,volsperzone):
             vol = EuVolume.make_euvol_from_vol(self.tester.create_volume(zone, size=size, snapshot=snapshot,timepergig=timepergig))
             testzone.volumes.append(vol)
             self.debug('create_vols_per_zone created  vol('+str(x)+') zone:'+str(zone)+' vol:'+str(vol.id))
         
     self.endsuccess() 
Example #10
0
 def attach_volume(self, volume, tester, dev=None, timeout=60):
     if not isinstance(volume, EuVolume):
         euvolume = EuVolume.make_euvol_from_vol(volume)
     return self.attach_euvolume(euvolume, tester=tester, dev=dev, timeout=timeout)
Example #11
0
 found = False
 for vol in cloudlist:
     #check to see if the volume is attached to us, but is not involved with the bdm for this instance
     found = False
     if (vol.attach_data.instance_id == self.id) and not ( self.root_device_type == 'ebs' and self.block_device_mapping.current_name != vol.attach_data.device):
         for avol in self.attached_vols:
             if avol.id == vol.id:
                 self.debug("Volume"+vol.id+" found attached")
                 found = True
                 break
         if not found: 
             dev = vol.attach_data.device
             try:
                 self.assertFilePresent(dev)
                 if not detach:
                     evol = EuVolume.make_euvol_from_vol(vol)
                     evol.guestdev = dev
                     evol.clouddev = dev
                     self.attached_vols.append(evol)
                 else:
                     self.tester.detach_volume(vol,timeout=timeout)
             except Exception,e:
                 if reattach or detach:
                     self.tester.detach_volume(vol,timeout=timeout)
                 if reattach:
                     dev = self.get_free_scsi_dev()
                     self.attach_volume(self, self, vol,dev )
             
         
 
 
Example #12
0
 def attach_volume(self, volume, dev=None, timeout=60):
     if not isinstance(volume, EuVolume):
         euvolume = EuVolume.make_euvol_from_vol(volume)
     return self.attach_euvolume(euvolume, dev=dev, timeout=timeout)
Example #13
0
            found = False
            if (vol.attach_data.instance_id
                    == self.id) and not (self.root_device_type == 'ebs' and
                                         self.block_device_mapping.current_name
                                         != vol.attach_data.device):
                for avol in self.attached_vols:
                    if avol.id == vol.id:
                        self.debug("Volume" + vol.id + " found attached")
                        found = True
                        break
                if not found:
                    dev = vol.attach_data.device
                    try:
                        self.assertFilePresent(dev)
                        if not detach:
                            evol = EuVolume.make_euvol_from_vol(vol)
                            evol.guestdev = dev
                            evol.clouddev = dev
                            self.attached_vols.append(evol)
                        else:
                            self.tester.detach_volume(vol, timeout=timeout)
                    except Exception, e:
                        if reattach or detach:
                            self.tester.detach_volume(vol, timeout=timeout)
                        if reattach:
                            dev = self.get_free_scsi_dev()
                            self.attach_volume(self, self, vol, dev)

    def stop_instance_and_verify(self,
                                 timeout=120,
                                 state='stopped',