Benutzer-Werkzeuge

Webseiten-Werkzeuge


aos-r8-webview_v2-api-json-omniswitch

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
aos-r8-webview_v2-api-json-omniswitch [2020/11/17 11:52] bennyaos-r8-webview_v2-api-json-omniswitch [2024/06/09 10:29] (aktuell) – Externe Bearbeitung 127.0.0.1
Zeile 1: Zeile 1:
-====== AOS Release 8 und WebView 2.0 ======+====== AOS Release 8 und WebView 2.0 (WebGUI & API) ====== 
 + 
 +In diesem Artikel werden die ersten Schritte mit dem AOS Release 8 WebView 2.0 beschrieben.
  
 ===== Installation/Inbetriebnahme von WebView 2.0 ===== ===== Installation/Inbetriebnahme von WebView 2.0 =====
Zeile 67: Zeile 69:
 </code> </code>
  
 +<WRAP center round tip 60%>
 +Ein Neustart ist nicht notwendig! Der Zugriff ist nun via WebGUI möglich (siehe folgender Screenshot), aber die Applikation noch nicht bootfest gemacht!
 +</WRAP>
 +
 +{{ ::web20:webgui-login.png?direct |}}
  
 <code> <code>
Zeile 94: Zeile 101:
 Router->                                                                                              Router->                                                                                             
 </code> </code>
 +
 +===== Verwendung der WebView 2.0 API =====
 +
 +==== API: Login und Ausgabe der Systemfunktionen ====
 +
 +=== Ausgabe in der CMD-Box/Shell ===
 +
 +<code>
 +% python3 print_capabilities.py
 +OS6465T-P12
 +{
 +    "802dot1AD_QOSDEICFI": true,
 +    "802dot1Q": false,
 +    "AAA_8021X": false,
 +    "AAA_SERVERS": true,
 +    "ACCESS_GUARDIAN": true,
 +    "ACTIVE_LEASES": true,
 +    "ALARM_MGR": true,
 +    "APP_FP": false,
 +    "APP_MON": false,
 +    "AUTOFABRIC_ALL_PROTOCOLS": false,
 +    "AUTO_FABRIC": true,
 +    "AVLAN": false,
 +    "BFD_STD": true,
 +    "BGP": false,
 +    "CHS_INLINEPOWER": true,
 +    "CHS_INLINEPOWER_802_DOT_3BT": false,
 +    "CHS_INLINEPOWER_CHASSISPOEMGT": false,
 +    "CHS_INLINEPOWER_FAST_POE": false,
 +    "CHS_INLINEPOWER_PERPAETUAL_POE": false,
 +    "CHS_INLINEPOWER_POWER_OVER_HDMI": false,
 +    "CHS_INLINEPOWER_REDUNDANCY": false,
 +    "CHS_MACALLOC": false,
 +    "CHS_STACKSTATICROUTE": false,
 +    "CHS_VRF": false,
 +    "CPE_TEST_HEAD": true,
 +    "DHCPV4_SRV": true,
 +    "DHCPV6_SRV": true,
 +    "DHCP_SNOOPING": true,
 +    "DISTRIBUTED_ARP": false,
 +    "DPI": true,
 +    "DVMRP": false,
 +    "DVMRP_BFD": true,
 +    "DYING_GASP": true,
 +    "EFMOAM": true,
 +    "ERP": true,
 +    "ESMDRV_HYBRID": false,
 +    "ETHOAM": true,
 +    "ETH_BEACON": false,
 +    "ETH_SERVICES": true,
 +    "FIPS": false,
 +    "HARDWARE_LOOPBACK": true,
 +    "HLTH_FABRIC": false,
 +    "INITIAL_PACKET_BUFFER": false,
 +    "IPMS_BRIDGING": true,
 +    "IPMS_HACLUSTER": true,
 +    "IPMS_IPV6": true,
 +    "IPMS_SSM_MAP": true,
 +    "IPSEC": false,
 +    "IPV6": true,
 +    "IPV6_LPND": false,
 +    "IPV6_LPND_RAF": true,
 +    "IPV6_REDIST": true,
 +    "IP_DISTRIBUTED_ARP": true,
 +    "IP_SERVICE": false,
 +    "IP_TUNNEL": false,
 +    "ISIS": false,
 +    "KERBEROS_SNOOPING": true,
 +    "L2GRE": false,
 +    "L2GRE_AUTO_DISCOVER": false,
 +    "L2GRE_RESERVED_VLAN": false,
 +    "LBD": true,
 +    "LFP": true,
 +    "LLDP_TRUSTAGENT": false,
 +    "MAC_SEC": true,
 +    "MAC_VXLAN": false,
 +    "MARVELL": true,
 +    "MPLS_LDP": true,
 +    "MSG_SRV": true,
 +    "MVRP": true,
 +    "OLD_VRRP": false,
 +    "OPENFLOW": false,
 +    "OSPF": false,
 +    "OSPF3": false,
 +    "PIM": false,
 +    "PMIRR_TAGREMOVE": false,
 +    "PORT-MAPPING": true,
 +    "PORT_MIRRORING_LINK_AGG": false,
 +    "PPPOE": false,
 +    "PTP": true,
 +    "QOS_VFC": true,
 +    "RDP": false,
 +    "RIPng": true,
 +    "ROUTER_AUTH_CAPTIVE_PORTAL": true,
 +    "SIP_SNOOPING": false,
 +    "SLB": false,
 +    "SL_QUARANTINE": false,
 +    "SPB_RFP": false,
 +    "SVC_ACCESS_PORT": true,
 +    "SVC_MGR": false,
 +    "SVC_SPB": true,
 +    "SVC_VXLAN": true,
 +    "SYSTEM_BLUETOOTH": true,
 +    "SYSTEM_BOOTROM": false,
 +    "SYSTEM_DEVICEPROFILE": true,
 +    "SYSTEM_FPGACMM": true,
 +    "SYSTEM_FPGANI": true,
 +    "SYSTEM_ISSU": true,
 +    "SYSTEM_LANPOWER": true,
 +    "SYSTEM_LICENSE": true,
 +    "SYSTEM_RFS": true,
 +    "SYSTEM_UBOOTCMM": true,
 +    "SYSTEM_UPDATE": true,
 +    "SYSTEM_UPLOAD": false,
 +    "SYSTEM_USBRECOVERY": false,
 +    "TCAM_MANAGER": false,
 +    "TDR": true,
 +    "TRANSPARENT_BRIDGING": false,
 +    "UDLD": true,
 +    "VC_HELLO_CONFIG": true,
 +    "VC_SPLIT_HELPER": true,
 +    "VC_SPLIT_PROTECTION": true,
 +    "VC_VFL_CONFIG": true,
 +    "VFC_GLOBAL_CONFIG": true,
 +    "VIRTUAL_CHASSIS": true,
 +    "VLAN_DHL": true,
 +    "VLAN_IPMVLAN": false,
 +    "VLAN_PORTMOBILITY": false,
 +    "VLAN_PVLAN": false,
 +    "VM_SNOOPING": false,
 +    "VNP_802dot1X": true,
 +    "VRRP": true,
 +    "VRRP3": true,
 +    "VSTK_ETHERNET_SERVICE_TUNNELMAC": true,
 +    "VSTK_ETHERNET_SERVICE_UNI_PROFILE": true,
 +    "WLAN": true,
 +    "ZERO_CONF": false,
 +    "alaAutoFabricRemoveVCReload": true,
 +    "alaChasEntPhysFanSpeed": true,
 +    "alaEServiceSapProfileEgressBW": true,
 +    "alaQoSConditionIpv6NH": false,
 +    "alaQoSConfigSwitchGroup": true,
 +    "chasEntPhysPowerUsed": true,
 +    "chasSupervisionRfsDfFlashFree": false,
 +    "healthDeviceTemperatureChasLatest": true,
 +    "lldpXMedFastStartRepeatCount": false,
 +    "slMacLearningVlanControlStatus": true
 +}
 +{
 +    "data": {
 +        "write-all": "true"
 +    },
 +    "username": "admin"
 +}
 +{
 +    "alaVirtualRouterNameTable": {
 +        "default": "default"
 +    },
 +    "current": "default"
 +}
 +{
 +    "alaVrConfigBgpStatus": "2",
 +    "alaVrConfigDvmrpStatus": "2",
 +    "alaVrConfigIsisStatus": "2",
 +    "alaVrConfigMplsLdpStatus": "2",
 +    "alaVrConfigOspf3Status": "2",
 +    "alaVrConfigOspfStatus": "2",
 +    "alaVrConfigPimStatus": "2",
 +    "alaVrConfigRipStatus": "2",
 +    "alaVrConfigRipngStatus": "2",
 +    "alaVrConfigVrrpStatus": "1"
 +}
 +</code>
 +
 +=== Quellcode für das obige Beispiel ===
 +
 +<file python print_capabilities.py>
 +#!/usr/bin/env python3
 +
 +import sys
 +try:
 +    import requests
 +except ImportError as ie:
 +    print(ie)
 +    sys.exit("Please install python-requests!")
 +import urllib3
 +import json
 +from mysecrets import mysecrets
 +
 +# Modify the mysecrets.py
 +fqdn = mysecrets["fqdn"]
 +username = mysecrets["username"]
 +password = mysecrets["password"]
 +validate_https_certificate = mysecrets["validate_https_certificate"]
 +# This will not work directly, as the params have to be urlencoded
 +#login_url = "https://{0}/?domain=auth&username={1}&password={2}".format(fqdn, username, password)
 +omniswitch_url = "https://{0}/".format(fqdn)
 +
 +login_params = {
 +    "domain":"auth",
 +    "username":username,
 +    "password":password
 +}
 +
 +req_headers = {
 +    "Accept":"application/vnd.alcatellucentaos+json",
 +    "ALU_CONTEXT":"vrf=default"
 +}
 +
 +if(validate_https_certificate.lower() == "yes"):
 +    check_certs = True
 +else:
 +    # This is needed to get rid of a warning coming from urllib3 on self-signed certificates
 +    # print("[!] Ignoring certificate warnings or self-signed certificates!")
 +    # print("[!] You should really fix this!")
 +    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
 +    check_certs = False    
 +
 +# req will also hold a session cookie for all following interactions
 +req = requests.Session()
 +
 +# Login and obtain cookie for session
 +resp = req.get(omniswitch_url, params=login_params, headers=req_headers, verify=check_certs)
 +if resp.status_code == 200:
 +    # resp.json() will contain something like {'result': {'domain': 'auth (login)', 'diag': 200, 'error': '', 'output': '', 'data': []}}
 +    if resp.json()["result"]["diag"] == 400:
 +        sys.exit(resp.json()["result"]["error"])
 +    elif resp.json()["result"]["diag"] == 200:
 +        pass
 +    else:
 +        sys.exit("Something went wrong: {0}".format(resp.json()))
 +
 +getwebview_params = {
 +    "domain":"callFunction",
 +    "function":"getWebviewInformation" 
 +}
 +
 +resp = req.get(omniswitch_url, params=getwebview_params, headers=req_headers, verify=check_certs)
 +if resp.status_code == 200:
 +    # resp.json() will contain something like {'result': {'domain': 'auth (login)', 'diag': 200, 'error': '', 'output': '', 'data': []}}
 +    if resp.json()["result"]["diag"] == 400:
 +        sys.exit(resp.json()["result"]["error"])
 +    elif resp.json()["result"]["diag"] == 200:
 +        for k, v in resp.json()["result"]["data"].items():
 +            if isinstance(v, str):
 +                print(v)
 +            elif isinstance(v, dict):
 +                print(json.dumps(v, indent=4, sort_keys=True))
 +    else:
 +        sys.exit("Something went wrong: {0}".format(resp.json()))
 +</file>
 +
 +<file python mysecrets.py>
 +mysecrets = {
 +    "fqdn":"omniswitch.fqdn",
 +    "username":"admin",
 +    "password":"password",
 +    "validate_https_certificate":"no"
 +}
 +</file>
 +
 +==== Weitere Beispiele auf GitHub ====
 +
 +  * [[https://github.com/BennyE/omniswitch-webview2.0-api|OmniSwitch WebView 2.0 API GitHub]]
 +  * [[https://github.com/BennyE/omniswitch-webview2.0-api/blob/main/port_118_enable_poe.py|PoE-Port 1/1/8 einschalten]]
 +  * [[https://github.com/BennyE/omniswitch-webview2.0-api/blob/main/port_118_disable_poe.py|PoE-Port 1/1/8 ausschalten]]
 +  * [[https://github.com/BennyE/omniswitch-webview2.0-api/blob/main/admin_state_port_118_enable.py|Port 1/1/8 administrativ einschalten]]
 +  * [[https://github.com/BennyE/omniswitch-webview2.0-api/blob/main/admin_state_port_118_disable.py|Port 1/1/8 administrativ ausschalten]]
 +
 +
aos-r8-webview_v2-api-json-omniswitch.1605613934.txt.gz · Zuletzt geändert: 2024/06/09 10:29 (Externe Bearbeitung)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki