def test_get_all_techniques_metadata_with_args(self): """get_all_techniques_metadata should return a list of all techniques with all defined metadata tags and methods_called""" alternative_path = os.path.dirname(os.path.realpath(__file__)) + "/test_methods" metadata = ncf.get_all_techniques_metadata(alt_path=alternative_path) number = len(ncf.get_all_techniques_filenames(alternative_path)) self.assertEquals(number, len(metadata))
def write_one_technique_for_rudder(destination_path, bundle_name): write_category_xml(destination_path) techniques = ncf.get_all_techniques_metadata(alt_path='/var/rudder/configuration-repository/ncf') if bundle_name in techniques.keys(): try: metadata = techniques[bundle_name] write_technique_for_rudder(destination_path, metadata) except Exception, e: print("Error: Unable to create Rudder Technique files related to ncf Technique "+bundle_name+" (" + str(e) + ")")
def write_all_techniques_for_rudder(root_path): write_category_xml(root_path) techniques = ncf.get_all_techniques_metadata() for technique, metadata in techniques.iteritems(): try: write_technique_for_rudder(root_path, metadata) except Exception, e: print("Error: Unable to create Rudder Technique files related to ncf Technique "+technique+", skipping... (" + str(e) + ")") continue
def test_get_all_techniques_metadata(self): """get_all_techniques_metadata should return a list of all techniques with all defined metadata tags and methods_called""" metadata = ncf.get_all_techniques_metadata() data = metadata["data"]["techniques"] errors = metadata["errors"] all_metadata = len(data) + len(errors) all_files = len(ncf.get_all_techniques_filenames()) self.assertEqual(all_files, all_metadata)
def get_techniques(): """Get all techniques from ncf folder passed as parameter, or default ncf folder if not defined""" try: # We need to get path from url params, if not present put "" as default value path = get_path_from_args(request) techniques = ncf.get_all_techniques_metadata(alt_path=path) resp = jsonify(techniques) return resp except Exception as e: return format_error(e, "techniques fetching", 500)
def get_techniques(): """Get all techniques from ncf folder passed as parameter, or default ncf folder if not defined""" try: # We need to get path from url params, if not present put "" as default value path = get_path_from_args(request) techniques = ncf.get_all_techniques_metadata(alt_path = path) resp = jsonify( techniques ) return resp except Exception as e: return format_error(e, "techniques fetching", 500)
def test_get_all_techniques_metadata(self): """get_all_techniques_metadata should return a list of all techniques with all defined metadata tags and methods_called""" metadata = ncf.get_all_techniques_metadata() data = metadata["data"] errors = metadata["errors"] all_metadata = len(data) + len(errors) all_files = len(ncf.get_all_techniques_filenames()) self.assertEquals(all_files, all_metadata)
def write_all_techniques_for_rudder(root_path): write_category_xml(root_path) techniques = ncf.get_all_techniques_metadata() for technique, metadata in techniques.iteritems(): try: write_technique_for_rudder(root_path, metadata) except Exception, e: print( "Error: Unable to create Rudder Technique files related to ncf Technique " + technique + ", skipping...") continue
def test_get_all_techniques_metadata_with_args(self): """get_all_techniques_metadata should return a list of all techniques with all defined metadata tags and methods_called""" alternative_path = os.path.dirname(os.path.realpath(__file__)) + "/test_methods" metadata = ncf.get_all_techniques_metadata(alt_path=alternative_path) data = metadata["data"] errors = metadata["errors"] all_metadata = len(data) + len(errors) all_files = len(ncf.get_all_techniques_filenames(alternative_path)) self.assertEquals(all_files, all_metadata)
def get_techniques(): """Get all techniques from ncf folder passed as parameter, or default ncf folder if not defined""" # We need to get path from url params, if not present put "" as default value if "path" in request.args: path = request.args['path'] else: path = "" techniques = ncf.get_all_techniques_metadata(alt_path = path) resp = jsonify( techniques ) return resp
def test_get_all_techniques_metadata_with_args(self): """get_all_techniques_metadata should return a list of all techniques with all defined metadata tags and methods_called""" alternative_path = os.path.dirname( os.path.realpath(__file__)) + "/test_methods" metadata = ncf.get_all_techniques_metadata(alt_path=alternative_path) data = metadata["data"] errors = metadata["errors"] all_metadata = len(data) + len(errors) all_files = len(ncf.get_all_techniques_filenames(alternative_path)) self.assertEqual(all_files, all_metadata)
def write_all_techniques_for_rudder(root_path): write_category_xml(root_path) techniques = ncf.get_all_techniques_metadata(alt_path='/var/rudder/configuration-repository/ncf')['data']['techniques'] ret = 0 for technique, metadata in techniques.items(): try: write_technique_for_rudder(root_path, metadata) except Exception as e: sys.stderr.write("Error: Unable to create Rudder Technique files related to ncf Technique "+technique+", skipping... (" + str(e) + ")\n") sys.stderr.write(traceback.format_exc()) ret = 1 continue exit(ret)
def write_one_technique_for_rudder(destination_path, bundle_name): write_category_xml(destination_path) techniques = ncf.get_all_techniques_metadata(alt_path='/var/rudder/configuration-repository/ncf')['data']['techniques'] if bundle_name in techniques.keys(): try: metadata = techniques[bundle_name] write_technique_for_rudder(destination_path, metadata) except Exception as e: sys.stderr.write("Error: Unable to create Rudder Technique files related to ncf Technique "+bundle_name+" (" + str(e) + ")\n") sys.stderr.write(traceback.format_exc()) exit(1) else: sys.stderr.write("Error: Unable to create Rudder Technique files related to ncf Technique "+bundle_name+", cannot find ncf Technique "+bundle_name + "\n") sys.stderr.write(traceback.format_exc()) exit(1)
def convert_all_to_dsc(root_path): techniques = ncf.get_all_techniques_metadata( alt_path=rudder_ncf_path)['data']['techniques'] methods = ncf.get_all_generic_methods_metadata( alt_path=rudder_ncf_path)['data']['generic_methods'] check_dsc_techniques_path() ret = 0 for technique, metadata in techniques.items(): try: convert_technique(metadata, methods) except Exception as e: sys.stderr.write( "Error: Unable to create Rudder Technique files related to ncf Technique " + technique + ", skipping... (" + str(e) + ")\n") sys.stderr.write(traceback.format_exc()) ret = 1 continue exit(ret)
def convert_one_to_dsc(destination_path, bundle_name): techniques = ncf.get_all_techniques_metadata( alt_path=rudder_ncf_path)['data']['techniques'] methods = ncf.get_all_generic_methods_metadata( alt_path=rudder_ncf_path)['data']['generic_methods'] check_dsc_techniques_path() if bundle_name in techniques.keys(): try: metadata = techniques[bundle_name] convert_technique(metadata, methods) except Exception as e: sys.stderr.write( "Error: Unable to create Rudder Technique files related to ncf Technique " + bundle_name + " (" + str(e) + ")\n") sys.stderr.write(traceback.format_exc()) exit(1) else: sys.stderr.write( "Error: Unable to create Rudder Technique files related to ncf Technique " + bundle_name + ", cannot find ncf Technique " + bundle_name + "\n") sys.stderr.write(traceback.format_exc()) exit(1)
def test_get_all_techniques_metadata(self): """get_all_techniques_metadata should return a list of all techniques with all defined metadata tags and methods_called""" metadata = ncf.get_all_techniques_metadata() number = len(ncf.get_all_techniques_filenames()) self.assertEquals(number, len(metadata))