def add_spec_missing_services_patch(region, services): """ Go through spec and determine patching """ LOGGER.info('Create 07_ssm_service_addition patch for region %s', region) spec_string = get_url_content(SPEC_REGIONS.get(region)) spec_string_standard = get_url_content(SPEC_REGIONS.get('us-east-1')) spec = json.loads(spec_string) spec_standard = json.loads(spec_string_standard) patches = [] for spec_type in ['ResourceTypes']: for service in services: found = False for resource in sorted(spec.get(spec_type).keys()): for spec_name in service_map.get(service): if resource.startswith(spec_name): found = True if found is False: for standard_spec_type in ['ResourceTypes', 'PropertyTypes']: for resource in sorted( spec_standard.get(standard_spec_type).keys()): for spec_name in service_map.get(service): if resource.startswith(spec_name): if spec_standard.get(standard_spec_type).get( resource): element = { 'op': 'add', 'path': '/%s/%s' % (standard_spec_type, resource), 'value': spec_standard.get( standard_spec_type).get(resource) } patches.append(element) elif standard_spec_type == 'ResourceTypes': print('patch for %s not found' % service) if patches: filename = 'src/cfnlint/data/ExtendedSpecs/%s/07_ssm_service_addition.json' % region with open(filename, 'w+') as f: json.dump(patches, f, indent=2, sort_keys=True, separators=(',', ': '))
def add_spec_patch(region, services): """ Go through spec and determine patching """ LOGGER.info('Create 06_ssm_service_removal patch for region %s', region) spec = json.loads(get_url_content(SPEC_REGIONS.get(region))) patches = [] for spec_type in ['ResourceTypes', 'PropertyTypes']: for resource in sorted(spec.get(spec_type).keys()): for service in services: for spec_name in service_map.get(service): if resource.startswith(spec_name): element = { 'op': 'remove', 'path': '/%s/%s' % (spec_type, resource) } patches.append(element) filename = 'src/cfnlint/data/ExtendedSpecs/%s/06_ssm_service_removal.json' % region with open(filename, 'w+') as f: json.dump(patches, f, indent=2, sort_keys=True, separators=(',', ': '))