class IPAddressRange(BaseSchema, CheckmkTuple): """ >>> schema = IPAddressRange() >>> rv = schema.dump(('ip_range', ('127.0.0.1', '127.0.0.2'))) >>> rv {'type': 'ip_range', 'from_address': '127.0.0.1', 'to_address': '127.0.0.2'} >>> schema.load(rv) ('ip_range', ('127.0.0.1', '127.0.0.2')) """ tuple_fields = ("type", ("from_address", "to_address")) cast_to_dict = True type = Constant( description="A range of addresses.", constant="ip_range", ) from_address = String( description="The first IPv4 address of this range.", validate=ValidateIPv4(), ) to_address = String( description="The last IPv4 address of this range.", validate=ValidateIPv4(), )
class SNMPCommunity(BaseSchema): cast_to_dict = True type = Constant(constant="v1_v2_community") community = String( description="SNMP community (SNMP Versions 1 and 2c)", ) @post_load def to_checkmk_str(self, data, **kwargs): return data["community"] @pre_dump def from_tuple(self, data, **kwargs): """ v1 'community' v3 ('noAuthNoPriv', 'sicherheitsname') v3 ('authNoPriv', 'SHA-512', 'sicherheitsname', 'passwort') v3 ('authPriv', 'SHA-512', 'sicherheitsname', 'passwort', 'DES', 'privacypasswort') Args: data: **kwargs: Returns: """ if isinstance(data, str): return { "type": "v1_v2_community", "community": data, }
class IPAddresses(BaseSchema, CheckmkTuple): """Represents a list of IPv4 addresses >>> schema = IPAddresses() >>> rv = schema.dump(('ip_list', ['127.0.0.1', '127.0.0.2'])) >>> rv {'type': 'ip_list', 'addresses': ['127.0.0.1', '127.0.0.2']} >>> schema.load(rv) ('ip_list', ['127.0.0.1', '127.0.0.2']) """ tuple_fields = ("type", "addresses") cast_to_dict = True type = Constant( description="A list of single IPv4 addresses.", constant="ip_list", ) addresses = List( String( validate=ValidateIPv4(), ) )
class SNMPv3AuthPrivacy(BaseSchema, CheckmkTuple): tuple_fields = ( "type", "auth_protocol", "security_name", "auth_password", "privacy_protocol", "privacy_password", ) converter = ( None, MappingConverter(AUTH_PROT_MAP), None, None, MappingConverter(PRIV_PROT_MAP), None, ) cast_to_dict = True type = Constant( description="SNMPv3 with authentication and privacy.", constant="authPriv", ) auth_protocol = String( description="Authentication protocol.", enum=list(AUTH_PROT_MAP.keys()), required=True, ) security_name = String( description="Security name", required=True, ) auth_password = String( description="Authentication pass phrase.", minLength=8, required=True, ) privacy_protocol = String( description=( "The privacy protocol. " "The only supported values in the Raw Edition are CBC-DES and AES-128. " "If selected, privacy_password needs to be supplied as well." ), required=True, enum=list(PRIV_PROT_MAP.keys()), ) privacy_password = String( description=( "Privacy pass phrase. " "If filled, privacy_protocol needs to be selected as well." ), required=True, minLength=8, )
class SNMPv3NoAuthNoPrivacy(BaseSchema, CheckmkTuple): tuple_fields = ("type", "security_name") cast_to_dict = True type = Constant( description="The type of credentials to use.", constant="noAuthNoPriv", ) security_name = String( description="Security name", required=True, )
class IPNetwork(BaseSchema, CheckmkTuple): tuple_fields = ("type", "network") cast_to_dict = True type = Constant( description="A single IPv4 network in CIDR notation.", constant="ip_network", ) network = String( description=( "A IPv4 network in CIDR notation. Minimum prefix length is 8 bit, " "maximum prefix length is 30 bit.\n\nValid examples:\n\n" " * `192.168.0.0/24`\n" " * `192.168.0.0/255.255.255.0`"), validate=ValidateIPv4Network(min_prefix=8, max_prefix=30), )
class SNMPv3AuthNoPrivacy(BaseSchema, CheckmkTuple): tuple_fields = ("type", "auth_protocol", "security_name", "auth_password") converter = (None, MappingConverter(AUTH_PROT_MAP), None, None) cast_to_dict = True type = Constant( description="The type of credentials to use.", constant="authNoPriv", ) auth_protocol = String( description="Authentication protocol.", enum=list(AUTH_PROT_MAP.keys()), required=True, ) security_name = String( description="Security name", required=True, ) auth_password = String( description="Authentication pass phrase.", minLength=8, required=True, )
class IPRegexp(BaseSchema, CheckmkTuple): """ >>> schema = IPRegexp() >>> rv = schema.dump(('ip_regex_list', ['127.0.[0-9].1', '127.0.[0-9].2'])) >>> schema.load(rv) ('ip_regex_list', ['127.0.[0-9].1', '127.0.[0-9].2']) """ tuple_fields = ("type", "regexp_list") cast_to_dict = True type = Constant( description="IPv4 addresses which match a regexp pattern", constant="ip_regex_list", ) regexp_list = List( String(validate=IsValidRegexp()), description=( "A list of regular expressions which are matched against the found " "IP addresses. The matches will be excluded from the result."), )