forked from Sysdeploy/idlers-agent
Implemented key categorization to distinguish between keys set only during server creation and those that can be updated
This commit is contained in:
parent
0072a07754
commit
de3d5fb4ab
20
agent.py
20
agent.py
|
@ -4,6 +4,24 @@ import logging
|
|||
import json
|
||||
import http.client
|
||||
|
||||
NON_UPDATABLE_KEYS = [
|
||||
'server_type',
|
||||
'os_id',
|
||||
'provider_id',
|
||||
'location_id',
|
||||
'ssh_port',
|
||||
'bandwidth',
|
||||
'was_promo',
|
||||
'active',
|
||||
'show_public',
|
||||
'owned_since',
|
||||
'currency',
|
||||
'price',
|
||||
'payment_term',
|
||||
'next_due_date',
|
||||
'ip1'
|
||||
]
|
||||
|
||||
class ServerData:
|
||||
def __init__(self):
|
||||
self.hostname = os.uname().nodename
|
||||
|
@ -110,7 +128,7 @@ class ServerManager:
|
|||
|
||||
def update_server(self, post_data, server_id):
|
||||
# remove following keys from post_data
|
||||
for key in ['ssh_port', 'ip1', 'currency', 'price', 'payment_term', 'next_due_date']:
|
||||
for key in NON_UPDATABLE_KEYS:
|
||||
post_data.pop(key, None)
|
||||
logging.info(f"Updating server with id {server_id}...")
|
||||
return self.send_request('PUT', '/api/servers/' + str(server_id), post_data)
|
||||
|
|
Loading…
Reference in New Issue
Block a user