Improve DHCP + Zeroconf manifest validation (#49321)
parent
f464663732
commit
984962d985
|
@ -10,15 +10,15 @@
|
|||
"dhcp": [
|
||||
{
|
||||
"hostname": "lyric-*",
|
||||
"macaddress": "48A2E6"
|
||||
"macaddress": "48A2E6*"
|
||||
},
|
||||
{
|
||||
"hostname": "lyric-*",
|
||||
"macaddress": "B82CA0"
|
||||
"macaddress": "B82CA0*"
|
||||
},
|
||||
{
|
||||
"hostname": "lyric-*",
|
||||
"macaddress": "00D02D"
|
||||
"macaddress": "00D02D*"
|
||||
}
|
||||
],
|
||||
"iot_class": "cloud_polling"
|
||||
|
|
|
@ -75,17 +75,17 @@ DHCP = [
|
|||
{
|
||||
"domain": "lyric",
|
||||
"hostname": "lyric-*",
|
||||
"macaddress": "48A2E6"
|
||||
"macaddress": "48A2E6*"
|
||||
},
|
||||
{
|
||||
"domain": "lyric",
|
||||
"hostname": "lyric-*",
|
||||
"macaddress": "B82CA0"
|
||||
"macaddress": "B82CA0*"
|
||||
},
|
||||
{
|
||||
"domain": "lyric",
|
||||
"hostname": "lyric-*",
|
||||
"macaddress": "00D02D"
|
||||
"macaddress": "00D02D*"
|
||||
},
|
||||
{
|
||||
"domain": "myq",
|
||||
|
|
|
@ -148,6 +148,13 @@ def verify_version(value: str):
|
|||
return value
|
||||
|
||||
|
||||
def verify_wildcard(value: str):
|
||||
"""Verify the matcher contains a wildcard."""
|
||||
if "*" not in value:
|
||||
raise vol.Invalid(f"'{value}' needs to contain a wildcard matcher")
|
||||
return value
|
||||
|
||||
|
||||
MANIFEST_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required("domain"): str,
|
||||
|
@ -160,7 +167,9 @@ MANIFEST_SCHEMA = vol.Schema(
|
|||
vol.Schema(
|
||||
{
|
||||
vol.Required("type"): str,
|
||||
vol.Optional("macaddress"): vol.All(str, verify_uppercase),
|
||||
vol.Optional("macaddress"): vol.All(
|
||||
str, verify_uppercase, verify_wildcard
|
||||
),
|
||||
vol.Optional("manufacturer"): vol.All(str, verify_lowercase),
|
||||
vol.Optional("name"): vol.All(str, verify_lowercase),
|
||||
}
|
||||
|
@ -174,7 +183,9 @@ MANIFEST_SCHEMA = vol.Schema(
|
|||
vol.Optional("dhcp"): [
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Optional("macaddress"): vol.All(str, verify_uppercase),
|
||||
vol.Optional("macaddress"): vol.All(
|
||||
str, verify_uppercase, verify_wildcard
|
||||
),
|
||||
vol.Optional("hostname"): vol.All(str, verify_lowercase),
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue