The Assimilation Project  based on Assimilation version 1.1.7.1474836767
consts.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # vim: smartindent tabstop=4 shiftwidth=4 expandtab
3 #
4 # This file is part of the Assimilation Project.
5 #
6 # Copyright (C) 2011, 2012 - Alan Robertson <alanr@unix.sh>
7 #
8 # The Assimilation software is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # The Assimilation software is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/
20 #
21 #
22 '''
23 This module defines various constants used by the Assimilation CMA
24 '''
25 
26 
27 # R0903: too few public methods
28 # pylint: disable=R0903
29 class CMAconsts(object):
30  '''
31  This class holds the constants we use for the CMA.
32  We make it a class to minimize namespace pollution.
33  '''
34  globaldomain = 'global'
35  metadomain = 'metadata'
36  BASERULESETNAME = 'BASE'
37 
38 #########################################################################
39 # Indexes:
40 # ringindex - index of all Ring objects [nodetype=ring]
41 # droneindex - index of all Drone objects [nodetype=drone]
42 # ipindex - index of all IP address objects [nodetype=ipaddr]
43 # macindex - index of all interfaces by MAC address [nodetype=nic]
44 #########################################################################
45 #
46 # Node types [nodetype enumeration values]:
47 #
48  NODE_ring = 'HbRing' # A ring of Drones
49  NODE_drone = 'Drone' # A server running our nanoprobes
50  NODE_system = 'SystemNode' # A system without a nanoprobe - switches so far...
51  NODE_nicnode = 'NICNode' # A network interface card (connection)
52  NODE_ipaddr = 'IPaddrNode' # IP address
53  NODE_ipproc = 'ProcessNode' # A client and/or server process
54  NODE_tcpipport = 'IPtcpportNode' # (ip, port) tuple for a TCP service
55  NODE_monitoraction = 'MonitorAction' # A (hopefully active) monitoring action
56  NODE_bprules = 'BPRules' # Best practices rules
57  NODE_bpruleset = 'BPRuleSet' # A set of best practice rules
58  NODE_jsonmap = 'JSONMapNode' # JSON map object stored as a string
59  NODE_childsystem = 'ChildSystem' # A VM or container system
60  NODE_vagrantsystem = 'VagrantSystem' # A child Vagrant VM system
61  NODE_dockersystem = 'DockerSystem' # A child Docker container
62 #
63 # Relationship types [reltype enumeration values]
64 # ---------------------------------------------------------------
65 # Constant name reltype fromnodetype tonodetype
66 # --------------- -------- ------------ ----------
67  REL_nicowner = 'nicowner' # NODE_NIC -> NODE_system - or subclass
68  REL_wiredto = 'wiredto' # NODE_NIC -> NODE_NIC
69  REL_ipowner = 'ipowner' # NODE_ipaddr -> NODE_NIC
70  REL_parentring = 'parentring' # NODE_ring -> NODE_ring
71  REL_baseip = 'baseip' # NODE_tcpipport -> NODE_ipaddr
72  REL_tcpservice = 'tcpservice' # NODE_tcpipport -> NODE_ipproc
73  #REL_ipphost = 'ipphost' # NODE_tcpipport -> NODE_system or subclass
74  REL_hosting = 'hosting' # NODE_drone -> NODE_ipproc
75  REL_monitoring = 'monitoring' # NODE_monitoraction-> NODE_ipproc OR SystemNode
76  REL_tcpclient = 'tcpclient' # NODE_ipproc -> NODE_tcpipport
77  REL_basedon = 'basedon' # NODE_BPRuleSet -> NODE_BPRuleSet
78  REL_basis = 'basis' # NODE_BPRules -> NODE_BPRules
79  REL_bprulefor = 'ruledbybp' # NODE_drone -> NODE_BPRules
80  REL_jsonattr = 'jsonattr' # NODE_system -> NODE_jsonmap
81  REL_parentsys = 'parentsys' # NODE_ChildSystem -> NODE_system
82  REL_oneringnext = 'RingNext_The_One_Ring' # NODE_drone -> NODE_Drone
83  REL_onering = 'RingMember_The_One_Ring' # NODE_drone -> NODE_ring
84  # RingMember_* # NODE_drone -> NODE_ring
85  # RingNext_* # NODE_drone -> NODE_drone
86 #
87 # Node_System (or Node_Drone) Roles that we've heard of... Other roles are possible...
88 #
89  ROLE_netfirewall = 'netfirewall'
90  ROLE_netbalancer = 'loadbalancer'
91  ROLE_repeater = 'repeater' # 802.11AB - Section 9.5.8.1
92  ROLE_bridge = 'bridge' # 802.11AB - Section 9.5.8.1 (AKA a "switch")
93  ROLE_tb_bridge = 'tb_bridge' # Cisco CDP_CAPMASK_TBBRIDGE - TB (transparent) bridge
94  ROLE_srcbridge = 'srcbridge' # Cisco SP (source route) Bridge CDP_CAPMASK_SPBRIDGE
95  ROLE_router = 'router' # 802.11AB - Section 9.5.8.1
96  ROLE_phone = 'phone' # 802.11AB - Section 9.5.8.1
97  ROLE_AccessPoint = 'WLANAP' # 802.11AB - Section 9.5.8.1
98  ROLE_DOCSIS = 'DOCSIS' # 802.11AB - Section 9.5.8.1
99  ROLE_igmp = 'igmp-filter' # Cisco IGMP_FILTER CDP_CAPMASK_IGMPFILTER
100  ROLE_Station = 'station' # 802.11AB - Section 9.5.8.1
101  ROLE_UPS = 'UPS'
102  ROLE_CRAC = 'crac'
103  ROLE_sensor = 'sensor'
104  ROLE_drone = 'drone' # http://bit.ly/197K7e9
105  ROLE_host = 'host'
106  ROLE_client = 'client'
107  ROLE_server = 'server'
108 
109 
110  # Return all the BPrules objects which are part of the given ruleset
111  # Our index would find us exactly the ones we want, but substituting into
112  # it doesn't work correctly. The good news is that there aren't many
113  # BPrule objects :-)
114  QUERY_RULESET_RULES = '''START n=node:BPRules('*:*')
115  WHERE n.rulesetname = {rulesetname}
116  RETURN n'''
117 
118  classkeymap = {}
119  uniqueindexes = {}