def validate_service_definitions(components_map, components=None): if not components: components = components_map.keys() else: validation_base.validate_components_names(components, components_map) not_passed_components = set() for component in components: try: jsonschema.validate(components_map[component]["service_content"], SERVICE_SCHEMA, format_checker=ServiceFormatChecker()) except jsonschema.ValidationError as e: LOG.error( "Validation of service definitions for component '%s' " "is not passed: '%s'", component, e.message) not_passed_components.add(component) if not_passed_components: raise RuntimeError( "Validation of service definitions for {} of {} components is " "not passed.".format(len(not_passed_components), len(components))) else: LOG.info("Service definitions validation passed successfully")
def validate_service_definitions(components_map, components=None): if not components: components = components_map.keys() else: validation_base.validate_components_names(components, components_map) not_passed_components = set() for component in components: try: jsonschema.validate(components_map[component]["service_content"], SERVICE_SCHEMA, format_checker=ServiceFormatChecker()) except jsonschema.ValidationError as e: LOG.error("Validation of service definitions for component '%s' " "is not passed: '%s'", component, e.message) not_passed_components.add(component) if not_passed_components: raise RuntimeError( "Validation of service definitions for {} of {} components is " "not passed.".format(len(not_passed_components), len(components)) ) else: LOG.info("Service definitions validation passed successfully")
def test_validate_components_names(self): # validations succeeded base_validation.validate_components_names({'service1'}, COMPONENTS_MAP) base_validation.validate_components_names({'service1', 'service2'}, COMPONENTS_MAP) # validations failed self.assertRaisesRegexp( RuntimeError, "Following components do not match any definitions: srv3", base_validation.validate_components_names, {'srv3'}, COMPONENTS_MAP) self.assertRaisesRegexp( RuntimeError, "Following components do not match any definitions: service4", base_validation.validate_components_names, {'service1', 'service4'}, COMPONENTS_MAP)
def show_dep(components): components_map = utils.get_deploy_components_info() base_validation.validate_components_names(set(components), components_map) deps = get_deps(components, components_map) print(" ".join(deps))
def show_dep(components): components_map = utils.get_deploy_components_info() base_validation.validate_components_names(set(components), components_map) deps = get_deps(components, components_map) print(" ".join(deps))