Example #1
0
def get_service_down_action_name(action):
    try:
        return SERVICE_DOWN_ACTION[action]
    except Exception:
        msg = '"%s" is not a valid value for Service Down Action' % (action)
        log.error(msg)
        raise base_exceptions.NamePropertyInvalid(msg)
Example #2
0
def get_method_name(lb_method):
    try:
        return LB_METHOD[lb_method]
    except Exception:
        msg = 'Member lb_method invalid: %s' % (lb_method)
        log.error(msg)
        raise base_exceptions.NamePropertyInvalid(msg)
Example #3
0
def get_status_name(status):
    try:
        return STATUS_POOL_MEMBER[status]
    except Exception:
        msg = 'Member status invalid: %s' % (status)
        log.error(msg)
        raise base_exceptions.NamePropertyInvalid(msg)
Example #4
0
def address_type(value):

    values = {
        # 'ATYPE_UNSET'
        '*:*': 'ATYPE_STAR_ADDRESS_STAR_PORT',
        '*:$': 'ATYPE_STAR_ADDRESS_EXPLICIT_PORT',
        # 'ATYPE_EXPLICIT_ADDRESS_EXPLICIT_PORT',
        # 'ATYPE_STAR_ADDRESS',
        # 'ATYPE_EXPLICIT_ADDRESS',
    }

    try:
        ipport = value.split(':')
        key = '*:$' if ipport[1] != '*' else '*:*'

        return {
            'address_type': values[key],
            'ipport': {
                'address': ipport[0] if ipport[0] != '*' else '0.0.0.0',
                'port': ipport[1] if ipport[1] != '*' else '0'
            }
        }
    except Exception:
        msg = 'Adress type not is invalid: %s' % (value)
        log.error(msg)
        raise base_exceptions.NamePropertyInvalid(msg)
Example #5
0
def template_type(value):

    values = {
        # 'unset':'TTYPE_UNSET',
        # 'icmp':'TTYPE_ICMP',
        'tcp': 'TTYPE_TCP',
        # 'tcp_echo':'TTYPE_TCP_ECHO',
        # 'external':'TTYPE_EXTERNAL',
        'http': 'TTYPE_HTTP',
        'https': 'TTYPE_HTTPS',
        # 'nntp':'TTYPE_NNTP',
        # 'ftp':'TTYPE_FTP',
        # 'pop3':'TTYPE_POP3',
        # 'smtp':'TTYPE_SMTP',
        # 'mssql':'TTYPE_MSSQL',
        # 'gateway':'TTYPE_GATEWAY',
        # 'imap':'TTYPE_IMAP',
        # 'radius':'TTYPE_RADIUS',
        # 'ldap':'TTYPE_LDAP',
        # 'wmi':'TTYPE_WMI',
        # 'snmp_dca':'TTYPE_SNMP_DCA',
        # 'snmp_dca_base':'TTYPE_SNMP_DCA_BASE',
        # 'real_server':'TTYPE_REAL_SERVER',
        'udp': 'TTYPE_UDP',
        # 'none':'TTYPE_NONE',
        # 'oracle':'TTYPE_ORACLE',
        # 'soap':'TTYPE_SOAP',
        # 'gateway_icmp':'TTYPE_GATEWAY_ICMP',
        # 'sip':'TTYPE_SIP',
        # 'tcp_half_open':'TTYPE_TCP_HALF_OPEN',
        # 'scripted':'TTYPE_SCRIPTED',
        # 'wap':'TTYPE_WAP',
        # 'rpc':'TTYPE_RPC',
        # 'smb':'TTYPE_SMB',
        # 'sasp':'TTYPE_SASP',
        # 'module_score':'TTYPE_MODULE_SCORE',
        # 'firepass':'******',
        # 'inband':'TTYPE_INBAND',
        # 'radius_accounting':'TTYPE_RADIUS_ACCOUNTING',
        # 'diameter':'TTYPE_DIAMETER',
        # 'virtual_location':'TTYPE_VIRTUAL_LOCATION',
        # 'mysql':'TTYPE_MYSQL',
        # 'postgresql':'TTYPE_POSTGRESQL'
    }

    try:
        return values[value.lower()]
    except Exception:
        msg = 'Template type not is invalid: %s' % (value)
        log.error(msg)
        raise base_exceptions.NamePropertyInvalid(msg)
Example #6
0
def procotol_type(value):

    values = {
        # 'any': 'PROTOCOL_ANY',
        # 'ipv6': 'PROTOCOL_IPV6',
        # 'routing': 'PROTOCOL_ROUTING',
        # 'none': 'PROTOCOL_NONE',
        # 'fragment': 'PROTOCOL_FRAGMENT',
        # 'dstopts': 'PROTOCOL_DSTOPTS',
        'tcp': 'PROTOCOL_TCP',
        'udp': 'PROTOCOL_UDP',
        # 'icmp': 'PROTOCOL_ICMP',
        # 'icmpv6': 'PROTOCOL_ICMPV6',
        # 'ospf': 'PROTOCOL_OSPF',
        # 'sctp': 'PROTOCOL_SCTP'
    }

    try:
        return values[value.lower()]
    except Exception:
        msg = 'Protocol type not is invalid: %s' % (value)
        log.error(msg)
        raise base_exceptions.NamePropertyInvalid(msg)