updated to allow config of the new server

This commit is contained in:
ske087
2026-06-26 10:11:44 +03:00
parent a48b3afb83
commit dbc1c882eb
14 changed files with 197 additions and 1127 deletions
+32
View File
@@ -197,6 +197,38 @@ def submit_update_request():
# ── Outcome 3: unknown device ─────────────────────────────
if not device:
# Devices with work_place=notconfig are unconfigured and must not
# be registered. Route them to their own "to_be_configured" bucket.
if not proposed_name or proposed_name.lower() == 'notconfig':
existing_tbc = (
session.query(WMTUpdateRequest)
.filter_by(mac_address=mac, status='to_be_configured')
.order_by(WMTUpdateRequest.submitted_at.desc())
.first()
)
if existing_tbc:
existing_tbc.submitted_at = datetime.utcnow()
existing_tbc.proposed_hostname = proposed_hostname or existing_tbc.proposed_hostname
existing_tbc.proposed_device_ip = proposed_ip or existing_tbc.proposed_device_ip
logger.debug(f'WMT notconfig heartbeat refreshed for {mac}')
else:
req = WMTUpdateRequest(
mac_address=mac,
device_id=None,
proposed_device_name=None,
proposed_hostname=proposed_hostname or None,
proposed_device_ip=proposed_ip or None,
client_config_mtime=data.get('client_config_mtime'),
submitted_at=datetime.utcnow(),
status='to_be_configured',
)
session.add(req)
logger.info(f'WMT unconfigured device queued: {proposed_hostname} / {mac}')
return jsonify({
'status': 'to_be_configured',
'message': 'Device has no work_place set. Awaiting admin assignment.',
}), 202
# Check if a pending request with the same data already exists
existing = (
session.query(WMTUpdateRequest)