2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 19:10:10 +00:00

Rename api.* attributes

Gather them into the deployment
category.
This commit is contained in:
Jarrod Johnson 2020-04-15 11:50:10 -04:00
parent 24bc1210d0
commit 2c1ddabf32
3 changed files with 9 additions and 9 deletions

View File

@ -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.'

View File

@ -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

View File

@ -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'