From 2c1ddabf32f3e74222817d75018d3b0cc46a78e1 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 15 Apr 2020 11:50:10 -0400 Subject: [PATCH] Rename api.* attributes Gather them into the deployment category. --- confluent_server/confluent/config/attributes.py | 4 ++-- confluent_server/confluent/credserver.py | 10 +++++----- confluent_server/confluent/selfservice.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/confluent_server/confluent/config/attributes.py b/confluent_server/confluent/config/attributes.py index df98574b..ed9cafa4 100644 --- a/confluent_server/confluent/config/attributes.py +++ b/confluent_server/confluent/config/attributes.py @@ -97,10 +97,10 @@ node = { 'description': ('Classification of node as server or switch'), 'validvalues': ('switch', 'server'), }, - 'api.key': { + 'deployment.apikey': { 'description': ('Crypt of api key for self api requests by node'), }, - 'api.armed': { + 'deployment.apiarmed': { 'description': ('Indicates whether the node authentication token interface ' 'is armed. If set to once, it will grant only the next ' 'request. If set to continuous, will allow many requests.' diff --git a/confluent_server/confluent/credserver.py b/confluent_server/confluent/credserver.py index 187bea7b..735110ee 100644 --- a/confluent_server/confluent/credserver.py +++ b/confluent_server/confluent/credserver.py @@ -39,8 +39,8 @@ class CredServer(object): return nodename = util.stringify(client.recv(tlv[1])) tlv = bytearray(client.recv(2)) - apiarmed = self.cfm.get_node_attributes(nodename, 'api.armed') - apiarmed = apiarmed.get(nodename, {}).get('api.armed', {}).get( + apiarmed = self.cfm.get_node_attributes(nodename, 'deployment.apiarmed') + apiarmed = apiarmed.get(nodename, {}).get('deployment.apiarmed', {}).get( 'value', None) if not apiarmed: client.close() @@ -49,7 +49,7 @@ class CredServer(object): now = datetime.datetime.utcnow() expiry = datetime.datetime.strptime(apiarmed, "%Y-%m-%dT%H:%M:%SZ") if now > expiry: - self.cfm.set_node_attributes({nodename: {'api.armed': ''}}) + self.cfm.set_node_attributes({nodename: {'deployment.apiarmed': ''}}) client.close() return client.send(b'\x02\x20') @@ -69,9 +69,9 @@ class CredServer(object): client.close() return echotoken = util.stringify(client.recv(tlv[1])) - cfgupdate = {nodename: {'api.key': echotoken, 'api.armed': ''}} + cfgupdate = {nodename: {'deployment.apikey': echotoken, 'deployment.apiarmed': ''}} if apiarmed == 'continuous': - del cfgupdate[nodename]['api.armed'] + del cfgupdate[nodename]['deployment.apiarmed'] self.cfm.set_node_attributes(cfgupdate) client.recv(2) # drain end of message client.send(b'\x05\x00') # report success diff --git a/confluent_server/confluent/selfservice.py b/confluent_server/confluent/selfservice.py index 30c8308c..9d75afc0 100644 --- a/confluent_server/confluent/selfservice.py +++ b/confluent_server/confluent/selfservice.py @@ -17,8 +17,8 @@ def handle_request(env, operation, start_response): yield 'Unauthorized' return cfg = configmanager.ConfigManager(None) - eak = cfg.get_node_attributes(nodename, 'api.key').get( - nodename, {}).get('api.key', {}).get('value', None) + eak = cfg.get_node_attributes(nodename, 'deployment.apikey').get( + nodename, {}).get('deployment.apikey', {}).get('value', None) if not eak: start_response('401 Unauthorized', []) yield 'Unauthorized'