�
��?ha � �J � S r SSKJrJr SSKJr SSKJr SSKJ r S\4S jr
g )
zM
Configuration Handler
Handles device configuration management in CML labs.
� )�Dict�Any)�FastMCP� )�
get_client)�
check_auth�mcpc � � U R 5 S[ S[ S[ S[ 4S j5 nU R 5 S[ S[ S[ 4S j5 ng)z;Register configuration management tools with the MCP server�lab_id�node_id�config�returnc � �� # � [ 5 nU( a US $ [ 5 R SSU SU S3US9I Sh v�N nSU 3$ N ! [ a nS [ U5 3s SnA$ SnAff = f7f)
z�
Configure a node with the specified configuration
Args:
lab_id: ID of the lab
node_id: ID of the node to configure
config: Configuration text to apply
Returns:
Confirmation message
�error�PUT�
/api/v0/labs/�/nodes/�/config)�contentNzConfiguration applied to node zError configuring node: )r r �request� Exception�str)r r r
�
auth_check�response�es �[C:\Users\jscon\Documents\Python_Projects\Claude-Modeling-Labs\src\handlers\configuration.py�configure_node�4register_configuration_tools.<locals>.configure_node s� � � � �\�
���g�&�&� 7�'�\�1�1����x�w�w�i�w�?�� 2� � �H� 4�G�9�=�=�
�� � 7�-�c�!�f�X�6�6�� 7�sD �A.�#A �A�A �A.�A �
A+�
A&� A+�!A.�&A+�+A.c � �� # � [ 5 nU( a US $ [ 5 R SSU SU S35 I Sh v�N nUR nU$ N! [ a nS[ U5 3s SnA$ SnAff = f7f)z�
Get the current configuration of a node
Args:
lab_id: ID of the lab
node_id: ID of the node
Returns:
Node configuration text or error message
r �GETr r r Nz"Error getting node configuration: )r r r �textr r )r r r r r
r s r �get_node_config�5register_configuration_tools.<locals>.get_node_config- s� � � � �\�
���g�&�&� A�'�\�1�1�%�=���PW�X_�W`�`g�9h�i�i�H��]�]�F��M� j�� � A�7��A��x�@�@�� A�sD �A8�$A �A�A �A8�A �
A5�
A0�*A5�+A8�0A5�5A8N)�toolr )r r r"