add Domain category
This commit is contained in:
		@@ -2,22 +2,33 @@ import platform
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_hostname():
 | 
			
		||||
    hostname = platform.node()
 | 
			
		||||
    if hostname.count("."):
 | 
			
		||||
        hostname = hostname.split(".")[0]
 | 
			
		||||
    return hostname
 | 
			
		||||
    node_name = platform.node()
 | 
			
		||||
    if node_name.count("."):
 | 
			
		||||
        return node_name.split(".")[0]
 | 
			
		||||
    else:
 | 
			
		||||
        return node_name
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_arch():
 | 
			
		||||
    return platform.system()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_domain():
 | 
			
		||||
    node_name = platform.node()
 | 
			
		||||
    if node_name.count("."):
 | 
			
		||||
        return '.'.join(node_name.split('.')[1:])
 | 
			
		||||
    else:
 | 
			
		||||
        return ''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def check_class(class_tuple):
 | 
			
		||||
    (prio, category, value, path) = class_tuple
 | 
			
		||||
    if category == 'Arch':
 | 
			
		||||
        return get_arch() == value
 | 
			
		||||
    elif category == 'Host':
 | 
			
		||||
        return get_hostname() == value
 | 
			
		||||
    elif category == 'Domain':
 | 
			
		||||
        return get_domain() == value
 | 
			
		||||
    elif value == '':           # if value is empty, we cannot filter anything, so it matches always
 | 
			
		||||
        return True
 | 
			
		||||
    else:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user