Commit 77cf78b9 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Merge branch 'fix-avs-hikvision-profile' into 'master'

Replace XML namespace parameter on profile Hikvision.DSKV8.

See merge request noc/noc!2269

(cherry picked from commit ca97c6cd)

710c7849 Replace XML namespace parameter on profile Hikvision.DSKV8.
parent 6e7853db
......@@ -19,7 +19,8 @@ class Script(BaseScript):
interface = IGetChassisID
def execute(self):
v = self.http.get("/ISAPI/System/deviceInfo", json=False, cached=True, use_basic=True)
v = self.http.get("/ISAPI/System/deviceInfo", cached=True, use_basic=True)
v = v.replace("\n", "")
root = ElementTree.fromstring(v)
for child in root:
key = child.tag.split("}")[1][0:]
......
......@@ -37,7 +37,8 @@ class Script(BaseScript):
def execute(self, **kwargs):
c = ""
v = self.http.get("/ISAPI/Streaming/channels", json=False, cached=True, use_basic=True)
v = self.http.get("/ISAPI/Streaming/channels", use_basic=True)
v = v.replace("\n", "")
root = ElementTree.fromstring(v)
v = self.xml_2_dict(root)
channels = v['StreamingChannelList']['StreamingChannel']
......@@ -53,7 +54,8 @@ class Script(BaseScript):
if key == "_text" or isinstance(value, six.string_types):
continue
c += " %s: %s\n" % (key, value[0]['_text'])
v = self.http.get("/ISAPI/Image/channels/1/color", json=False, cached=True, use_basic=True)
v = self.http.get("/ISAPI/Image/channels/1/color", use_basic=True)
v = v.replace("\n", "")
root = ElementTree.fromstring(v)
v = self.xml_2_dict(root)
color = v['Color']
......@@ -64,7 +66,8 @@ class Script(BaseScript):
c += " %s: %s\n" % (key, value[0]['_text'])
try:
v = self.http.get("/ISAPI/Image/channels/1/WDR", json=False, cached=True, use_basic=True)
v = self.http.get("/ISAPI/Image/channels/1/WDR", use_basic=True)
v = v.replace("\n", "")
root = ElementTree.fromstring(v)
v = self.xml_2_dict(root)
c += "WDR:\n"
......@@ -74,36 +77,41 @@ class Script(BaseScript):
pass
try:
v = self.http.get("/ISAPI/Image/channels/1/BLC", json=False, cached=True, use_basic=True)
v = self.http.get("/ISAPI/Image/channels/1/BLC", use_basic=True)
v = v.replace("\n", "")
root = ElementTree.fromstring(v)
v = self.xml_2_dict(root)
c += "BLC:\n"
c += " enabled: %s\n" % v['BLC']['enabled'][0]['_text']
c += " BLCMode: %s\n" % v['BLC']['BLCMode'][0]['_text']
if 'BLCMode' in v['BLC']:
c += " BLCMode: %s\n" % v['BLC']['BLCMode'][0]['_text']
except HTTPError:
pass
try:
v = self.http.get("/ISAPI/System/Video/inputs/channels/1/overlays/capabilities",
json=False, cached=True, use_basic=True)
v = self.http.get("/ISAPI/System/Video/inputs/channels/1/overlays/capabilities", use_basic=True)
v = v.replace("\n", "")
root = ElementTree.fromstring(v)
v = self.xml_2_dict(root)
overlay = v['VideoOverlay']['TextOverlayList'][0]['TextOverlay']
if overlay:
c += "Overlays:\n"
i = 1
for o in overlay:
text = o['displayText'][0]
if text:
c += " TextOverlay%d: \"%s\"\n" % (i, text['_text'])
else:
c += " TextOverlay%d: \"\"\n" % i
i = i + 1
overlay = v['VideoOverlay']['TextOverlayList'][0]
if 'TextOverlay' in overlay:
overlay = overlay['TextOverlay']
if overlay:
c += "Overlays:\n"
i = 1
for o in overlay:
text = o['displayText'][0]
if text:
c += " TextOverlay%d: \"%s\"\n" % (i, text['_text'])
else:
c += " TextOverlay%d: \"\"\n" % i
i = i + 1
except HTTPError:
pass
try:
v = self.http.get("/ISAPI/System/time", json=False, cached=True, use_basic=True)
v = self.http.get("/ISAPI/System/time", use_basic=True)
v = v.replace("\n", "")
root = ElementTree.fromstring(v)
v = self.xml_2_dict(root)
timeMode = v['Time']['timeMode'][0]['_text']
......@@ -113,7 +121,8 @@ class Script(BaseScript):
pass
try:
v = self.http.get("/ISAPI/System/time/ntpServers", json=False, cached=True, use_basic=True)
v = self.http.get("/ISAPI/System/time/ntpServers", use_basic=True)
v = v.replace("\n", "")
root = ElementTree.fromstring(v)
v = self.xml_2_dict(root)
ntp_servers = v['NTPServerList']['NTPServer']
......
......@@ -24,7 +24,8 @@ class Script(BaseScript):
ns = {'isapi': 'http://www.isapi.org/ver20/XMLSchema',
'std-cgi': 'http://www.std-cgi.com/ver20/XMLSchema',
'hikvision': 'http://www.hikvision.com/ver20/XMLSchema'}
v = self.http.get("/ISAPI/System/Network/interfaces", cached=True, use_basic=True)
v = self.http.get("/ISAPI/System/Network/interfaces", use_basic=True)
v = v.replace("\n", "")
if "std-cgi" in v:
ns['ns'] = ns["std-cgi"]
elif "www.hikvision.com" in v:
......@@ -34,7 +35,7 @@ class Script(BaseScript):
root = ElementTree.fromstring(v)
# mac = self.scripts.get_chassis_id()[0]["first_chassis_mac"]
for o in root:
o_id = o.find("ns:id", ns).text
o_id = o.find("{%s}id" % ns["ns"]).text
name = "eth%s" % o_id
iface = {
"name": name,
......@@ -50,23 +51,24 @@ class Script(BaseScript):
}
try:
v = self.http.get("/ISAPI/System/Network/interfaces/%s/Link" % o_id, use_basic=True)
v = v.replace("\n", "")
v = ElementTree.fromstring(v)
mac = v.find("ns:MACAddress", ns).text
mac = v.find("{%s}MACAddress" % ns["ns"]).text
except HTTPError:
mac = self.scripts.get_chassis_id()[0]["first_chassis_mac"]
if mac:
sub["mac"] = mac
iface["mac"] = mac
ip = o.find("ns:IPAddress", ns)
ip = o.find("{%s}IPAddress" % ns["ns"])
# for ip in ip_addresses:
afi = ip.find("ns:ipVersion", ns).text
afi = ip.find("{%s}ipVersion" % ns["ns"]).text
if afi == "v4":
if "IPv4" not in sub["enabled_afi"]:
sub["enabled_afi"] += ["IPv4"]
ip_address = "%s/%s" % (
ip.find("ns:ipAddress", ns).text, IPv4.netmask_to_len(
ip.find("ns:subnetMask", ns).text
ip.find("{%s}ipAddress" % ns["ns"]).text, IPv4.netmask_to_len(
ip.find("{%s}subnetMask" % ns["ns"]).text
)
)
if "ipv4_addresses" in sub:
......@@ -77,7 +79,7 @@ class Script(BaseScript):
if "IPv6" not in sub["enabled_afi"]:
sub["enabled_afi"] += ["IPv6"]
ip_address = IPv6(
ip.find("ns:ipAddress", ns).text, netmask=ip.find("ns:subnetMask", ns).text
ip.find("{%s}ipAddress" % ns["ns"]).text, netmask=ip.find("ns:subnetMask", ns).text
).prefix
iface["subinterfaces"] = [sub]
......
......@@ -25,7 +25,8 @@ class Script(BaseScript):
ns = {'isapi': 'http://www.isapi.org/ver20/XMLSchema',
'std-cgi': 'http://www.std-cgi.com/ver20/XMLSchema',
'hikvision': 'http://www.hikvision.com/ver20/XMLSchema'}
v = self.http.get("/ISAPI/System/deviceInfo", use_basic=True)
v = self.http.get("/ISAPI/System/deviceInfo", cached=True, use_basic=True)
v = v.replace("\n", "")
if "std-cgi" in v:
ns['ns'] = ns["std-cgi"]
elif "www.hikvision.com" in v:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment