From 2bbf4b9e987c9cdcc0b4fa951c632e1d89e1f9b6 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 28 Feb 2019 12:59:41 -0500 Subject: [PATCH] Implement direct add switches Allow addition of switches without associated nodes. This allows populating mac database without requiring associated nodes. --- confluent_server/confluent/config/attributes.py | 7 ++++--- confluent_server/confluent/networking/macmap.py | 4 +++- confluent_server/confluent/networking/netutil.py | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/config/attributes.py b/confluent_server/confluent/config/attributes.py index a83520f0..1a14d887 100644 --- a/confluent_server/confluent/config/attributes.py +++ b/confluent_server/confluent/config/attributes.py @@ -93,9 +93,10 @@ node = { 'description': ('List of static groups for which this node is ' 'considered a member'), }, - #'type': { - # 'description': ('Classification of node as system, vm, etc') - #}, + 'type': { + 'description': ('Classification of node as server or switch'), + 'validvalues': ('switch', 'server'), + }, #'id': { # 'description': ('Numeric identifier for node') #}, diff --git a/confluent_server/confluent/networking/macmap.py b/confluent_server/confluent/networking/macmap.py index 2522a030..0a374d5a 100644 --- a/confluent_server/confluent/networking/macmap.py +++ b/confluent_server/confluent/networking/macmap.py @@ -315,10 +315,12 @@ def _full_updatemacmap(configmanager): 'Network topology not available to tenants') # here's a list of switches... need to add nodes that are switches nodelocations = configmanager.get_node_attributes( - configmanager.list_nodes(), ('net*.switch', 'net*.switchport')) + configmanager.list_nodes(), ('type', 'net*.switch', 'net*.switchport')) switches = set([]) for node in nodelocations: cfg = nodelocations[node] + if cfg.get('type', {}).get('value', None) == 'switch': + switches.add(node) for attr in cfg: if not attr.endswith('.switch') or 'value' not in cfg[attr]: continue diff --git a/confluent_server/confluent/networking/netutil.py b/confluent_server/confluent/networking/netutil.py index 60106c34..508c8662 100644 --- a/confluent_server/confluent/networking/netutil.py +++ b/confluent_server/confluent/networking/netutil.py @@ -42,10 +42,12 @@ def get_switchcreds(configmanager, switches): def list_switches(configmanager): nodelocations = configmanager.get_node_attributes( - configmanager.list_nodes(), ('net*.switch', 'net*.switchport')) + configmanager.list_nodes(), ('type', 'net*.switch', 'net*.switchport')) switches = set([]) for node in nodelocations: cfg = nodelocations[node] + if cfg.get('type', {}).get('value', None) == 'switch': + switches.add(node) for attr in cfg: if not attr.endswith('.switch') or 'value' not in cfg[attr]: continue