Implemented key categorization to distinguish between keys set only during server creation and those that can be updated
All checks were successful
buildbot/multibuild_parent Build done.
buildbot/travis_bionic Build done.

This commit is contained in:
Shailaja Kumari 2024-06-13 16:15:24 +05:30
parent 0072a07754
commit de3d5fb4ab
Signed by: shailaja
GPG Key ID: 2B9455CAFBC4D75A

View File

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