def __collect_manifest_data(bundle_id: str, target_path: str, bundle_time: str): """Collecting manifest summary data using the discovery library.""" directory = os.path.dirname(ManifestSupportBundle._tmp_src) if not os.path.exists(directory): os.makedirs(directory) tar_name, file_name = ManifestSupportBundle.__generate_file_names( bundle_id, bundle_time) file_path = ManifestSupportBundle._tmp_src + file_name tar_file = os.path.join(target_path, tar_name + '.tar.gz') manifest_id = Discovery.generate_node_manifest( store_url = 'json://%s' % file_path) # Update bundle request info with discovery request_id ManifestSupportBundle.__update_request_info(bundle_id, manifest_id, tar_file) while not Discovery.get_gen_node_manifest_status(manifest_id)\ .startswith(('Success', 'Failed')): time.sleep(0.5)
def get_status(bundle_id: str): """Get status of support bundle.""" status = None req_id = 'sb_%s' % bundle_id manifest_id = req_register.get(['%s>manifest_id' % req_id]) manifest_status = Discovery.get_gen_node_manifest_status(manifest_id[0]) # Extract manifest status from the message. # Example : "Failed - error(22): Invalid rpath 'node>abc'" status = manifest_status.split(' ')[0] if status != 'In-progress': return status return None
def get_node_manifest(self, resource_type=None): retries = RETRIES status = "" self.logger.debug("Running resource manifest command") request_id = Discovery.generate_node_manifest(rpath=resource_type) self.logger.debug(f"Requestid for manifest - {request_id}") while retries > 0: status = Discovery.get_gen_node_manifest_status(request_id) if "Success" in status: break elif "Failed" in status: raise CortxSetupError(status) retries -= 1 time.sleep(WAIT) else: if retries == 0 and "Success" not in status: raise CortxSetupError( "Timed out error." "Generation of node manifest is taking longer than expected.") return Discovery.get_node_manifest(request_id)
def test_generate_node_health_on_invalid_rpath(self): """Check for failed status on invalid rpath.""" req_id = Discovery.generate_node_health(invalid_rpath) status = Discovery.get_gen_node_health_status(req_id) self.assertIn("Failed", status) self.assertIn("Invalid rpath", status)
def test_get_node_health_static_store_url(self): """Check for static store url.""" request_id = Discovery.generate_node_health() url = Discovery.get_node_health(request_id) self.assertIsNotNone(url)
def test_get_node_health(self): """Check for generated resource map location.""" req_id = Discovery.generate_node_health(valid_rpath) url = Discovery.get_node_health(req_id) self.assertIsNotNone(url)
def test_get_gen_node_health_status_success_on_health(self): """Check for node health status using valid request_id.""" request_id = Discovery.generate_node_health(valid_rpath) status = Discovery.get_gen_node_health_status(request_id) self.assertEqual(status, "Success")
def test_generate_node_health(self): """Check for immediate request id.""" request_id = Discovery.generate_node_health(valid_rpath) self.assertIsNotNone(request_id)
def test_get_node_manifest(self): """Check for generated manifest location.""" req_id = Discovery.generate_node_manifest(valid_rpath) url = Discovery.get_node_manifest(req_id) self.assertIsNotNone(url)
def test_get_gen_node_manifest_success_on_manifest(self): """Check for manifest request status using valid request_id.""" request_id = Discovery.generate_node_manifest(valid_rpath) status = Discovery.get_gen_node_manifest_status(request_id) self.assertEqual(status, "Success")