Benutzer-Werkzeuge

Webseiten-Werkzeuge


ne:netzwerkmanagement

Netzwerkmanangement

Netconf & YANG

RFCs

Tools

MQTT-Netconf-YANG Bridge

LED-Color: blue

mosquitto_pub -d -h localhost -p 1883 -t "yang/config" -m '{ 
"device":{ "description": "MQTT-Device identified by UUID",
 "uuid":{ "type": "string", "value": "F97dfF79-8A12-4F4F-8F69-6B8F3C2EdadDD" },
 "device-category":{ "description": "Identifies the device category", "type": "string", "value":"L-LAMP" } }, 
"rpc": { "set_color_blue": { "description": "RPC call that sets the LED Color to blue",
 "mqtt-command": "BLUE", "input": { "uuid": { "description": "Sends request to device specified by uuid", "type": "string" } } }, 
"switch_off": { "description": "Switches the LIFX-Led off", "mqtt-command": "OFF" } } }'
{  
   "device":{  
      "description":"MQTT-Device identified by UUID",
      "uuid":{  
         "type":"string",
         "value":"F97dfF79-8A12-4F4F-8F69-6B8F3C2EdadDD"
      },
      "device-category":{  
         "description":"Identifies the device category",
         "type":"string",
         "value":"L-LAMP"
      }
   },
   "rpc":{  
      "set_color_blue":{  
         "description":"RPC call that sets the LED Color to blue",
         "mqtt-command":"BLUE",
         "input":{  
            "uuid":{  
               "description":"Sends request to device specified by uuid",
               "type":"string"
            }
         }
      },
      "switch_off":{  
         "description":"Switches the LIFX-Led off",
         "mqtt-command":"OFF"
      }
   }
}

LED-Color: green

mosquitto_pub -d -h localhost -p 1883 -t "yang/config" -m '{ "device":{ "description": "MQTT-Device identified by UUID",
 "uuid":{ "type": "string", "value": "F97dfF79-8A12-4F4F-8F69-6B8F3C2EdadDD" },
 "device-category":{ "description": "Identifies the device category", "type": "string", "value":"L-LAMP" } },
 "rpc": { "set_color_green": { "description": "RPC call that sets the LED Color to green",
 "mqtt-command": "GREEN", "input": { "uuid": { "description": "Sends request to device specified by uuid",
 "type": "string" } } }, "switch_off": { "description": "Switches the LIFX-Led off", "mqtt-command": "OFF" } } }'
{  
   "device":{  
      "description":"MQTT-Device identified by UUID",
      "uuid":{  
         "type":"string",
         "value":"F97dfF79-8A12-4F4F-8F69-6B8F3C2EdadDD"
      },
      "device-category":{  
         "description":"Identifies the device category",
         "type":"string",
         "value":"L-LAMP"
      }
   },
   "rpc":{  
      "set_color_green":{  
         "description":"RPC call that sets the LED Color to green",
         "mqtt-command":"GREEN",
         "input":{  
            "uuid":{  
               "description":"Sends request to device specified by uuid",
               "type":"string"
            }
         }
      },
      "switch_off":{  
         "description":"Switches the LIFX-Led off",
         "mqtt-command":"OFF"
      }
   }
}

LED-Color: green + blue

mosquitto_pub -d -h localhost -p 1883 -t "yang/config" -m '{ 
"device":{ "description": "MQTT-Device identified by UUID", "uuid":{ "type": "string", "value": "F97dfF79-8A12-4F4F-8F69-6B8F3C2EdadDD" }, "device-category":{ "description": "Identifies the device category", "type": "string", "value":"L-LAMP" } }, 
"rpc": { 
"set_color_blue": { "description": "RPC call that sets the LED Color to blue", "mqtt-command": "BLUE", "input": { "uuid": { "description": "Sends request to device specified by uuid", "type": "string" } } },
"set_color_green": { "description": "RPC call that sets the LED Color to green", "mqtt-command": "GREEN", "input": { "uuid": { "description": "Sends request to device specified by uuid", "type": "string" } } }, 
"switch_off": { "description": "Switches the LIFX-Led off", "mqtt-command": "OFF" } } }'
{  
   "device":{  
      "description":"MQTT-Device identified by UUID",
      "uuid":{  
         "type":"string",
         "value":"F97dfF79-8A12-4F4F-8F69-6B8F3C2EdadDD"
      },
      "device-category":{  
         "description":"Identifies the device category",
         "type":"string",
         "value":"L-LAMP"
      }
   },
   "rpc":{  
      "set_color_blue":{  
         "description":"RPC call that sets the LED Color to blue",
         "mqtt-command":"BLUE",
         "input":{  
            "uuid":{  
               "description":"Sends request to device specified by uuid",
               "type":"string"
            }
         }
      },
      "set_color_green":{  
         "description":"RPC call that sets the LED Color to green",
         "mqtt-command":"GREEN",
         "input":{  
            "uuid":{  
               "description":"Sends request to device specified by uuid",
               "type":"string"
            }
         }
      },
      "switch_off":{  
         "description":"Switches the LIFX-Led off",
         "mqtt-command":"OFF"
      }
   }
}
m = manager.connect_ssh("localhost", port=44555, username="Thomas", password="admin",allow_agent=False,hostkey_verify=False,look_for_keys=False)
n = xml_.to_ele('<get-schema/>')
m.dispatch(n)
n = xml_.to_ele('<get/>')
n = xml_.to_ele('<set_color_blue><uuid>12345</uuid></set_color_blue>')
n = xml_.to_ele('<set_color_green><uuid>12345</uuid></set_color_green>')
n = xml_.to_ele('<switch_off><uuid>1fff</uuid></switch_off>')

:!: ACHTUNG: Server stürzt ab, wenn kein UUID tag angegeben wird.

Setup in iTerm: (cd /Users/Thomas/LIFX/demo):

  • Links: mqtt/LIFX bridge (./mqtt)
  • Mitte: mqtt_publisher (send json)
  • Rechts: mqtt_subscriber (mosquitto_sub -d -h localhost -p 1883 -t „#“)
  • Unten: /usr/local/sbin/mosquitto -c ./mqtt.conf

Terminal:

Virtenv starten:

source python-virtenv/bin/activate

NETCONF/MQTT bridge:

python -i netconf_Server.py   # Achtung: MQTT Broker muss vorher gestartet sein!

ncclient:

from ncclient import manager
from ncclient import xml_
for capability in m.server_capabilities:
...             print(capability)
m = manager.connect_ssh('ios-xe-mgmt.cisco.com', port=10000, username="root", password='C!sc0123',allow_agent=False,hostkey_verify=False,look_for_keys=False)
Diese Website verwendet Cookies. Durch die Nutzung der Website stimmen Sie dem Speichern von Cookies auf Ihrem Computer zu. Außerdem bestätigen Sie, dass Sie unsere Datenschutzbestimmungen gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website.Weitere Information
ne/netzwerkmanagement.txt · Zuletzt geändert: 2018/01/31 13:41 von admin