====== 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 =====
==== Prüfen welche Pakete bisher vorhanden sind ====
BennyE@mbp ~ % ssh admin@router
Password:
________ ________ ________ ________ ________
|\ __ \|\ __ \|\ ____\ |\ __ \|\ __ \
\ \ \|\ \ \ \|\ \ \ \___|_ \ \ \|\ \ \ \|\ \
\ \ __ \ \ \\\ \ \_____ \ \ \ _ _\ \ __ \
\ \ \ \ \ \ \\\ \|____|\ \ \ \ \\ \\ \ \|\ \
\ \__\ \__\ \_______\____\_\ \ \ \__\\ _\\ \_______\
\|__|\|__|\|_______|\_________\ \|__|\|__|\|_______|
\|_________|
OmniSwitch 6465T
Router->
Router-> pkgmgr list
Legend: (+) indicates package is not saved across reboot
(*) indicates packages will be installed or removed after reload
Name Version Status Install Script
---------------+---------------------+------------------+---------------------------------
ams default installed default
ams-apps default installed default
Router->
==== Hochladen des WebView 2.0 Pakets ====
Bitte darauf achten dass das WebView 2.0 Paket zum verwendeten AOS passt!
Router-> show microcode working
/flash/working
Package Release Size Description
-----------------+-------------------------+---------+-----------------------------------
Nos.img 8.7.354.R01 219355400 Alcatel-Lucent OS
BennyE@mbp Downloads % scp package-webview-8.7.R01-354.deb admin@router:/flash/working/pkg
Password:
package-webview-8.7.R01-354.deb 100% 12MB 1.5MB/s 00:07
==== Prüfen der Checksumme des WebView 2.0 Pakets ====
Router-> pkgmgr verify package-webview-8.7.R01-354.deb
Verifying MD5 checksum.. OK
==== Installation des WebView 2.0 Pakets ====
Router-> pkgmgr install package-webview-8.7.R01-354.deb
Verifying MD5 checksum.. OK
System Memory check.. PASS
Extracting control files for package package-webview-8.7.R01-354.deb .. OK
Package Dependency check.. PASS
Unpacking webview (from /flash/working/pkg/package-webview-8.7.R01-354.deb)...
Setting up webview (8.7.R01-354)...
Installing package package-webview-8.7.R01-354.deb .. OK
Commit is required complete package webview installation
Ein Neustart ist nicht notwendig! Der Zugriff ist nun via WebGUI möglich (siehe folgender Screenshot), aber die Applikation noch nicht bootfest gemacht!
{{ ::web20:webgui-login.png?direct |}}
Router-> pkgmgr list
Legend: (+) indicates package is not saved across reboot
(*) indicates packages will be installed or removed after reload
Name Version Status Install Script
---------------+---------------------+------------------+---------------------------------
ams default installed default
ams-apps default installed default
+ webview 8.7.R01-354 installed /flash/working/pkg/webview/install.sh
==== WebView 2.0 Applikation bootfest machen ====
Router-> pkgmgr commit
Package(s) Committed
Router->
Router-> pkgmgr list
Legend: (+) indicates package is not saved across reboot
(*) indicates packages will be installed or removed after reload
Name Version Status Install Script
---------------+---------------------+------------------+---------------------------------
ams default installed default
ams-apps default installed default
webview 8.7.R01-354 installed /flash/working/pkg/webview/install.sh
Router->
===== Verwendung der WebView 2.0 API =====
==== API: Login und Ausgabe der Systemfunktionen ====
=== Ausgabe in der CMD-Box/Shell ===
% 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"
}
=== Quellcode für das obige Beispiel ===
#!/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()))
mysecrets = {
"fqdn":"omniswitch.fqdn",
"username":"admin",
"password":"password",
"validate_https_certificate":"no"
}
==== 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]]