+ match = RE_INTERNAL_NETWORK_RID.match(k)
+ if not match:
+ invalid_networks.append(k)
+
+ assert not set(invalid_networks), (
+ "Heat templates must only create internal networks "
+ "and follow format int_{{network-role}}_network"
+ "{}".format(", ".join(invalid_networks))
+ )
+
+
+@validates("R-16241")
+def test_network_has_subnet(yaml_file):
+ """
+ if creating internal network, make sure there is a
+ corresponding subnet that references it
+ """
+
+ with open(yaml_file) as fh:
+ yml = yaml.load(fh)
+
+ # skip if resources are not defined
+ if "resources" not in yml:
+ pytest.skip("No resources specified in the heat template")
+
+ networks = []
+
+ for k, v in yml["resources"].items():
+ if not has_properties(v) or v.get("type") not in ["OS::Neutron::Net"]: