Я написал скрипт Python для запуска ACL, но когда я запускаю скрипт, я получаю сообщение об ошибке
HTTP 404 Not Found
Я не могу войти в систему через скрипт.Прикрепив код для справки.
import requests
import time
from requests.auth import HTTPBasicAuth
ONOS_REST_API = "http://172.17.0.2:8181/onos/v1"
ONOS_USER = "onos"
ONOS_PASSWORD = "rocks"
SWITCH = "of:0000000000000001"
SWITCH_PORT = "1"
PACKET_RESET = 1000 # substract this to atual stats
PACKET_TO_TRIGGER_ACL = 6000000000000
def get_packet_count(session):
return session.get("%s/statistics/ports/%s/%s" % (ONOS_REST_API, SWITCH, SWITCH_PORT)).json()["packetsReceived"]-PACKET_RESET
def set_acl(session):
session.post("%s/172.17.0.2:8181/onos/v1/acl" % (ONOS_REST_API), json={"srcIp":"10.0.0.2/32", "dstIp":"10.0.0.1/32", "action": "deny"})
def login():
session = requests.Session()
print session.get(ONOS_REST_API, auth=HTTPBasicAuth(ONOS_USER, ONOS_PASSWORD)).json()
return session
if __name__ == "__main__":
session = login()
while True:
# Check port packet count
packets = get_packet_count(session)
if packets >= PACKET_TO_TRIGGER_ACL:
set_acl(session)
break
time.sleep(10)