def reboot_setup(self): # save the partition list and mount points, as well as the cpu count partition_list = partition_lib.get_partition_list(self, exclude_swap=False) mount_info = partition_lib.get_mount_info(partition_list) self._state.set('client', 'mount_info', mount_info) self._state.set('client', 'cpu_count', utils.count_cpus())
def test_get_partition_list(self): def fake_open(filename): """Fake open() to pass to get_partition_list as __open.""" if filename == '/proc/swaps': return StringIO(SAMPLE_SWAPS) elif filename == '/proc/partitions': return StringIO(SAMPLE_PARTITIONS_HDC_ONLY) else: self.assertFalse("Unexpected open() call: %s" % filename) job = 'FakeJob' # Test a filter func that denies all. parts = partition.get_partition_list(job, filter_func=lambda x: False, open_func=fake_open) self.assertEqual([], parts) self.god.check_playback() # Test normal operation. self.god.stub_function(partition, 'partition') partition.partition.expect_call(job, '/dev/hdc3').and_return('3') parts = partition.get_partition_list(job, open_func=fake_open) self.assertEqual(['3'], parts) self.god.check_playback() # Test exclude_swap can be disabled. partition.partition.expect_call(job, '/dev/hdc2').and_return('2') partition.partition.expect_call(job, '/dev/hdc3').and_return('3') parts = partition.get_partition_list(job, exclude_swap=False, open_func=fake_open) self.assertEqual(['2', '3'], parts) self.god.check_playback() # Test that min_blocks works. partition.partition.expect_call(job, '/dev/hdc3').and_return('3') parts = partition.get_partition_list(job, min_blocks=600000, exclude_swap=False, open_func=fake_open) self.assertEqual(['3'], parts) self.god.check_playback()
def _check_post_reboot(self, subdir, running_id=None): """ Function to perform post boot checks such as if the system configuration has changed across reboots (specifically, CPUs and partitions). @param subdir: The subdir to use in the job.record call. @param running_id: An optional running_id to include in the reboot failure log message @raise JobError: Raised if the current configuration does not match the pre-reboot configuration. """ abort_on_mismatch = GLOBAL_CONFIG.get_config_value('CLIENT', 'abort_on_mismatch', type=bool, default=False) # check to see if any partitions have changed partition_list = partition_lib.get_partition_list(self, exclude_swap=False) mount_info = partition_lib.get_mount_info(partition_list) old_mount_info = self._state.get('client', 'mount_info') if mount_info != old_mount_info: new_entries = mount_info - old_mount_info old_entries = old_mount_info - mount_info description = ("mounted partitions are different after reboot " "(old entries: %s, new entries: %s)" % (old_entries, new_entries)) if abort_on_mismatch: self._record_reboot_failure(subdir, "reboot.verify_config", description, running_id=running_id) raise error.JobError("Reboot failed: %s" % description) else: logging.warning(description) # check to see if any CPUs have changed cpu_count = utils.count_cpus() old_count = self._state.get('client', 'cpu_count') if cpu_count != old_count: description = ('Number of CPUs changed after reboot ' '(old count: %d, new count: %d)' % (old_count, cpu_count)) if abort_on_mismatch: self._record_reboot_failure(subdir, 'reboot.verify_config', description, running_id=running_id) raise error.JobError('Reboot failed: %s' % description) else: logging.warning(description)
def _check_post_reboot(self, subdir, running_id=None): """ Function to perform post boot checks such as if the mounted partition list has changed across reboots. """ partition_list = partition_lib.get_partition_list(self) mount_info = set((p.device, p.get_mountpoint()) for p in partition_list) old_mount_info = self.get_state("__mount_info") if mount_info != old_mount_info: new_entries = mount_info - old_mount_info old_entries = old_mount_info - mount_info description = ("mounted partitions are different after reboot " "(old entries: %s, new entries: %s)" % (old_entries, new_entries)) self._record_reboot_failure(subdir, "reboot.verify_config", description, running_id=running_id) raise error.JobError("Reboot failed: %s" % description)
def _check_post_reboot(self, subdir, running_id=None): """ Function to perform post boot checks such as if the system configuration has changed across reboots (specifically, CPUs and partitions). @param subdir: The subdir to use in the job.record call. @param running_id: An optional running_id to include in the reboot failure log message @raise JobError: Raised if the current configuration does not match the pre-reboot configuration. """ # check to see if any partitions have changed partition_list = partition_lib.get_partition_list(self, exclude_swap=False) mount_info = partition_lib.get_mount_info(partition_list) old_mount_info = self._state.get("client", "mount_info") if mount_info != old_mount_info: new_entries = mount_info - old_mount_info old_entries = old_mount_info - mount_info description = "mounted partitions are different after reboot " "(old entries: %s, new entries: %s)" % ( old_entries, new_entries, ) self._record_reboot_failure(subdir, "reboot.verify_config", description, running_id=running_id) raise error.JobError("Reboot failed: %s" % description) # check to see if any CPUs have changed cpu_count = utils.count_cpus() old_count = self._state.get("client", "cpu_count") if cpu_count != old_count: description = "Number of CPUs changed after reboot " "(old count: %d, new count: %d)" % ( old_count, cpu_count, ) self._record_reboot_failure(subdir, "reboot.verify_config", description, running_id=running_id) raise error.JobError("Reboot failed: %s" % description)
def reboot_setup(self): # save the partition list and their mount point and compare it # after reboot partition_list = partition_lib.get_partition_list(self) mount_info = set((p.device, p.get_mountpoint()) for p in partition_list) self.set_state("__mount_info", mount_info)